]> git.sesse.net Git - ffmpeg/commitdiff
hwaccel: fix use with frame based multithreading
authorJanne Grunau <janne-libav@jannau.net>
Wed, 13 Mar 2013 22:36:51 +0000 (23:36 +0100)
committerJanne Grunau <janne-libav@jannau.net>
Tue, 26 Mar 2013 18:44:50 +0000 (19:44 +0100)
Allows use of AVHWAccel based decoders with frame based multithreading.
The decoders will be forced into an non-concurrent mode by delaying
ff_thread_finish_setup() calls after decoding of the current frame
is finished.

This wastes memory by unnecessarily using multiple threads and thus
copies of the decoder context but allows seamless switching between
hardware accelerated and frame threaded software decoding when the
hardware decoder does not support the stream.

libavcodec/h263dec.c
libavcodec/h264.c
libavcodec/pthread.c
libavcodec/version.h

index 28fb2dbbd5c17ac267ed495dc7bdb398d45c0bd3..e8edad7ab67cb619a5f0e187e493e66720a57e7f 100644 (file)
@@ -627,7 +627,8 @@ retry:
     if(ff_MPV_frame_start(s, avctx) < 0)
         return -1;
 
-    if (!s->divx_packed) ff_thread_finish_setup(avctx);
+    if (!s->divx_packed && !avctx->hwaccel)
+        ff_thread_finish_setup(avctx);
 
     if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) {
         ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer);
@@ -720,6 +721,9 @@ intrax8_decoded:
 
     ff_MPV_frame_end(s);
 
+    if (!s->divx_packed && avctx->hwaccel)
+        ff_thread_finish_setup(avctx);
+
     assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
     assert(s->current_picture.f.pict_type == s->pict_type);
     if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
index f6f00bd9ed7128b00e25fd2c3a2f38f2d3e7aaca..6721365eb9673a58edede6298b7f28908e0f567f 100644 (file)
@@ -2032,7 +2032,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
         av_log(h->avctx, AV_LOG_DEBUG, "no picture\n");
     }
 
-    if (setup_finished)
+    if (setup_finished && !h->avctx->hwaccel)
         ff_thread_finish_setup(h->avctx);
 }
 
index 9a92288dbb9827816bb5f380db5fd600f650fee1..404804dec1845c2fb0fcade80bd277c31c53045c 100644 (file)
@@ -428,6 +428,9 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
         dst->colorspace  = src->colorspace;
         dst->color_range = src->color_range;
         dst->chroma_sample_location = src->chroma_sample_location;
+
+        dst->hwaccel = src->hwaccel;
+        dst->hwaccel_context = src->hwaccel_context;
     }
 
     if (for_user) {
index 8b4fbce1e5e57a45669efa87f413def658fe2c43..394bf1a386394f992d8150f7c8526bf5f3a847fd 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 #define LIBAVCODEC_VERSION_MAJOR 55
-#define LIBAVCODEC_VERSION_MINOR  0
+#define LIBAVCODEC_VERSION_MINOR  1
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \