[FFmpeg-devel] [PATCH v2 02/13] avcodec: add extended AVCodec color metadata

Niklas Haas ffmpeg at haasn.xyz
Sat Oct 14 13:29:15 EEST 2023


On Fri, 13 Oct 2023 19:10:33 +0200 Andreas Rheinhardt <andreas.rheinhardt at outlook.com> wrote:
> This design has several drawbacks:
> 1. It adds stuff that will only be set by a tiny minority of AVCodec's
> to all of them.
> 2. It is based around the underlying assumption that the set of
> permissible states (tupels) is a cartesian product of a set of color
> spaces, a set of color ranges etc. This is wrong: E.g. VP9 disallows
> limited-range RGB (it is syntactically impossible to set the color range
> when using RGB color space).
> 3. I don't see how the MJPEG encoder behaviour where the valid formats
> de facto depend upon strictness can be encoded in this way; isn't the
> aim to get rid of the necessity of the workaround in ffmpeg cli?
> 
> 1. and 2. suggests using some form of function that returns a list of
> supported tupels; if said function uses an AVCodecContext* parameter,
> said list can depend upon the state of the AVCodecContext given to it,
> thereby solving 3. to the extent that one can get the supported
> combinations given AVCodecContext options (but I do not see a good way
> to signal which options modify the supported combinations).

There are two other designs I can think of:

1. Enumerate all possible combinations as a list. To avoid combinatoric
   explosion, setting any field to 'UNSPECIFIED' implies no restriction
   on that field. So the default (no list) would be equivalent to a list
   with a single entry containing values of UNSPECIFIED for every entry.

2. Provide a single function which merely checks if a given combination
   is supported or not.

#2 would work for the short term but runs into the same risk of
exponential explosion if we need to start finding a common format
between different filters.

So maybe #1 is the correct approach here. It would also simplify
extending the filter API, as we would only need one set of list
managing/merging/compat testing boilerplate for all of the colorspace
metadata.

I will try implementing #1 on a separate branch.


More information about the ffmpeg-devel mailing list