comparison h263.c @ 8691:25aa5388fa97 libavcodec

Make ff_h263_resync() return the bit position of the resync_marker or a negative number if none was found. Patch by Gwenol«± Beauchesne: gbeauchesne splitted minus desktop com
author benoit
date Fri, 30 Jan 2009 17:13:03 +0000
parents 6c220a238087
children e9d9d946f213
comparison
equal deleted inserted replaced
8690:6c220a238087 8691:25aa5388fa97
3294 s->last_mv[1][0][1]= 0; 3294 s->last_mv[1][0][1]= 0;
3295 } 3295 }
3296 3296
3297 /** 3297 /**
3298 * decodes the group of blocks / video packet header. 3298 * decodes the group of blocks / video packet header.
3299 * @return <0 if no resync found 3299 * @return bit position of the resync_marker, or <0 if none was found
3300 */ 3300 */
3301 int ff_h263_resync(MpegEncContext *s){ 3301 int ff_h263_resync(MpegEncContext *s){
3302 int left, ret; 3302 int left, pos, ret;
3303 3303
3304 if(s->codec_id==CODEC_ID_MPEG4){ 3304 if(s->codec_id==CODEC_ID_MPEG4){
3305 skip_bits1(&s->gb); 3305 skip_bits1(&s->gb);
3306 align_get_bits(&s->gb); 3306 align_get_bits(&s->gb);
3307 } 3307 }
3308 3308
3309 if(show_bits(&s->gb, 16)==0){ 3309 if(show_bits(&s->gb, 16)==0){
3310 pos= get_bits_count(&s->gb);
3310 if(s->codec_id==CODEC_ID_MPEG4) 3311 if(s->codec_id==CODEC_ID_MPEG4)
3311 ret= mpeg4_decode_video_packet_header(s); 3312 ret= mpeg4_decode_video_packet_header(s);
3312 else 3313 else
3313 ret= h263_decode_gob_header(s); 3314 ret= h263_decode_gob_header(s);
3314 if(ret>=0) 3315 if(ret>=0)
3315 return 0; 3316 return pos;
3316 } 3317 }
3317 //OK, it's not where it is supposed to be ... 3318 //OK, it's not where it is supposed to be ...
3318 s->gb= s->last_resync_gb; 3319 s->gb= s->last_resync_gb;
3319 align_get_bits(&s->gb); 3320 align_get_bits(&s->gb);
3320 left= s->gb.size_in_bits - get_bits_count(&s->gb); 3321 left= s->gb.size_in_bits - get_bits_count(&s->gb);
3321 3322
3322 for(;left>16+1+5+5; left-=8){ 3323 for(;left>16+1+5+5; left-=8){
3323 if(show_bits(&s->gb, 16)==0){ 3324 if(show_bits(&s->gb, 16)==0){
3324 GetBitContext bak= s->gb; 3325 GetBitContext bak= s->gb;
3325 3326
3327 pos= get_bits_count(&s->gb);
3326 if(s->codec_id==CODEC_ID_MPEG4) 3328 if(s->codec_id==CODEC_ID_MPEG4)
3327 ret= mpeg4_decode_video_packet_header(s); 3329 ret= mpeg4_decode_video_packet_header(s);
3328 else 3330 else
3329 ret= h263_decode_gob_header(s); 3331 ret= h263_decode_gob_header(s);
3330 if(ret>=0) 3332 if(ret>=0)
3331 return 0; 3333 return pos;
3332 3334
3333 s->gb= bak; 3335 s->gb= bak;
3334 } 3336 }
3335 skip_bits(&s->gb, 8); 3337 skip_bits(&s->gb, 8);
3336 } 3338 }