diff options
author | Paul B Mahol <onemda@gmail.com> | 2016-12-26 22:27:01 +0300 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2016-12-26 22:27:01 +0300 |
commit | 31bf37cba8ff1e385d38653e0381485c3a8b4c8a (patch) | |
tree | d017e02b79abc6b1fead023909bbce495aa265c3 /libavcodec/ylc.c | |
parent | 341d3ee441474167ac784bb39f2c31f211451707 (diff) |
avcodec/ylc: add frame threading support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/ylc.c')
-rw-r--r-- | libavcodec/ylc.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c index 81a57741c7..3230c56dac 100644 --- a/libavcodec/ylc.c +++ b/libavcodec/ylc.c @@ -31,6 +31,7 @@ #include "get_bits.h" #include "huffyuvdsp.h" #include "internal.h" +#include "thread.h" #include "unary.h" typedef struct YLCContext { @@ -282,6 +283,7 @@ static int decode_frame(AVCodecContext *avctx, int TL[4] = { 128, 128, 128, 128 }; int L[4] = { 128, 128, 128, 128 }; YLCContext *s = avctx->priv_data; + ThreadFrame frame = { .f = data }; const uint8_t *buf = avpkt->data; int ret, x, y, toffset, boffset; AVFrame * const p = data; @@ -303,7 +305,7 @@ static int decode_frame(AVCodecContext *avctx, if (toffset >= boffset || boffset >= avpkt->size) return AVERROR_INVALIDDATA; - if ((ret = ff_get_buffer(avctx, p, 0)) < 0) + if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) return ret; av_fast_malloc(&s->table_bits, &s->table_bits_size, @@ -447,6 +449,24 @@ static int decode_frame(AVCodecContext *avctx, return avpkt->size; } +#if HAVE_THREADS +static int init_thread_copy(AVCodecContext *avctx) +{ + YLCContext *s = avctx->priv_data; + + memset(&s->vlc[0], 0, sizeof(VLC)); + memset(&s->vlc[1], 0, sizeof(VLC)); + memset(&s->vlc[2], 0, sizeof(VLC)); + memset(&s->vlc[3], 0, sizeof(VLC)); + s->table_bits = NULL; + s->table_bits_size = 0; + s->bitstream_bits = NULL; + s->bitstream_bits_size = 0; + + return 0; +} +#endif + static av_cold int decode_end(AVCodecContext *avctx) { YLCContext *s = avctx->priv_data; @@ -470,7 +490,8 @@ AVCodec ff_ylc_decoder = { .id = AV_CODEC_ID_YLC, .priv_data_size = sizeof(YLCContext), .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, }; |