Ticket #3545: patchrawvideopixfmt

File patchrawvideopixfmt, 3.8 KB (added by Carl Eugen Hoyos, 12 years ago)
Line 
1diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
2index a03b1be..2344bd6 100644
3--- a/libavcodec/rawdec.c
4+++ b/libavcodec/rawdec.c
5@@ -76,6 +76,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
6
7 ff_dsputil_init(&context->dsp, avctx);
8
9+ if (avctx->pix_fmt == AV_PIX_FMT_NONE)
10 if ( avctx->codec_tag == MKTAG('r','a','w',' ')
11 || avctx->codec_tag == MKTAG('N','O','1','6'))
12 avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
13diff --git a/libavformat/avidec.c b/libavformat/avidec.c
14index 84d6ed1..5226ee8 100644
15--- a/libavformat/avidec.c
16+++ b/libavformat/avidec.c
17@@ -29,6 +29,7 @@
18 #include "libavutil/internal.h"
19 #include "libavutil/intreadwrite.h"
20 #include "libavutil/mathematics.h"
21+#include "libavutil/pixdesc.h"
22 #include "avformat.h"
23 #include "avi.h"
24 #include "dv.h"
25@@ -80,11 +81,13 @@ typedef struct {
26 int use_odml;
27 #define MAX_ODML_DEPTH 1000
28 int64_t dts_max;
29+ char *pixel_format;
30 } AVIContext;
31
32
33 static const AVOption options[] = {
34 { "use_odml", "use odml index", offsetof(AVIContext, use_odml), AV_OPT_TYPE_INT, {.i64 = 1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM},
35+ { "pixel_format", "set pixel format", offsetof(AVIContext, pixel_format), AV_OPT_TYPE_STRING, {.str = ""}, 0, 0, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM},
36 { NULL },
37 };
38
39@@ -766,6 +769,9 @@ static int avi_read_header(AVFormatContext *s)
40 st->codec->codec_tag = tag1;
41 st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
42 tag1);
43+if(st->codec->codec_id == AV_CODEC_ID_RAWVIDEO &&
44+av_get_pix_fmt(avi->pixel_format) != AV_PIX_FMT_NONE)
45+st->codec->pix_fmt = av_get_pix_fmt(avi->pixel_format);
46 /* This is needed to get the pict type which is necessary
47 * for generating correct pts. */
48 st->need_parsing = AVSTREAM_PARSE_HEADERS;
49diff --git a/libavformat/isom.h b/libavformat/isom.h
50index a929ebf..78c24cb 100644
51--- a/libavformat/isom.h
52+++ b/libavformat/isom.h
53@@ -167,6 +167,7 @@ typedef struct MOVContext {
54 int64_t next_root_atom; ///< offset of the next root atom
55 int *bitrates; ///< bitrates read before streams creation
56 int bitrates_count;
57+ char *pixel_format;
58 } MOVContext;
59
60 int ff_mp4_read_descr_len(AVIOContext *pb);
61diff --git a/libavformat/mov.c b/libavformat/mov.c
62index ed0d93d..a86670c 100644
63--- a/libavformat/mov.c
64+++ b/libavformat/mov.c
65@@ -38,6 +38,7 @@
66 #include "libavutil/dict.h"
67 #include "libavutil/opt.h"
68 #include "libavutil/timecode.h"
69+#include "libavutil/pixdesc.h"
70 #include "libavcodec/ac3tab.h"
71 #include "avformat.h"
72 #include "internal.h"
73@@ -3501,6 +3502,7 @@ static int mov_read_header(AVFormatContext *s)
74 for (i = 0; i < s->nb_streams; i++) {
75 AVStream *st = s->streams[i];
76 MOVStreamContext *sc = st->priv_data;
77+ MOVContext *mov = s->priv_data;
78 fix_timescale(mov, sc);
79 if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->codec_id == AV_CODEC_ID_AAC) {
80 st->skip_samples = sc->start_pad;
81@@ -3518,6 +3520,8 @@ static int mov_read_header(AVFormatContext *s)
82 return err;
83 }
84 }
85+if(av_get_pix_fmt(mov->pixel_format) != AV_PIX_FMT_NONE)
86+st->codec->pix_fmt = av_get_pix_fmt(mov->pixel_format);
87 }
88
89 if (mov->trex_data) {
90@@ -3739,6 +3743,7 @@ static const AVOption options[] = {
91 0, 1, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM},
92 {"ignore_editlist", "", offsetof(MOVContext, ignore_editlist), FF_OPT_TYPE_INT, {.i64 = 0},
93 0, 1, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM},
94+ { "pixel_format", "set pixel format", offsetof(MOVContext, pixel_format), AV_OPT_TYPE_STRING, {.str = ""}, 0, 0, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM},
95 {NULL}
96 };
97