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 4819C4E24E for ; Mon, 10 Mar 2025 10:52:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3CBF368E462; Mon, 10 Mar 2025 12:52:49 +0200 (EET) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C6BFC68E396 for ; Mon, 10 Mar 2025 12:52:42 +0200 (EET) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-43948f77f1aso23296965e9.0 for ; Mon, 10 Mar 2025 03:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741603962; x=1742208762; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=/5dDMn7t8FIPT8WRFoxScEu0y2lC5kCRuu806cSccwI=; b=EsV4kFYNuJtLI15JvdgQ64MwjIYzJOLIVZahXB+89LJa9fztjj1+r0atF49bZI8Qy9 zPkhV/dtUEHiao9Dj/W0tiflMXanXwvdpBFaO+kaXbNhNQW6RLZlyEyb4F8K/bCdWXVj NhSnKjeMOOhiscUpFLulUXNrpI2somhzWTb7SMkNzZDZ3d7aAOPG15w/EiLmcDdsQBd3 FQmJwJm5CY1Kwannzg+UjEDdTUDiNTKtNF0ODxk4t2k5E1277wisUJMupTZnwWWNG2Fb zfGsqAoYMspW5fVj23c4dacrSjwqmDWieMecMmIQZ+2iCkhvRdTu7pmHtCp4clTCk7/4 dWgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741603962; x=1742208762; h=content-transfer-encoding:in-reply-to:content-language:references :to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/5dDMn7t8FIPT8WRFoxScEu0y2lC5kCRuu806cSccwI=; b=N2IJfIRevy9J/zbP6vk0ERuLNyfXQbbGSGBmVE8V0iLlXppIE+iSh//nwXlIgaCg5T hIaxiZShMsOgWDyqtY+poItPfx5Qdv7uaCmzRLoIRmV0aA1WiNKGr88O7zij5bcciGj9 oAt0ge2QySL+QcEWCxYj5Xgi22xz1ys2TI8pFU4nihTyZcpa2rMWhFUWWccO3FL9Xqim GPnhAUUwGP+ESnKhtGSuVaaEvH1RyTi4xXeypWR2pEEG0Ltjq9AP86lk8iNxG+hrxVso PirMMCiG34CooJ1ft65+sWZbmLSpT8YStLxFuNu9MKXNUmbWAXQt0BMdHMnW3ftRCrSU ts0g== X-Gm-Message-State: AOJu0Yw9uJNHrVYHp+XSf4BuSE0mEWGIwPy6fQG1qS6fa6YlhWhgX8sj nAFEdPkoD7qeZozz8SqW5PhUqMUkOiZr/Ae+WsyHtFOIbRWPVQZlxMnaLQ== X-Gm-Gg: ASbGncscCo+wrcLg3Kl1iVYUr6Ist/B2ACPMFF1QMWhMxTjwTbluqraAraT2Fa7w//B nWNVoEpsUhxt5zIaeSHxF74427ztYq4AgDw26Yi9cmLLhF9+8nnfn7YjVS7d5mEhql/slvnqYf+ zMPoVCe5LNMsRV0Ohj/avNgUHdiTM7ilUo6pxVd53+jgYt+wLL9e6OzZHLEMVCTaMUNERyCUs0/ RBSInn3ZVoIeslBklZ0pl3VDh0JveeTucY3HrPzDEyoqSRYqQZGTsvj0NlWsKdRaMT9JOeZJrFD i/RlSGm09b5S5XYjBXugGKlj39r/oqdz0J8eHue57dSB/Gl/bgm4FQdBNQL7wi7JmywfSWWREXb /z8UgcpogTk/S2ALYBwdvXsM= X-Google-Smtp-Source: AGHT+IH2T071bj8w1ieBsw2BfujwKQRFZad33mJmGF0YSvg/myiR776lBJTG0ZjrYgV8FeMxQlnyww== X-Received: by 2002:a5d:588f:0:b0:38f:3b9b:6f91 with SMTP id ffacd0b85a97d-39132d31b0emr6485685f8f.12.1741603961828; Mon, 10 Mar 2025 03:52:41 -0700 (PDT) Received: from ?IPV6:2001:9e8:1d92:d700:e519:8bb2:4ccf:d26b? ([2001:9e8:1d92:d700:e519:8bb2:4ccf:d26b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c103aa5sm14667618f8f.94.2025.03.10.03.52.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Mar 2025 03:52:41 -0700 (PDT) Message-ID: Date: Mon, 10 Mar 2025 11:52:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Leandro Santiago To: ffmpeg-devel@ffmpeg.org References: <15e94abf-61dc-49ab-a209-bf6d1b3701ae@gmail.com> Content-Language: en-US In-Reply-To: <15e94abf-61dc-49ab-a209-bf6d1b3701ae@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] avutil/frame: add new functions to get frame side data 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: Just pinging to see if anyone has had time to look at this patch :-) I also noticed that this patch did not trigger an entry on patchwork. Is it normal or should the patches go to patchwork automatically? Also, what's the correct approach within ffmpeg codebase to implement unit tests? Or would you recommend using the FATE tests? On 3/4/25 12:55, Leandro Santiago wrote: > The functions are: > > av_frame_side_data_get_nth_c() > av_frame_side_data_get_nth() > av_frame_get_nth_side_data() > > They mimic the counterparts without the `_nth` suffix/infix, with an extra > argument, which specifies the relative position of the entry of a given > type. > > Signed-off-by: Leandro Santiago > --- > libavutil/frame.c | 10 ++++++++++ > libavutil/frame.h | 43 ++++++++++++++++++++++++++++++++++++++++--- > libavutil/side_data.c | 14 +++++++++++--- > 3 files changed, 61 insertions(+), 6 deletions(-) > > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 71bde48f8b..dd0fd06378 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -699,6 +699,16 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, > ); > } > > +AVFrameSideData *av_frame_get_nth_side_data(const AVFrame *frame, > + enum AVFrameSideDataType type, > + int n) > +{ > + return (AVFrameSideData *)av_frame_side_data_get_nth( > + frame->side_data, frame->nb_side_data, > + type, n > + ); > +} > + > static int frame_copy_video(AVFrame *dst, const AVFrame *src) > { > int planes; > diff --git a/libavutil/frame.h b/libavutil/frame.h > index 49260ae2dd..56375280bb 100644 > --- a/libavutil/frame.h > +++ b/libavutil/frame.h > @@ -1017,12 +1017,22 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, > AVBufferRef *buf); > > /** > - * @return a pointer to the side data of a given type on success, NULL if there > + * @return a pointer to the first side data of a given type on success, NULL if there > * is no side data with such type in this frame. > */ > AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, > enum AVFrameSideDataType type); > > +/** > + * @return a pointer to the side data of a given type on success, > + * after skipping the first matches. Otherwise return NULL if there > + * is no side data with such type in this frame or if all the matches were skipped. > + * @param n the relative position of the side data entry > + */ > +AVFrameSideData *av_frame_get_nth_side_data(const AVFrame *frame, > + enum AVFrameSideDataType type, > + int n); > + > /** > * Remove and free all side data instances of the given type. > */ > @@ -1170,7 +1180,7 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, > const AVFrameSideData *src, unsigned int flags); > > /** > - * Get a side data entry of a specific type from an array. > + * Get the first side data entry of a specific type from an array. > * > * @param sd array of side data. > * @param nb_sd integer containing the number of entries in the array. > @@ -1184,7 +1194,24 @@ const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *s > enum AVFrameSideDataType type); > > /** > - * Wrapper around av_frame_side_data_get_c() to workaround the limitation > + * Get a side data entry of a specific type from an array. > + * > + * @param sd array of side data. > + * @param nb_sd integer containing the number of entries in the array. > + * @param type type of side data to be queried > + * @param n relative position of the side data entry. > + * > + * @return a pointer to the side data of a given type on success, NULL if there > + * is no side data with such type in this set or all the entries were skipped. > + */ > +const AVFrameSideData *av_frame_side_data_get_nth_c(const AVFrameSideData * const *sd, > + const int nb_sd, > + enum AVFrameSideDataType type, > + int n > +); > + > +/** > + * Wrappers around av_frame_side_data_get{_nth}_c() and to workaround the limitation > * that for any type T the conversion from T * const * to const T * const * > * is not performed automatically in C. > * @see av_frame_side_data_get_c() > @@ -1198,6 +1225,16 @@ const AVFrameSideData *av_frame_side_data_get(AVFrameSideData * const *sd, > nb_sd, type); > } > > +static inline > +const AVFrameSideData *av_frame_side_data_get_nth(AVFrameSideData * const *sd, > + const int nb_sd, > + enum AVFrameSideDataType type, > + int n) > +{ > + return av_frame_side_data_get_nth_c((const AVFrameSideData * const *)sd, > + nb_sd, type, n); > +} > + > /** > * Remove and free all side data instances of the given type from an array. > */ > diff --git a/libavutil/side_data.c b/libavutil/side_data.c > index 17965f2d3c..bfe408e611 100644 > --- a/libavutil/side_data.c > +++ b/libavutil/side_data.c > @@ -301,13 +301,21 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, > return 0; > } > > -const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *sd, > +const AVFrameSideData *av_frame_side_data_get_nth_c(const AVFrameSideData * const *sd, > const int nb_sd, > - enum AVFrameSideDataType type) > + enum AVFrameSideDataType type, > + int n) > { > for (int i = 0; i < nb_sd; i++) { > - if (sd[i]->type == type) > + if (sd[i]->type == type && --n < 0) > return sd[i]; > } > return NULL; > } > + > +const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *sd, > + const int nb_sd, > + enum AVFrameSideDataType type) > +{ > + return av_frame_side_data_get_nth_c(sd, nb_sd, type, 0); > +} _______________________________________________ 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".