---
libavdevice/vfwcap.c | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c
index 8eecf5b..a245d0e 100644
--- a/libavdevice/vfwcap.c
+++ b/libavdevice/vfwcap.c
@@ -20,6 +20,8 @@
*/
#include "libavformat/avformat.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
#include <windows.h>
#include <vfw.h>
@@ -34,12 +36,14 @@
/* End of missing MinGW defines */
struct vfw_ctx {
+ AVClass *class;
HWND hwnd;
HANDLE mutex;
HANDLE event;
AVPacketList *pktl;
unsigned int curbufsize;
unsigned int frame_num;
+ int width, height;
};
static enum PixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount)
@@ -244,8 +248,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")) {
@@ -318,10 +320,14 @@ 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 (ap->width > 0)
+ ctx->width = ap->width;
+ if (ap->height > 0)
+ ctx->height = ap->height;
+ if (ctx->width > 0)
+ bi->bmiHeader.biWidth = ctx->width ;
+ if (ctx->height > 0)
+ bi->bmiHeader.biHeight = ctx->height;
if (0) {
/* For testing yet unsupported compressions
@@ -370,8 +376,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 = ctx->width;
+ codec->height = ctx->height;
codec->pix_fmt = vfw_pixfmt(biCompression, biBitCount);
if(codec->pix_fmt == PIX_FMT_NONE) {
codec->codec_id = vfw_codecid(biCompression);
@@ -452,6 +458,19 @@ static int vfw_read_packet(AVFormatContext *s, AVPacket
*pkt)
return pkt->size;
}
+static const AVOption options[] = {
+ { "width", "", offsetof(struct vfw_ctx, width), FF_OPT_TYPE_INT, {.dbl
= 640}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { "height", "", offsetof(struct vfw_ctx, height), FF_OPT_TYPE_INT, {.dbl
= 480}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { NULL },
+};
+
+static const AVClass vfw_class = {
+ .class_name = "VFW grab interface",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVInputFormat ff_vfwcap_demuxer = {
"vfwcap",
NULL_IF_CONFIG_SMALL("VFW video capture"),
@@ -461,4 +480,5 @@ AVInputFormat ff_vfwcap_demuxer = {
vfw_read_packet,
vfw_read_close,
.flags = AVFMT_NOFILE,
+ .priv_class = &vfw_class,
};
--
1.7.5.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel