diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-06-03 15:42:39 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-06-05 22:35:31 +0000 |
commit | d97044640c0706c5ba7b6dcef8506e2ba7aef33c (patch) | |
tree | 10b50d4d6ba9558b9a5ffc95a73ba31a5734b0da /libavcodec/takdec.c | |
parent | d5f7f1fef157e0f1dccaf6e39b40e8e3a63c3ef0 (diff) | |
download | ffmpeg-d97044640c0706c5ba7b6dcef8506e2ba7aef33c.tar.gz |
takdec: frame multi-threading support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/takdec.c')
-rw-r--r-- | libavcodec/takdec.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index f36cec334b..9878303c70 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -28,6 +28,7 @@ #include "libavutil/internal.h" #include "libavutil/samplefmt.h" #include "tak.h" +#include "thread.h" #include "avcodec.h" #include "dsputil.h" #include "internal.h" @@ -673,6 +674,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, { TAKDecContext *s = avctx->priv_data; AVFrame *frame = data; + ThreadFrame tframe = { .f = data }; GetBitContext *gb = &s->gb; int chan, i, ret, hsize; @@ -736,8 +738,9 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, : s->ti.frame_samples; frame->nb_samples = s->nb_samples; - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0) return ret; + ff_thread_finish_setup(avctx); if (avctx->bits_per_raw_sample <= 16) { int buf_size = av_samples_get_buffer_size(NULL, avctx->channels, @@ -899,6 +902,18 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, return pkt->size; } +static int update_thread_context(AVCodecContext *dst, + const AVCodecContext *src) +{ + TAKDecContext *tsrc = src->priv_data; + TAKDecContext *tdst = dst->priv_data; + + if (dst == src) + return 0; + memcpy(&tdst->ti, &tsrc->ti, sizeof(TAKStreamInfo)); + return 0; +} + static av_cold int tak_decode_close(AVCodecContext *avctx) { TAKDecContext *s = avctx->priv_data; @@ -916,7 +931,8 @@ AVCodec ff_tak_decoder = { .init = tak_decode_init, .close = tak_decode_close, .decode = tak_decode_frame, - .capabilities = CODEC_CAP_DR1, + .update_thread_context = update_thread_context, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, .long_name = NULL_IF_CONFIG_SMALL("TAK (Tom's lossless Audio Kompressor)"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, |