---
libavdevice/v4l.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c
index 54d0394..191da98 100644
--- a/libavdevice/v4l.c
+++ b/libavdevice/v4l.c
@@ -25,6 +25,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
#include "libavformat/avformat.h"
#include "libavcodec/dsputil.h"
#include <unistd.h>
@@ -53,6 +54,7 @@ typedef struct {
struct video_mmap gb_buf;
int gb_frame;
int standard;
+ char *video_size;
} VideoData;
static const struct {
@@ -80,7 +82,7 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
struct video_tuner tuner;
struct video_audio audio;
struct video_picture pict;
- int j;
+ int j, ret;
int vformat_num = FF_ARRAY_ELEMS(video_formats);
if (ap->time_base.den <= 0) {
@@ -89,9 +91,6 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
}
s->time_base = ap->time_base;
- s->video_win.width = ap->width;
- s->video_win.height = ap->height;
-
st = av_new_stream(s1, 0);
if (!st)
return AVERROR(ENOMEM);
@@ -113,6 +112,20 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
goto fail;
}
+ if (s->video_size) {
+ ret = av_parse_video_size(&s->video_win.width, &s->video_win.height,
s->video_size);
+ av_freep(&s->video_size);
+ if (ret < 0) {
+ av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n");
+ goto fail;
+ }
+ }
+#if FF_API_FORMAT_PARAMETERS
+ if (ap->width > 0)
+ s->video_win.width = ap->width;
+ if (ap->height > 0)
+ s->video_win.height = ap->height;
+#endif
/* no values set, autodetect them */
if (s->video_win.width <= 0 || s->video_win.height <= 0) {
if (ioctl(video_fd, VIDIOCGWIN, &s->video_win, sizeof(s->video_win)) <
0) {
@@ -342,11 +355,14 @@ static int grab_read_close(AVFormatContext *s1)
return 0;
}
+#define OFFSET(x) offsetof(VideoData, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
{ "standard", "", offsetof(VideoData, standard), FF_OPT_TYPE_INT, {.dbl =
VIDEO_MODE_NTSC}, VIDEO_MODE_PAL, VIDEO_MODE_NTSC, AV_OPT_FLAG_DECODING_PARAM,
"standard" },
{ "PAL", "", 0, FF_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_PAL}, 0, 0,
AV_OPT_FLAG_DECODING_PARAM, "standard" },
{ "SECAM", "", 0, FF_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_SECAM}, 0, 0,
AV_OPT_FLAG_DECODING_PARAM, "standard" },
{ "NTSC", "", 0, FF_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_NTSC}, 0, 0,
AV_OPT_FLAG_DECODING_PARAM, "standard" },
+ { "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 },
};
--
1.7.5.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel