huffyuv: Add multithreading support

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
oldabi
Alexander Strange 14 years ago committed by Ronald S. Bultje
parent ad9791e12b
commit 76d8846c4e
  1. 33
      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

Loading…
Cancel
Save