diff options
Diffstat (limited to 'libavcodec/libopenjpegdec.c')
-rw-r--r-- | libavcodec/libopenjpegdec.c | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c index eeb3dd6..5476e0a 100644 --- a/libavcodec/libopenjpegdec.c +++ b/libavcodec/libopenjpegdec.c @@ -67,7 +67,6 @@ static const enum AVPixelFormat libopenjpeg_all_pix_fmts[] = {RGB_PIXEL_FORMATS typedef struct { AVClass *class; opj_dparameters_t dec_params; - AVFrame image; int lowqual; } LibOpenJPEGContext; @@ -221,16 +220,6 @@ static av_cold int libopenjpeg_decode_init(AVCodecContext *avctx) LibOpenJPEGContext *ctx = avctx->priv_data; opj_set_default_decoder_parameters(&ctx->dec_params); - avcodec_get_frame_defaults(&ctx->image); - avctx->coded_frame = &ctx->image; - return 0; -} - -static av_cold int libopenjpeg_decode_init_thread_copy(AVCodecContext *avctx) -{ - LibOpenJPEGContext *ctx = avctx->priv_data; - - avctx->coded_frame = &ctx->image; return 0; } @@ -241,7 +230,8 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, uint8_t *buf = avpkt->data; int buf_size = avpkt->size; LibOpenJPEGContext *ctx = avctx->priv_data; - AVFrame *picture = &ctx->image, *output = data; + ThreadFrame frame = { .f = data }; + AVFrame *picture = data; const AVPixFmtDescriptor *desc; opj_dinfo_t *dec; opj_cio_t *stream; @@ -320,10 +310,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, if (image->comps[i].prec > avctx->bits_per_raw_sample) avctx->bits_per_raw_sample = image->comps[i].prec; - if (picture->data[0]) - ff_thread_release_buffer(avctx, picture); - - if (ff_thread_get_buffer(avctx, picture) < 0) { + if (ff_thread_get_buffer(avctx, &frame, 0) < 0) { av_log(avctx, AV_LOG_ERROR, "ff_thread_get_buffer() failed\n"); goto done; } @@ -385,7 +372,6 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx, goto done; } - *output = ctx->image; *got_frame = 1; ret = buf_size; @@ -395,15 +381,6 @@ done: return ret; } -static av_cold int libopenjpeg_decode_close(AVCodecContext *avctx) -{ - LibOpenJPEGContext *ctx = avctx->priv_data; - - if (ctx->image.data[0]) - ff_thread_release_buffer(avctx, &ctx->image); - return 0; -} - #define OFFSET(x) offsetof(LibOpenJPEGContext, x) #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM @@ -425,11 +402,9 @@ AVCodec ff_libopenjpeg_decoder = { .id = AV_CODEC_ID_JPEG2000, .priv_data_size = sizeof(LibOpenJPEGContext), .init = libopenjpeg_decode_init, - .close = libopenjpeg_decode_close, .decode = libopenjpeg_decode_frame, .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, .max_lowres = 31, .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"), .priv_class = &class, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(libopenjpeg_decode_init_thread_copy), }; |