mirror of https://git.ffmpeg.org/ffmpeg.git
huffyuv: Add multithreading support
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit 76d8846c4e
)
This commit is contained in:
parent
05fa64a7c5
commit
e9e9139cee
|
@ -32,6 +32,7 @@
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "put_bits.h"
|
#include "put_bits.h"
|
||||||
#include "dsputil.h"
|
#include "dsputil.h"
|
||||||
|
#include "thread.h"
|
||||||
|
|
||||||
#define VLC_BITS 11
|
#define VLC_BITS 11
|
||||||
|
|
||||||
|
@ -527,6 +528,28 @@ s->bgr32=1;
|
||||||
|
|
||||||
return 0;
|
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 */
|
#endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */
|
||||||
|
|
||||||
#if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
|
#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);
|
s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (const uint32_t*)buf, buf_size/4);
|
||||||
|
|
||||||
if(p->data[0])
|
if(p->data[0])
|
||||||
avctx->release_buffer(avctx, p);
|
ff_thread_release_buffer(avctx, p);
|
||||||
|
|
||||||
p->reference= 0;
|
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");
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1425,8 +1448,9 @@ AVCodec ff_huffyuv_decoder = {
|
||||||
NULL,
|
NULL,
|
||||||
decode_end,
|
decode_end,
|
||||||
decode_frame,
|
decode_frame,
|
||||||
CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
|
CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
|
||||||
NULL,
|
NULL,
|
||||||
|
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
|
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -1441,8 +1465,9 @@ AVCodec ff_ffvhuff_decoder = {
|
||||||
NULL,
|
NULL,
|
||||||
decode_end,
|
decode_end,
|
||||||
decode_frame,
|
decode_frame,
|
||||||
CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
|
CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
|
||||||
NULL,
|
NULL,
|
||||||
|
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),
|
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue