static inline void mc_dir_part(AVSContext *h,Picture *pic,
                               int chroma_height,int delta,int list,uint8_t *dest_y,
                               uint8_t *dest_cb,uint8_t *dest_cr,int src_x_offset,
                               int src_y_offset,qpel_mc_func *qpix_op,
                               h264_chroma_mc_func chroma_op,cavs_vector *mv)
{
    MpegEncContext * const s = &h->s;
    const int mx= mv->x + src_x_offset*8;
    const int my= mv->y + src_y_offset*8;
    const int luma_xy= (mx&3) + ((my&3)<<2);
    uint8_t * src_y  = pic->f.data[0] + (mx >> 2) + (my >> 2) * h->l_stride;
    uint8_t * src_cb = pic->f.data[1] + (mx >> 3) + (my >> 3) * h->c_stride;
    uint8_t * src_cr = pic->f.data[2] + (mx >> 3) + (my >> 3) * h->c_stride;
    int extra_width= 0;
    int extra_height= extra_width;
    int emu=0;
    const int full_mx= mx>>2;
    const int full_my= my>>2;
    const int pic_width  = 16*h->mb_width;
    const int pic_height = 16*h->mb_height;
    if(!pic->f.data[0])
        return;
    if(mx&7) extra_width -= 3;
    if(my&7) extra_height -= 3;
    if(   full_mx < 0-extra_width
          || full_my < 0-extra_height
          || full_mx + 16  > pic_width + extra_width
          || full_my + 16  > pic_height + extra_height){
        s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*h->l_stride, h->l_stride,
                            16+5, 16+5 , full_mx-2, full_my-2, pic_width, pic_height);
        src_y= s->edge_emu_buffer + 2 + 2*h->l_stride;
        emu=1;
    }
    qpix_op[luma_xy](dest_y, src_y, h->l_stride);
    if(emu){
        s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->c_stride,
                            9, 9 , (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
        src_cb= s->edge_emu_buffer;
    }
    chroma_op(dest_cb, src_cb, h->c_stride, chroma_height, mx&7, my&7);
    if(emu){
        s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr, h->c_stride,
                            9, 9 , (mx>>3), (my>>3), pic_width>>1, pic_height>>1);
        src_cr= s->edge_emu_buffer;
    }
    chroma_op(dest_cr, src_cr, h->c_stride, chroma_height, mx&7, my&7);
}
['void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type) {\n    if(ff_cavs_partition_flags[mb_type] == 0){\n        mc_part_std(h, 8, 0, h->cy, h->cu, h->cv, 0, 0,\n                h->cdsp.put_cavs_qpel_pixels_tab[0],\n                h->s.dsp.put_h264_chroma_pixels_tab[0],\n                h->cdsp.avg_cavs_qpel_pixels_tab[0],\n                h->s.dsp.avg_h264_chroma_pixels_tab[0],&h->mv[MV_FWD_X0]);\n    }else{\n        mc_part_std(h, 4, 0, h->cy, h->cu, h->cv, 0, 0,\n                h->cdsp.put_cavs_qpel_pixels_tab[1],\n                h->s.dsp.put_h264_chroma_pixels_tab[1],\n                h->cdsp.avg_cavs_qpel_pixels_tab[1],\n                h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X0]);\n        mc_part_std(h, 4, 0, h->cy, h->cu, h->cv, 4, 0,\n                h->cdsp.put_cavs_qpel_pixels_tab[1],\n                h->s.dsp.put_h264_chroma_pixels_tab[1],\n                h->cdsp.avg_cavs_qpel_pixels_tab[1],\n                h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X1]);\n        mc_part_std(h, 4, 0, h->cy, h->cu, h->cv, 0, 4,\n                h->cdsp.put_cavs_qpel_pixels_tab[1],\n                h->s.dsp.put_h264_chroma_pixels_tab[1],\n                h->cdsp.avg_cavs_qpel_pixels_tab[1],\n                h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X2]);\n        mc_part_std(h, 4, 0, h->cy, h->cu, h->cv, 4, 4,\n                h->cdsp.put_cavs_qpel_pixels_tab[1],\n                h->s.dsp.put_h264_chroma_pixels_tab[1],\n                h->cdsp.avg_cavs_qpel_pixels_tab[1],\n                h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X3]);\n    }\n}', 'static inline void mc_part_std(AVSContext *h,int chroma_height,int delta,\n                               uint8_t *dest_y,uint8_t *dest_cb,uint8_t *dest_cr,\n                               int x_offset, int y_offset,qpel_mc_func *qpix_put,\n                               h264_chroma_mc_func chroma_put,qpel_mc_func *qpix_avg,\n                               h264_chroma_mc_func chroma_avg, cavs_vector *mv)\n{\n    qpel_mc_func *qpix_op=  qpix_put;\n    h264_chroma_mc_func chroma_op= chroma_put;\n    dest_y  += 2*x_offset + 2*y_offset*h->l_stride;\n    dest_cb +=   x_offset +   y_offset*h->c_stride;\n    dest_cr +=   x_offset +   y_offset*h->c_stride;\n    x_offset += 8*h->mbx;\n    y_offset += 8*h->mby;\n    if(mv->ref >= 0){\n        Picture *ref= &h->DPB[mv->ref];\n        mc_dir_part(h, ref, chroma_height, delta, 0,\n                    dest_y, dest_cb, dest_cr, x_offset, y_offset,\n                    qpix_op, chroma_op, mv);\n        qpix_op=  qpix_avg;\n        chroma_op= chroma_avg;\n    }\n    if((mv+MV_BWD_OFFS)->ref >= 0){\n        Picture *ref= &h->DPB[0];\n        mc_dir_part(h, ref, chroma_height, delta, 1,\n                    dest_y, dest_cb, dest_cr, x_offset, y_offset,\n                    qpix_op, chroma_op, mv+MV_BWD_OFFS);\n    }\n}', 'static inline void mc_dir_part(AVSContext *h,Picture *pic,\n                               int chroma_height,int delta,int list,uint8_t *dest_y,\n                               uint8_t *dest_cb,uint8_t *dest_cr,int src_x_offset,\n                               int src_y_offset,qpel_mc_func *qpix_op,\n                               h264_chroma_mc_func chroma_op,cavs_vector *mv)\n{\n    MpegEncContext * const s = &h->s;\n    const int mx= mv->x + src_x_offset*8;\n    const int my= mv->y + src_y_offset*8;\n    const int luma_xy= (mx&3) + ((my&3)<<2);\n    uint8_t * src_y  = pic->f.data[0] + (mx >> 2) + (my >> 2) * h->l_stride;\n    uint8_t * src_cb = pic->f.data[1] + (mx >> 3) + (my >> 3) * h->c_stride;\n    uint8_t * src_cr = pic->f.data[2] + (mx >> 3) + (my >> 3) * h->c_stride;\n    int extra_width= 0;\n    int extra_height= extra_width;\n    int emu=0;\n    const int full_mx= mx>>2;\n    const int full_my= my>>2;\n    const int pic_width  = 16*h->mb_width;\n    const int pic_height = 16*h->mb_height;\n    if(!pic->f.data[0])\n        return;\n    if(mx&7) extra_width -= 3;\n    if(my&7) extra_height -= 3;\n    if(   full_mx < 0-extra_width\n          || full_my < 0-extra_height\n          || full_mx + 16  > pic_width + extra_width\n          || full_my + 16  > pic_height + extra_height){\n        s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*h->l_stride, h->l_stride,\n                            16+5, 16+5 , full_mx-2, full_my-2, pic_width, pic_height);\n        src_y= s->edge_emu_buffer + 2 + 2*h->l_stride;\n        emu=1;\n    }\n    qpix_op[luma_xy](dest_y, src_y, h->l_stride);\n    if(emu){\n        s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->c_stride,\n                            9, 9 , (mx>>3), (my>>3), pic_width>>1, pic_height>>1);\n        src_cb= s->edge_emu_buffer;\n    }\n    chroma_op(dest_cb, src_cb, h->c_stride, chroma_height, mx&7, my&7);\n    if(emu){\n        s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr, h->c_stride,\n                            9, 9 , (mx>>3), (my>>3), pic_width>>1, pic_height>>1);\n        src_cr= s->edge_emu_buffer;\n    }\n    chroma_op(dest_cr, src_cr, h->c_stride, chroma_height, mx&7, my&7);\n}']