1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

alac: frame multi-threading support

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2013-06-03 16:45:26 +00:00
parent 9684d7f1a2
commit b28851a1d6

View File

@ -50,6 +50,7 @@
#include "get_bits.h" #include "get_bits.h"
#include "bytestream.h" #include "bytestream.h"
#include "internal.h" #include "internal.h"
#include "thread.h"
#include "unary.h" #include "unary.h"
#include "mathops.h" #include "mathops.h"
#include "alac_data.h" #include "alac_data.h"
@ -287,9 +288,10 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (!alac->nb_samples) { if (!alac->nb_samples) {
ThreadFrame tframe = { .f = frame };
/* get output buffer */ /* get output buffer */
frame->nb_samples = output_samples; frame->nb_samples = output_samples;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0)
return ret; return ret;
} else if (output_samples != alac->nb_samples) { } else if (output_samples != alac->nb_samples) {
av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %u != %d\n", av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %u != %d\n",
@ -616,6 +618,12 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
return 0; return 0;
} }
static int init_thread_copy(AVCodecContext *avctx)
{
ALACContext *alac = avctx->priv_data;
return allocate_buffers(alac);
}
AVCodec ff_alac_decoder = { AVCodec ff_alac_decoder = {
.name = "alac", .name = "alac",
.type = AVMEDIA_TYPE_AUDIO, .type = AVMEDIA_TYPE_AUDIO,
@ -624,6 +632,7 @@ AVCodec ff_alac_decoder = {
.init = alac_decode_init, .init = alac_decode_init,
.close = alac_decode_close, .close = alac_decode_close,
.decode = alac_decode_frame, .decode = alac_decode_frame,
.capabilities = CODEC_CAP_DR1, .init_thread_copy = init_thread_copy,
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
}; };