diff mbox

[FFmpeg-devel,4/9] avformat/matroskaenc: Remove redundant assert

Message ID 20191015111737.14246-4-andreas.rheinhardt@gmail.com
State Accepted
Commit b4e36df74faf0174e0734792a16fee1ed6f5be2c
Headers show

Commit Message

Andreas Rheinhardt Oct. 15, 2019, 11:17 a.m. UTC
The Matroska muxer groups index entries with the same pts together in
order to save a few bytes. Because of Matroska's variable-length length
fields, mkv_write_cues() does this by first finding out how many index
entries will be grouped together before actually writing them.
Currently, it is asserted at both of these stages that the stream index
of the list of designated index entries is valid. But the second assert
is redundant, because the very same index entries have already been
checked.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/matroskaenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Almer Oct. 22, 2019, 12:16 a.m. UTC | #1
On 10/15/2019 8:17 AM, Andreas Rheinhardt wrote:
> The Matroska muxer groups index entries with the same pts together in
> order to save a few bytes. Because of Matroska's variable-length length
> fields, mkv_write_cues() does this by first finding out how many index
> entries will be grouped together before actually writing them.
> Currently, it is asserted at both of these stages that the stream index
> of the list of designated index entries is valid. But the second assert
> is redundant, because the very same index entries have already been
> checked.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/matroskaenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index e024c58c84..eb8977ff9c 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -601,7 +601,7 @@ static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tra
>              tracks[j].has_cue = 0;
>          for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
>              int tracknum = entry[j].stream_idx;
> -            av_assert0(tracknum>=0 && tracknum<num_tracks);
> +
>              if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
>                  continue;
>              tracks[tracknum].has_cue = 1;

Applied.
diff mbox

Patch

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index e024c58c84..eb8977ff9c 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -601,7 +601,7 @@  static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tra
             tracks[j].has_cue = 0;
         for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
             int tracknum = entry[j].stream_idx;
-            av_assert0(tracknum>=0 && tracknum<num_tracks);
+
             if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
                 continue;
             tracks[tracknum].has_cue = 1;