[FFmpeg-devel] [PATCH] avcodec/internal: Move AVCodecInternal to a header of its own

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Aug 2 18:37:07 EEST 2023


Anton Khirnov:
> Quoting Andreas Rheinhardt (2023-07-11 03:10:38)
>> This allows to avoid exposing AVCodecInternal to files that
>> don't need it and only include internal.h for something else
>> (like the avpriv functions which are of course included outside
>> of libavcodec where AVCodecInternal should never be visible).
> 
> Actually looking at all those other things in internal.h it seems to me
> that (almost?) all of them belong somewhere else.
> 
> Multiple functions are only used in one place, some others are
> encoding-only and belong in encode.h, etc.
> 

I just sent some patches that moved some of those functions to their
only callers; there is one more, namely ff_alloc_timecode_sei(), but I
am unsure of how intentional it was to put it in utils.c.

ff_guess_coded_bitrate() could be moved to encode.h, but I am unsure
whether the implementation should not be moved to encode.c (or to a new
encode_utils.c?) in this case. Furthermore this function is only used by
encoders, but it is used to set a field (namely AVCodecContext.bit_rate)
which encoders are not allowed to set (for raw codecs the bitrate that
will be used is actually determined by other factors (like dimensions
fps, pixel/sample format), but normally bitrate is an input parameter
when encoding).

ff_add_cpb_side_data() is used by mostly encoders, but also used by
mpeg12dec.c, so there is currently no better place for this.

The two avpriv functions as well as ff_toupper4() (duplicated into lavf
for shared builds) can't be moved to their only callers, obviously.

ff_exp2fi() is only used by two places and could be moved to e.g.
mathops.h, but then this function would be included in so many places
where it is not used.

ff_match_2uint16() could be used to e.g. mpegutils.h, but that is just
based upon the current users and not about the function itself.

FF_SANE_NB_CHANNELS is used in several demuxers (which is the reason why
I want to separate AVCodecInternal out of internal.h).

So I conclude that one can't move everything except AVCodecInternal out
of internal.h into existing headers/callers. So either one adds a new
header misc.h or utils.h for the rest or one adds a new header for
AVCodecInternal. Or one leaves everything as it is.

- Andreas



More information about the ffmpeg-devel mailing list