summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2017-02-15 10:37:02 -0700
committerJohn Stebbins <[email protected]>2017-02-15 10:37:02 -0700
commit396249d1e7231b961fc3fe53b2f25743a832f3b6 (patch)
tree04c7e0eff96675dd5436522efa6f510be0e354c9
parent05f743e784fe69e2950d32e8ac177c34a2f3e5c8 (diff)
libav: fix failure to scan wmv file
Fixes problem reported here https://forum.handbrake.fr/viewtopic.php?f=11&t=35690 Also possibly related https://github.com/HandBrake/HandBrake/issues/466 https://github.com/HandBrake/HandBrake/issues/495
-rw-r--r--contrib/ffmpeg/A08-wmv-scan-fail.patch117
1 files changed, 117 insertions, 0 deletions
diff --git a/contrib/ffmpeg/A08-wmv-scan-fail.patch b/contrib/ffmpeg/A08-wmv-scan-fail.patch
new file mode 100644
index 000000000..14b03e83c
--- /dev/null
+++ b/contrib/ffmpeg/A08-wmv-scan-fail.patch
@@ -0,0 +1,117 @@
+From 0539d84d985e811e5989ef27c13f7e2dda0f9b89 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?=
+Date: Wed, 8 Feb 2017 12:51:37 +0100
+Subject: [PATCH] asfdec: Account for different Format Data sizes
+
+Some muxers may use the BMP_HEADER Format Data size instead
+of the ASF-specific one.
+
+Bug-Id: 1020
+
+Signed-off-by: Diego Biurrun <[email protected]>
+---
+ libavformat/asfdec.c | 12 +++++++-----
+ libavformat/avidec.c | 2 +-
+ libavformat/riff.h | 3 ++-
+ libavformat/riffdec.c | 6 ++++--
+ libavformat/wtv.c | 2 +-
+ 5 files changed, 15 insertions(+), 10 deletions(-)
+
+diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
+index d602af8..34730b2 100644
+--- a/libavformat/asfdec.c
++++ b/libavformat/asfdec.c
+@@ -691,20 +691,22 @@ static int asf_read_properties(AVFormatContext *s, const GUIDParseTable *g)
+
+ static int parse_video_info(AVIOContext *pb, AVStream *st)
+ {
+- uint16_t size;
++ uint16_t size_asf; // ASF-specific Format Data size
++ uint32_t size_bmp; // BMP_HEADER-specific Format Data size
+ unsigned int tag;
+
+ st->codecpar->width = avio_rl32(pb);
+ st->codecpar->height = avio_rl32(pb);
+ avio_skip(pb, 1); // skip reserved flags
+- size = avio_rl16(pb); // size of the Format Data
+- tag = ff_get_bmp_header(pb, st);
++ size_asf = avio_rl16(pb);
++ tag = ff_get_bmp_header(pb, st, &size_bmp);
+ st->codecpar->codec_tag = tag;
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
++ size_bmp = FFMAX(size_asf, size_bmp);
+
+- if (size > BMP_HEADER_SIZE) {
++ if (size_bmp > BMP_HEADER_SIZE) {
+ int ret;
+- st->codecpar->extradata_size = size - BMP_HEADER_SIZE;
++ st->codecpar->extradata_size = size_bmp - BMP_HEADER_SIZE;
+ if (!(st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +
+ AV_INPUT_BUFFER_PADDING_SIZE))) {
+ st->codecpar->extradata_size = 0;
+diff --git a/libavformat/avidec.c b/libavformat/avidec.c
+index 701cccb..870066e 100644
+--- a/libavformat/avidec.c
++++ b/libavformat/avidec.c
+@@ -613,7 +613,7 @@ static int avi_read_header(AVFormatContext *s)
+ avio_skip(pb, size);
+ break;
+ }
+- tag1 = ff_get_bmp_header(pb, st);
++ tag1 = ff_get_bmp_header(pb, st, NULL);
+
+ if (tag1 == MKTAG('D', 'X', 'S', 'B') ||
+ tag1 == MKTAG('D', 'X', 'S', 'A')) {
+diff --git a/libavformat/riff.h b/libavformat/riff.h
+index a45c7f3..e5f4645 100644
+--- a/libavformat/riff.h
++++ b/libavformat/riff.h
+@@ -41,9 +41,10 @@ void ff_end_tag(AVIOContext *pb, int64_t start);
+ /**
+ * Read BITMAPINFOHEADER structure and set AVStream codec width, height and
+ * bits_per_encoded_sample fields. Does not read extradata.
++ * Writes the size of the BMP file to *size.
+ * @return codec tag
+ */
+-int ff_get_bmp_header(AVIOContext *pb, AVStream *st);
++int ff_get_bmp_header(AVIOContext *pb, AVStream *st, uint32_t *size);
+
+ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, const AVCodecTag *tags, int for_asf);
+ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par);
+diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
+index 8124835..db83b32 100644
+--- a/libavformat/riffdec.c
++++ b/libavformat/riffdec.c
+@@ -180,10 +180,12 @@ enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps)
+ return id;
+ }
+
+-int ff_get_bmp_header(AVIOContext *pb, AVStream *st)
++int ff_get_bmp_header(AVIOContext *pb, AVStream *st, uint32_t *size)
+ {
+ int tag1;
+- avio_rl32(pb); /* size */
++ uint32_t size_ = avio_rl32(pb);
++ if (size)
++ *size = size_;
+ st->codecpar->width = avio_rl32(pb);
+ st->codecpar->height = (int32_t)avio_rl32(pb);
+ avio_rl16(pb); /* planes */
+diff --git a/libavformat/wtv.c b/libavformat/wtv.c
+index 794dd4b..d750cef 100644
+--- a/libavformat/wtv.c
++++ b/libavformat/wtv.c
+@@ -586,7 +586,7 @@ static int parse_videoinfoheader2(AVFormatContext *s, AVStream *st)
+ AVIOContext *pb = wtv->pb;
+
+ avio_skip(pb, 72); // picture aspect ratio is unreliable
+- ff_get_bmp_header(pb, st);
++ ff_get_bmp_header(pb, st, NULL);
+
+ return 72 + 40;
+ }
+--
+2.9.3
+