History

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).

Andreas Rheinhardt committed 1 year ago

Commit 289cb3b1 parent 25b0a8e3 files · +12 −18Browse files

Unified · Split

3 files
  1. libavcodec/cri.c +4 −6
  2. libavcodec/tdsc.c +4 −6
  3. libavcodec/tiff.c +4 −6
libavcodec/cri.c+4−6
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727
2828 #define BITSTREAM_READER_LE
2929
30+#include "libavutil/attributes_internal.h"
3031 #include "libavutil/intfloat.h"
3132 #include "libavutil/display.h"
3233 #include "avcodec.h"
@@ -51,7 +52,6 @@ typedef struct CRIContext { · 18 unmodified lines
5152 static av_cold int cri_decode_init(AVCodecContext *avctx)
5253 {
5354 CRIContext *s = avctx->priv_data;
54− const AVCodec *codec;
5555 int ret;
5656
5757 s->jpgframe = av_frame_alloc();
@@ -62,16 +62,14 @@ static av_cold int cri_decode_init(AVCodecContext *avctx) · 4 unmodified lines
6262 if (!s->jpkt)
6363 return AVERROR(ENOMEM);
6464
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);
6967 if (!s->jpeg_avctx)
7068 return AVERROR(ENOMEM);
7169 s->jpeg_avctx->flags = avctx->flags;
7270 s->jpeg_avctx->flags2 = avctx->flags2;
7371 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);
7573 if (ret < 0)
7674 return ret;
7775
libavcodec/tdsc.c+4−6
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #include <stdint.h>
3737 #include <zlib.h>
3838
39+#include "libavutil/attributes_internal.h"
3940 #include "libavutil/imgutils.h"
4041 #include "libavutil/mem.h"
4142
@@ -95,7 +96,6 @@ static av_cold int tdsc_close(AVCodecContext *avctx) · 53 unmodified lines
9596 static av_cold int tdsc_init(AVCodecContext *avctx)
9697 {
9798 TDSCContext *ctx = avctx->priv_data;
98− const AVCodec *codec;
9999 int ret;
100100
101101 avctx->pix_fmt = AV_PIX_FMT_BGR24;
@@ -120,16 +120,14 @@ static av_cold int tdsc_init(AVCodecContext *avctx) · 18 unmodified lines
120120 return AVERROR(ENOMEM);
121121
122122 /* 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);
127125 if (!ctx->jpeg_avctx)
128126 return AVERROR(ENOMEM);
129127 ctx->jpeg_avctx->flags = avctx->flags;
130128 ctx->jpeg_avctx->flags2 = avctx->flags2;
131129 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);
133131 if (ret < 0)
134132 return ret;
135133
libavcodec/tiff.c+4−6
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #include <float.h>
3737
3838 #include "libavutil/attributes.h"
39+#include "libavutil/attributes_internal.h"
3940 #include "libavutil/avstring.h"
4041 #include "libavutil/error.h"
4142 #include "libavutil/intreadwrite.h"
@@ -2409,7 +2410,6 @@ again: · 2367 unmodified lines
24092410 static av_cold int tiff_init(AVCodecContext *avctx)
24102411 {
24112412 TiffContext *s = avctx->priv_data;
2412− const AVCodec *codec;
24132413 int ret;
24142414
24152415 s->width = 0;
@@ -2429,17 +2429,15 @@ static av_cold int tiff_init(AVCodecContext *avctx) · 13 unmodified lines
24292429 return AVERROR(ENOMEM);
24302430
24312431 /* 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);
24362434 if (!s->avctx_mjpeg)
24372435 return AVERROR(ENOMEM);
24382436 s->avctx_mjpeg->flags = avctx->flags;
24392437 s->avctx_mjpeg->flags2 = avctx->flags2;
24402438 s->avctx_mjpeg->idct_algo = avctx->idct_algo;
24412439 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);
24432441 if (ret < 0) {
24442442 return ret;
24452443 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t