[FFmpeg-devel] [PATCH v2] avfilter/formats: optimize ff_all_formats

Nicolas George george at nsup.org
Mon Dec 23 17:11:53 EET 2019


Tomas Härdin (12019-12-09):
> As far as I can tell this is OK, and it passes FATE. But it just looks
> very very wrong. Why does this function even exist if all it
> effectively does is return the integers from 0..count-1?

For some time, there were gaps in the list of pixel formats, the task of
this function was precisely there to avoid the gaps and keep only the
actual pixel formats.

I am not sure about this change. It is technically valid, but it may
cause problems later.

There is an intermediate solution: keep the loop, but allocate only
once (simplified):

        while ((desc = ...))
            count++;
        ret->formats = av_malloc_array(count, sizeof(*ret->formats));
        count = 0;
        while ((desc = ...))
            ret->formats[count] = ...;

What do other developers think about it, with these explanations?

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20191223/848f1db7/attachment.sig>


More information about the ffmpeg-devel mailing list