[FFmpeg-devel] [PATCH v2 23/33] avutil/opt: add av_opt_print_num

Diederick C. Niehorster dcnieho at gmail.com
Fri Jun 11 23:57:07 EEST 2021


On Fri, Jun 11, 2021 at 10:38 PM Diederick Niehorster <dcnieho at gmail.com> wrote:
>
> This function allows formatting an option value stored in a double (such
> as the min and max fields of an AVOption, or min_value and max_value of
> an AVOptionRange) properly, e.g. 1 for a AV_OPT_TYPE_PIXEL_FMT -> yuyv422.
>
> Useful when printing more info about an option than just its value.
> Usage will be shown in upcoming device_get_capabilities example.

This solution is not perfect, since multiple of the options returned
are not formatted properly now:
- "codec", which is just printed as int since there is no
AV_OPT_TYPE_CODEC or something like that
- "frame_size"/"window_size": these are reported as three components:
"pixel_count", "width", "height", none of which have a known type (and
thus we default to printing the provided double.

The other solution which enables handling this is to add a new
function avdevice_capabilities_print, which you pass a single
AVOptionRange* (not AVOptionRanges** as that would create many lines
of output) and it returns a formatted string. In the implementation of
that function, since we know all the options (and related components),
we can special-case the formatting where needed so that it all comes
out right.

Cheers,
Dee


More information about the ffmpeg-devel mailing list