---
 libavformat/rawdec.c |    9 ++++++++-
 libavformat/rawdec.h |    1 +
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index dd7230f..d4b56c9 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -24,6 +24,7 @@
 #include "avio_internal.h"
 #include "rawdec.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 
 /* raw input */
 int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
@@ -68,6 +69,9 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters 
*ap)
             }
         case AVMEDIA_TYPE_VIDEO: {
             RawVideoDemuxerContext *s1 = s->priv_data;
+            enum PixelFormat pix_fmt   = av_get_pix_fmt(s1->pix_fmt);
+            av_freep(&s1->pix_fmt);
+
             if(ap->time_base.num)
                 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
             else
@@ -77,10 +81,12 @@ int ff_raw_read_header(AVFormatContext *s, 
AVFormatParameters *ap)
                 s1->width = ap->width;
             if (ap->height > 0)
                 s1->height = ap->height;
+            if (ap->pix_fmt)
+                pix_fmt = ap->pix_fmt;
 #endif
             st->codec->width  = s1->width;
             st->codec->height = s1->height;
-            st->codec->pix_fmt = ap->pix_fmt;
+            st->codec->pix_fmt = pix_fmt;
             if(st->codec->pix_fmt == PIX_FMT_NONE)
                 st->codec->pix_fmt= PIX_FMT_YUV420P;
             break;
@@ -176,6 +182,7 @@ const AVClass ff_rawaudio_demuxer_class = {
 static const AVOption video_options[] = {
     { "width",  "", offsetof(RawVideoDemuxerContext, width),  FF_OPT_TYPE_INT, 
{.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { "height", "", offsetof(RawVideoDemuxerContext, height), FF_OPT_TYPE_INT, 
{.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { "pixel_format", "", offsetof(RawVideoDemuxerContext, pix_fmt), 
FF_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
     { NULL },
 };
 
diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h
index bb5af47..16b74ea 100644
--- a/libavformat/rawdec.h
+++ b/libavformat/rawdec.h
@@ -34,6 +34,7 @@ typedef struct RawAudioDemuxerContext {
 typedef struct RawVideoDemuxerContext {
     AVClass *class;
     int width, height;
+    char *pix_fmt;
 } RawVideoDemuxerContext;
 
 extern const AVClass ff_rawaudio_demuxer_class;
-- 
1.7.5.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to