s->picture_number++;
int mpeg4_decode_picture_header(MpegEncContext * s){    int time_incr, startcode, state, v; redo:    /* search next start code */    align_get_bits(&s->gb);    state = 0xff;    for(;;) {        v = get_bits(&s->gb, 8);        if (state == 0x000001) {            state = ((state << 8) | v) & 0xffffff;            startcode = state;            break;        }        state = ((state << 8) | v) & 0xffffff;        /* XXX: really detect end of frame */        if (state == 0)            return -1;    }//printf("startcode %X %d\n", startcode, get_bits_count(&s->gb));    if (startcode == 0x120) { // Video Object Layer        int time_increment_resolution, width, height, vo_ver_id;        /* vol header */        skip_bits(&s->gb, 1); /* random access */        skip_bits(&s->gb, 8); /* vo_type */        if (get_bits1(&s->gb) != 0) { /* is_ol_id */            vo_ver_id = get_bits(&s->gb, 4); /* vo_ver_id */            skip_bits(&s->gb, 3); /* vo_priority */        } else {            vo_ver_id = 1;        }                s->aspect_ratio_info= get_bits(&s->gb, 4);	if(s->aspect_ratio_info == EXTENDET_PAR){            skip_bits(&s->gb, 8); //par_width            skip_bits(&s->gb, 8); // par_height        }        if(get_bits1(&s->gb)){ /* vol control parameter */            printf("vol control parameter not supported\n");            return -1;           }        s->shape = get_bits(&s->gb, 2); /* vol shape */        if(s->shape == GRAY_SHAPE && vo_ver_id != 1){            printf("Gray shape not supported\n");            skip_bits(&s->gb, 4);  //video_object_layer_shape_extension        }        skip_bits1(&s->gb);   /* marker */                time_increment_resolution = get_bits(&s->gb, 16);        s->time_increment_bits = av_log2(time_increment_resolution - 1) + 1;        if (s->time_increment_bits < 1)            s->time_increment_bits = 1;        skip_bits1(&s->gb);   /* marker */        if (get_bits1(&s->gb) != 0) {   /* fixed_vop_rate  */            skip_bits(&s->gb, s->time_increment_bits);        }        if (s->shape != BIN_ONLY_SHAPE) {            if (s->shape == RECT_SHAPE) {                skip_bits1(&s->gb);   /* marker */                width = get_bits(&s->gb, 13);                skip_bits1(&s->gb);   /* marker */                height = get_bits(&s->gb, 13);                skip_bits1(&s->gb);   /* marker */            }                        skip_bits1(&s->gb);   /* interlaced */            if(!get_bits1(&s->gb)) printf("OBMC not supported\n");   /* OBMC Disable */            if (vo_ver_id == 1) {                s->vol_sprite_usage = get_bits1(&s->gb); /* vol_sprite_usage */            } else {                s->vol_sprite_usage = get_bits(&s->gb, 2); /* vol_sprite_usage */            }            if(s->vol_sprite_usage==STATIC_SPRITE) printf("Static Sprites not supported\n");            if(s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE){                if(s->vol_sprite_usage==STATIC_SPRITE){                    s->sprite_width = get_bits(&s->gb, 13);                    skip_bits1(&s->gb); /* marker */                    s->sprite_height= get_bits(&s->gb, 13);                    skip_bits1(&s->gb); /* marker */                    s->sprite_left  = get_bits(&s->gb, 13);                    skip_bits1(&s->gb); /* marker */                    s->sprite_top   = get_bits(&s->gb, 13);                    skip_bits1(&s->gb); /* marker */                }                s->num_sprite_warping_points= get_bits(&s->gb, 6);                s->sprite_warping_accuracy = get_bits(&s->gb, 2);                s->sprite_brightness_change= get_bits1(&s->gb);                if(s->vol_sprite_usage==STATIC_SPRITE)                    s->low_latency_sprite= get_bits1(&s->gb);                        }            // FIXME sadct disable bit if verid!=1 && shape not rect                        if (get_bits1(&s->gb) == 1) {   /* not_8_bit */                s->quant_precision = get_bits(&s->gb, 4); /* quant_precision */                skip_bits(&s->gb, 4); /* bits_per_pixel */            } else {                s->quant_precision = 5;            }                        // FIXME a bunch of grayscale shape things            if(get_bits1(&s->gb)) printf("Quant-Type not supported\n");  /* vol_quant_type */ //FIXME            if(vo_ver_id != 1)                 s->quarter_sample= get_bits1(&s->gb);            else s->quarter_sample=0;            if(s->quarter_sample) printf("Quarter sample not supported\n");#if 0            if(get_bits1(&s->gb)) printf("Complexity est disabled\n");            if(get_bits1(&s->gb)) printf("resync disable\n");#else            skip_bits1(&s->gb);   /* complexity_estimation_disabled */            skip_bits1(&s->gb);   /* resync_marker_disabled */#endif            s->data_partioning= get_bits1(&s->gb);            if(s->data_partioning){                printf("data partitioning not supported\n");                skip_bits1(&s->gb); // reversible vlc            }                        if(vo_ver_id != 1) {                s->new_pred= get_bits1(&s->gb);                if(s->new_pred){                    printf("new pred not supported\n");                    skip_bits(&s->gb, 2); /* requested upstream message type */                    skip_bits1(&s->gb); /* newpred segment type */                }                s->reduced_res_vop= get_bits1(&s->gb);                if(s->reduced_res_vop) printf("reduced resolution VOP not supported\n");            }            else{                s->new_pred=0;                s->reduced_res_vop= 0;            }            s->scalability= get_bits1(&s->gb);            if (s->scalability) {                printf("bad scalability!!!\n");                return -1;            }        }//printf("end Data %X %d\n", show_bits(&s->gb, 32), get_bits_count(&s->gb)&0x7);        goto redo;    } else if (startcode == 0x1b2) { //userdata//printf("user Data %X\n", show_bits(&s->gb, 32));        goto redo;    } else if (startcode != 0x1b6) { //VOP        goto redo;    }    s->pict_type = get_bits(&s->gb, 2) + 1;	/* pict type: I = 0 , P = 1 */    if(s->pict_type == B_TYPE)    {        printf("B-VOP\n");	return -1;    }    if(s->pict_type == S_TYPE)    {        printf("S-VOP\n");//	return -1;    }        /* XXX: parse time base */    time_incr = 0;    while (get_bits1(&s->gb) != 0)         time_incr++;    skip_bits1(&s->gb);   	/* marker */    skip_bits(&s->gb, s->time_increment_bits);    skip_bits1(&s->gb);   	/* marker */    /* vop coded */    if (get_bits1(&s->gb) != 1)        goto redo;        if (s->shape != BIN_ONLY_SHAPE && ( s->pict_type == P_TYPE                          || (s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE))) {        /* rounding type for motion estimation */	s->no_rounding = get_bits1(&s->gb);    } else {	s->no_rounding = 0;    }//FIXME reduced res stuff     if (s->shape != RECT_SHAPE) {         if (s->vol_sprite_usage != 1 || s->pict_type != I_TYPE) {             int width, height, hor_spat_ref, ver_spat_ref;              width = get_bits(&s->gb, 13);             skip_bits1(&s->gb);   /* marker */             height = get_bits(&s->gb, 13);             skip_bits1(&s->gb);   /* marker */             hor_spat_ref = get_bits(&s->gb, 13); /* hor_spat_ref */             skip_bits1(&s->gb);   /* marker */             ver_spat_ref = get_bits(&s->gb, 13); /* ver_spat_ref */         }         skip_bits1(&s->gb); /* change_CR_disable */          if (get_bits1(&s->gb) != 0) {             skip_bits(&s->gb, 8); /* constant_alpha_value */         }     }//FIXME complexity estimation stuff          if (s->shape != BIN_ONLY_SHAPE) {         skip_bits(&s->gb, 3); /* intra dc VLC threshold */         //FIXME interlaced specific bits     }     if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){         if(s->num_sprite_warping_points){             mpeg4_decode_sprite_trajectory(s);         }         if(s->sprite_brightness_change) printf("sprite_brightness_change not supported\n");         if(s->vol_sprite_usage==STATIC_SPRITE) printf("static sprite not supported\n");     }     if (s->shape != BIN_ONLY_SHAPE) {         /* note: we do not use quant_precision to avoid problem if no            MPEG4 vol header as it is found on some old opendivx            movies */         s->qscale = get_bits(&s->gb, 5);           if (s->pict_type != I_TYPE) {             s->f_code = get_bits(&s->gb, 3);	/* fcode_for */         }         if (s->pict_type == B_TYPE) {             s->b_code = get_bits(&s->gb, 3);         }//printf("quant:%d fcode:%d\n", s->qscale, s->f_code);         if(!s->scalability){             if (s->shape!=RECT_SHAPE && s->pict_type!=I_TYPE) {                 skip_bits1(&s->gb); // vop shape coding type             }         }     }//printf("end Data %X %d\n", show_bits(&s->gb, 32), get_bits_count(&s->gb)&0x7);     return 0;}