summaryrefslogtreecommitdiff
path: root/libavcodec/mpeg4videodec.c
diff options
context:
space:
mode:
authorAlexander Strange <astrange@ithinksw.com>2011-06-02 10:15:58 -0700
committerRonald S. Bultje <rsbultje@gmail.com>2011-06-02 10:16:20 -0700
commit6a9c85944427e3c4355bce67d7f677ec69527bff (patch)
treedf4bb83f820a5c0295485ca8b7751c4063d5165f /libavcodec/mpeg4videodec.c
parent53be7b23e9d7074d1aeee77407b008411d034e9e (diff)
H264/MPEG frame-level multi-threading.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/mpeg4videodec.c')
-rw-r--r--libavcodec/mpeg4videodec.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 66d4127884..81f09c5a4b 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -23,6 +23,7 @@
#include "mpegvideo.h"
#include "mpeg4video.h"
#include "h263.h"
+#include "thread.h"
// The defines below define the number of bits that are read at once for
// reading vlc values. Changing these may improve speed and data cache needs
@@ -373,7 +374,13 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s)
return -1;
}
if(s->pict_type == AV_PICTURE_TYPE_B){
- 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_thread_await_progress((AVFrame*)s->next_picture_ptr, mb_y++, 0);
+ 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
}
@@ -1303,6 +1310,8 @@ static int mpeg4_decode_mb(MpegEncContext *s,
s->last_mv[i][1][0]=
s->last_mv[i][1][1]= 0;
}
+
+ ff_thread_await_progress((AVFrame*)s->next_picture_ptr, s->mb_y, 0);
}
/* if we skipped it in the future P Frame than skip it now too */
@@ -1482,6 +1491,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==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta]){
+ ff_thread_await_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, 0);
+ }
+
if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta])
return SLICE_OK;
return SLICE_END;
@@ -2235,11 +2250,12 @@ AVCodec ff_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,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
.pix_fmts= ff_hwaccel_pixfmt_list_420,
+ .update_thread_context= ONLY_IF_THREADS_ENABLED(ff_mpeg_update_thread_context)
};