[FFmpeg-devel] [PATCH 9/9] fftools, libavcodec, libavfilter: Add const to some AVCodec *

Paul B Mahol onemda at gmail.com
Fri Sep 11 12:17:27 EEST 2020


On Thu, Sep 10, 2020 at 11:49:01PM +0200, Andreas Rheinhardt wrote:
> The user has no business modifying the underlying AVCodec.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  fftools/ffmpeg.h           | 5 +++--
>  fftools/ffmpeg_filter.c    | 5 +++--
>  libavcodec/avrndec.c       | 2 +-
>  libavcodec/utils.c         | 4 ++--
>  libavfilter/lavfutils.c    | 2 +-
>  libavfilter/src_movie.c    | 2 +-
>  libavfilter/vf_mcdeint.c   | 2 +-
>  libavfilter/vf_subtitles.c | 2 +-
>  libavfilter/vf_uspp.c      | 2 +-
>  9 files changed, 14 insertions(+), 12 deletions(-)
> 

lgtm

> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> index 908bc73fca..8665218dcf 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -638,8 +638,9 @@ void assert_avoptions(AVDictionary *m);
>  
>  int guess_input_channel_layout(InputStream *ist);
>  
> -enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx, AVCodec *codec, enum AVPixelFormat target);
> -void choose_sample_fmt(AVStream *st, AVCodec *codec);
> +enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx,
> +                                    const AVCodec *codec, enum AVPixelFormat target);
> +void choose_sample_fmt(AVStream *st, const AVCodec *codec);
>  
>  int configure_filtergraph(FilterGraph *fg);
>  int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index 3c507f8c1d..e9e31e043e 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -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) {
>          const enum AVPixelFormat *p = codec->pix_fmts;
> @@ -90,7 +91,7 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCod
>      return target;
>  }
>  
> -void choose_sample_fmt(AVStream *st, AVCodec *codec)
> +void choose_sample_fmt(AVStream *st, const AVCodec *codec)
>  {
>      if (codec && codec->sample_fmts) {
>          const enum AVSampleFormat *p = codec->sample_fmts;
> diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c
> index a7bdab280d..f4ec490de5 100644
> --- a/libavcodec/avrndec.c
> +++ b/libavcodec/avrndec.c
> @@ -46,7 +46,7 @@ static av_cold int init(AVCodecContext *avctx)
>      }
>  
>      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;
>          if (!codec) {
>              av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 2e5185f364..d93a0953fa 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -695,7 +695,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
>      if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&
>          avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
>          const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder";
> -        AVCodec *codec2;
> +        const AVCodec *codec2;
>          av_log(avctx, AV_LOG_ERROR,
>                 "The %s '%s' is experimental but experimental codecs are not enabled, "
>                 "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 AVCodecDescriptor *cd;
> -    AVCodec *codec;
> +    const AVCodec *codec;
>  
>      if (id == AV_CODEC_ID_NONE)
>          return "none";
> diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c
> index 57af5ebfdc..a2085ed5ef 100644
> --- a/libavfilter/lavfutils.c
> +++ b/libavfilter/lavfutils.c
> @@ -27,7 +27,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
>  {
>      AVInputFormat *iformat = NULL;
>      AVFormatContext *format_ctx = NULL;
> -    AVCodec *codec;
> +    const AVCodec *codec;
>      AVCodecContext *codec_ctx = NULL;
>      AVCodecParameters *par;
>      AVFrame *frame = NULL;
> diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
> index d83cb6d1e4..ab12c34f4a 100644
> --- a/libavfilter/src_movie.c
> +++ b/libavfilter/src_movie.c
> @@ -155,7 +155,7 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec)
>  
>  static int open_stream(AVFilterContext *ctx, MovieStream *st)
>  {
> -    AVCodec *codec;
> +    const AVCodec *codec;
>      int ret;
>  
>      codec = avcodec_find_decoder(st->st->codecpar->codec_id);
> diff --git a/libavfilter/vf_mcdeint.c b/libavfilter/vf_mcdeint.c
> index 9cdec6308d..bc7b3230d3 100644
> --- a/libavfilter/vf_mcdeint.c
> +++ b/libavfilter/vf_mcdeint.c
> @@ -102,7 +102,7 @@ static int config_props(AVFilterLink *inlink)
>  {
>      AVFilterContext *ctx = inlink->dst;
>      MCDeintContext *mcdeint = ctx->priv;
> -    AVCodec *enc;
> +    const AVCodec *enc;
>      AVCodecContext *enc_ctx;
>      AVDictionary *opts = NULL;
>      int ret;
> diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
> index f9733c3935..f53aa063d2 100644
> --- a/libavfilter/vf_subtitles.c
> +++ b/libavfilter/vf_subtitles.c
> @@ -302,7 +302,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
>      AVDictionary *codec_opts = NULL;
>      AVFormatContext *fmt = NULL;
>      AVCodecContext *dec_ctx = NULL;
> -    AVCodec *dec = NULL;
> +    const AVCodec *dec;
>      const AVCodecDescriptor *dec_desc;
>      AVStream *st;
>      AVPacket pkt;
> diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
> index 72a0f562af..6a814350e8 100644
> --- a/libavfilter/vf_uspp.c
> +++ b/libavfilter/vf_uspp.c
> @@ -316,7 +316,7 @@ static int config_input(AVFilterLink *inlink)
>      const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
>      int i;
>  
> -    AVCodec *enc = avcodec_find_encoder(AV_CODEC_ID_SNOW);
> +    const AVCodec *enc = avcodec_find_encoder(AV_CODEC_ID_SNOW);
>      if (!enc) {
>          av_log(ctx, AV_LOG_ERROR, "SNOW encoder not found.\n");
>          return AVERROR(EINVAL);
> -- 
> 2.20.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list