[libav-commits] utvideo: frame multithreading.

Aneesh Dogra git at libav.org
Sun Jan 8 22:09:37 CET 2012


Module: libav
Branch: master
Commit: 12e984aed76d52e959bb7cbee72c149444ff58ce

Author:    Aneesh Dogra <lionaneesh at gmail.com>
Committer: Ronald S. Bultje <rsbultje at gmail.com>
Date:      Mon Jan  9 01:07:46 2012 +0530

utvideo: frame multithreading.

>> time ./avconv -i file.avi -f null -
Before : real	0m7.784s
After  : real   0m3.662s

Tested on a Intel Core i3 Processor (2 cores, 4 threads).

Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>

---

 libavcodec/utvideo.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/utvideo.c b/libavcodec/utvideo.c
index d105d29..89854c2 100644
--- a/libavcodec/utvideo.c
+++ b/libavcodec/utvideo.c
@@ -31,6 +31,7 @@
 #include "bytestream.h"
 #include "get_bits.h"
 #include "dsputil.h"
+#include "thread.h"
 
 enum {
     PRED_NONE = 0,
@@ -366,15 +367,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
     int ret;
 
     if (c->pic.data[0])
-        avctx->release_buffer(avctx, &c->pic);
+        ff_thread_release_buffer(avctx, &c->pic);
 
     c->pic.reference = 1;
     c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
-    if ((ret = avctx->get_buffer(avctx, &c->pic)) < 0) {
+    if ((ret = ff_thread_get_buffer(avctx, &c->pic)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return ret;
     }
 
+    ff_thread_finish_setup(avctx);
+
     /* parse plane structure to retrieve frame flags and validate slice offsets */
     ptr = buf;
     for (i = 0; i < c->planes; i++) {
@@ -557,7 +560,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
     UtvideoContext * const c = avctx->priv_data;
 
     if (c->pic.data[0])
-        avctx->release_buffer(avctx, &c->pic);
+        ff_thread_release_buffer(avctx, &c->pic);
 
     av_freep(&c->slice_bits);
 
@@ -572,7 +575,7 @@ AVCodec ff_utvideo_decoder = {
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
     .long_name      = NULL_IF_CONFIG_SMALL("Ut Video"),
 };
 



More information about the libav-commits mailing list