ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | Mon Apr 21 18:48:10 2025 +0200| [289cb3beff8d73537206c29dd5e155d19805425c] | committer: Andreas Rheinhardt
avcodec/cri,tdsc,tiff: Use ff_mjpeg_decoder directly This is simpler than calling avcodec_find_decoder(). Notice that av_codec_init_static() has already been called by the time we reach these decoders' init functions, so it is not necessary to call avcodec_find_decoder() for it (which doesn't do anything for the mjpeg decoder anyway). Reviewed-by: Kacper Michajlow <kaspe...@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=289cb3beff8d73537206c29dd5e155d19805425c --- libavcodec/cri.c | 10 ++++------ libavcodec/tdsc.c | 10 ++++------ libavcodec/tiff.c | 10 ++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/libavcodec/cri.c b/libavcodec/cri.c index 6932bb6745..56ec485f7a 100644 --- a/libavcodec/cri.c +++ b/libavcodec/cri.c @@ -27,6 +27,7 @@ #define BITSTREAM_READER_LE +#include "libavutil/attributes_internal.h" #include "libavutil/intfloat.h" #include "libavutil/display.h" #include "avcodec.h" @@ -51,7 +52,6 @@ typedef struct CRIContext { static av_cold int cri_decode_init(AVCodecContext *avctx) { CRIContext *s = avctx->priv_data; - const AVCodec *codec; int ret; s->jpgframe = av_frame_alloc(); @@ -62,16 +62,14 @@ static av_cold int cri_decode_init(AVCodecContext *avctx) if (!s->jpkt) return AVERROR(ENOMEM); - codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); - if (!codec) - return AVERROR_BUG; - s->jpeg_avctx = avcodec_alloc_context3(codec); + EXTERN const FFCodec ff_mjpeg_decoder; + s->jpeg_avctx = avcodec_alloc_context3(&ff_mjpeg_decoder.p); if (!s->jpeg_avctx) return AVERROR(ENOMEM); s->jpeg_avctx->flags = avctx->flags; s->jpeg_avctx->flags2 = avctx->flags2; s->jpeg_avctx->idct_algo = avctx->idct_algo; - ret = avcodec_open2(s->jpeg_avctx, codec, NULL); + ret = avcodec_open2(s->jpeg_avctx, NULL, NULL); if (ret < 0) return ret; diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c index ab0a70859b..225ddf3701 100644 --- a/libavcodec/tdsc.c +++ b/libavcodec/tdsc.c @@ -36,6 +36,7 @@ #include <stdint.h> #include <zlib.h> +#include "libavutil/attributes_internal.h" #include "libavutil/imgutils.h" #include "libavutil/mem.h" @@ -95,7 +96,6 @@ static av_cold int tdsc_close(AVCodecContext *avctx) static av_cold int tdsc_init(AVCodecContext *avctx) { TDSCContext *ctx = avctx->priv_data; - const AVCodec *codec; int ret; avctx->pix_fmt = AV_PIX_FMT_BGR24; @@ -120,16 +120,14 @@ static av_cold int tdsc_init(AVCodecContext *avctx) return AVERROR(ENOMEM); /* Prepare everything needed for JPEG decoding */ - codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); - if (!codec) - return AVERROR_BUG; - ctx->jpeg_avctx = avcodec_alloc_context3(codec); + EXTERN const FFCodec ff_mjpeg_decoder; + ctx->jpeg_avctx = avcodec_alloc_context3(&ff_mjpeg_decoder.p); if (!ctx->jpeg_avctx) return AVERROR(ENOMEM); ctx->jpeg_avctx->flags = avctx->flags; ctx->jpeg_avctx->flags2 = avctx->flags2; ctx->jpeg_avctx->idct_algo = avctx->idct_algo; - ret = avcodec_open2(ctx->jpeg_avctx, codec, NULL); + ret = avcodec_open2(ctx->jpeg_avctx, NULL, NULL); if (ret < 0) return ret; diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 37b56e9757..e515845a83 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -36,6 +36,7 @@ #include <float.h> #include "libavutil/attributes.h" +#include "libavutil/attributes_internal.h" #include "libavutil/avstring.h" #include "libavutil/error.h" #include "libavutil/intreadwrite.h" @@ -2409,7 +2410,6 @@ again: static av_cold int tiff_init(AVCodecContext *avctx) { TiffContext *s = avctx->priv_data; - const AVCodec *codec; int ret; s->width = 0; @@ -2429,17 +2429,15 @@ static av_cold int tiff_init(AVCodecContext *avctx) return AVERROR(ENOMEM); /* Prepare everything needed for JPEG decoding */ - codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); - if (!codec) - return AVERROR_BUG; - s->avctx_mjpeg = avcodec_alloc_context3(codec); + EXTERN const FFCodec ff_mjpeg_decoder; + s->avctx_mjpeg = avcodec_alloc_context3(&ff_mjpeg_decoder.p); if (!s->avctx_mjpeg) return AVERROR(ENOMEM); s->avctx_mjpeg->flags = avctx->flags; s->avctx_mjpeg->flags2 = avctx->flags2; s->avctx_mjpeg->idct_algo = avctx->idct_algo; s->avctx_mjpeg->max_pixels = avctx->max_pixels; - ret = avcodec_open2(s->avctx_mjpeg, codec, NULL); + ret = avcodec_open2(s->avctx_mjpeg, NULL, NULL); if (ret < 0) { return ret; } _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".