⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mc-c.c.svn-base

📁 H.264 source codes
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
    pixel_avg_w8( dst, i_dst_stride, tmp1, 8, tmp2, 8, i_height );}static void mc_xy23_w8( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    uint8_t tmp1[8*16];    uint8_t tmp2[8*16];    mc_hc_w8( src,              i_src_stride, tmp1, 8, i_height );    mc_hh_w8( src+i_src_stride, i_src_stride, tmp2, 8, i_height );    pixel_avg_w8( dst, i_dst_stride, tmp1, 8, tmp2, 8, i_height );}#endif/***************************************************************************** * MC with width == 16 (height <= 16) *****************************************************************************/static inline void mc_hh_w16( uint8_t *src, int i_src, uint8_t *dst, int i_dst, int i_height ){    mc_hh_w4( &src[ 0], i_src, &dst[ 0], i_dst, i_height );    mc_hh_w4( &src[ 4], i_src, &dst[ 4], i_dst, i_height );    mc_hh_w4( &src[ 8], i_src, &dst[ 8], i_dst, i_height );    mc_hh_w4( &src[12], i_src, &dst[12], i_dst, i_height );}static inline void mc_hv_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    mc_hv_w8( src,     i_src_stride, dst,     i_dst_stride, i_height );    mc_hv_w8( &src[8], i_src_stride, &dst[8], i_dst_stride, i_height );}static inline void mc_hc_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    mc_hc_w8( src,     i_src_stride, dst,     i_dst_stride, i_height );    mc_hc_w8( &src[8], i_src_stride, &dst[8], i_dst_stride, i_height );}/* MMX avg/copy */MC_IH( mc_xy10, mmxext, 16, 16, 0 )MC_IH( mc_xy30, mmxext, 16, 16, 1 )MC_IV( mc_xy01, mmxext, 16, 16, 0 )MC_IV( mc_xy03, mmxext, 16, 16, i_src_stride )MC_HV( mc_xy11, mmxext, 16, 16, 0, 0 )MC_HV( mc_xy31, mmxext, 16, 16, 1, 0 )MC_HV( mc_xy13, mmxext, 16, 16, 0, i_src_stride )MC_HV( mc_xy33, mmxext, 16, 16, 1, i_src_stride )MC_CH( mc_xy21, mmxext, 16, 16, 0 )MC_CH( mc_xy23, mmxext, 16, 16, i_src_stride )MC_CV( mc_xy12, mmxext, 16, 16, 0 )MC_CV( mc_xy32, mmxext, 16, 16, 1 )/* SSE2 avg/copy */MC_IH( mc_xy10, sse2, 16, 16, 0 )MC_IH( mc_xy30, sse2, 16, 16, 1 )MC_IV( mc_xy01, sse2, 16, 16, 0 )MC_IV( mc_xy03, sse2, 16, 16, i_src_stride )MC_HV( mc_xy11, sse2, 16, 16, 0, 0 )MC_HV( mc_xy31, sse2, 16, 16, 1, 0 )MC_HV( mc_xy13, sse2, 16, 16, 0, i_src_stride )MC_HV( mc_xy33, sse2, 16, 16, 1, i_src_stride )MC_CH( mc_xy21, sse2, 16, 16, 0 )MC_CH( mc_xy23, sse2, 16, 16, i_src_stride )MC_CV( mc_xy12, sse2, 16, 16, 0 )MC_CV( mc_xy32, sse2, 16, 16, 1 )#if 0/* mc I+H */static void mc_xy10_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp[16*16], 16);    mc_hh_w16( src, i_src_stride, tmp, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, src, i_src_stride, tmp, 16, i_height );}static void mc_xy30_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp[16*16], 16);    mc_hh_w16( src, i_src_stride, tmp, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, src+1, i_src_stride, tmp, 16, i_height );}/* mc I+V */static void mc_xy01_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp[16*16], 16);    mc_hv_w16( src, i_src_stride, tmp, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, src, i_src_stride, tmp, 16, i_height );}static void mc_xy03_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp[16*16], 16);    mc_hv_w16( src, i_src_stride, tmp, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, src+i_src_stride, i_src_stride, tmp, 16, i_height );}/* H+V */static void mc_xy11_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp1[16*16], 16);    DECLARE_ALIGNED(uint8_t, tmp2[16*16], 16);    mc_hv_w16( src, i_src_stride, tmp1, 16, i_height );    mc_hh_w16( src, i_src_stride, tmp2, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, tmp1, 16, tmp2, 16, i_height );}static void mc_xy31_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp1[16*16], 16);    DECLARE_ALIGNED(uint8_t, tmp2[16*16], 16);    mc_hv_w16( src+1, i_src_stride, tmp1, 16, i_height );    mc_hh_w16( src,   i_src_stride, tmp2, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, tmp1, 16, tmp2, 16, i_height );}static void mc_xy13_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp1[16*16], 16);    DECLARE_ALIGNED(uint8_t, tmp2[16*16], 16);    mc_hv_w16( src,              i_src_stride, tmp1, 16, i_height );    mc_hh_w16( src+i_src_stride, i_src_stride, tmp2, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, tmp1, 16, tmp2, 16, i_height );}static void mc_xy33_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp1[16*16], 16);    DECLARE_ALIGNED(uint8_t, tmp2[16*16], 16);    mc_hv_w16( src+1,            i_src_stride, tmp1, 16, i_height );    mc_hh_w16( src+i_src_stride, i_src_stride, tmp2, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, tmp1, 16, tmp2, 16, i_height );}static void mc_xy21_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp1[16*16], 16);    DECLARE_ALIGNED(uint8_t, tmp2[16*16], 16);    mc_hc_w16( src, i_src_stride, tmp1, 16, i_height );    mc_hh_w16( src, i_src_stride, tmp2, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, tmp1, 16, tmp2, 16, i_height );}static void mc_xy12_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp1[16*16], 16);    DECLARE_ALIGNED(uint8_t, tmp2[16*16], 16);    mc_hc_w16( src, i_src_stride, tmp1, 16, i_height );    mc_hv_w16( src, i_src_stride, tmp2, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, tmp1, 16, tmp2, 16, i_height );}static void mc_xy32_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp1[16*16], 16);    DECLARE_ALIGNED(uint8_t, tmp2[16*16], 16);    mc_hc_w16( src,   i_src_stride, tmp1, 16, i_height );    mc_hv_w16( src+1, i_src_stride, tmp2, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, tmp1, 16, tmp2, 16, i_height );}static void mc_xy23_w16( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int i_height ){    DECLARE_ALIGNED(uint8_t, tmp1[16*16], 16);    DECLARE_ALIGNED(uint8_t, tmp2[16*16], 16);    mc_hc_w16( src,              i_src_stride, tmp1, 16, i_height );    mc_hh_w16( src+i_src_stride, i_src_stride, tmp2, 16, i_height );    pixel_avg_w16( dst, i_dst_stride, tmp1, 16, tmp2, 16, i_height );}#endif#define MOTION_COMPENSATION_LUMA \    src += (mvy >> 2) * i_src_stride + (mvx >> 2);  \    if( i_width == 4 )                              \    {                                               \        pf_mc[0][mvy&0x03][mvx&0x03]( src, i_src_stride, dst, i_dst_stride, i_height ); \    }                                               \    else if( i_width == 8 )                         \    {                                               \        pf_mc[1][mvy&0x03][mvx&0x03]( src, i_src_stride, dst, i_dst_stride, i_height ); \    }                                               \    else if( i_width == 16 )                        \    {                                               \        pf_mc[2][mvy&0x03][mvx&0x03]( src, i_src_stride, dst, i_dst_stride, i_height ); \    }                                               \    else                                            \    {                                               \        fprintf( stderr, "Error: motion_compensation_luma called with invalid width" ); \    }static void motion_compensation_luma_mmxext( uint8_t *src, int i_src_stride,                                             uint8_t *dst, int i_dst_stride,                                             int mvx,int mvy,                                             int i_width, int i_height ){    static const pf_mc_t pf_mc[3][4][4] =    /*XXX [dqy][dqx] */    {        {            { x264_mc_copy_w4_mmxext,   mc_xy10_w4_mmxext,    mc_hh_w4,             mc_xy30_w4_mmxext },            { mc_xy01_w4_mmxext,        mc_xy11_w4_mmxext,    mc_xy21_w4_mmxext,    mc_xy31_w4_mmxext },            { mc_hv_w4,                 mc_xy12_w4_mmxext,    mc_hc_w4,             mc_xy32_w4_mmxext },            { mc_xy03_w4_mmxext,        mc_xy13_w4_mmxext,    mc_xy23_w4_mmxext,    mc_xy33_w4_mmxext },        },        {            { x264_mc_copy_w8_mmxext,   mc_xy10_w8_mmxext,    mc_hh_w8,             mc_xy30_w8_mmxext },            { mc_xy01_w8_mmxext,        mc_xy11_w8_mmxext,    mc_xy21_w8_mmxext,    mc_xy31_w8_mmxext },            { mc_hv_w8,                 mc_xy12_w8_mmxext,    mc_hc_w8,             mc_xy32_w8_mmxext },            { mc_xy03_w8_mmxext,        mc_xy13_w8_mmxext,    mc_xy23_w8_mmxext,    mc_xy33_w8_mmxext },        },        {            { x264_mc_copy_w16_mmxext,   mc_xy10_w16_mmxext,    mc_hh_w16,             mc_xy30_w16_mmxext },            { mc_xy01_w16_mmxext,        mc_xy11_w16_mmxext,    mc_xy21_w16_mmxext,    mc_xy31_w16_mmxext },            { mc_hv_w16,                 mc_xy12_w16_mmxext,    mc_hc_w16,             mc_xy32_w16_mmxext },            { mc_xy03_w16_mmxext,        mc_xy13_w16_mmxext,    mc_xy23_w16_mmxext,    mc_xy33_w16_mmxext },        }    };    MOTION_COMPENSATION_LUMA}static void motion_compensation_luma_sse2( uint8_t *src, int i_src_stride,                                           uint8_t *dst, int i_dst_stride,                                           int mvx,int mvy,                                           int i_width, int i_height ){    static const pf_mc_t pf_mc[3][4][4] =    /*XXX [dqy][dqx] */    {        {            { x264_mc_copy_w4_mmxext,   mc_xy10_w4_mmxext,    mc_hh_w4,             mc_xy30_w4_mmxext },            { mc_xy01_w4_mmxext,        mc_xy11_w4_mmxext,    mc_xy21_w4_mmxext,    mc_xy31_w4_mmxext },            { mc_hv_w4,                 mc_xy12_w4_mmxext,    mc_hc_w4,             mc_xy32_w4_mmxext },            { mc_xy03_w4_mmxext,        mc_xy13_w4_mmxext,    mc_xy23_w4_mmxext,    mc_xy33_w4_mmxext },        },        {            { x264_mc_copy_w8_mmxext,   mc_xy10_w8_mmxext,    mc_hh_w8,             mc_xy30_w8_mmxext },            { mc_xy01_w8_mmxext,        mc_xy11_w8_mmxext,    mc_xy21_w8_mmxext,    mc_xy31_w8_mmxext },            { mc_hv_w8,                 mc_xy12_w8_mmxext,    mc_hc_w8,             mc_xy32_w8_mmxext },            { mc_xy03_w8_mmxext,        mc_xy13_w8_mmxext,    mc_xy23_w8_mmxext,    mc_xy33_w8_mmxext },        },        {            { x264_mc_copy_w16_sse2,   mc_xy10_w16_sse2,    mc_hh_w16,             mc_xy30_w16_sse2 },            { mc_xy01_w16_sse2,        mc_xy11_w16_sse2,    mc_xy21_w16_sse2,    mc_xy31_w16_sse2 },            { mc_hv_w16,                 mc_xy12_w16_sse2,    mc_hc_w16,             mc_xy32_w16_sse2 },            { mc_xy03_w16_sse2,        mc_xy13_w16_sse2,    mc_xy23_w16_sse2,    mc_xy33_w16_sse2 },        }    };    MOTION_COMPENSATION_LUMA}#endifvoid mc_luma_mmx( uint8_t *src[4], int i_src_stride,              uint8_t *dst,    int i_dst_stride,              int mvx,int mvy,              int i_width, int i_height ){    uint8_t *src1, *src2;    int correction = (mvx&1) && (mvy&1) && ((mvx&2) ^ (mvy&2));    int hpel1x = mvx>>1;    int hpel1y = (mvy+1-correction)>>1;    int filter1 = (hpel1x & 1) + ( (hpel1y & 1) << 1 );    src1 = src[filter1] + (hpel1y >> 1) * i_src_stride + (hpel1x >> 1);    if ( (mvx|mvy) & 1 ) /* qpel interpolation needed */    {        int hpel2x = (mvx+1)>>1;        int hpel2y = (mvy+correction)>>1;        int filter2 = (hpel2x & 1) + ( (hpel2y & 1) <<1 );        src2 = src[filter2] + (hpel2y >> 1) * i_src_stride + (hpel2x >> 1);        switch(i_width) {        case 4:            x264_pixel_avg_w4_mmxext( dst, i_dst_stride, src1, i_src_stride,                          src2, i_src_stride, i_height );            break;        case 8:            x264_pixel_avg_w8_mmxext( dst, i_dst_stride, src1, i_src_stride,                          src2, i_src_stride, i_height );            break;        case 16:        default:            x264_pixel_avg_w16_mmxext(dst, i_dst_stride, src1, i_src_stride,                          src2, i_src_stride, i_height );        }    }    else    {        switch(i_width) {        case 4:            x264_mc_copy_w4_mmxext( src1, i_src_stride, dst, i_dst_stride, i_height );            break;        case 8:            x264_mc_copy_w8_mmxext( src1, i_src_stride, dst, i_dst_stride, i_height );            break;        case 16:            x264_mc_copy_w16_mmxext( src1, i_src_stride, dst, i_dst_stride, i_height );            break;        }    }}uint8_t *get_ref_mmx( uint8_t *src[4], int i_src_stride,                      uint8_t *dst,   int *i_dst_stride,                      int mvx,int mvy,                      int i_width, int i_height ){    uint8_t *src1, *src2;    int correction = (mvx&1) && (mvy&1) && ((mvx&2) ^ (mvy&2));    int hpel1x = mvx>>1;    int hpel1y = (mvy+1-correction)>>1;    int filter1 = (hpel1x & 1) + ( (hpel1y & 1) << 1 );    src1 = src[filter1] + (hpel1y >> 1) * i_src_stride + (hpel1x >> 1);    if ( (mvx|mvy) & 1 ) /* qpel interpolation needed */    {        int hpel2x = (mvx+1)>>1;        int hpel2y = (mvy+correction)>>1;        int filter2 = (hpel2x & 1) + ( (hpel2y & 1) <<1 );        src2 = src[filter2] + (hpel2y >> 1) * i_src_stride + (hpel2x >> 1);            switch(i_width) {        case 4:            x264_pixel_avg_w4_mmxext( dst, *i_dst_stride, src1, i_src_stride,                          src2, i_src_stride, i_height );            break;        case 8:            x264_pixel_avg_w8_mmxext( dst, *i_dst_stride, src1, i_src_stride,                          src2, i_src_stride, i_height );            break;        case 16:        default:            x264_pixel_avg_w16_mmxext(dst, *i_dst_stride, src1, i_src_stride,                          src2, i_src_stride, i_height );        }        return dst;    }    else    {        *i_dst_stride = i_src_stride;        return src1;    }}void x264_mc_mmxext_init( x264_mc_functions_t *pf ){    pf->mc_luma   = mc_luma_mmx;    pf->get_ref   = get_ref_mmx;}void x264_mc_sse2_init( x264_mc_functions_t *pf ){    /* todo: use sse2 */    pf->mc_luma   = mc_luma_mmx;    pf->get_ref   = get_ref_mmx;}#if 0void get_funcs_mmx(pf_mc_t *int_h, pf_mc_t *int_v, pf_mc_t *int_hv){    *int_h = mc_hh_w16;    *int_v = mc_hv_w16;    *int_hv = mc_hc_w16;}void get_funcs_sse2(pf_mc_t *int_h, pf_mc_t *int_v, pf_mc_t *int_hv){    *int_h = mc_hh_w16;    *int_v = mc_hv_w16;    *int_hv = mc_hc_w16;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -