alac: frame multi-threading support
authorPaul B Mahol <onemda@gmail.com>
Mon, 3 Jun 2013 16:45:26 +0000 (16:45 +0000)
committerPaul B Mahol <onemda@gmail.com>
Wed, 5 Jun 2013 22:35:32 +0000 (22:35 +0000)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavcodec/alac.c

index 751b40b046519ef7122f189d13986d6c0b9aef21..9a6a11814806152437fa9fb8146939602ac38de0 100644 (file)
@@ -50,6 +50,7 @@
 #include "get_bits.h"
 #include "bytestream.h"
 #include "internal.h"
+#include "thread.h"
 #include "unary.h"
 #include "mathops.h"
 #include "alac_data.h"
@@ -287,9 +288,10 @@ static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
         return AVERROR_INVALIDDATA;
     }
     if (!alac->nb_samples) {
+        ThreadFrame tframe = { .f = frame };
         /* get output buffer */
         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;
     } else if (output_samples != alac->nb_samples) {
         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;
 }
 
+static int init_thread_copy(AVCodecContext *avctx)
+{
+    ALACContext *alac = avctx->priv_data;
+    return allocate_buffers(alac);
+}
+
 AVCodec ff_alac_decoder = {
     .name           = "alac",
     .type           = AVMEDIA_TYPE_AUDIO,
@@ -624,6 +632,7 @@ AVCodec ff_alac_decoder = {
     .init           = alac_decode_init,
     .close          = alac_decode_close,
     .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)"),
 };