---
libavdevice/v4l.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c
index f946bb3..bd011e1 100644
--- a/libavdevice/v4l.c
+++ b/libavdevice/v4l.c
@@ -53,6 +53,7 @@ typedef struct {
struct video_mmap gb_buf;
int gb_frame;
int standard;
+ char *pix_fmt;
} VideoData;
static const struct {
@@ -82,6 +83,7 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
struct video_picture pict;
int j;
int vformat_num = FF_ARRAY_ELEMS(video_formats);
+ enum PixelFormat pix_fmt = av_get_pix_fmt(s->pix_fmt);
if (ap->time_base.den <= 0) {
av_log(s1, AV_LOG_ERROR, "Wrong time base (%d)\n", ap->time_base.den);
@@ -94,6 +96,8 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
s->video_win.width = ap->width;
if (ap->height > 0)
s->video_win.height = ap->height;
+ if (ap->pix_fmt)
+ pix_fmt = ap->pix_fmt;
#endif
st = av_new_stream(s1, 0);
@@ -131,7 +135,7 @@ static int grab_read_header(AVFormatContext *s1,
AVFormatParameters *ap)
desired_palette = -1;
desired_depth = -1;
for (j = 0; j < vformat_num; j++) {
- if (ap->pix_fmt == video_formats[j].pix_fmt) {
+ if (pix_fmt == video_formats[j].pix_fmt) {
desired_palette = video_formats[j].palette;
desired_depth = video_formats[j].depth;
break;
@@ -342,6 +346,8 @@ static int grab_read_close(AVFormatContext *s1)
s->audio_saved.flags |= VIDEO_AUDIO_MUTE;
ioctl(s->fd, VIDIOCSAUDIO, &s->audio_saved);
+ av_freep(&s->pix_fmt);
+
close(s->fd);
return 0;
}
@@ -353,6 +359,7 @@ static const AVOption options[] = {
{ "NTSC", "", 0, FF_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_NTSC}, 0, 0,
AV_OPT_FLAG_DECODING_PARAM, "standard" },
{ "width", "", offsetof(VideoData, video_win.width), FF_OPT_TYPE_INT,
{.dbl = 640}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
{ "height", "", offsetof(VideoData, video_win.height), FF_OPT_TYPE_INT,
{.dbl = 480}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { "pixel_format", "", offsetof(VideoData, pix_fmt), FF_OPT_TYPE_STRING,
{.str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
{ NULL },
};
--
1.7.5.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel