aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mov.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-23 03:00:12 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-23 03:25:51 +0100
commitd1c28e35300130f0ee28a3e5bbeb2cea403fad57 (patch)
treea18d0b0989962e2e2cab201fbf6128ae8332d8a4 /libavformat/mov.c
parent9f50dafe9025555f11e66e3b09cf3db2cd53cfb2 (diff)
parent4e8d6218c3cb8b9feffb70f8a53859540b975b36 (diff)
downloadffmpeg-d1c28e35300130f0ee28a3e5bbeb2cea403fad57.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: build: fix standalone compilation of OMA muxer build: fix standalone compilation of Microsoft XMV demuxer build: fix standalone compilation of Core Audio Format demuxer kvmc: fix invalid reads 4xm: Add a check in decode_i_frame to prevent buffer overreads adpcm: fix IMA SMJPEG decoding options: set minimum for "threads" to zero bsd: use number of logical CPUs as automatic thread count windows: use number of CPUs as automatic thread count linux: use number of CPUs as automatic thread count pthreads: reset active_thread_type when slice thread_init returrns early v410dec: include correct headers Drop ALT_ prefix from BITSTREAM_READER_LE name. lavfi: always build vsrc_buffer. ra144enc: zero the reflection coeffs if the filter is unstable sws: readd PAL8 to isPacked() mov: Don't stick the QuickTime field ordering atom in extradata. truespeech: fix invalid reads in truespeech_apply_twopoint_filter() Conflicts: configure libavcodec/4xm.c libavcodec/avcodec.h libavfilter/Makefile libavfilter/allfilters.c libavformat/Makefile libswscale/swscale_internal.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index e18c861edc..dd8e92ee31 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -857,6 +857,40 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
+static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+ AVStream *st;
+ unsigned mov_field_order;
+ enum AVFieldOrder decoded_field_order = AV_FIELD_UNKNOWN;
+
+ if (c->fc->nb_streams < 1) // will happen with jp2 files
+ return 0;
+ st = c->fc->streams[c->fc->nb_streams-1];
+ if (atom.size < 2)
+ return AVERROR_INVALIDDATA;
+ mov_field_order = avio_rb16(pb);
+ if ((mov_field_order & 0xFF00) == 0x0100)
+ decoded_field_order = AV_FIELD_PROGRESSIVE;
+ else if ((mov_field_order & 0xFF00) == 0x0200) {
+ switch (mov_field_order & 0xFF) {
+ case 0x01: decoded_field_order = AV_FIELD_TT;
+ break;
+ case 0x06: decoded_field_order = AV_FIELD_BB;
+ break;
+ case 0x09: decoded_field_order = AV_FIELD_TB;
+ break;
+ case 0x0E: decoded_field_order = AV_FIELD_BT;
+ break;
+ }
+ }
+ if (decoded_field_order == AV_FIELD_UNKNOWN && mov_field_order) {
+ av_log(NULL, AV_LOG_ERROR, "Unknown MOV field order 0x%04x\n", mov_field_order);
+ }
+ st->codec->field_order = decoded_field_order;
+
+ return 0;
+}
+
/* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom,
enum CodecID codec_id)
@@ -898,11 +932,6 @@ static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return mov_read_extradata(c, pb, atom, CODEC_ID_AVS);
}
-static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
-{
- return mov_read_extradata(c, pb, atom, CODEC_ID_MJPEG);
-}
-
static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
return mov_read_extradata(c, pb, atom, CODEC_ID_JPEG2000);
@@ -950,6 +979,15 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if ((uint64_t)atom.size > (1<<30))
return -1;
+ if (atom.size >= 10) {
+ // Broken files created by legacy versions of Libav and FFmpeg will
+ // wrap a whole fiel atom inside of a glbl atom.
+ unsigned size = avio_rb32(pb);
+ unsigned type = avio_rl32(pb);
+ avio_seek(pb, -8, SEEK_CUR);
+ if (type == MKTAG('f','i','e','l') && size == atom.size)
+ return mov_read_default(c, pb, atom);
+ }
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)