---
 libavcodec/h263.c    |   18 +++++++++++++++++-
 libavcodec/h263dec.c |    8 +++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index ad54203..e9e121d 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -39,6 +39,7 @@
 #include "mpegvideo.h"
 #include "h263data.h"
 #include "mpeg4data.h"
+#include "thread.h"
 
 //#undef NDEBUG
 //#include <assert.h>
@@ -3201,7 +3202,14 @@ static int mpeg4_decode_video_packet_header(MpegEncContext *s)
         return -1;
     }
     if(s->pict_type == FF_B_TYPE){
-        while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) mb_num++;
+        int mb_x = 0, mb_y = 0;
+
+        while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) {
+            if (!mb_x) ff_await_decode_progress((AVFrame*)s->next_picture_ptr, mb_y++);
+            mb_num++;
+            if (++mb_x == s->mb_width) mb_x = 0;
+        }
+
         if(mb_num >= s->mb_num) return -1; // slice contains just skipped MBs which where already decoded
     }
 
@@ -4291,6 +4299,8 @@ int ff_mpeg4_decode_mb(MpegEncContext *s,
                 s->last_mv[i][1][0]=
                 s->last_mv[i][1][1]= 0;
             }
+
+            ff_await_decode_progress((AVFrame*)s->next_picture_ptr, s->mb_y);
         }
 
         /* if we skipped it in the future P Frame than skip it now too */
@@ -4470,6 +4480,12 @@ end:
     if(s->codec_id==CODEC_ID_MPEG4){
         if(mpeg4_is_resync(s)){
             const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
+
+            if(s->pict_type==FF_B_TYPE){
+                ff_await_decode_progress((AVFrame*)s->next_picture_ptr,
+                                         (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y);
+            }
+
             if(s->pict_type==FF_B_TYPE && s->next_picture.mbskip_table[xy + delta])
                 return SLICE_OK;
             return SLICE_END;
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 9549846..692760c 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -31,6 +31,7 @@
 #include "h263_parser.h"
 #include "mpeg4video_parser.h"
 #include "msmpeg4.h"
+#include "thread.h"
 
 //#define DEBUG
 //#define PRINT_FRAME_TIME
@@ -226,6 +227,7 @@ static int decode_slice(MpegEncContext *s){
                     if(++s->mb_x >= s->mb_width){
                         s->mb_x=0;
                         ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
+                        MPV_report_decode_progress(s);
                         s->mb_y++;
                     }
                     return 0;
@@ -246,6 +248,7 @@ static int decode_slice(MpegEncContext *s){
         }
 
         ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
+        MPV_report_decode_progress(s);
 
         s->mb_x= 0;
     }
@@ -615,6 +618,8 @@ retry:
     if(MPV_frame_start(s, avctx) < 0)
         return -1;
 
+    ff_report_predecode_done(avctx);
+
 #ifdef DEBUG
     av_log(avctx, AV_LOG_DEBUG, "qscale=%d\n", s->qscale);
 #endif
@@ -721,9 +726,10 @@ AVCodec mpeg4_decoder = {
     NULL,
     ff_h263_decode_end,
     ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
+    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_FRAME_THREADS,
     .flush= ff_mpeg_flush,
     .long_name= "MPEG-4 part 2",
+    .update_context= ff_mpeg_update_context
 };
 
 AVCodec h263_decoder = {
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to