[FFmpeg-devel] [PATCH] avutil/frame: move wipe_side_data counter to its utilized scope

Jan Ekström jeebjp at gmail.com
Mon Mar 13 11:53:08 EET 2023


On Mon, Mar 13, 2023 at 12:10 AM Andreas Rheinhardt
<andreas.rheinhardt at outlook.com> wrote:
>
> Jan Ekström:
> > Originally in 77b2cd7b41d7ec8008b6fac753c04f77824c514c this
> > counter was separate in av_frame_unref, in which the same counter
> > was re-utilized multiple times over multiple loops.
> >
> > This code was then refactored into wipe_side_data as-is in
> > 5d839778b9f3edb682b7f71dde4f80f07c75b098 , keeping the location of
> > counter initialization. This was unnecessary, as the counter was
> > no longer utilized outside of the for loop's scope and thus could
> > reside within the loop itself.
> > ---
> >  libavutil/frame.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > index 9545477acc..d06a673779 100644
> > --- a/libavutil/frame.c
> > +++ b/libavutil/frame.c
> > @@ -74,9 +74,7 @@ static void free_side_data(AVFrameSideData **ptr_sd)
> >
> >  static void wipe_side_data(AVFrame *frame)
> >  {
> > -    int i;
> > -
> > -    for (i = 0; i < frame->nb_side_data; i++) {
> > +    for (int i = 0; i < frame->nb_side_data; i++) {
> >          free_side_data(&frame->side_data[i]);
> >      }
> >      frame->nb_side_data = 0;
>
> Don't create a patch for a single for loop; do this for all for loops in
> this file where it is possible.
>

Noted. I just noticed this specific case as I was working on the side
data to avctx stuff for passing through HDR metadata etc to encoders.

Will check the rest of the file for related stuff as I get off $dayjob .

Jan


More information about the ffmpeg-devel mailing list