]> git.sesse.net Git - ffmpeg/commitdiff
avformat/matroskadec: Simplify checks for cook and ATRAC3
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 20 Apr 2020 06:54:23 +0000 (08:54 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 1 May 2020 05:50:30 +0000 (07:50 +0200)
Some conditions which don't change and which can therefore be checked
in read_header() were instead rechecked upon parsing each block. This
has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/matroskadec.c

index 1dc0b77962b08e8e71ffb1ef55ef15fa1a5dff6e..5643e15a2072669ff944ed99eb57c4ccdabb102f 100644 (file)
@@ -2624,7 +2624,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)
+                } else if (track->audio.sub_packet_size <= 0 ||
+                           track->audio.frame_size % track->audio.sub_packet_size)
                     return AVERROR_INVALIDDATA;
                 st->codecpar->block_align = track->audio.sub_packet_size;
                 extradata_offset       = 78;
@@ -3138,7 +3139,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
             }
             memcpy(track->audio.buf + y * w, data, w);
         } else {
-            if (size < sps * w / sps || h<=0 || w%sps) {
+            if (size < w) {
                 av_log(matroska->ctx, AV_LOG_ERROR,
                        "Corrupt generic RM-style audio packet size\n");
                 return AVERROR_INVALIDDATA;