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 B9D794CC60 for ; Mon, 24 Feb 2025 20:52:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 33FC868C993; Mon, 24 Feb 2025 22:52:16 +0200 (EET) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B60A268B9E4 for ; Mon, 24 Feb 2025 22:52:08 +0200 (EET) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 2F9352819FD4B; 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; bh=sJ68dFEK8iS40PRKGr2jJMqfVh/E9b2EvMIxxgePQYs=; b=noeQ+6qcZ9s8f75A3YTBX0KrwWvprdK7g1qurvJmKpEgjvBJz+nUaH0G7369D4gb0S/DLU hSsjJSDqH2T71tsrpWqF7JJE+M9tnPF7eCWuU4tFacgB0ZHCn2i1h4/G1KGTIQYrkXJSsU c9ipZBRV6QHaJoKQvXIS4hX2FW23SwxNIhqkbnLgzuxi0y0gb3QmZfigcTY6F9VPzBKRr2 n3TGhHt4XOFmEdpHG9HM0vkGjkjGIfdCKXrmYkBPj31AV7PvDmVjvVVoFEVxiSCM9ahiZu rtV8ilkGXRIJIwTX3FI3Wgb3kXDpbn55WoE9bh4BXNG/lItugbGXktOAIHobdQ== From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Feb 2025 21:51:48 +0100 Message-ID: <20250224205159.13620-1-timo@rothenpieler.org> X-Mailer: git-send-email 2.45.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avutil/timecode: add av_timecode_set_smpte 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: --- doc/APIchanges | 3 +++ libavutil/timecode.c | 24 +++++++++++++++--------- libavutil/timecode.h | 17 +++++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index ac506f4b56..71240d39fd 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2025-02-xx - xxxxxxxxxx - lavu 59.58.100 - timecode.h + Add av_timecode_set_smpte(). + 2025-02-xx - xxxxxxxxxx - lavu 59.57.100 - log.h Add flags AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME. diff --git a/libavutil/timecode.c b/libavutil/timecode.c index f454466f97..e6cd811a2b 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -136,23 +136,29 @@ static unsigned bcd2uint(uint8_t bcd) return low + 10*high; } -char *av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field) +void av_timecode_set_smpte(int *drop, int *hh, int *mm, int *ss, int *ff, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field) { - 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 && !prevent_df; // 1-bit drop if not arbitrary bit + *hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours + *mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes + *ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds + *ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames + *drop = tcsmpte & 1<<30 && !prevent_df; // 1-bit drop if not arbitrary bit if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) { - ff <<= 1; + *ff <<= 1; if (!skip_field) { if (av_cmp_q(rate, (AVRational) {50, 1}) == 0) - ff += !!(tcsmpte & 1 << 7); + *ff += !!(tcsmpte & 1 << 7); else - ff += !!(tcsmpte & 1 << 23); + *ff += !!(tcsmpte & 1 << 23); } } +} + +char *av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field) +{ + int hh, mm, ss, ff, drop; + av_timecode_set_smpte(&drop, &hh, &mm, &ss, &ff, rate, tcsmpte, prevent_df, skip_field); snprintf(buf, AV_TIMECODE_STR_SIZE, "%02u:%02u:%02u%c%02u", hh, mm, ss, drop ? ';' : ':', ff); diff --git a/libavutil/timecode.h b/libavutil/timecode.h index fe0fc83576..2685e48db2 100644 --- a/libavutil/timecode.h +++ b/libavutil/timecode.h @@ -95,6 +95,23 @@ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum) */ uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff); +/** + * Convert SMPTE 12M binary representation to sei info. + * + * @param drop drop flag output + * @param hh hour output + * @param mm minute output + * @param ss second output + * @param ff frame number output + * @param rate frame rate of the timecode + * @param tcsmpte the 32-bit SMPTE timecode + * @param prevent_df prevent the use of a drop flag when it is known the DF bit + * is arbitrary + * @param skip_field prevent the use of a field flag when it is known the field + * bit is arbitrary (e.g. because it is used as PC flag) + */ +void av_timecode_set_smpte(int *drop, int *hh, int *mm, int *ss, int *ff, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field); + /** * Load timecode string in buf. * diff --git a/libavutil/version.h b/libavutil/version.h index ee4a36cb17..4b584fd569 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 57 +#define LIBAVUTIL_VERSION_MINOR 58 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 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".