build: address AVCodec, AVInputFormat, AVOutputFormat const warnings

FFmpeg recently changed these to be const on their side.
This commit is contained in:
sfan5 2021-05-01 21:53:56 +02:00
parent 02fbdf8aaf
commit 39630dc8b6
10 changed files with 17 additions and 17 deletions

View File

@ -85,7 +85,7 @@ static bool init(struct mp_filter *da, struct mp_codec_params *codec,
struct ad_lavc_params *opts = struct ad_lavc_params *opts =
mp_get_config_group(ctx, da->global, &ad_lavc_conf); mp_get_config_group(ctx, da->global, &ad_lavc_conf);
AVCodecContext *lavc_context; AVCodecContext *lavc_context;
AVCodec *lavc_codec; const AVCodec *lavc_codec;
ctx->codec_timebase = mp_get_codec_timebase(codec); ctx->codec_timebase = mp_get_codec_timebase(codec);

View File

@ -116,7 +116,7 @@ static void determine_codec_params(struct mp_filter *da, AVPacket *pkt,
if (profile != FF_PROFILE_UNKNOWN || spdif_ctx->codec_id != AV_CODEC_ID_DTS) if (profile != FF_PROFILE_UNKNOWN || spdif_ctx->codec_id != AV_CODEC_ID_DTS)
return; return;
AVCodec *codec = avcodec_find_decoder(spdif_ctx->codec_id); const AVCodec *codec = avcodec_find_decoder(spdif_ctx->codec_id);
if (!codec) if (!codec)
goto done; goto done;

View File

@ -68,7 +68,7 @@ struct priv {
struct mp_aframe *in_frame; struct mp_aframe *in_frame;
struct mp_aframe_pool *out_pool; struct mp_aframe_pool *out_pool;
struct AVCodec *lavc_acodec; const struct AVCodec *lavc_acodec;
struct AVCodecContext *lavc_actx; struct AVCodecContext *lavc_actx;
int bit_rate; int bit_rate;
int out_samples; // upper bound on encoded output per AC3 frame int out_samples; // upper bound on encoded output per AC3 frame

View File

@ -270,7 +270,7 @@ int mp_codec_to_av_codec_id(const char *codec)
if (desc) if (desc)
id = desc->id; id = desc->id;
if (id == AV_CODEC_ID_NONE) { if (id == AV_CODEC_ID_NONE) {
AVCodec *avcodec = avcodec_find_decoder_by_name(codec); const AVCodec *avcodec = avcodec_find_decoder_by_name(codec);
if (avcodec) if (avcodec)
id = avcodec->id; id = avcodec->id;
} }
@ -285,7 +285,7 @@ const char *mp_codec_from_av_codec_id(int codec_id)
if (desc) if (desc)
name = desc->name; name = desc->name;
if (!name) { if (!name) {
AVCodec *avcodec = avcodec_find_decoder(codec_id); const AVCodec *avcodec = avcodec_find_decoder(codec_id);
if (avcodec) if (avcodec)
name = avcodec->name; name = avcodec->name;
} }

View File

@ -735,7 +735,7 @@ static void encoder_destroy(void *ptr)
free_stream(p->twopass_bytebuffer); free_stream(p->twopass_bytebuffer);
} }
static AVCodec *find_codec_for(struct encode_lavc_context *ctx, static const AVCodec *find_codec_for(struct encode_lavc_context *ctx,
enum stream_type type, bool *used_auto) enum stream_type type, bool *used_auto)
{ {
char *codec_name = type == STREAM_VIDEO char *codec_name = type == STREAM_VIDEO
@ -746,7 +746,7 @@ static AVCodec *find_codec_for(struct encode_lavc_context *ctx,
*used_auto = !(codec_name && codec_name[0]); *used_auto = !(codec_name && codec_name[0]);
AVCodec *codec; const AVCodec *codec;
if (*used_auto) { if (*used_auto) {
codec = avcodec_find_encoder(av_guess_codec(ctx->oformat, NULL, codec = avcodec_find_encoder(av_guess_codec(ctx->oformat, NULL,
ctx->options->file, NULL, ctx->options->file, NULL,
@ -797,7 +797,7 @@ struct encoder_context *encoder_context_alloc(struct encode_lavc_context *ctx,
}; };
bool auto_codec; bool auto_codec;
AVCodec *codec = find_codec_for(ctx, type, &auto_codec); const AVCodec *codec = find_codec_for(ctx, type, &auto_codec);
const char *tname = stream_type_name(type); const char *tname = stream_type_name(type);
if (!codec) { if (!codec) {

View File

@ -41,7 +41,7 @@ struct encode_lavc_context {
struct encode_opts *options; struct encode_opts *options;
struct mp_log *log; struct mp_log *log;
struct encode_priv *priv; struct encode_priv *priv;
AVOutputFormat *oformat; const AVOutputFormat *oformat;
const char *filename; const char *filename;
// All entry points must be guarded with the lock. Functions called by // All entry points must be guarded with the lock. Functions called by
@ -71,7 +71,7 @@ struct encoder_context {
struct mpv_global *global; struct mpv_global *global;
struct encode_opts *options; struct encode_opts *options;
struct mp_log *log; struct mp_log *log;
AVOutputFormat *oformat; const AVOutputFormat *oformat;
// (avoid using this) // (avoid using this)
struct encode_lavc_context *encode_lavc_ctx; struct encode_lavc_context *encode_lavc_ctx;

View File

@ -227,7 +227,7 @@ typedef struct lavf_priv {
bool own_stream; bool own_stream;
char *filename; char *filename;
struct format_hack format_hack; struct format_hack format_hack;
AVInputFormat *avif; const AVInputFormat *avif;
int avif_flags; int avif_flags;
AVFormatContext *avfc; AVFormatContext *avfc;
AVIOContext *pb; AVIOContext *pb;
@ -443,7 +443,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
if (!lavfdopts->allow_mimetype || !mime_type) if (!lavfdopts->allow_mimetype || !mime_type)
mime_type = ""; mime_type = "";
AVInputFormat *forced_format = NULL; const AVInputFormat *forced_format = NULL;
const char *format = lavfdopts->format; const char *format = lavfdopts->format;
if (!format) if (!format)
format = s->lavf_type; format = s->lavf_type;

View File

@ -75,7 +75,7 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name,
AVCodecContext *avctx = NULL; AVCodecContext *avctx = NULL;
AVDictionary *opts = NULL; AVDictionary *opts = NULL;
const char *fmt = get_lavc_format(priv->codec); const char *fmt = get_lavc_format(priv->codec);
AVCodec *codec = avcodec_find_decoder(mp_codec_to_av_codec_id(fmt)); const AVCodec *codec = avcodec_find_decoder(mp_codec_to_av_codec_id(fmt));
if (!codec) if (!codec)
goto error; goto error;
avctx = avcodec_alloc_context3(codec); avctx = avcodec_alloc_context3(codec);

View File

@ -91,7 +91,7 @@ static int init(struct sd *sd)
struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv); struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv);
AVCodecContext *ctx = NULL; AVCodecContext *ctx = NULL;
AVCodec *sub_codec = avcodec_find_decoder(cid); const AVCodec *sub_codec = avcodec_find_decoder(cid);
if (!sub_codec) if (!sub_codec)
goto error; goto error;
ctx = avcodec_alloc_context3(sub_codec); ctx = avcodec_alloc_context3(sub_codec);

View File

@ -103,7 +103,7 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp
av_init_packet(&pkt); av_init_packet(&pkt);
struct AVCodec *codec; const AVCodec *codec;
if (ctx->opts->format == AV_CODEC_ID_WEBP) { if (ctx->opts->format == AV_CODEC_ID_WEBP) {
codec = avcodec_find_encoder_by_name("libwebp"); // non-animated encoder codec = avcodec_find_encoder_by_name("libwebp"); // non-animated encoder
} else { } else {
@ -251,7 +251,7 @@ static bool write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp
#endif #endif
static int get_encoder_format(struct AVCodec *codec, int srcfmt, bool highdepth) static int get_encoder_format(const AVCodec *codec, int srcfmt, bool highdepth)
{ {
const enum AVPixelFormat *pix_fmts = codec->pix_fmts; const enum AVPixelFormat *pix_fmts = codec->pix_fmts;
int current = 0; int current = 0;
@ -277,7 +277,7 @@ static int get_encoder_format(struct AVCodec *codec, int srcfmt, bool highdepth)
static int get_target_format(struct image_writer_ctx *ctx) static int get_target_format(struct image_writer_ctx *ctx)
{ {
struct AVCodec *codec = avcodec_find_encoder(ctx->opts->format); const AVCodec *codec = avcodec_find_encoder(ctx->opts->format);
if (!codec) if (!codec)
goto unknown; goto unknown;