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 ESMTP id 63D364A48C for ; Thu, 28 Mar 2024 12:19:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E809E68D6C3; Thu, 28 Mar 2024 14:19:34 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 463A268D4D7 for ; Thu, 28 Mar 2024 14:19:28 +0200 (EET) Authentication-Results: mail0.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=KOjXsCKC; dkim-atps=neutral Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id EDA8B240DAC for ; Thu, 28 Mar 2024 13:19:27 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 6sMdH1subR8S for ; Thu, 28 Mar 2024 13:19:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1711628367; bh=8mHscNAFQ7to0wOZ1t4AJV1y1UYjc48VNmM9seIEmO8=; h=Subject:From:To:In-Reply-To:References:Date:From; b=KOjXsCKCru2irZEoKluad7MQ2kYinWo+MC5hSAf6C/vGVvWxbRxCj2jzNjYonjiuF dJ61EdKJS8r2qTC025BEvFxGXla+nyyifYQcGYSOha98x5Rqeaxu5MYdD2rFKevGoc LIwjBoC/euCaleKgm7VveOjuyKizkMrmOxdvtZYhOO7i3BqlH2h+7EZkRO6rnx6nOU wCcpDmqQdCfAO52cUuHbD4GzMWvWRFCzjg40guvEQTZ2Y8pXVNOlAeVJZz2I0hhk4S 7UrCuifCTWvJgtWzLaxl6RWT9cqkai8Pat8XFkr0TIFb0W1sABb/j233hG4rsudxLx SqIL9uARai0zg== Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 65E9D2404AF for ; Thu, 28 Mar 2024 13:19:27 +0100 (CET) Received: by lain.khirnov.net (Postfix, from userid 1000) id 444671601B9; Thu, 28 Mar 2024 13:19:27 +0100 (CET) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <91096d51-c7c3-4d46-85ce-61fee7e3be0c@gmail.com> References: <20240328031210.21407-1-jamrial@gmail.com> <20240328031210.21407-2-jamrial@gmail.com> <171162527283.7287.16403425396625504098@lain.khirnov.net> <91096d51-c7c3-4d46-85ce-61fee7e3be0c@gmail.com> Mail-Followup-To: FFmpeg development discussions and patches Date: Thu, 28 Mar 2024 13:19:27 +0100 Message-ID: <171162836725.7287.11280806609859440632@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 2/7 v4] avutil/frame: add helper for adding side data w/ AVBufferRef to array 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: 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: Quoting James Almer (2024-03-28 12:49:08) > On 3/28/2024 8:27 AM, Anton Khirnov wrote: > > Quoting James Almer (2024-03-28 04:12:05) > >> Signed-off-by: James Almer > >> --- > >> libavutil/frame.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ > >> libavutil/frame.h | 34 ++++++++++++++++++++++++++++++ > >> 2 files changed, 87 insertions(+) > >> > >> diff --git a/libavutil/frame.c b/libavutil/frame.c > >> index d9bd19b2aa..a165e56a64 100644 > >> --- a/libavutil/frame.c > >> +++ b/libavutil/frame.c > >> @@ -834,6 +834,59 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, > >> return ret; > >> } > >> > >> +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, > >> + enum AVFrameSideDataType type, > >> + AVBufferRef **pbuf, unsigned int flags) > >> +{ > >> + const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); > >> + AVFrameSideData *sd_dst = NULL; > >> + AVBufferRef *buf; > >> + > >> + if (!sd || !pbuf || !*pbuf || !nb_sd || (*nb_sd && !*sd)) > > > > Overzealous checks like these tend to hide bugs. Any of these conditions > > being false means the caller is insane and we should crash. > > I'll remove some, but others simplify the code below (like knowing > beforehand that *pbuf is not NULL). You can just assume them all to be true. Or use av_assert0(). > >> diff --git a/libavutil/frame.h b/libavutil/frame.h > >> index 2ea129888e..3e5d170a5b 100644 > >> --- a/libavutil/frame.h > >> +++ b/libavutil/frame.h > >> @@ -1048,6 +1048,10 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); > >> * Don't add a new entry if another of the same type exists. > >> */ > >> #define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1) > >> +/** > >> + * Create a new reference instead of taking ownership of the passed in one. > >> + */ > >> +#define AV_FRAME_SIDE_DATA_FLAG_NEW_REF (1 << 2) > > > > Who needs this? > > Someone who wants to keep the reference around, like when attaching a > buffer to several outputs (global to individual output frames). Is that a common enough use case to warrant this flag? It complicates the code quite substantially. And if you're making some side data instance global, what is the point of also attaching it to frames? -- Anton Khirnov _______________________________________________ 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".