void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)

{

    int time_incr;

    int time_div, time_mod;



    if (s->pict_type == AV_PICTURE_TYPE_I) {

        if (!(s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {

            if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT)  // HACK, the reference sw is buggy

                mpeg4_encode_visual_object_header(s);

            if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0)  // HACK, the reference sw is buggy

                mpeg4_encode_vol_header(s, 0, 0);

        }

        if (!(s->workaround_bugs & FF_BUG_MS))

            mpeg4_encode_gop_header(s);

    }



    s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B;



    put_bits(&s->pb, 16, 0);                /* vop header */

    put_bits(&s->pb, 16, VOP_STARTCODE);    /* vop header */

    put_bits(&s->pb, 2, s->pict_type - 1);  /* pict type: I = 0 , P = 1 */



    time_div  = FFUDIV(s->time, s->avctx->time_base.den);

    time_mod  = FFUMOD(s->time, s->avctx->time_base.den);

    time_incr = time_div - s->last_time_base;

    av_assert0(time_incr >= 0);

    while (time_incr--)

        put_bits(&s->pb, 1, 1);



    put_bits(&s->pb, 1, 0);



    put_bits(&s->pb, 1, 1);                             /* marker */

    put_bits(&s->pb, s->time_increment_bits, time_mod); /* time increment */

    put_bits(&s->pb, 1, 1);                             /* marker */

    put_bits(&s->pb, 1, 1);                             /* vop coded */

    if (s->pict_type == AV_PICTURE_TYPE_P) {

        put_bits(&s->pb, 1, s->no_rounding);    /* rounding type */

    }

    put_bits(&s->pb, 3, 0);     /* intra dc VLC threshold */

    if (!s->progressive_sequence) {

        put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);

        put_bits(&s->pb, 1, s->alternate_scan);

    }

    // FIXME sprite stuff



    put_bits(&s->pb, 5, s->qscale);



    if (s->pict_type != AV_PICTURE_TYPE_I)

        put_bits(&s->pb, 3, s->f_code);  /* fcode_for */

    if (s->pict_type == AV_PICTURE_TYPE_B)

        put_bits(&s->pb, 3, s->b_code);  /* fcode_back */

}

void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)

{

    int time_incr;

    int time_div, time_mod;



    if (s->pict_type == AV_PICTURE_TYPE_I) {

        if (!(s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {

            if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT)  

                mpeg4_encode_visual_object_header(s);

            if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0)  

                mpeg4_encode_vol_header(s, 0, 0);

        }

        if (!(s->workaround_bugs & FF_BUG_MS))

            mpeg4_encode_gop_header(s);

    }



    s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B;



    put_bits(&s->pb, 16, 0);                

    put_bits(&s->pb, 16, VOP_STARTCODE);    

    put_bits(&s->pb, 2, s->pict_type - 1);  



    time_div  = FFUDIV(s->time, s->avctx->time_base.den);

    time_mod  = FFUMOD(s->time, s->avctx->time_base.den);

    time_incr = time_div - s->last_time_base;

    av_assert0(time_incr >= 0);

    while (time_incr--)

        put_bits(&s->pb, 1, 1);



    put_bits(&s->pb, 1, 0);



    put_bits(&s->pb, 1, 1);                             

    put_bits(&s->pb, s->time_increment_bits, time_mod); 

    put_bits(&s->pb, 1, 1);                             

    put_bits(&s->pb, 1, 1);                             

    if (s->pict_type == AV_PICTURE_TYPE_P) {

        put_bits(&s->pb, 1, s->no_rounding);    

    }

    put_bits(&s->pb, 3, 0);     

    if (!s->progressive_sequence) {

        put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);

        put_bits(&s->pb, 1, s->alternate_scan);

    }

    



    put_bits(&s->pb, 5, s->qscale);



    if (s->pict_type != AV_PICTURE_TYPE_I)

        put_bits(&s->pb, 3, s->f_code);  

    if (s->pict_type == AV_PICTURE_TYPE_B)

        put_bits(&s->pb, 3, s->b_code);  

}

void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
void FUNC_0(MpegEncContext *VAR_0, int VAR_1)

