---
 libavcodec/h264.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index c77d9ba..afc3eb3 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -33,6 +33,7 @@
 #include "h264_parser.h"
 #include "golomb.h"
 #include "rectangle.h"
+#include "thread.h"
 
 #include "cabac.h"
 #ifdef ARCH_X86
@@ -2247,11 +2248,11 @@ static int frame_start(H264Context *h){
     /* can't be in alloc_tables because linesize isn't known there.
      * FIXME: redo bipred weight to not require extra buffer? */
     for(i = 0; i < s->avctx->thread_count; i++)
-        if(!h->thread_context[i]->s.obmc_scratchpad)
+        if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad)
             h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*2*s->linesize + 8*2*s->uvlinesize);
 
     /* some macroblocks will be accessed before they're available */
-    if(FRAME_MBAFF || s->avctx->thread_count > 1)
+    if(FRAME_MBAFF || USE_AVCODEC_EXECUTE(s->avctx))
         memset(h->slice_table, -1, (s->mb_height*s->mb_stride-1) * sizeof(uint8_t));
 
 //    s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1;
@@ -3964,6 +3965,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
         init_scan_tables(h);
         alloc_tables(h);
 
+        if (!USE_AVCODEC_EXECUTE(s->avctx)) {
+            if (context_init(h) < 0)
+                return -1;
+        } else {
         for(i = 1; i < s->avctx->thread_count; i++) {
             H264Context *c;
             c = h->thread_context[i] = av_malloc(sizeof(H264Context));
@@ -3978,6 +3983,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
         for(i = 0; i < s->avctx->thread_count; i++)
             if(context_init(h->thread_context[i]) < 0)
                 return -1;
+        }
 
         s->avctx->width = s->width;
         s->avctx->height = s->height;
@@ -7479,7 +7485,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
     H264Context *hx; ///< thread context
     int context_count = 0;
 
-    h->max_contexts = avctx->thread_count;
+    h->max_contexts = USE_AVCODEC_EXECUTE(s->avctx) ? avctx->thread_count : 1;
 #if 0
     int i;
     for(i=0; i<50; i++){
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to