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 CEADB4D976 for ; Wed, 26 Feb 2025 20:05:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3D0E668CDCE; Wed, 26 Feb 2025 22:05:53 +0200 (EET) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5075168C85C for ; Wed, 26 Feb 2025 22:05:46 +0200 (EET) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id C342C2819FD62 for ; Wed, 26 Feb 2025 21:05:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1740600345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y4VDpcawwwPJXkRPurzLtHmV3C6D7WracFrsnDZpj64=; b=Vmw8YE6MqYvKZATnKsjbCYA7jZmGemnN7/SJvdkoimm1aGekjg6UZLQMWz3RxXnEOgohQG IUgwAxdM0H/DiuWHuuH2juTN+MkPpxHpAi6RiSUX8rAVg6lK0NRtIfZ69U4iIHdWeULTrt tigwD1wxRBe80iz2tYFKdj6MDeskLsTMUkYwLyRx+J0mPzy2cozdLCE+i0VgKox70SeVQB 7IV/Oar/B1P5BnT0d/m0lDRW6WKhHbMv3nJTR4n+aLi5Y7Y+y0OI2eWHEOtmWR/nmXptcr rKICZLcLluFMnXzqfkFip9ZIgjoQgHd/+gTqpGyHtSf82J0FBErt46+doRSkuQ== Message-ID: <08722f02-7ce1-476d-92d9-81d8ad4c0ee5@rothenpieler.org> Date: Wed, 26 Feb 2025 21:05:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20250224205159.13620-1-timo@rothenpieler.org> Content-Language: en-US From: Timo Rothenpieler In-Reply-To: <20250224205159.13620-1-timo@rothenpieler.org> Subject: Re: [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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 24.02.2025 21:51, Timo Rothenpieler wrote: > --- > 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, \ ping. Would really like a second pair of eyes on new public API before I push this. _______________________________________________ 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".