Skip to content

Commit

Permalink
avcodec/lcldec: add support for frame threads
Browse files Browse the repository at this point in the history
Signed-off-by: Paul B Mahol <[email protected]>
  • Loading branch information
richardpl committed Apr 11, 2017
1 parent 8378466 commit c61dc28
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions libavcodec/lcldec.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "bytestream.h"
#include "internal.h"
#include "lcl.h"
#include "thread.h"

#if CONFIG_ZLIB_DECODER
#include <zlib.h>
Expand Down Expand Up @@ -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)
{
AVFrame *frame = data;
ThreadFrame tframe = { .f = data };
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
LclDecContext * const c = avctx->priv_data;
Expand All @@ -173,7 +175,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
unsigned int len = buf_size;
int linesize;

if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0)
return ret;

outptr = frame->data[0]; // Output image pointer
Expand Down Expand Up @@ -618,6 +620,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
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)
{
LclDecContext * const c = avctx->priv_data;
Expand All @@ -639,9 +648,10 @@ AVCodec ff_mszh_decoder = {
.id = AV_CODEC_ID_MSZH,
.priv_data_size = sizeof(LclDecContext),
.init = decode_init,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
.close = decode_end,
.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,
};
#endif
Expand All @@ -654,9 +664,10 @@ AVCodec ff_zlib_decoder = {
.id = AV_CODEC_ID_ZLIB,
.priv_data_size = sizeof(LclDecContext),
.init = decode_init,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
.close = decode_end,
.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,
};
#endif

0 comments on commit c61dc28

Please sign in to comment.