[FFmpeg-cvslog] lavc: copy AVCodecContext for threads

Paul B Mahol git at videolan.org
Thu Jun 13 23:53:35 CEST 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Jun 13 21:49:18 2013 +0000| [ff0bdf937568908a35d4091cb5c83a0155117ae6] | committer: Paul B Mahol

lavc: copy AVCodecContext for threads

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff0bdf937568908a35d4091cb5c83a0155117ae6
---

 libavcodec/alac.c    |    1 +
 libavcodec/flacdec.c |    2 +-
 libavcodec/takdec.c  |    8 ++++++++
 libavcodec/tta.c     |    2 ++
 libavcodec/wavpack.c |    8 ++++++++
 5 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index c6f01b3..6ffc006 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -621,6 +621,7 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
 static int init_thread_copy(AVCodecContext *avctx)
 {
     ALACContext *alac = avctx->priv_data;
+    alac->avctx = avctx;
     return allocate_buffers(alac);
 }
 
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index a0c950b..c5847e3 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -498,7 +498,6 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data,
     int ret;
 
     *got_frame_ptr = 0;
-    s->avctx = avctx;
 
     if (s->max_framesize == 0) {
         s->max_framesize =
@@ -575,6 +574,7 @@ static int init_thread_copy(AVCodecContext *avctx)
     FLACContext *s = avctx->priv_data;
     s->decoded_buffer = NULL;
     s->decoded_buffer_size = 0;
+    s->avctx = avctx;
     if (s->max_blocksize)
         return allocate_buffers(s);
     return 0;
diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
index c9c861c..9e01ee0 100644
--- a/libavcodec/takdec.c
+++ b/libavcodec/takdec.c
@@ -902,6 +902,13 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
     return pkt->size;
 }
 
+static int init_thread_copy(AVCodecContext *avctx)
+{
+    TAKDecContext *s = avctx->priv_data;
+    s->avctx = avctx;
+    return 0;
+}
+
 static int update_thread_context(AVCodecContext *dst,
                                  const AVCodecContext *src)
 {
@@ -931,6 +938,7 @@ AVCodec ff_tak_decoder = {
     .init             = tak_decode_init,
     .close            = tak_decode_close,
     .decode           = tak_decode_frame,
+    .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
     .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
     .capabilities     = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
     .long_name        = NULL_IF_CONFIG_SMALL("TAK (Tom's lossless Audio Kompressor)"),
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index 710aa35..6697d84 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -410,6 +410,8 @@ error:
 
 static int init_thread_copy(AVCodecContext *avctx)
 {
+    TTAContext *s = avctx->priv_data;
+    s->avctx = avctx;
     return allocate_buffers(avctx);
 }
 
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index de5bc6c..47f598a 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -728,6 +728,13 @@ static av_cold int wv_alloc_frame_context(WavpackContext *c)
     return 0;
 }
 
+static int init_thread_copy(AVCodecContext *avctx)
+{
+    WavpackContext *s = avctx->priv_data;
+    s->avctx = avctx;
+    return 0;
+}
+
 static av_cold int wavpack_decode_init(AVCodecContext *avctx)
 {
     WavpackContext *s = avctx->priv_data;
@@ -1238,6 +1245,7 @@ AVCodec ff_wavpack_decoder = {
     .close          = wavpack_decode_end,
     .decode         = wavpack_decode_frame,
     .flush          = wavpack_decode_flush,
+    .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
     .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
     .long_name      = NULL_IF_CONFIG_SMALL("WavPack"),
 };



More information about the ffmpeg-cvslog mailing list