{

    int VAR_2;

    int VAR_3, VAR_4;



    if (VAR_0->pict_type == AV_PICTURE_TYPE_I) {

        if (!(VAR_0->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {

            if (VAR_0->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT)  

                mpeg4_encode_visual_object_header(VAR_0);

            if (VAR_0->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || VAR_1 == 0)  

                mpeg4_encode_vol_header(VAR_0, 0, 0);

        }

        if (!(VAR_0->workaround_bugs & FF_BUG_MS))

            mpeg4_encode_gop_header(VAR_0);

    }



    VAR_0->partitioned_frame = VAR_0->data_partitioning && VAR_0->pict_type != AV_PICTURE_TYPE_B;



    put_bits(&VAR_0->pb, 16, 0);                

    put_bits(&VAR_0->pb, 16, VOP_STARTCODE);    

    put_bits(&VAR_0->pb, 2, VAR_0->pict_type - 1);  



    VAR_3  = FFUDIV(VAR_0->time, VAR_0->avctx->time_base.den);

    VAR_4  = FFUMOD(VAR_0->time, VAR_0->avctx->time_base.den);

    VAR_2 = VAR_3 - VAR_0->last_time_base;

    av_assert0(VAR_2 >= 0);

    while (VAR_2--)

        put_bits(&VAR_0->pb, 1, 1);



    put_bits(&VAR_0->pb, 1, 0);



    put_bits(&VAR_0->pb, 1, 1);                             

    put_bits(&VAR_0->pb, VAR_0->time_increment_bits, VAR_4); 

    put_bits(&VAR_0->pb, 1, 1);                             

    put_bits(&VAR_0->pb, 1, 1);                             

    if (VAR_0->pict_type == AV_PICTURE_TYPE_P) {

        put_bits(&VAR_0->pb, 1, VAR_0->no_rounding);    

    }

    put_bits(&VAR_0->pb, 3, 0);     

    if (!VAR_0->progressive_sequence) {

        put_bits(&VAR_0->pb, 1, VAR_0->current_picture_ptr->f->top_field_first);

        put_bits(&VAR_0->pb, 1, VAR_0->alternate_scan);

    }

    



    put_bits(&VAR_0->pb, 5, VAR_0->qscale);



    if (VAR_0->pict_type != AV_PICTURE_TYPE_I)

        put_bits(&VAR_0->pb, 3, VAR_0->f_code);  

    if (VAR_0->pict_type == AV_PICTURE_TYPE_B)

        put_bits(&VAR_0->pb, 3, VAR_0->b_code);  

}

void FUNC_0(MpegEncContext *VAR_0, int VAR_1)
{ int VAR_2; int VAR_3, VAR_4; if (VAR_0->pict_type == AV_PICTURE_TYPE_I) { if (!(VAR_0->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) { if (VAR_0->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT)
mpeg4_encode_visual_object_header(VAR_0); if (VAR_0->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || VAR_1 == 0)
mpeg4_encode_vol_header(VAR_0, 0, 0); } if (!(VAR_0->workaround_bugs & FF_BUG_MS))
mpeg4_encode_gop_header(VAR_0); } VAR_0->partitioned_frame = VAR_0->data_partitioning && VAR_0->pict_type != AV_PICTURE_TYPE_B; put_bits(&VAR_0->pb, 16, 0); put_bits(&VAR_0->pb, 16, VOP_STARTCODE); put_bits(&VAR_0->pb, 2, VAR_0->pict_type - 1); VAR_3  = FFUDIV(VAR_0->time, VAR_0->avctx->time_base.den); VAR_4  = FFUMOD(VAR_0->time, VAR_0->avctx->time_base.den); VAR_2 = VAR_3 - VAR_0->last_time_base; av_assert0(VAR_2 >= 0); while (VAR_2--)
put_bits(&VAR_0->pb, 1, 1); put_bits(&VAR_0->pb, 1, 0); put_bits(&VAR_0->pb, 1, 1); put_bits(&VAR_0->pb, VAR_0->time_increment_bits, VAR_4); put_bits(&VAR_0->pb, 1, 1); put_bits(&VAR_0->pb, 1, 1); if (VAR_0->pict_type == AV_PICTURE_TYPE_P) { put_bits(&VAR_0->pb, 1, VAR_0->no_rounding); } put_bits(&VAR_0->pb, 3, 0); if (!VAR_0->progressive_sequence) { put_bits(&VAR_0->pb, 1, VAR_0->current_picture_ptr->f->top_field_first); put_bits(&VAR_0->pb, 1, VAR_0->alternate_scan); } put_bits(&VAR_0->pb, 5, VAR_0->qscale); if (VAR_0->pict_type != AV_PICTURE_TYPE_I)
put_bits(&VAR_0->pb, 3, VAR_0->f_code); if (VAR_0->pict_type == AV_PICTURE_TYPE_B)
put_bits(&VAR_0->pb, 3, VAR_0->b_code); }