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

zhilizhao quinkblack at foxmail.com
Tue Dec 24 14:22:07 EET 2019


Hi Nicolas,

> On Dec 24, 2019, at 6:50 PM, Nicolas George <george at nsup.org> wrote:
> 
> zhilizhao (12019-12-24):
>> 1. AV_PIX_FMT_NB depends on !gaps, unless we calculate and set it manually
> 
> NB is not really the "number of".
> 
>> 2. The reason to deprecated VAAPI in this way (ABI incompatible) is
>> AV_PIX_FMT cannot have gaps
> 
> No, it was because we WANTED AV_PIX_FMT to not have gaps. It had some in
> the past, there may be reasons to have anew in the future.
> 
> But I just realized: there is a much simpler reason that makes this
> particular approach impossible:
> 
> AV_PIX_FMT_NB         ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav*
> AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically
> 
> you cannot use AV_PIX_FMT_NB or AV_SAMPLE_FMT_NB in lavfi, only in lavu.

I get the idea. However, if lavi is built agains version A of libavutils
and use version B at runtime, it’s not guaranteed to work with or without
access to AV_PIX_FMT_NB:

1. For major version bump, AV_PIX_FMT_XXX may have different values
in different versions of libavutils

2. For minor version bump, if there is new AV_PIX_FMT_XXX appends to
AVPixelFormat, it would be safe to use a smaller AV_PIX_FMT_NB_old.
(if we don’t know what the new format is, we don’t know how to deal with it)

IMO the requirement of link with shared libavutils:

1. For libavutils: never change old entries of AVPixelFormat, append new
entry to the tail

2. On the client side of libavutils: access the subset of known formats, and careful
about iterate overflow

PS: It’s not clear the comments are ffmpeg-user oriented or libavutils-user oriented.
libavcodec, libavfilter, and libavdevice have access to AV_PIX_FMT_NB.

Can you help me figure out these contradictions?

> 
> Regards,
> 
> -- 
>  Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list