s->field_mv_table[mb_index][i][0]= s->mv[0][i][0]; s->field_mv_table[mb_index][i][1]= s->mv[0][i][1]; s->field_select_table[mb_index][i]= s->field_select[0][i]; } s->co_located_type_table[mb_index]= CO_LOCATED_TYPE_FIELDMV; }
s->field_mv_table[mb_xy][i][0]= s->mv[0][i][0]; s->field_mv_table[mb_xy][i][1]= s->mv[0][i][1]; s->field_select_table[mb_xy][i]= s->field_select[0][i]; } }
void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64]){    int mb_x, mb_y;    const int mb_xy = s->mb_y * s->mb_width + s->mb_x;    mb_x = s->mb_x;    mb_y = s->mb_y;    s->current_picture.qscale_table[mb_xy]= s->qscale;    /* update DC predictors for P macroblocks */    if (!s->mb_intra) {        if (s->h263_pred || s->h263_aic) {            if(s->mbintra_table[mb_xy])                ff_clean_intra_table_entries(s);        } else {            s->last_dc[0] =            s->last_dc[1] =            s->last_dc[2] = 128 << s->intra_dc_precision;        }    }    else if (s->h263_pred || s->h263_aic)        s->mbintra_table[mb_xy]=1;    /* update motion predictor, not for B-frames as they need the motion_val from the last P/S-Frame */    if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE) { //FIXME move into h263.c if possible, format specific stuff shouldnt be here        //FIXME a lot of thet is only needed for !low_delay        const int wrap = s->block_wrap[0];        const int xy = s->block_index[0];        const int mb_index= s->mb_x + s->mb_y*s->mb_width;        if(s->mv_type == MV_TYPE_8X8){            s->co_located_type_table[mb_index]= CO_LOCATED_TYPE_4MV;        } else {            int motion_x, motion_y;            if (s->mb_intra) {                motion_x = 0;                motion_y = 0;                if(s->co_located_type_table)                    s->co_located_type_table[mb_index]= 0;            } else if (s->mv_type == MV_TYPE_16X16) {                motion_x = s->mv[0][0][0];                motion_y = s->mv[0][0][1];                if(s->co_located_type_table)                    s->co_located_type_table[mb_index]= 0;            } else /*if (s->mv_type == MV_TYPE_FIELD)*/ {                int i;                motion_x = s->mv[0][0][0] + s->mv[0][1][0];                motion_y = s->mv[0][0][1] + s->mv[0][1][1];                motion_x = (motion_x>>1) | (motion_x&1);                for(i=0; i<2; i++){                    s->field_mv_table[mb_index][i][0]= s->mv[0][i][0];                    s->field_mv_table[mb_index][i][1]= s->mv[0][i][1];                    s->field_select_table[mb_index][i]= s->field_select[0][i];                }                s->co_located_type_table[mb_index]= CO_LOCATED_TYPE_FIELDMV;            }            /* no update if 8X8 because it has been done during parsing */            s->motion_val[xy][0] = motion_x;            s->motion_val[xy][1] = motion_y;            s->motion_val[xy + 1][0] = motion_x;            s->motion_val[xy + 1][1] = motion_y;            s->motion_val[xy + wrap][0] = motion_x;            s->motion_val[xy + wrap][1] = motion_y;            s->motion_val[xy + 1 + wrap][0] = motion_x;            s->motion_val[xy + 1 + wrap][1] = motion_y;        }    }        if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc        uint8_t *dest_y, *dest_cb, *dest_cr;        int dct_linesize, dct_offset;        op_pixels_func (*op_pix)[4];        qpel_mc_func (*op_qpix)[16];        const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics        const int uvlinesize= s->current_picture.linesize[1];        /* avoid copy if macroblock skipped in last frame too */        if (s->pict_type != B_TYPE) {            s->current_picture.mbskip_table[mb_xy]= s->mb_skiped;        }        /* skip only during decoding as we might trash the buffers during encoding a bit */        if(!s->encoding){            uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];            const int age= s->current_picture.age;            assert(age);            if (s->mb_skiped) {                s->mb_skiped= 0;                assert(s->pict_type!=I_TYPE);                 (*mbskip_ptr) ++; /* indicate that this time we skiped it */                if(*mbskip_ptr >99) *mbskip_ptr= 99;                /* if previous was skipped too, then nothing to do !  */                if (*mbskip_ptr >= age && s->current_picture.reference){                    return;                }            } else if(!s->current_picture.reference){                (*mbskip_ptr) ++; /* increase counter so the age can be compared cleanly */                if(*mbskip_ptr >99) *mbskip_ptr= 99;            } else{                *mbskip_ptr = 0; /* not skipped */            }        }else            s->mb_skiped= 0;        if(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME){ //FIXME precalc            dest_y  = s->current_picture.data[0] + mb_x * 16;            dest_cb = s->current_picture.data[1] + mb_x * 8;            dest_cr = s->current_picture.data[2] + mb_x * 8;        }else{            dest_y  = s->current_picture.data[0] + (mb_y * 16* linesize  ) + mb_x * 16;            dest_cb = s->current_picture.data[1] + (mb_y * 8 * uvlinesize) + mb_x * 8;            dest_cr = s->current_picture.data[2] + (mb_y * 8 * uvlinesize) + mb_x * 8;        }        if (s->interlaced_dct) {            dct_linesize = linesize * 2;            dct_offset = linesize;        } else {            dct_linesize = linesize;            dct_offset = linesize * 8;        }        if (!s->mb_intra) {            /* motion handling */            /* decoding or more than one mb_type (MC was allready done otherwise) */            if((!s->encoding) || (s->mb_type[mb_xy]&(s->mb_type[mb_xy]-1))){                if ((!s->no_rounding) || s->pict_type==B_TYPE){                		    op_pix = s->dsp.put_pixels_tab;                    op_qpix= s->dsp.put_qpel_pixels_tab;                }else{                    op_pix = s->dsp.put_no_rnd_pixels_tab;                    op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;                }                if (s->mv_dir & MV_DIR_FORWARD) {                    MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);		    op_pix = s->dsp.avg_pixels_tab;                    op_qpix= s->dsp.avg_qpel_pixels_tab;                }                if (s->mv_dir & MV_DIR_BACKWARD) {                    MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);                }            }            /* skip dequant / idct if we are really late ;) */            if(s->hurry_up>1) return;            /* add dct residue */            if(s->encoding || !(   s->mpeg2 || s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO                                 || (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant))){                add_dequant_dct(s, block[0], 0, dest_y, dct_linesize);                add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize);                add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);                if(!(s->flags&CODEC_FLAG_GRAY)){                    add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize);                    add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize);                }            } else if(s->codec_id != CODEC_ID_WMV2){                add_dct(s, block[0], 0, dest_y, dct_linesize);                add_dct(s, block[1], 1, dest_y + 8, dct_linesize);                add_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);                add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);                if(!(s->flags&CODEC_FLAG_GRAY)){                    add_dct(s, block[4], 4, dest_cb, uvlinesize);                    add_dct(s, block[5], 5, dest_cr, uvlinesize);                }            } #ifdef CONFIG_RISKY            else{                ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);            }#endif        } else {            /* dct only in intra block */            if(s->encoding || !(s->mpeg2 || s->codec_id==CODEC_ID_MPEG1VIDEO)){                put_dct(s, block[0], 0, dest_y, dct_linesize);                put_dct(s, block[1], 1, dest_y + 8, dct_linesize);                put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);                put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);                if(!(s->flags&CODEC_FLAG_GRAY)){                    put_dct(s, block[4], 4, dest_cb, uvlinesize);                    put_dct(s, block[5], 5, dest_cr, uvlinesize);                }            }else{                s->dsp.idct_put(dest_y                 , dct_linesize, block[0]);                s->dsp.idct_put(dest_y              + 8, dct_linesize, block[1]);                s->dsp.idct_put(dest_y + dct_offset    , dct_linesize, block[2]);                s->dsp.idct_put(dest_y + dct_offset + 8, dct_linesize, block[3]);                if(!(s->flags&CODEC_FLAG_GRAY)){                    s->dsp.idct_put(dest_cb, uvlinesize, block[4]);                    s->dsp.idct_put(dest_cr, uvlinesize, block[5]);                }            }        }    }}