diff options
author | Alexander Strange <astrange@ithinksw.com> | 2011-02-17 03:44:25 -0500 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2011-03-01 11:39:25 -0500 |
commit | 76d8846c4e918749b045ea2ee7399a069af5e4a5 (patch) | |
tree | f286e95e6fa7cb10237c93b40c358b5fc2718157 /libavcodec/huffyuv.c | |
parent | ad9791e12b6653a465803062e2543f25916300d3 (diff) | |
download | ffmpeg-76d8846c4e918749b045ea2ee7399a069af5e4a5.tar.gz |
huffyuv: Add multithreading support
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/huffyuv.c')
-rw-r--r-- | libavcodec/huffyuv.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index 2eb5864c47..f81a042c7f 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -32,6 +32,7 @@ #include "get_bits.h" #include "put_bits.h" #include "dsputil.h" +#include "thread.h" #define VLC_BITS 11 @@ -527,6 +528,28 @@ s->bgr32=1; return 0; } + +static av_cold int decode_init_thread_copy(AVCodecContext *avctx) +{ + HYuvContext *s = avctx->priv_data; + int i; + + avctx->coded_frame= &s->picture; + alloc_temp(s); + + for (i = 0; i < 6; i++) + s->vlc[i].table = NULL; + + if(s->version==2){ + if(read_huffman_tables(s, ((uint8_t*)avctx->extradata)+4, avctx->extradata_size) < 0) + return -1; + }else{ + if(read_old_huffman_tables(s) < 0) + return -1; + } + + return 0; +} #endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */ #if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER @@ -950,10 +973,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (const uint32_t*)buf, buf_size/4); if(p->data[0]) - avctx->release_buffer(avctx, p); + ff_thread_release_buffer(avctx, p); p->reference= 0; - if(avctx->get_buffer(avctx, p) < 0){ + if(ff_thread_get_buffer(avctx, p) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } @@ -1425,8 +1448,9 @@ AVCodec ff_huffyuv_decoder = { NULL, decode_end, decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, + CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, NULL, + .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), }; #endif @@ -1441,8 +1465,9 @@ AVCodec ff_ffvhuff_decoder = { NULL, decode_end, decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, + CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, NULL, + .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), }; #endif |