Do not write negative values in CodecDelay as the embl accepts only
unsigned integers.

CC: [email protected]
Bug-Id: CID 1238790
---
 libavformat/matroskaenc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 4ec474d..6571de1 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -767,14 +767,17 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
         put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & 
AV_DISPOSITION_DEFAULT));
 
     if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->initial_padding) {
+        int delay = av_rescale_q(codec->initial_padding,
+                                 (AVRational) { 1, codec->sample_rate },
+                                 (AVRational) { 1, 1000000000 });
+        if (delay < 0)
+            return AVERROR_INVALIDDATA;
+
         mkv->tracks[i].ts_offset = av_rescale_q(codec->initial_padding,
                                                 (AVRational){ 1, 
codec->sample_rate },
                                                 st->time_base);
 
-        put_ebml_uint(pb, MATROSKA_ID_CODECDELAY,
-                      av_rescale_q(codec->initial_padding,
-                                   (AVRational){ 1, codec->sample_rate },
-                                   (AVRational){ 1, 1000000000 }));
+        put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, delay);
     }
 
     // look for a codec ID string specific to mkv to use,
-- 
1.9.3 (Apple Git-50)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to