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).
Unified · Split
| @@ -27,6 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | |
| 28 | 28 | #define BITSTREAM_READER_LE |
| 29 | 29 | |
| 30 | +#include "libavutil/attributes_internal.h" | |
| 30 | 31 | #include "libavutil/intfloat.h" |
| 31 | 32 | #include "libavutil/display.h" |
| 32 | 33 | #include "avcodec.h" |
| @@ -51,7 +52,6 @@ typedef struct CRIContext { · 18 unmodified lines | ||
| 51 | 52 | static av_cold int cri_decode_init(AVCodecContext *avctx) |
| 52 | 53 | { |
| 53 | 54 | CRIContext *s = avctx->priv_data; |
| 54 | − const AVCodec *codec; | |
| 55 | 55 | int ret; |
| 56 | 56 | |
| 57 | 57 | s->jpgframe = av_frame_alloc(); |
| @@ -62,16 +62,14 @@ static av_cold int cri_decode_init(AVCodecContext *avctx) · 4 unmodified lines | ||
| 62 | 62 | if (!s->jpkt) |
| 63 | 63 | return AVERROR(ENOMEM); |
| 64 | 64 | |
| 65 | − codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); | |
| 66 | − if (!codec) | |
| 67 | − return AVERROR_BUG; | |
| 68 | − s->jpeg_avctx = avcodec_alloc_context3(codec); | |
| 65 | + EXTERN const FFCodec ff_mjpeg_decoder; | |
| 66 | + s->jpeg_avctx = avcodec_alloc_context3(&ff_mjpeg_decoder.p); | |
| 69 | 67 | if (!s->jpeg_avctx) |
| 70 | 68 | return AVERROR(ENOMEM); |
| 71 | 69 | s->jpeg_avctx->flags = avctx->flags; |
| 72 | 70 | s->jpeg_avctx->flags2 = avctx->flags2; |
| 73 | 71 | s->jpeg_avctx->idct_algo = avctx->idct_algo; |
| 74 | − ret = avcodec_open2(s->jpeg_avctx, codec, NULL); | |
| 72 | + ret = avcodec_open2(s->jpeg_avctx, NULL, NULL); | |
| 75 | 73 | if (ret < 0) |
| 76 | 74 | return ret; |
| 77 | 75 | |
| @@ -36,6 +36,7 @@ · 35 unmodified lines | ||
| 36 | 36 | #include <stdint.h> |
| 37 | 37 | #include <zlib.h> |
| 38 | 38 | |
| 39 | +#include "libavutil/attributes_internal.h" | |
| 39 | 40 | #include "libavutil/imgutils.h" |
| 40 | 41 | #include "libavutil/mem.h" |
| 41 | 42 | |
| @@ -95,7 +96,6 @@ static av_cold int tdsc_close(AVCodecContext *avctx) · 53 unmodified lines | ||
| 95 | 96 | static av_cold int tdsc_init(AVCodecContext *avctx) |
| 96 | 97 | { |
| 97 | 98 | TDSCContext *ctx = avctx->priv_data; |
| 98 | − const AVCodec *codec; | |
| 99 | 99 | int ret; |
| 100 | 100 | |
| 101 | 101 | avctx->pix_fmt = AV_PIX_FMT_BGR24; |
| @@ -120,16 +120,14 @@ static av_cold int tdsc_init(AVCodecContext *avctx) · 18 unmodified lines | ||
| 120 | 120 | return AVERROR(ENOMEM); |
| 121 | 121 | |
| 122 | 122 | /* Prepare everything needed for JPEG decoding */ |
| 123 | − codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); | |
| 124 | − if (!codec) | |
| 125 | − return AVERROR_BUG; | |
| 126 | − ctx->jpeg_avctx = avcodec_alloc_context3(codec); | |
| 123 | + EXTERN const FFCodec ff_mjpeg_decoder; | |
| 124 | + ctx->jpeg_avctx = avcodec_alloc_context3(&ff_mjpeg_decoder.p); | |
| 127 | 125 | if (!ctx->jpeg_avctx) |
| 128 | 126 | return AVERROR(ENOMEM); |
| 129 | 127 | ctx->jpeg_avctx->flags = avctx->flags; |
| 130 | 128 | ctx->jpeg_avctx->flags2 = avctx->flags2; |
| 131 | 129 | ctx->jpeg_avctx->idct_algo = avctx->idct_algo; |
| 132 | − ret = avcodec_open2(ctx->jpeg_avctx, codec, NULL); | |
| 130 | + ret = avcodec_open2(ctx->jpeg_avctx, NULL, NULL); | |
| 133 | 131 | if (ret < 0) |
| 134 | 132 | return ret; |
| 135 | 133 | |
| @@ -36,6 +36,7 @@ · 35 unmodified lines | ||
| 36 | 36 | #include <float.h> |
| 37 | 37 | |
| 38 | 38 | #include "libavutil/attributes.h" |
| 39 | +#include "libavutil/attributes_internal.h" | |
| 39 | 40 | #include "libavutil/avstring.h" |
| 40 | 41 | #include "libavutil/error.h" |
| 41 | 42 | #include "libavutil/intreadwrite.h" |
| @@ -2409,7 +2410,6 @@ again: · 2367 unmodified lines | ||
| 2409 | 2410 | static av_cold int tiff_init(AVCodecContext *avctx) |
| 2410 | 2411 | { |
| 2411 | 2412 | TiffContext *s = avctx->priv_data; |
| 2412 | − const AVCodec *codec; | |
| 2413 | 2413 | int ret; |
| 2414 | 2414 | |
| 2415 | 2415 | s->width = 0; |
| @@ -2429,17 +2429,15 @@ static av_cold int tiff_init(AVCodecContext *avctx) · 13 unmodified lines | ||
| 2429 | 2429 | return AVERROR(ENOMEM); |
| 2430 | 2430 | |
| 2431 | 2431 | /* Prepare everything needed for JPEG decoding */ |
| 2432 | − codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); | |
| 2433 | − if (!codec) | |
| 2434 | − return AVERROR_BUG; | |
| 2435 | − s->avctx_mjpeg = avcodec_alloc_context3(codec); | |
| 2432 | + EXTERN const FFCodec ff_mjpeg_decoder; | |
| 2433 | + s->avctx_mjpeg = avcodec_alloc_context3(&ff_mjpeg_decoder.p); | |
| 2436 | 2434 | if (!s->avctx_mjpeg) |
| 2437 | 2435 | return AVERROR(ENOMEM); |
| 2438 | 2436 | s->avctx_mjpeg->flags = avctx->flags; |
| 2439 | 2437 | s->avctx_mjpeg->flags2 = avctx->flags2; |
| 2440 | 2438 | s->avctx_mjpeg->idct_algo = avctx->idct_algo; |
| 2441 | 2439 | s->avctx_mjpeg->max_pixels = avctx->max_pixels; |
| 2442 | − ret = avcodec_open2(s->avctx_mjpeg, codec, NULL); | |
| 2440 | + ret = avcodec_open2(s->avctx_mjpeg, NULL, NULL); | |
| 2443 | 2441 | if (ret < 0) { |
| 2444 | 2442 | return ret; |
| 2445 | 2443 | } |