comparison h263.c @ 346:c2f789fe4945 libavcodec

detecting xvid/divx4/opendivx and set low_delay flag
author michaelni
date Sat, 27 Apr 2002 14:10:47 +0000
parents 9f6071a87e17
children 6ebbecc10063
comparison
equal deleted inserted replaced
345:e05b357a398a 346:c2f789fe4945
2582 /* decode mpeg4 VOP header */ 2582 /* decode mpeg4 VOP header */
2583 int mpeg4_decode_picture_header(MpegEncContext * s) 2583 int mpeg4_decode_picture_header(MpegEncContext * s)
2584 { 2584 {
2585 int time_incr, startcode, state, v; 2585 int time_incr, startcode, state, v;
2586 int time_increment; 2586 int time_increment;
2587 int vol_control=-1;
2587 2588
2588 redo: 2589 redo:
2589 /* search next start code */ 2590 /* search next start code */
2590 align_get_bits(&s->gb); 2591 align_get_bits(&s->gb);
2591 state = 0xff; 2592 state = 0xff;
2625 if(s->aspect_ratio_info == EXTENDET_PAR){ 2626 if(s->aspect_ratio_info == EXTENDET_PAR){
2626 skip_bits(&s->gb, 8); //par_width 2627 skip_bits(&s->gb, 8); //par_width
2627 skip_bits(&s->gb, 8); // par_height 2628 skip_bits(&s->gb, 8); // par_height
2628 } 2629 }
2629 2630
2630 if(get_bits1(&s->gb)){ /* vol control parameter */ 2631 if(vol_control=get_bits1(&s->gb)){ /* vol control parameter */
2631 int chroma_format= get_bits(&s->gb, 2); 2632 int chroma_format= get_bits(&s->gb, 2);
2632 if(chroma_format!=1){ 2633 if(chroma_format!=1){
2633 printf("illegal chroma format\n"); 2634 printf("illegal chroma format\n");
2634 } 2635 }
2635 s->low_delay= get_bits1(&s->gb); 2636 s->low_delay= get_bits1(&s->gb);
2941 if (s->shape!=RECT_SHAPE && s->pict_type!=I_TYPE) { 2942 if (s->shape!=RECT_SHAPE && s->pict_type!=I_TYPE) {
2942 skip_bits1(&s->gb); // vop shape coding type 2943 skip_bits1(&s->gb); // vop shape coding type
2943 } 2944 }
2944 } 2945 }
2945 } 2946 }
2947 /* detect buggy encoders which dont set the low_delay flag (divx4/xvid/opendivx)*/
2948 // note we cannot detect divx5 without b-frames easyly (allthough its buggy too)
2949 if(s->vo_type==0 && vol_control==0 && s->divx_version==0){
2950 if(s->picture_number==0)
2951 printf("looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
2952 s->low_delay=1;
2953 }
2954
2946 s->picture_number++; // better than pic number==0 allways ;) 2955 s->picture_number++; // better than pic number==0 allways ;)
2947 //printf("done\n"); 2956 //printf("done\n");
2957
2948 return 0; 2958 return 0;
2949 } 2959 }
2950 2960
2951 /* don't understand why they choose a different header ! */ 2961 /* don't understand why they choose a different header ! */
2952 int intel_h263_decode_picture_header(MpegEncContext *s) 2962 int intel_h263_decode_picture_header(MpegEncContext *s)