avformat/avformat: Avoid including codec.h, frame.h

AVCodec is only ever used as an incomplete type (i.e. via a pointer
to an AVCodec) in avformat.h and it is not really part of the core
of avformat.h or libavformat; almost none of our internal users
make use of it (and none make use of hwcontext.h, which is implicitly
included). So switch to use struct AVCodec, but continue to include
codec.h for external users for compatibility.

Also, do the same for AVFrame and frame.h, which is implicitly included
by codec.h (via lavu/hwcontext.h).

Also, remove an unnecessary inclusion of <time.h>.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2023-09-02 12:11:59 +02:00
parent 4e633e51da
commit 0c6e5f321b
25 changed files with 47 additions and 16 deletions

View File

@ -39,6 +39,7 @@
#include <alsa/asoundlib.h>
#include "libavutil/frame.h"
#include "libavutil/internal.h"
#include "libavutil/time.h"

View File

@ -49,6 +49,7 @@
#endif
#include "libavutil/common.h"
#include "libavutil/frame.h"
#include "libavutil/pixdesc.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"

View File

@ -26,6 +26,7 @@
#include "libavformat/mux.h"
#include "libavformat/version.h"
#include "libavutil/channel_layout.h"
#include "libavutil/frame.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"

View File

@ -32,6 +32,7 @@
#include <X11/extensions/Xvlib.h>
#include <sys/shm.h>
#include "libavutil/frame.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"

View File

@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <time.h>
#include "libavutil/attributes.h"
#include "libavutil/common.h"
#include "libavutil/dict.h"

View File

@ -23,12 +23,14 @@
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/frame.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "libavutil/samplefmt.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/codec.h"
#include "libavcodec/bsf.h"
#include "libavcodec/codec_desc.h"
#include "libavcodec/packet_internal.h"

View File

@ -307,10 +307,8 @@
* @}
*/
#include <time.h>
#include <stdio.h> /* FILE */
#include "libavcodec/codec.h"
#include "libavcodec/codec_par.h"
#include "libavcodec/defs.h"
#include "libavcodec/packet.h"
@ -325,10 +323,13 @@
* to avoid unnecessary rebuilds. When included externally, keep including
* the full version information. */
#include "libavformat/version.h"
#include "libavutil/frame.h"
#include "libavcodec/codec.h"
#endif
struct AVFormatContext;
struct AVFrame;
struct AVDeviceInfoList;
/**
@ -1569,7 +1570,7 @@ typedef struct AVFormatContext {
* the same codec_id.
* Demuxing: Set by user
*/
const AVCodec *video_codec;
const struct AVCodec *video_codec;
/**
* Forced audio codec.
@ -1577,7 +1578,7 @@ typedef struct AVFormatContext {
* the same codec_id.
* Demuxing: Set by user
*/
const AVCodec *audio_codec;
const struct AVCodec *audio_codec;
/**
* Forced subtitle codec.
@ -1585,7 +1586,7 @@ typedef struct AVFormatContext {
* the same codec_id.
* Demuxing: Set by user
*/
const AVCodec *subtitle_codec;
const struct AVCodec *subtitle_codec;
/**
* Forced data codec.
@ -1593,7 +1594,7 @@ typedef struct AVFormatContext {
* the same codec_id.
* Demuxing: Set by user
*/
const AVCodec *data_codec;
const struct AVCodec *data_codec;
/**
* Number of bytes to be written as padding in a metadata header.
@ -1842,7 +1843,7 @@ const AVClass *av_stream_get_class(void);
*
* @return newly created stream or NULL on error.
*/
AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c);
AVStream *avformat_new_stream(AVFormatContext *s, const struct AVCodec *c);
/**
* Wrap an existing array as stream side data.
@ -2076,7 +2077,7 @@ int av_find_best_stream(AVFormatContext *ic,
enum AVMediaType type,
int wanted_stream_nb,
int related_stream,
const AVCodec **decoder_ret,
const struct AVCodec **decoder_ret,
int flags);
/**
@ -2352,7 +2353,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
* See av_interleaved_write_uncoded_frame() for details.
*/
int av_write_uncoded_frame(AVFormatContext *s, int stream_index,
AVFrame *frame);
struct AVFrame *frame);
/**
* Write an uncoded frame to an output media file.
@ -2371,7 +2372,7 @@ int av_write_uncoded_frame(AVFormatContext *s, int stream_index,
* @return >=0 for success, a negative code on error
*/
int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index,
AVFrame *frame);
struct AVFrame *frame);
/**
* Test whether a muxer supports uncoded frame.
@ -2759,7 +2760,8 @@ const struct AVCodecTag *avformat_get_mov_audio_tags(void);
* @param frame the frame with the aspect ratio to be determined
* @return the guessed (valid) sample_aspect_ratio, 0/1 if no idea
*/
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame);
AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream,
struct AVFrame *frame);
/**
* Guess the frame rate, based on both the container and codec information.
@ -2769,7 +2771,8 @@ AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *strea
* @param frame the frame for which the frame rate should be determined, may be NULL
* @return the guessed (valid) frame rate, 0/1 if no idea
*/
AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame);
AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream,
struct AVFrame *frame);
/**
* Check if the stream st contained in s is matched by the stream specifier

View File

@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <libxml/parser.h>
#include <time.h>
#include "libavutil/bprint.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"

View File

@ -22,6 +22,7 @@
#include "config.h"
#include "config_components.h"
#include <time.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif

View File

@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <time.h>
#include "libavutil/parseutils.h"
#include "avio_internal.h"
#include "avformat.h"

View File

@ -19,6 +19,7 @@
*/
#include <string.h>
#include <time.h>
#include "libavutil/avstring.h"
#include "libavutil/internal.h"

