aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-14 01:36:54 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-04-02 07:12:01 +0200
commit048bc3fe31502e0fa5ba115cc91611a72c8fec2e (patch)
tree804d47d6b8acde136663fe7f8f904167b713af69 /libavformat
parentad91cf1f2f5793db5c6dd7ab9947fcc6d7832607 (diff)
downloadffmpeg-048bc3fe31502e0fa5ba115cc91611a72c8fec2e.tar.gz
avformat/matroskadec: Add a workaround for missing WavPack extradata
mkvmerge versions 6.2 to 40.0 had a bug that made it not propagate the WavPack extradata (containing the WavPack version) during remuxing from a Matroska file; currently our demuxer would treat every WavPack block encountered as invalid data (unless the WavPack stream is to be discarded (i.e. the streams discard is >= AVDISCARD_ALL)) and try to resync to the next level 1 element. Luckily, the WavPack version is currently not really important; so we fix this problem by assuming a version. David Bryant, the creator of WavPack, recommended using version 0x410 (the most recent version) for this. And this is what this commit does. A FATE-test for this has been added. Reviewed-by: David Bryant <david@wavpack.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/matroskadec.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index b2bdd5efda..c699ce66b8 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2613,6 +2613,14 @@ static int matroska_parse_tracks(AVFormatContext *s)
ret = matroska_parse_flac(s, track, &extradata_offset);
if (ret < 0)
return ret;
+ } else if (codec_id == AV_CODEC_ID_WAVPACK && track->codec_priv.size < 2) {
+ av_log(matroska->ctx, AV_LOG_INFO, "Assuming WavPack version 4.10 "
+ "in absence of valid CodecPrivate.\n");
+ extradata_size = 2;
+ extradata = av_mallocz(2 + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!extradata)
+ return AVERROR(ENOMEM);
+ AV_WL16(extradata, 0x410);
} else if (codec_id == AV_CODEC_ID_PRORES && track->codec_priv.size == 4) {
fourcc = AV_RL32(track->codec_priv.data);
} else if (codec_id == AV_CODEC_ID_VP9 && track->codec_priv.size) {
@@ -3165,9 +3173,10 @@ static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src,
uint16_t ver;
int ret, offset = 0;
- if (srclen < 12 || track->stream->codecpar->extradata_size < 2)
+ if (srclen < 12)
return AVERROR_INVALIDDATA;
+ av_assert1(track->stream->codecpar->extradata_size >= 2);
ver = AV_RL16(track->stream->codecpar->extradata);
samples = AV_RL32(src);