From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 81F8F4D82B for ; Mon, 24 Feb 2025 20:52:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9F74168C971; Mon, 24 Feb 2025 22:52:17 +0200 (EET) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 15DCA68B9E4 for ; Mon, 24 Feb 2025 22:52:09 +0200 (EET) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 7C1BD2819FD4D; Mon, 24 Feb 2025 21:52:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1740430328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WZR0gMjjEDxPebl1vtcWRlLeTwbKu7VCBYngEMmhyFU=; b=jsyeqL/nSkSQ837wExoYMMKIyJAIg753u69s/E5nEq2vVr6st0vXwA+EGUF5fNIkXpguE3 Eh4AY73uMj2snWJbxARbuwrhdfbxMZ6KMPJmKSgjyyhxeoClgBMW+9AsohCEPLNd1Tqcy9 2jbzYATWv6DgnNcOv0sWmMOVk78DwAqio8313X55hl81y9oHoopC4He4S/KPnmC1izWwdZ r/zcuBJCiOOyeZqq3QT0Y171+4s4UuP74kN/NPqnXkv/sjFGipgw0oYBzqfeYDcvZZClM4 H9KXeStAskFG92FHRng2Zh26m1SmnOUSe3PDwLfMLmcu9K8btIZiYreNecc4RQ== From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Feb 2025 21:51:49 +0100 Message-ID: <20250224205159.13620-2-timo@rothenpieler.org> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250224205159.13620-1-timo@rothenpieler.org> References: <20250224205159.13620-1-timo@rothenpieler.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/utils: use new av_timecode_set_smpte function X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Timo Rothenpieler Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- libavcodec/utils.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index dd846b4ae9..1e1ad9a833 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -33,6 +33,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" #include "libavutil/pixfmt.h" +#include "libavutil/timecode.h" #include "avcodec.h" #include "codec.h" #include "codec_desc.h" @@ -1006,23 +1007,8 @@ int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t prefix_l put_bits(&pb, 2, m); // num_clock_ts for (int j = 1; j <= m; j++) { - uint32_t tcsmpte = tc[j]; - unsigned hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours - unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes - unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds - unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames - unsigned drop = tcsmpte & 1<<30 && !0; // 1-bit drop if not arbitrary bit - - /* Calculate frame number of HEVC by SMPTE ST 12-1:2014 Sec 12.2 if rate > 30FPS */ - if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) { - unsigned pc; - ff *= 2; - if (av_cmp_q(rate, (AVRational) {50, 1}) == 0) - pc = !!(tcsmpte & 1 << 7); - else - pc = !!(tcsmpte & 1 << 23); - ff = (ff + pc) & 0x7f; - } + int hh, mm, ss, ff, drop; + av_timecode_set_smpte(&drop, &hh, &mm, &ss, &ff, rate, tc[j], 0, 0); put_bits(&pb, 1, 1); // clock_timestamp_flag put_bits(&pb, 1, 1); // units_field_based_flag -- 2.45.3 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".