[FFmpeg-devel] [PATCH 2/2] huffyuv: Add multithreading support
Alexander Strange
astrange
Thu Feb 17 10:10:09 CET 2011
---
libavcodec/huffyuv.c | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 2eb5864..f81a042 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
--
1.7.4.1
More information about the ffmpeg-devel
mailing list