View File

@ -23,6 +23,7 @@
#include "config.h"
#include "config_components.h"
#include <stdint.h>
#include <time.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <stdint.h>
#include <time.h>
#include "libavutil/time_internal.h"

View File

@ -22,6 +22,7 @@
#include "config.h"
#include "config_components.h"
#include <time.h>
#if CONFIG_ZLIB
#include <zlib.h>
#endif /* CONFIG_ZLIB */

View File

@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <time.h>
#include "config_components.h"
#include "libavutil/intreadwrite.h"

View File

@ -566,8 +566,8 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
enum AVCodecID ff_guess_image2_codec(const char *filename);
const AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
enum AVCodecID codec_id);
const struct AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st,
enum AVCodecID codec_id);
/**
* Set the time base and wrapping info for a given stream. This will be used

View File

@ -24,6 +24,8 @@
* Magic Lantern Video (MLV) demuxer
*/
#include <time.h>
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/rational.h"

View File

@ -24,12 +24,14 @@
#include "mux.h"
#include "version.h"
#include "libavcodec/bsf.h"
#include "libavcodec/codec_desc.h"
#include "libavcodec/internal.h"
#include "libavcodec/packet_internal.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "libavutil/timestamp.h"
#include "libavutil/avassert.h"
#include "libavutil/frame.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"

View File

@ -96,7 +96,7 @@ typedef struct FFOutputFormat {
* by setting the pointer to NULL.
*/
int (*write_uncoded_frame)(AVFormatContext *, int stream_index,
AVFrame **frame, unsigned flags);
struct AVFrame **frame, unsigned flags);
/**
* Returns device list with it properties.
* @see avdevice_list_devices() for more details.

View File

@ -45,6 +45,7 @@
*/
#include <inttypes.h>
#include <time.h>
#include "libavutil/aes.h"
#include "libavutil/avstring.h"

View File

@ -21,6 +21,7 @@
#include "libavutil/adler32.h"
#include "libavutil/avassert.h"
#include "libavutil/bprint.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
#include "libavformat/mux.h"

View File

@ -32,6 +32,7 @@
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "libavutil/avstring.h"
#include "libavutil/dict.h"

View File

@ -29,6 +29,7 @@
#include <float.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "avformat.h"
#include "matroska.h"

View File

@ -26,6 +26,7 @@
*/
#include <inttypes.h>
#include <time.h>
#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"

View File

@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/frame.h"
#include "libavutil/pixdesc.h"
#include "avformat.h"
#include "internal.h"