1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/lcldec: add support for frame threads

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2017-04-11 17:05:01 +02:00
parent 8378466507
commit c61dc28911

View File

@ -46,6 +46,7 @@
#include "bytestream.h" #include "bytestream.h"
#include "internal.h" #include "internal.h"
#include "lcl.h" #include "lcl.h"
#include "thread.h"
#if CONFIG_ZLIB_DECODER #if CONFIG_ZLIB_DECODER
#include <zlib.h> #include <zlib.h>
@ -157,6 +158,7 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{ {
AVFrame *frame = data; AVFrame *frame = data;
ThreadFrame tframe = { .f = data };
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
LclDecContext * const c = avctx->priv_data; LclDecContext * const c = avctx->priv_data;
@ -173,7 +175,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
unsigned int len = buf_size; unsigned int len = buf_size;
int linesize; int linesize;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0)
return ret; return ret;
outptr = frame->data[0]; // Output image pointer outptr = frame->data[0]; // Output image pointer
@ -618,6 +620,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
return 0; return 0;
} }
#if HAVE_THREADS
static int init_thread_copy(AVCodecContext *avctx)
{
return decode_init(avctx);
}
#endif
static av_cold int decode_end(AVCodecContext *avctx) static av_cold int decode_end(AVCodecContext *avctx)
{ {
LclDecContext * const c = avctx->priv_data; LclDecContext * const c = avctx->priv_data;
@ -639,9 +648,10 @@ AVCodec ff_mszh_decoder = {
.id = AV_CODEC_ID_MSZH, .id = AV_CODEC_ID_MSZH,
.priv_data_size = sizeof(LclDecContext), .priv_data_size = sizeof(LclDecContext),
.init = decode_init, .init = decode_init,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
.close = decode_end, .close = decode_end,
.decode = decode_frame, .decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}; };
#endif #endif
@ -654,9 +664,10 @@ AVCodec ff_zlib_decoder = {
.id = AV_CODEC_ID_ZLIB, .id = AV_CODEC_ID_ZLIB,
.priv_data_size = sizeof(LclDecContext), .priv_data_size = sizeof(LclDecContext),
.init = decode_init, .init = decode_init,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
.close = decode_end, .close = decode_end,
.decode = decode_frame, .decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}; };
#endif #endif