]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pthread.c
vble: remove flags copy, its not used in any speed relevant code.
[ffmpeg] / libavcodec / pthread.c
index 08104914eec182f505781f74573141d5f98006ba..04181e229f5b8db0c7fb66dfe764e3ab441d4536 100644 (file)
  * @see doc/multithreading.txt
  */
 
-#include <pthread.h>
-
+#include "config.h"
 #include "avcodec.h"
+#include "internal.h"
 #include "thread.h"
 
+#if HAVE_PTHREADS
+#include <pthread.h>
+#elif HAVE_W32THREADS
+#include "w32pthreads.h"
+#endif
+
 typedef int (action_func)(AVCodecContext *c, void *arg);
 typedef int (action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr);
 
@@ -332,6 +338,9 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
         dst->height    = src->height;
         dst->pix_fmt   = src->pix_fmt;
 
+        dst->coded_width  = src->coded_width;
+        dst->coded_height = src->coded_height;
+
         dst->has_b_frames = src->has_b_frames;
         dst->idct_algo    = src->idct_algo;
         dst->slice_count  = src->slice_count;
@@ -354,8 +363,8 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
     }
 
     if (for_user) {
+        dst->delay         = src->thread_count - 1;
         dst->coded_frame   = src->coded_frame;
-        dst->has_b_frames += src->thread_count - 1;
     } else {
         if (dst->codec->update_thread_context)
             err = dst->codec->update_thread_context(dst, src);
@@ -634,7 +643,7 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count)
 
     park_frame_worker_threads(fctx, thread_count);
 
-    if (fctx->prev_thread)
+    if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
         update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0);
 
     fctx->die = 1;
@@ -787,6 +796,8 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
 
     f->owner = avctx;
 
+    ff_init_buffer_info(avctx, f);
+
     if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {
         f->thread_opaque = NULL;
         return avctx->get_buffer(avctx, f);
@@ -899,6 +910,10 @@ int ff_thread_init(AVCodecContext *avctx)
         return -1;
     }
 
+#if HAVE_W32THREADS
+    w32thread_init();
+#endif
+
     if (avctx->codec) {
         validate_thread_parameters(avctx);