Fixes CID1238790
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e6971db12b8ae49712b77378fa8141de4904082b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
... | ... |
@@ -896,14 +896,18 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, |
896 | 896 |
} |
897 | 897 |
|
898 | 898 |
if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->initial_padding && codec->codec_id == AV_CODEC_ID_OPUS) { |
899 |
+ int64_t codecdelay = av_rescale_q(codec->initial_padding, |
|
900 |
+ (AVRational){ 1, codec->sample_rate }, |
|
901 |
+ (AVRational){ 1, 1000000000 }); |
|
902 |
+ if (codecdelay < 0) { |
|
903 |
+ av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n"); |
|
904 |
+ return AVERROR(EINVAL); |
|
905 |
+ } |
|
899 | 906 |
// mkv->tracks[i].ts_offset = av_rescale_q(codec->initial_padding, |
900 | 907 |
// (AVRational){ 1, codec->sample_rate }, |
901 | 908 |
// st->time_base); |
902 | 909 |
|
903 |
- put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, |
|
904 |
- av_rescale_q(codec->initial_padding, |
|
905 |
- (AVRational){ 1, codec->sample_rate }, |
|
906 |
- (AVRational){ 1, 1000000000 })); |
|
910 |
+ put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, codecdelay); |
|
907 | 911 |
} |
908 | 912 |
if (codec->codec_id == AV_CODEC_ID_OPUS) { |
909 | 913 |
put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL); |