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 BC0A04E362 for ; Mon, 10 Mar 2025 20:46:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 499C468C38C; Mon, 10 Mar 2025 22:46:09 +0200 (EET) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4431268C360 for ; Mon, 10 Mar 2025 22:46:02 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id A22AE443D8 for ; Mon, 10 Mar 2025 20:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1741639561; 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=9wjbdIV9Lr9UR9mvRWIHstP5B87DZNeXWRwthFHoZZQ=; b=XHtm4pf1bSXES2QYKVbHq7Z97T2b+D3/fjWa7nxqGev/wIkhD52hAK+o0em0R/nI9uZFPc 1fZ7+AtFkVOPvSJRefL8hLJInyNSBvY8xHkoFA09d1qUNM7y8qIzRzpm41c8CU6MgskiAS tfHWwSG3uY6ZOWMhNuqYZ0xhMf0pt2ckY9/TSt7UMSSywC90LpM7nNEHUlv7oi/f2UKdQY UOhilU25fS6bW/gcNIOeQH4nFoGHVURVY29CDD5yRGwB4jpppC8ZqgeFh0ssRUAK/EMb6J cg5eoocIMmRfFGJdYlpxzERuxTGMW4jiLgT0GNqMw7XQzmA6UfjTv0D7fHtX3A== Date: Mon, 10 Mar 2025 21:46:00 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250310204600.GP4991@pb2> References: <20250225220121.98449-1-romain.beauxis@gmail.com> <20250225220121.98449-2-romain.beauxis@gmail.com> <20250309183143.GJ4991@pb2> MIME-Version: 1.0 In-Reply-To: X-GND-State: clean X-GND-Score: -70 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduvddtfeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdeftddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddunecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpedutedvhfduuedugedufefghefhvedvgffgffekhfdvgfdvtefftdejkeehteefheenucfkphepgedurdeiiedrieejrdduudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieejrdduudefpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH v7 1/8] Add generic metadata injection using AV_PKT_DATA_METADATA_UPDATE 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-Type: multipart/mixed; boundary="===============6062370149463005419==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============6062370149463005419== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pfS+lPWLHeKc+Omf" Content-Disposition: inline --pfS+lPWLHeKc+Omf Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 10, 2025 at 08:50:06AM -0500, Romain Beauxis wrote: > Le dim. 9 mars 2025 =E0 13:31, Michael Niedermayer > a =E9crit : > > > > On Tue, Feb 25, 2025 at 04:01:14PM -0600, Romain Beauxis wrote: > > > libavcodec/decode.c: intercept `AV_PKT_DATA_METADATA_UPDATE` packet > > > extra data, attach them to the next decoded frame. > > > > > > --- > > > libavcodec/decode.c | 20 ++++++++++++++++++++ > > > 1 file changed, 20 insertions(+) > > > > > > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > > > index cac7e620d2..96e2f0ce95 100644 > > > --- a/libavcodec/decode.c > > > +++ b/libavcodec/decode.c > > > @@ -97,6 +97,8 @@ typedef struct DecodeContext { > > > int lcevc_frame; > > > int width; > > > int height; > > > + > > > + AVDictionary *pending_metadata; > > > } DecodeContext; > > > > > > static DecodeContext *decode_ctx(AVCodecInternal *avci) > > > @@ -729,6 +731,8 @@ int attribute_align_arg avcodec_send_packet(AVCod= ecContext *avctx, const AVPacke > > > { > > > AVCodecInternal *avci =3D avctx->internal; > > > DecodeContext *dc =3D decode_ctx(avci); > > > + const uint8_t *side_metadata; > > > + size_t size; > > > int ret; > > > > > > if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec= )) > > > @@ -746,6 +750,14 @@ int attribute_align_arg avcodec_send_packet(AVCo= decContext *avctx, const AVPacke > > > ret =3D av_packet_ref(avci->buffer_pkt, avpkt); > > > if (ret < 0) > > > return ret; > > > + > > > + side_metadata =3D av_packet_get_side_data(avpkt, AV_PKT_DATA= _METADATA_UPDATE, &size); > > > + if (side_metadata) { > > > + av_dict_free(&dc->pending_metadata); > > > + ret =3D av_packet_unpack_dictionary(side_metadata, size,= &dc->pending_metadata); > > > + if (ret < 0) > > > + return ret; > > > + } > > > } else > > > dc->draining_started =3D 1; > > > > > > @@ -815,6 +827,7 @@ fail: > > > int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame) > > > { > > > AVCodecInternal *avci =3D avctx->internal; > > > + DecodeContext *dc =3D decode_ctx(avci); > > > int ret; > > > > > > if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec= )) > > > @@ -887,6 +900,12 @@ int ff_decode_receive_frame(AVCodecContext *avct= x, AVFrame *frame) > > > } > > > } > > > #endif > > > + > > > + if (dc->pending_metadata) { > > > + av_dict_copy(&frame->metadata, dc->pending_metadata, AV_DICT= _APPEND); > > > + av_dict_free(&dc->pending_metadata); > > > + } > > > + > > > return 0; > > > fail: > > > av_frame_unref(frame); > > > > Does this work correctly, if theres a delay/latency in the decoder ? >=20 > Can you describe a scenario that you're thinking about? The users feeds several packets into a multi threaded decoder and then depending on the threads and luck sooner or later one frame comes out. Passing some data in a way that disregards this, feels wrong Hypothetically there also could be a 2nd AV_PKT_DATA_METADATA_UPDATE going in before the frame corresponding to the first comes out but i may be missing something thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is a danger to trust the dream we wish for rather than the science we have, -- Dr. Kenneth Brown --pfS+lPWLHeKc+Omf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZ89PgwAKCRBhHseHBAsP q5lVAJwNcOyi1473nwDhPV66NzZMdiKpvACdFNc/x+qGP+0UUE7DSGsd/DNokCE= =lHVx -----END PGP SIGNATURE----- --pfS+lPWLHeKc+Omf-- --===============6062370149463005419== 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 https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============6062370149463005419==--