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 2F95C4B0F7 for ; Fri, 28 Feb 2025 22:49:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 556A368DC0C; Sat, 1 Mar 2025 00:49:49 +0200 (EET) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3039C68DD09 for ; Sat, 1 Mar 2025 00:49:43 +0200 (EET) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 7DBA82819FD04 for ; Fri, 28 Feb 2025 23:49:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1740782982; 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=koYas9Jwo+KinQyUL3SpuWxk8L17LFv5hawJnMuGUQg=; b=f9BBGNWlxpxiRiH0jnMEbVvyKgXApbAYGP252uUwzB6VLomrsGRY9v+kH14W/Fx5Lg0cLG 2m2tDfoqCJhJLCDGr9WT55XSZJC4OxeWj24bEBFEpQWRbXp/58MYLzL9N9C0VtLo6QEfnl kMRDhd/syDYlDrsF66iafbkyIGtakAEWedJt6at0Rc0ymrskThYGW29JAhZ6IwC5iFBS5s /zNFeBB+1OZ0iLoxni9Cv61oMqfRySN1/myAEvtZ/tKFQZ6xrPgv9B2WjUzzPi3IYFgED3 Rvl966K40qVe1R/zvvcdw8X+6Pc4wK9mduaTD/P536NmsR0rEuStmS5ILjGZsw== Message-ID: Date: Fri, 28 Feb 2025 23:49:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20250228224640.30747-1-timo@rothenpieler.org> <20250228224640.30747-2-timo@rothenpieler.org> Content-Language: en-US From: Timo Rothenpieler In-Reply-To: <20250228224640.30747-2-timo@rothenpieler.org> Subject: Re: [FFmpeg-devel] [PATCH v2 2/3] avcodec/utils: use new ff_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 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 28.02.2025 23:46, Timo Rothenpieler wrote: > --- > libavcodec/Makefile | 2 ++ > libavcodec/timecode_internal.c | 19 +++++++++++++++++++ > libavcodec/utils.c | 29 +++-------------------------- > libavutil/Makefile | 3 +++ > 4 files changed, 27 insertions(+), 26 deletions(-) > create mode 100644 libavcodec/timecode_internal.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 499f826635..e3ccbf1838 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -64,6 +64,8 @@ OBJS = ac3_parser.o \ > vorbis_parser.o \ > xiph.o \ > > +SHLIBOBJS = timecode_internal.o \ > + > # subsystems > include $(SRC_PATH)/libavcodec/aac/Makefile > include $(SRC_PATH)/libavcodec/hevc/Makefile > diff --git a/libavcodec/timecode_internal.c b/libavcodec/timecode_internal.c > new file mode 100644 > index 0000000000..8682bb1b2e > --- /dev/null > +++ b/libavcodec/timecode_internal.c > @@ -0,0 +1,19 @@ > +/* > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include "libavutil/timecode_internal.c" > diff --git a/libavcodec/utils.c b/libavcodec/utils.c > index dd846b4ae9..0aa5a6f55e 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_internal.h" > #include "avcodec.h" > #include "codec.h" > #include "codec_desc.h" > @@ -968,15 +969,6 @@ AVCPBProperties *av_cpb_properties_alloc(size_t *size) > return props; > } > > -static unsigned bcd2uint(uint8_t bcd) > -{ > - unsigned low = bcd & 0xf; > - unsigned high = bcd >> 4; > - if (low > 9 || high > 9) > - return 0; > - return low + 10*high; > -} > - > int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t prefix_len, > void **data, size_t *sei_size) > { > @@ -1006,23 +998,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; > - } > + unsigned hh, mm, ss, ff, drop; > + ff_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 > diff --git a/libavutil/Makefile b/libavutil/Makefile > index b2b3b9c156..ad534a8acc 100644 > --- a/libavutil/Makefile > +++ b/libavutil/Makefile > @@ -180,6 +180,7 @@ OBJS = adler32.o \ > threadmessage.o \ > time.o \ > timecode.o \ > + timecode_internal.o \ This line belongs into the first patch, fixed locally. > timestamp.o \ > tree.o \ > twofish.o \ > @@ -196,6 +197,8 @@ OBJS = adler32.o \ > video_enc_params.o \ > video_hint.o \ > > +STLIBOBJS = timecode_internal.o \ > + > > OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o > OBJS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.o _______________________________________________ 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".