fftools, libavcodec, libavfilter: Add const to some AVCodec *

The user has no business modifying the underlying AVCodec.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-09-10 22:11:57 +02:00
parent b091df7210
commit 0086432fc7
9 changed files with 14 additions and 12 deletions

View File

@ -638,8 +638,9 @@ void assert_avoptions(AVDictionary *m);
int guess_input_channel_layout(InputStream *ist); int guess_input_channel_layout(InputStream *ist);
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx, AVCodec *codec, enum AVPixelFormat target); enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx,
void choose_sample_fmt(AVStream *st, AVCodec *codec); const AVCodec *codec, enum AVPixelFormat target);
void choose_sample_fmt(AVStream *st, const AVCodec *codec);
int configure_filtergraph(FilterGraph *fg); int configure_filtergraph(FilterGraph *fg);
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out); int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);

View File

@ -60,7 +60,8 @@ static const enum AVPixelFormat *get_compliance_unofficial_pix_fmts(enum AVCodec
} }
} }
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCodec *codec, enum AVPixelFormat target) enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx,
const AVCodec *codec, enum AVPixelFormat target)
{ {
if (codec && codec->pix_fmts) { if (codec && codec->pix_fmts) {
const enum AVPixelFormat *p = codec->pix_fmts; const enum AVPixelFormat *p = codec->pix_fmts;
@ -90,7 +91,7 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCod
return target; return target;
} }
void choose_sample_fmt(AVStream *st, AVCodec *codec) void choose_sample_fmt(AVStream *st, const AVCodec *codec)
{ {
if (codec && codec->sample_fmts) { if (codec && codec->sample_fmts) {
const enum AVSampleFormat *p = codec->sample_fmts; const enum AVSampleFormat *p = codec->sample_fmts;

View File

@ -46,7 +46,7 @@ static av_cold int init(AVCodecContext *avctx)
} }
if(a->is_mjpeg) { if(a->is_mjpeg) {
AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
AVDictionary *thread_opt = NULL; AVDictionary *thread_opt = NULL;
if (!codec) { if (!codec) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n"); av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");

View File

@ -695,7 +695,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) && if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&
avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder"; const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder";
AVCodec *codec2; const AVCodec *codec2;
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"The %s '%s' is experimental but experimental codecs are not enabled, " "The %s '%s' is experimental but experimental codecs are not enabled, "
"add '-strict %d' if you want to use it.\n", "add '-strict %d' if you want to use it.\n",
@ -1193,7 +1193,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
const char *avcodec_get_name(enum AVCodecID id) const char *avcodec_get_name(enum AVCodecID id)
{ {
const AVCodecDescriptor *cd; const AVCodecDescriptor *cd;
AVCodec *codec; const AVCodec *codec;
if (id == AV_CODEC_ID_NONE) if (id == AV_CODEC_ID_NONE)
return "none"; return "none";

View File

@ -27,7 +27,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
{ {
AVInputFormat *iformat = NULL; AVInputFormat *iformat = NULL;
AVFormatContext *format_ctx = NULL; AVFormatContext *format_ctx = NULL;
AVCodec *codec; const AVCodec *codec;
AVCodecContext *codec_ctx = NULL; AVCodecContext *codec_ctx = NULL;
AVCodecParameters *par; AVCodecParameters *par;
AVFrame *frame = NULL; AVFrame *frame = NULL;

View File

@ -155,7 +155,7 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
static int open_stream(AVFilterContext *ctx, MovieStream *st) static int open_stream(AVFilterContext *ctx, MovieStream *st)
{ {
AVCodec *codec; const AVCodec *codec;
int ret; int ret;
codec = avcodec_find_decoder(st->st->codecpar->codec_id); codec = avcodec_find_decoder(st->st->codecpar->codec_id);

View File

@ -102,7 +102,7 @@ static int config_props(AVFilterLink *inlink)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
MCDeintContext *mcdeint = ctx->priv; MCDeintContext *mcdeint = ctx->priv;
AVCodec *enc; const AVCodec *enc;
AVCodecContext *enc_ctx; AVCodecContext *enc_ctx;
AVDictionary *opts = NULL; AVDictionary *opts = NULL;
int ret; int ret;

View File

@ -302,7 +302,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
AVDictionary *codec_opts = NULL; AVDictionary *codec_opts = NULL;
AVFormatContext *fmt = NULL; AVFormatContext *fmt = NULL;
AVCodecContext *dec_ctx = NULL; AVCodecContext *dec_ctx = NULL;
AVCodec *dec = NULL; const AVCodec *dec;
const AVCodecDescriptor *dec_desc; const AVCodecDescriptor *dec_desc;
AVStream *st; AVStream *st;
AVPacket pkt; AVPacket pkt;

View File

@ -316,7 +316,7 @@ static int config_input(AVFilterLink *inlink)
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
int i; int i;
AVCodec *enc = avcodec_find_encoder(AV_CODEC_ID_SNOW); const AVCodec *enc = avcodec_find_encoder(AV_CODEC_ID_SNOW);
if (!enc) { if (!enc) {
av_log(ctx, AV_LOG_ERROR, "SNOW encoder not found.\n"); av_log(ctx, AV_LOG_ERROR, "SNOW encoder not found.\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);