mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0]); mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1]);
mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code);
void mpeg1_encode_mb(MpegEncContext *s,                     DCTELEM block[6][64],                     int motion_x, int motion_y){    int mb_incr, i, cbp, mb_x, mb_y;    mb_x = s->mb_x;    mb_y = s->mb_y;    /* compute cbp */    cbp = 0;    for(i=0;i<6;i++) {        if (s->block_last_index[i] >= 0)            cbp |= 1 << (5 - i);    }    /* skip macroblock, except if first or last macroblock of a slice */    if ((cbp | motion_x | motion_y) == 0 &&        (!((mb_x | mb_y) == 0 ||           (mb_x == s->mb_width - 1 && mb_y == s->mb_height - 1)))) {        s->mb_incr++;        s->qscale -= s->dquant;        s->skip_count++;        s->misc_bits++;        s->last_bits++;    } else {        /* output mb incr */        mb_incr = s->mb_incr;        while (mb_incr > 33) {            put_bits(&s->pb, 11, 0x008);            mb_incr -= 33;        }        put_bits(&s->pb, mbAddrIncrTable[mb_incr - 1][1],                  mbAddrIncrTable[mb_incr - 1][0]);                if (s->pict_type == I_TYPE) {            if(s->dquant && cbp){                put_bits(&s->pb, 2, 1); /* macroblock_type : macroblock_quant = 1 */                put_bits(&s->pb, 5, s->qscale);            }else{                put_bits(&s->pb, 1, 1); /* macroblock_type : macroblock_quant = 0 */                s->qscale -= s->dquant;            }            s->misc_bits+= get_bits_diff(s);            s->i_count++;        } else {            if (s->mb_intra) {                if(s->dquant && cbp){                    put_bits(&s->pb, 6, 0x01);                    put_bits(&s->pb, 5, s->qscale);                }else{                    put_bits(&s->pb, 5, 0x03);                    s->qscale -= s->dquant;                }                s->misc_bits+= get_bits_diff(s);                s->i_count++;            } else {                if (cbp != 0) {                    if (motion_x == 0 && motion_y == 0) {                        if(s->dquant){                            put_bits(&s->pb, 5, 1); /* macroblock_pattern & quant */                            put_bits(&s->pb, 5, s->qscale);                        }else{                            put_bits(&s->pb, 2, 1); /* macroblock_pattern only */                        }                        s->misc_bits+= get_bits_diff(s);                        put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);                    } else {                        if(s->dquant){                            put_bits(&s->pb, 5, 2); /* motion + cbp */                            put_bits(&s->pb, 5, s->qscale);                        }else{                            put_bits(&s->pb, 1, 1); /* motion + cbp */                        }                        s->misc_bits+= get_bits_diff(s);                        mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0]);                         mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1]);                         s->mv_bits+= get_bits_diff(s);                        put_bits(&s->pb, mbPatTable[cbp - 1][1], mbPatTable[cbp - 1][0]);                    }                } else {                    put_bits(&s->pb, 3, 1); /* motion only */                    mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0]);                     mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1]);                     s->qscale -= s->dquant;                    s->mv_bits+= get_bits_diff(s);                }                s->f_count++;            }        }        for(i=0;i<6;i++) {            if (cbp & (1 << (5 - i))) {                mpeg1_encode_block(s, block[i], i);            }        }        s->mb_incr = 1;        if(s->mb_intra)            s->i_tex_bits+= get_bits_diff(s);        else            s->p_tex_bits+= get_bits_diff(s);    }    s->last_mv[0][0][0] = motion_x;    s->last_mv[0][0][1] = motion_y;}