diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-06-03 05:19:30 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-06-03 05:19:30 +0200 |
commit | 99eb31e263a24bc6c5a7a3f455a2bcb04a60e70e (patch) | |
tree | 83aab2f083fd3d6923d4e76fe0cc0c41ef7aef35 /libavdevice/fbdev.c | |
parent | 9034001b17077e9da5205c4344eb1b88b9882f03 (diff) | |
parent | f190f676bc93a7e80344f2feeb3b9b44604d4717 (diff) | |
download | ffmpeg-99eb31e263a24bc6c5a7a3f455a2bcb04a60e70e.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (25 commits)
Replace custom DEBUG preprocessor trickery by the standard one.
vorbis: Remove non-compiling debug statement.
vorbis: Remove pointless DEBUG #ifdef around debug output macros.
cook: Remove non-compiling debug output.
Remove pointless #ifdefs around function declarations in a header.
Replace #ifdef + av_log() combinations by av_dlog().
Replace custom debug output functions by av_dlog().
cook: Remove unused debug functions.
Remove stray extra arguments from av_dlog() invocations.
targa: fix big-endian build
v4l2: remove one forgotten use of AVFormatParameters.pix_fmt.
vfwcap: add a framerate private option.
v4l2: add a framerate private option.
libdc1394: add a framerate private option.
fbdev: add a framerate private option.
bktr: add a framerate private option.
oma: check avio_read() return value
nutdec: remove unused variable
Remove unused variables
swscale: allocate larger buffer to handle altivec overreads.
...
Conflicts:
ffmpeg.c
libavcodec/dca.c
libavcodec/dirac.c
libavcodec/error_resilience.c
libavcodec/h264.c
libavcodec/mpeg12.c
libavcodec/mpeg4videodec.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo_enc.c
libavcodec/pthread.c
libavcodec/rv10.c
libavcodec/s302m.c
libavcodec/shorten.c
libavcodec/truemotion2.c
libavcodec/utils.c
libavdevice/dv1394.c
libavdevice/fbdev.c
libavdevice/libdc1394.c
libavdevice/v4l2.c
libavformat/4xm.c
libavformat/apetag.c
libavformat/asfdec.c
libavformat/avidec.c
libavformat/mmf.c
libavformat/mpeg.c
libavformat/mpegenc.c
libavformat/mpegts.c
libavformat/oggdec.c
libavformat/oggparseogm.c
libavformat/rl2.c
libavformat/rmdec.c
libavformat/rpl.c
libavformat/rtpdec_latm.c
libavformat/sauce.c
libavformat/sol.c
libswscale/utils.c
tests/ref/vsynth1/error
tests/ref/vsynth2/error
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavdevice/fbdev.c')
-rw-r--r-- | libavdevice/fbdev.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index 19bf5ad5ef..0d41b5d6ba 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -37,7 +37,10 @@ #include <time.h> #include <linux/fb.h> +#include "libavutil/log.h" #include "libavutil/mem.h" +#include "libavutil/opt.h" +#include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "avdevice.h" @@ -74,8 +77,10 @@ static enum PixelFormat get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *var } typedef struct { + AVClass *class; ///< class for private options int frame_size; ///< size in bytes of a grabbed frame - AVRational time_base; ///< time base + AVRational fps; ///< framerate + char *framerate; ///< framerate string set by a private option int64_t time_frame; ///< time for the next frame to output (in 1/1000000 units) int fd; ///< framebuffer device file descriptor @@ -97,16 +102,21 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, enum PixelFormat pix_fmt; int ret, flags = O_RDONLY; + ret = av_parse_video_rate(&fbdev->fps, fbdev->framerate); + av_freep(&fbdev->framerate); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + return ret; + } +#if FF_API_FORMAT_PARAMETERS + if (ap->time_base.num) + fbdev->fps = (AVRational){ap->time_base.den, ap->time_base.num}; +#endif + if (!(st = av_new_stream(avctx, 0))) return AVERROR(ENOMEM); av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in microseconds */ - if (ap->time_base.den <= 0) { - av_log(avctx, AV_LOG_ERROR, "Invalid time base %d/%d\n", - ap->time_base.num, ap->time_base.den); - return AVERROR(EINVAL); - } - /* NONBLOCK is ignored by the fbdev driver, only set for consistency */ if (avctx->flags & AVFMT_FLAG_NONBLOCK) flags |= O_NONBLOCK; @@ -146,7 +156,6 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, fbdev->bytes_per_pixel = (fbdev->varinfo.bits_per_pixel + 7) >> 3; fbdev->frame_linesize = fbdev->width * fbdev->bytes_per_pixel; fbdev->frame_size = fbdev->frame_linesize * fbdev->heigth; - fbdev->time_base = ap->time_base; fbdev->time_frame = AV_NOPTS_VALUE; fbdev->data = mmap(NULL, fbdev->fixinfo.smem_len, PROT_READ, MAP_SHARED, fbdev->fd, 0); if (fbdev->data == MAP_FAILED) { @@ -162,13 +171,13 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, st->codec->pix_fmt = pix_fmt; st->codec->time_base = ap->time_base; st->codec->bit_rate = - fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel / av_q2d(ap->time_base) * 8; + fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel * av_q2d(fbdev->fps) * 8; av_log(avctx, AV_LOG_INFO, - "w:%d h:%d bpp:%d pixfmt:%s tb:%d/%d bit_rate:%d\n", + "w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%d\n", fbdev->width, fbdev->heigth, fbdev->varinfo.bits_per_pixel, av_pix_fmt_descriptors[pix_fmt].name, - ap->time_base.num, ap->time_base.den, + fbdev->fps.num, fbdev->fps.den, st->codec->bit_rate); return 0; @@ -196,7 +205,7 @@ static int fbdev_read_packet(AVFormatContext *avctx, AVPacket *pkt) "time_frame:%"PRId64" curtime:%"PRId64" delay:%"PRId64"\n", fbdev->time_frame, curtime, delay); if (delay <= 0) { - fbdev->time_frame += INT64_C(1000000) * av_q2d(fbdev->time_base); + fbdev->time_frame += INT64_C(1000000) / av_q2d(fbdev->fps); break; } if (avctx->flags & AVFMT_FLAG_NONBLOCK) @@ -240,6 +249,20 @@ av_cold static int fbdev_read_close(AVFormatContext *avctx) return 0; } +#define OFFSET(x) offsetof(FBDevContext, x) +#define DEC AV_OPT_FLAG_DECODING_PARAM +static const AVOption options[] = { + { "framerate","", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { NULL }, +}; + +static const AVClass fbdev_class = { + .class_name = "fbdev indev", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVInputFormat ff_fbdev_demuxer = { .name = "fbdev", .long_name = NULL_IF_CONFIG_SMALL("Linux framebuffer"), @@ -248,4 +271,5 @@ AVInputFormat ff_fbdev_demuxer = { .read_packet = fbdev_read_packet, .read_close = fbdev_read_close, .flags = AVFMT_NOFILE, + .priv_class = &fbdev_class, }; |