From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id B2AD74513A for ; Sat, 13 Sep 2025 11:12:11 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'2qxjLQ2KDppTNQSJ6tBJT2QDvLzBEEsdOYVBccEbJEc=', expected b'KeHty35Yi2HO+iuPdO2ZM8EvZVHABz0yaisM7uL7qBo=')) header.d=niedermayer.cc header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1757761920; h=date : to : message-id : references : mime-version : in-reply-to : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : from; bh=E+gVl1T8vcbnshJUKd/6+Q/RM3OyNAujIrfljbayAbY=; b=UHPywTo0x+3gBx3J6qSTWJqNFmfGyZi9382BLU9bVmGKEN8NQpRKHJCJvQZoCl1i1cyt8 tCOk86jqDKtLafjYhTvenZbORTdrg4I2w2NIIyzu9ph7ACJdcEHiI0Odf9EqOwdroGPCRiW /JclRTGv6QQI+QZvk94F/9/KLoPEhRy5V5bQkP6j+Qe+0/i8V7qRpydJDdge3edi82t3n7D t3sh/oSkPIowzXrx9nwtTgZKzH3SBohT6ITRhCFfx2+x7+Nm/OIMXFzEjiM+W812khvoybB p/IVbwf48HnqHKvAdDObpPBjs81Y0zxsSLMIOa7w7Wj6FfFwiQXrE/uuEmOA== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id B7F2C6802B6; Sat, 13 Sep 2025 14:12:00 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1757761919; b=mS9eiZH8/6/PvBmB/qcktDooyxzKb3OMEbgkNpuuW1NjEGtMgRGVkgVAwm26gZ6q0Kgev JCiIO2GTor09KnUU1EmYYxf38JUsqYeD1OrgS9rQb9zCz83D0eU5rzjkdyxMbVhJ41bObdx 4vd3xWbmAvVqGdbDDnlPZ7dfgqfDd5KQ96+kzJ2WmoBUnOsKarcCBRnPuuRkjimLMC5qkYM qq/qvtE42Jp8h1PcAg0d0NYC9IST943QHTXOCXuR40Kit31jrFcbwtH3DrOFYjVcnEW8pzt R95RQx+3rC/3PO7Oe3m+eAacRRCCuqAGgaF7r7zFjX2UWVww222z0zR2EwWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1757761919; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=2qxjLQ2KDppTNQSJ6tBJT2QDvLzBEEsdOYVBccEbJEc=; b=nbEd1CByqLhHjOVM0BegwEzPXD1kRmDyIwhJzyrZ4duXZgE6BvtDUNCJRuEWg2kVRH35q mnVV6G0xwlkOVd2mbrN5e5KQ1eTI9gqM93munkMX1rXj06m/yuZcjoPofPMgx8AdLIDHoIi 3ZoRhGf/Mal//5CjGYy2tPheg+sbUMFkAyZCExy7MpfXmEXXb6nJMIbg+or7oJnnRLkN5DF Fw20O8NTVm7dkVVfl1uqBcFjEd7PYQZIeigUQPRDlVbSzRLgjMRLEgThVJM5RPM7DlqKFbL AxTqowV+oeFZsduf3xeaqjCcsyKl32HD3ngjYNYA2PAAvYYwZWrC7CrbGk2g== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=niedermayer.cc; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=niedermayer.cc; arc=none (Message is not ARC signed); dmarc=none Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 855C068004A for ; Sat, 13 Sep 2025 14:11:45 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id BEE874328F for ; Sat, 13 Sep 2025 11:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1757761904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=KeHty35Yi2HO+iuPdO2ZM8EvZVHABz0yaisM7uL7qBo=; b=ffbMdOAIAOert/RvJwXwY/8zj0x1v/Xtd21N3z9VSCyovr13GmhBxZp0FFrKKIM1zBn35n D+12uMllb99F5/btBp2aQqHiT0l/PIVK0dRNvZdot9W5lz3oNyeDM7ruP0SnrXv1s+P3kg 4JMygEn+WtjkqdzYS1p3SJ1OCMoCFPvuFfDhsUBcQb6BiQDMTSBneFulSDmF8OsOuE01UC q4Qm4MAz6mMhQO80ZDIYIMAYygJ81S/v0Ip/k4hQn0EoWoIVmmFy7TUlfbmFkRyBIaUjUt PDGF0SuwV4tE0f4sjNUj76XHt9Kodwlel6NhUeUBflGL8Tsm+FrkBwsRN8MXbQ== Date: Sat, 13 Sep 2025 13:11:44 +0200 To: FFmpeg development discussions and patches Message-ID: <20250913111144.GF29660@pb2> References: <9c3941f4-5b79-4a49-8842-f8eaecceee7a@mediaarea.net> MIME-Version: 1.0 In-Reply-To: <9c3941f4-5b79-4a49-8842-f8eaecceee7a@mediaarea.net> X-GND-State: clean X-GND-Score: -70 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdefudejkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdlfedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepieegkedtjeduffejhfetgeejtdegteetgfegtdfhjefgvefhteegkeejtddvhfevnecukfhppeeguddrieeirdeihedrudejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeguddrieeirdeihedrudejiedphhgvlhhopehlohgtrghlhhhoshhtpdhmrghilhhfrhhomhepmhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtpdhnsggprhgtphhtthhopedupdhrtghpthhtohepfhhfmhhpvghgqdguvghvvghlsehffhhmphgvghdrohhrgh X-GND-Sasl: michael@niedermayer.cc Message-ID-Hash: 4XNV2KC3AJEEA3OLFA2R3JYDQTNDPJA6 X-Message-ID-Hash: 4XNV2KC3AJEEA3OLFA2R3JYDQTNDPJA6 X-MailFrom: SRS0=BF69=3Y=niedermayer.cc=michael@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] Re: [PATCH 4/7] 32-bit timecode to 64-bit RFC 5484 timecode functions List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michael Niedermayer via ffmpeg-devel Cc: Michael Niedermayer Content-Type: multipart/mixed; boundary="===============8606122938664963901==" Archived-At: List-Archive: List-Post: --===============8606122938664963901== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Kj619Q1ZBIHU1PdK" Content-Disposition: inline --Kj619Q1ZBIHU1PdK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 09, 2025 at 02:40:50PM +0200, Jerome Martinez via ffmpeg-devel = wrote: > timecode.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++ > timecode.h | 22 ++++++++++++ > 2 files changed, 126 insertions(+) > 8969dd4cc3cc1d77acde18a6eae065e9413757b2 0004-32-bit-timecode-to-64-bit-= RFC-5484-timecode-function.patch > >From 36cc44569a898c8401944bc16b791632fd4ac985 Mon Sep 17 00:00:00 2001 > From: Dave Rice > Date: Mon, 30 Jun 2025 00:00:00 +0200 > Subject: [PATCH 4/7] 32-bit timecode to 64-bit RFC 5484 timecode functions >=20 > --- > libavutil/timecode.c | 104 +++++++++++++++++++++++++++++++++++++++++++ > libavutil/timecode.h | 22 +++++++++ > 2 files changed, 126 insertions(+) >=20 > diff --git a/libavutil/timecode.c b/libavutil/timecode.c > index bca16b6ac2..81fb66a5e4 100644 > --- a/libavutil/timecode.c > +++ b/libavutil/timecode.c > @@ -243,3 +243,107 @@ int av_timecode_init_from_string(AVTimecode *tc, AV= Rational rate, const char *st > =20 > return av_timecode_init_from_components(tc, rate, flags, hh, mm, ss,= ff, log_ctx); > } > + > +static int bcd_to_int(int bcd) { > + return ((bcd >> 4) & 0xF) * 10 + (bcd & 0xF); > +} > + > +uint64_t av_timecode_expand_to_64bit(uint32_t tc32) > +{ > + uint64_t tc64 =3D 0; > + > + int hours_bcd =3D tc32 & 0x3F; // bits 0-5 > + int bgf1 =3D (tc32 >> 6) & 0x1; // bit 6 > + int bgf2 =3D (tc32 >> 7) & 0x1; // bit 7 > + int minutes_bcd =3D (tc32 >> 8) & 0x7F; // bits 8-14 > + int bgf0 =3D (tc32 >> 15) & 0x1; // bit 15 > + int seconds_bcd =3D (tc32 >> 16) & 0x7F; // bits 16-22 > + int frames_bcd =3D (tc32 >> 24) & 0x3F; // bits 24-29 > + int drop =3D (tc32 >> 30) & 0x1; // bit 30 > + int color =3D (tc32 >> 31) & 0x1; // bit 31 > + > + int hours =3D bcd_to_int(hours_bcd); > + int minutes =3D bcd_to_int(minutes_bcd); > + int seconds =3D bcd_to_int(seconds_bcd); > + int frames =3D bcd_to_int(frames_bcd); > + > + // Units and tens > + int uh =3D hours % 10, th =3D hours / 10; > + int um =3D minutes % 10, tm =3D minutes / 10; > + int us =3D seconds % 10, ts =3D seconds / 10; > + int uf =3D frames % 10, tf =3D frames / 10; > + > + // Assign bits as per RFC 5484 layout > + tc64 |=3D (uint64_t)(uf & 0xF) << 0; // Units of frames uf is limited to 0..9 it doesnt need &0xf > + tc64 |=3D 0 << 4; // First binary group > + tc64 |=3D (uint64_t)(tf & 0x3) << 8; // Tens of frames (2 bits) > + tc64 |=3D (uint64_t)drop << 10; // Drop frame flag > + tc64 |=3D (uint64_t)color << 11; // Color frame flag > + tc64 |=3D 0 << 12; // Second binary group > + > + tc64 |=3D (uint64_t)(us & 0xF) << 16; // Units of seconds us is limited to 0..9 it doesnt need &0xf > + tc64 |=3D 0 << 20; // Third binary group > + tc64 |=3D (uint64_t)(ts & 0x7) << 24; // Tens of seconds > + tc64 |=3D 0 << 27; // Polarity correction > + tc64 |=3D 0 << 28; // Fourth binary group > + > + tc64 |=3D (uint64_t)(um & 0xF) << 32; // Units of minutes same > + tc64 |=3D (uint64_t)0 << 36; // Fifth binary group > + tc64 |=3D (uint64_t)(tm & 0x7) << 40; // Tens of minutes > + tc64 |=3D (uint64_t)bgf0 << 43; // BGF0 > + tc64 |=3D (uint64_t)0 << 44; // Sixth binary group > + > + tc64 |=3D (uint64_t)(uh & 0xF) << 48; // Units of hours same > + tc64 |=3D (uint64_t)0 << 52; // Seventh binary group > + tc64 |=3D (uint64_t)(th & 0x3) << 56; // Tens of hours > + tc64 |=3D (uint64_t)bgf1 << 58; // BGF1 > + tc64 |=3D (uint64_t)bgf2 << 59; // BGF2 > + tc64 |=3D (uint64_t)0 << 60; // Eighth binary group > + > + return tc64; > +} > + > +static int int_to_bcd(int val) { > + return ((val / 10) << 4) | (val % 10); > +} > + > +uint32_t av_timecode_parse_from_64bit(uint64_t tc64) > +{ > + uint32_t tc32 =3D 0; > + > + int uf =3D (tc64 >> 0) & 0xF; // Ones of frames > + int tf =3D (tc64 >> 8) & 0x3; // Tens of frames > + int drop =3D (tc64 >> 10) & 0x1; > + int color=3D (tc64 >> 11) & 0x1; > + > + int us =3D (tc64 >> 16) & 0xF; // Ones of seconds > + int ts =3D (tc64 >> 24) & 0x7; // Tens of seconds > + > + int um =3D (tc64 >> 32) & 0xF; // Ones of minutes > + int tm =3D (tc64 >> 40) & 0x7; // Tens of minutes > + int bgf0 =3D (tc64 >> 43) & 0x1; > + > + int uh =3D (tc64 >> 48) & 0xF; // Ones of hours > + int th =3D (tc64 >> 56) & 0x3; // Tens of hours > + int bgf1 =3D (tc64 >> 58) & 0x1; > + int bgf2 =3D (tc64 >> 59) & 0x1; > + > + int hours =3D int_to_bcd(th * 10 + uh); > + int minutes =3D int_to_bcd(tm * 10 + um); > + int seconds =3D int_to_bcd(ts * 10 + us); > + int frames =3D int_to_bcd(tf * 10 + uf); > + > + // Assemble tc32 using the FFmpeg SMPTE 32-bit format > + tc32 |=3D (hours & 0x3F) << 0; // bits 0-5: hours (BCD) > + tc32 |=3D (bgf1 & 0x1) << 6; // bit 6: BGF1 > + tc32 |=3D (bgf2 & 0x1) << 7; // bit 7: BGF2 (or FIELD) > + tc32 |=3D (minutes & 0x7F) << 8; // bits 8-14: minutes (BCD) > + tc32 |=3D (bgf0 & 0x1) << 15; // bit 15: BGF0 > + tc32 |=3D (seconds & 0x7F) << 16; // bits 16-22: seconds (BCD) > + tc32 |=3D 0 << 23; // bit 23: FIELD (set to 0) > + tc32 |=3D (frames & 0x3F) << 24; // bits 24-29: frames (BCD) > + tc32 |=3D (drop & 0x1) << 30; // bit 30: drop frame flag > + tc32 |=3D (color & 0x1) << 31; // bit 31: color frame flag > + > + return tc32; > +} should some of these functions have checks on the input being valid ? or is such a check harmfull ? or already done elsewhere ? thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt. --Kj619Q1ZBIHU1PdK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaMVRbwAKCRBhHseHBAsP q1agAJ0XI3kYWvZ6nFFiNeFPUsXAPBo88QCfZhu4NqZ/eSR7e/MU2fwRRAC0rZU= =Ny64 -----END PGP SIGNATURE----- --Kj619Q1ZBIHU1PdK-- --===============8606122938664963901== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org --===============8606122938664963901==--