diff mbox series

[FFmpeg-devel,03/11] avformat/matroskadec: Fix demuxing RealAudio 28.8

Message ID 20200423030741.12158-3-andreas.rheinhardt@gmail.com
State Accepted
Commit c91e3690d9c6667123b116c9fd3becf5f4f4530e
Headers show
Series [FFmpeg-devel,01/11] avformat/matroskadec: Reject sipr flavor > 3 | expand


Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt April 23, 2020, 3:07 a.m. UTC
RealAudio 28.8 does not need or use sub_packet_size for its demuxing
and this field is therefore commonly set to zero. But since 18ca491b
the Real Audio specific demuxing is no longer applied if sub_packet_size
is zero because the codepath for cook and ATRAC3 divide by it; this made
these files undecodable.

Furthermore, since 569d18aa (merged in 2c8d876d) sub_packet_size being
zero is used as an indicator for invalid data, so that a file containing
such a track was completely skipped.

This commit fixes this by not checking sub_packet_size for RealAudio
28.8 at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Actually, the Matroska demuxer presumes that RealAudio 28.8 is always
INT4-interleaved. This commit fixes demuxing for such tracks. But
apparently it can also be INT0-interleaved (our RealMedia muxer writes
packets with this method).
Btw: Remuxing cook and ATRAC3 with our RealMedia muxer leads to broken
files that not even our demuxer can read (sub_packet_size is not set

 libavformat/matroskadec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series


diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 668323ba08..844f96cd52 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2608,8 +2608,7 @@  static int matroska_parse_tracks(AVFormatContext *s)
             track->audio.sub_packet_size = avio_rb16(&b);
             if (track->audio.coded_framesize <= 0 ||
                 track->audio.sub_packet_h    <= 0 ||
-                track->audio.frame_size      <= 0 ||
-                track->audio.sub_packet_size <= 0 && codec_id != AV_CODEC_ID_SIPR)
+                track->audio.frame_size      <= 0)
                 return AVERROR_INVALIDDATA;
             if (codec_id == AV_CODEC_ID_RA_288) {
@@ -2622,7 +2621,8 @@  static int matroska_parse_tracks(AVFormatContext *s)
                         return AVERROR_INVALIDDATA;
                     track->audio.sub_packet_size = ff_sipr_subpk_size[flavor];
                     st->codecpar->bit_rate          = sipr_bit_rate[flavor];
-                }
+                } else if (track->audio.sub_packet_size <= 0)
+                    return AVERROR_INVALIDDATA;
                 st->codecpar->block_align = track->audio.sub_packet_size;
                 extradata_offset       = 78;