comparison h263.c @ 4161:f81bca10a740 libavcodec

100l for me, iam being to stupid to read the mpeg4 spec / eat stuffing mbs a the end of the picture
author michael
date Wed, 08 Nov 2006 18:15:54 +0000
parents 0f28fc219799
children 4cd1a0848637
comparison
equal deleted inserted replaced
4160:357dc960e3e2 4161:f81bca10a740
3186 /** 3186 /**
3187 * check if the next stuff is a resync marker or the end. 3187 * check if the next stuff is a resync marker or the end.
3188 * @return 0 if not 3188 * @return 0 if not
3189 */ 3189 */
3190 static inline int mpeg4_is_resync(MpegEncContext *s){ 3190 static inline int mpeg4_is_resync(MpegEncContext *s){
3191 const int bits_count= get_bits_count(&s->gb); 3191 int bits_count= get_bits_count(&s->gb);
3192 int v= show_bits(&s->gb, 16);
3192 3193
3193 if(s->workaround_bugs&FF_BUG_NO_PADDING){ 3194 if(s->workaround_bugs&FF_BUG_NO_PADDING){
3194 return 0; 3195 return 0;
3195 } 3196 }
3196 3197
3198 while(v<=0xFF){
3199 if(s->pict_type==B_TYPE || (v>>(8-s->pict_type)!=1))
3200 break;
3201 skip_bits(&s->gb, 8+s->pict_type);
3202 bits_count+= 8+s->pict_type;
3203 v= show_bits(&s->gb, 16);
3204 }
3205
3197 if(bits_count + 8 >= s->gb.size_in_bits){ 3206 if(bits_count + 8 >= s->gb.size_in_bits){
3198 int v= show_bits(&s->gb, 8); 3207 v>>=8;
3199 v|= 0x7F >> (7-(bits_count&7)); 3208 v|= 0x7F >> (7-(bits_count&7));
3200 3209
3201 if(v==0x7F) 3210 if(v==0x7F)
3202 return 1; 3211 return 1;
3203 }else{ 3212 }else{
3204 if(show_bits(&s->gb, 16) == ff_mpeg4_resync_prefix[bits_count&7]){ 3213 if(v == ff_mpeg4_resync_prefix[bits_count&7]){
3205 int len; 3214 int len;
3206 GetBitContext gb= s->gb; 3215 GetBitContext gb= s->gb;
3207 3216
3208 skip_bits(&s->gb, 1); 3217 skip_bits(&s->gb, 1);
3209 align_get_bits(&s->gb); 3218 align_get_bits(&s->gb);
4518 } 4527 }
4519 end: 4528 end:
4520 4529
4521 /* per-MB end of slice check */ 4530 /* per-MB end of slice check */
4522 if(s->codec_id==CODEC_ID_MPEG4){ 4531 if(s->codec_id==CODEC_ID_MPEG4){
4523 #if 0 //http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_IEC_14496-4_2004_Conformance_Testing/video_conformance/version_1/simple/ERROR.ZIP/mit025.m4v needs this but its unclear if the mpeg4 standard allows this at all (MN)
4524 if(s->pict_type != B_TYPE){
4525 while(show_bits(&s->gb, 9 + (s->pict_type == P_TYPE)) == 1)
4526 skip_bits(&s->gb, 9 + (s->pict_type == P_TYPE));
4527 }
4528 #endif
4529 if(mpeg4_is_resync(s)){ 4532 if(mpeg4_is_resync(s)){
4530 const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1; 4533 const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
4531 if(s->pict_type==B_TYPE && s->next_picture.mbskip_table[xy + delta]) 4534 if(s->pict_type==B_TYPE && s->next_picture.mbskip_table[xy + delta])
4532 return SLICE_OK; 4535 return SLICE_OK;
4533 return SLICE_END; 4536 return SLICE_END;