From patchwork Sat Sep 5 18:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22117 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CDE3444BABC for ; Sat, 5 Sep 2020 21:22:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5B4568AA40; Sat, 5 Sep 2020 21:22:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9678868AEBC for ; Sat, 5 Sep 2020 21:22:27 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 71C00E44BB; Sat, 5 Sep 2020 20:22:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q7wCcqe3nMIQ; Sat, 5 Sep 2020 20:22:25 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 33B8CE44CA; Sat, 5 Sep 2020 20:22:25 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:12 +0200 Message-Id: <20200905182217.28037-3-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905182217.28037-1-cus@passwd.hu> References: <20200905182217.28037-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] avutil/timecode: do not trash bits on invalid av_timecode_get_smpte arguments X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The function has no way to return error, so let's clip or calculate modulo. Signed-off-by: Marton Balint --- libavutil/timecode.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavutil/timecode.c b/libavutil/timecode.c index c0956adadb..806638ddfc 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -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;