diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-05-27 23:47:05 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-05-27 23:48:22 +0200 |
commit | 8381ab143779d25611a1bb05d674bc39fe940f77 (patch) | |
tree | 74773be2c947475433dcc47898aec49a0c4b198b /libavdevice/vfwcap.c | |
parent | b8773e44d56667edea2d68d067d0c156522ca304 (diff) | |
parent | 79aeade6f6f8fbd7ce1da619fdd475e5db88ae24 (diff) | |
download | ffmpeg-8381ab143779d25611a1bb05d674bc39fe940f77.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (29 commits)
ARM: disable ff_vector_fmul_vfp on VFPv3 systems
ARM: check for VFPv3
swscale: Remove unused variables in x86 code.
doc: Drop DJGPP section, Libav now compiles out-of-the-box on FreeDOS.
x86: Add appropriate ifdefs around certain AVX functions.
cmdutils: use sws_freeContext() instead of av_freep().
swscale: delay allocation of formatConvBuffer().
swscale: fix build with --disable-swscale-alpha.
movenc: Deprecate the global RTP hinting flag, use a private AVOption instead
movenc: Add an AVClass for setting muxer specific options
swscale: fix non-bitexact yuv2yuv[X2]() MMX/MMX2 functions.
configure: report yasm/nasm presence properly
tcp: make connect() timeout properly
rawdec: factor video demuxer definitions into a macro.
rtspdec: add initial_pause private option.
lavf: deprecate AVFormatParameters.width/height.
tty: add video_size private option.
rawdec: add video_size private option.
x11grab: add video_size private option.
x11grab: factorize returning error codes.
...
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavdevice/vfwcap.c')
-rw-r--r-- | libavdevice/vfwcap.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index b8b8f52deb..75841d8acb 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -19,6 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/log.h" +#include "libavutil/opt.h" +#include "libavutil/parseutils.h" #include <windows.h> #include <vfw.h> #include "avdevice.h" @@ -32,12 +35,14 @@ /* End of missing MinGW defines */ struct vfw_ctx { + const AVClass *class; HWND hwnd; HANDLE mutex; HANDLE event; AVPacketList *pktl; unsigned int curbufsize; unsigned int frame_num; + char *video_size; /**< A string describing video size, set by a private option. */ }; static enum PixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount) @@ -228,6 +233,8 @@ static int vfw_read_close(AVFormatContext *s) pktl = next; } + av_freep(&ctx->video_size); + return 0; } @@ -242,8 +249,6 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) CAPTUREPARMS cparms; DWORD biCompression; WORD biBitCount; - int width; - int height; int ret; if (!strcmp(s->filename, "list")) { @@ -316,10 +321,20 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) dump_bih(s, &bi->bmiHeader); - width = ap->width ? ap->width : bi->bmiHeader.biWidth ; - height = ap->height ? ap->height : bi->bmiHeader.biHeight; - bi->bmiHeader.biWidth = width ; - bi->bmiHeader.biHeight = height; + + if (ctx->video_size) { + ret = av_parse_video_size(&bi->bmiHeader.biWidth, &bi->bmiHeader.biHeight, ctx->video_size); + if (ret < 0) { + av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n"); + goto fail_bi; + } + } +#if FF_API_FORMAT_PARAMETERS + if (ap->width > 0) + bi->bmiHeader.biWidth = ap->width; + if (ap->height > 0) + bi->bmiHeader.biHeight = ap->height; +#endif if (0) { /* For testing yet unsupported compressions @@ -368,8 +383,8 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) codec = st->codec; codec->time_base = ap->time_base; codec->codec_type = AVMEDIA_TYPE_VIDEO; - codec->width = width; - codec->height = height; + codec->width = bi->bmiHeader.biWidth; + codec->height = bi->bmiHeader.biHeight; codec->pix_fmt = vfw_pixfmt(biCompression, biBitCount); if(codec->pix_fmt == PIX_FMT_NONE) { codec->codec_id = vfw_codecid(biCompression); @@ -450,6 +465,20 @@ static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt) return pkt->size; } +#define OFFSET(x) offsetof(struct vfw_ctx, x) +#define DEC AV_OPT_FLAG_DECODING_PARAM +static const AVOption options[] = { + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { NULL }, +}; + +static const AVClass vfw_class = { + .class_name = "VFW indev", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVInputFormat ff_vfwcap_demuxer = { "vfwcap", NULL_IF_CONFIG_SMALL("VFW video capture"), @@ -459,4 +488,5 @@ AVInputFormat ff_vfwcap_demuxer = { vfw_read_packet, vfw_read_close, .flags = AVFMT_NOFILE, + .priv_class = &vfw_class, }; |