]> git.sesse.net Git - ffmpeg/commitdiff
avutil/timecode: do not trash bits on invalid av_timecode_get_smpte arguments
authorMarton Balint <cus@passwd.hu>
Sat, 5 Sep 2020 15:46:42 +0000 (17:46 +0200)
committerMarton Balint <cus@passwd.hu>
Sun, 13 Sep 2020 15:51:57 +0000 (17:51 +0200)
The function has no way to return error, so let's clip or calculate modulo.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavutil/timecode.c

index c0956adadb74d3f61bf4fa9791cbd10788d6967b..806638ddfcefaf39ba6828f82c743c405851430b 100644 (file)
@@ -84,6 +84,11 @@ uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss
         ff /= 2;
     }
 
+    hh = hh % 24;
+    mm = av_clip(mm, 0, 59);
+    ss = av_clip(ss, 0, 59);
+    ff = ff % 40;
+
     tc |= drop << 30;
     tc |= (ff / 10) << 28;
     tc |= (ff % 10) << 24;