mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
mpeg4videodec: rewrite the slice end detection of non partitioned packets.
This no longer needs thread syncronization thus speeding frame multithreading up. Fixes Ticket28 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
e5e0580b93
commit
78a041a9db
@ -130,10 +130,11 @@ static inline int mpeg4_is_resync(MpegEncContext *s){
|
|||||||
v|= 0x7F >> (7-(bits_count&7));
|
v|= 0x7F >> (7-(bits_count&7));
|
||||||
|
|
||||||
if(v==0x7F)
|
if(v==0x7F)
|
||||||
return 1;
|
return s->mb_num;
|
||||||
}else{
|
}else{
|
||||||
if(v == ff_mpeg4_resync_prefix[bits_count&7]){
|
if(v == ff_mpeg4_resync_prefix[bits_count&7]){
|
||||||
int len;
|
int len, mb_num;
|
||||||
|
int mb_num_bits= av_log2(s->mb_num - 1) + 1;
|
||||||
GetBitContext gb= s->gb;
|
GetBitContext gb= s->gb;
|
||||||
|
|
||||||
skip_bits(&s->gb, 1);
|
skip_bits(&s->gb, 1);
|
||||||
@ -143,10 +144,14 @@ static inline int mpeg4_is_resync(MpegEncContext *s){
|
|||||||
if(get_bits1(&s->gb)) break;
|
if(get_bits1(&s->gb)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mb_num= get_bits(&s->gb, mb_num_bits);
|
||||||
|
if(!mb_num || mb_num > s->mb_num || get_bits_count(&s->gb)+6 > s->gb.size_in_bits)
|
||||||
|
mb_num= -1;
|
||||||
|
|
||||||
s->gb= gb;
|
s->gb= gb;
|
||||||
|
|
||||||
if(len>=ff_mpeg4_get_video_packet_prefix_length(s))
|
if(len>=ff_mpeg4_get_video_packet_prefix_length(s))
|
||||||
return 1;
|
return mb_num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -373,16 +378,6 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s)
|
|||||||
av_log(s->avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
|
av_log(s->avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(s->pict_type == AV_PICTURE_TYPE_B){
|
|
||||||
int mb_x = 0, mb_y = 0;
|
|
||||||
|
|
||||||
while (s->next_picture.f.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
|
|
||||||
}
|
|
||||||
|
|
||||||
s->mb_x= mb_num % s->mb_width;
|
s->mb_x= mb_num % s->mb_width;
|
||||||
s->mb_y= mb_num / s->mb_width;
|
s->mb_y= mb_num / s->mb_width;
|
||||||
@ -1488,17 +1483,12 @@ end:
|
|||||||
|
|
||||||
/* per-MB end of slice check */
|
/* per-MB end of slice check */
|
||||||
if(s->codec_id==CODEC_ID_MPEG4){
|
if(s->codec_id==CODEC_ID_MPEG4){
|
||||||
if(mpeg4_is_resync(s)){
|
int next= mpeg4_is_resync(s);
|
||||||
const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
|
if(next) {
|
||||||
|
if (s->mb_x + s->mb_y*s->mb_width + 1 > next && s->avctx->error_recognition >= FF_ER_AGGRESSIVE) {
|
||||||
if(s->pict_type==AV_PICTURE_TYPE_B){
|
return -1;
|
||||||
ff_thread_await_progress((AVFrame*)s->next_picture_ptr,
|
} else if (s->mb_x + s->mb_y*s->mb_width + 1 >= next)
|
||||||
(s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0);
|
return SLICE_END;
|
||||||
}
|
|
||||||
|
|
||||||
if (s->pict_type == AV_PICTURE_TYPE_B && s->next_picture.f.mbskip_table[xy + delta])
|
|
||||||
return SLICE_OK;
|
|
||||||
return SLICE_END;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user