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

📄 h264dsp_mmx.c

📁 mpeg4 video codec mpeg4 video codec
💻 C
📖 第 1 页 / 共 3 页
字号:
        "psubw %%mm1, %%mm0		\n\t"\        "psubw %%mm4, %%mm3		\n\t"\        "psraw $2, %%mm0		\n\t"\        "psraw $2, %%mm3		\n\t"\        "psubw %%mm1, %%mm0		\n\t"\        "psubw %%mm4, %%mm3		\n\t"\        "paddsw %%mm2, %%mm0		\n\t"\        "paddsw %%mm5, %%mm3		\n\t"\        "psraw $2, %%mm0		\n\t"\        "psraw $2, %%mm3		\n\t"\        "paddw %%mm6, %%mm2		\n\t"\        "paddw %%mm6, %%mm5		\n\t"\        "paddw %%mm2, %%mm0		\n\t"\        "paddw %%mm5, %%mm3		\n\t"\        "psraw $6, %%mm0		\n\t"\        "psraw $6, %%mm3		\n\t"\        "packuswb %%mm3, %%mm0		\n\t"\        OP(%%mm0, (%1),%%mm7, q)\        "add $32, %0			\n\t"\        "add %3, %1			\n\t"\        "decl %2			\n\t"\        " jnz 1b			\n\t"\        : "+a"(tmp), "+c"(dst), "+m"(h)\        : "S"((long)dstStride), "m"(ff_pw_32)\        : "memory"\    );\}\static void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\    OPNAME ## h264_qpel8_v_lowpass_ ## MMX(dst  , src  , dstStride, srcStride);\    OPNAME ## h264_qpel8_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\    src += 8*srcStride;\    dst += 8*dstStride;\    OPNAME ## h264_qpel8_v_lowpass_ ## MMX(dst  , src  , dstStride, srcStride);\    OPNAME ## h264_qpel8_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\}\\static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\    OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst  , src  , dstStride, srcStride);\    OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\    src += 8*srcStride;\    dst += 8*dstStride;\    OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst  , src  , dstStride, srcStride);\    OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\}\\static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\    OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(dst  , tmp  , src  , dstStride, tmpStride, srcStride);\    OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(dst+8, tmp  , src+8, dstStride, tmpStride, srcStride);\    src += 8*srcStride;\    dst += 8*dstStride;\    OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(dst  , tmp  , src  , dstStride, tmpStride, srcStride);\    OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(dst+8, tmp  , src+8, dstStride, tmpStride, srcStride);\}\#define H264_MC(OPNAME, SIZE, MMX) \static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\    OPNAME ## pixels ## SIZE ## _mmx(dst, src, stride, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*SIZE/8];\    uint8_t * const half= (uint8_t*)temp;\    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(half, src, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, half, stride, stride, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*SIZE/8];\    uint8_t * const half= (uint8_t*)temp;\    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(half, src, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+1, half, stride, stride, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*SIZE/8];\    uint8_t * const half= (uint8_t*)temp;\    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(half, src, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, half, stride, stride, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*SIZE/8];\    uint8_t * const half= (uint8_t*)temp;\    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(half, src, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, half, stride, stride, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*SIZE/4];\    uint8_t * const halfH= (uint8_t*)temp;\    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src, SIZE, stride);\    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfV, stride, SIZE, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*SIZE/4];\    uint8_t * const halfH= (uint8_t*)temp;\    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src, SIZE, stride);\    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfV, stride, SIZE, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*SIZE/4];\    uint8_t * const halfH= (uint8_t*)temp;\    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src + stride, SIZE, stride);\    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfV, stride, SIZE, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*SIZE/4];\    uint8_t * const halfH= (uint8_t*)temp;\    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src + stride, SIZE, stride);\    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfV, stride, SIZE, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*(SIZE+8)/4];\    int16_t * const tmp= (int16_t*)temp;\    OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, tmp, src, stride, SIZE, stride);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4];\    uint8_t * const halfH= (uint8_t*)temp;\    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src, SIZE, stride);\    put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfHV, stride, SIZE, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4];\    uint8_t * const halfH= (uint8_t*)temp;\    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src + stride, SIZE, stride);\    put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfHV, stride, SIZE, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4];\    uint8_t * const halfV= (uint8_t*)temp;\    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\    put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfV, halfHV, stride, SIZE, SIZE);\}\\static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4];\    uint8_t * const halfV= (uint8_t*)temp;\    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\    put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfV, halfHV, stride, SIZE, SIZE);\}\#define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b "	\n\t"#define AVG_3DNOW_OP(a,b,temp, size) \"mov" #size " " #b ", " #temp "	\n\t"\"pavgusb " #temp ", " #a "	\n\t"\"mov" #size " " #a ", " #b "	\n\t"#define AVG_MMX2_OP(a,b,temp, size) \"mov" #size " " #b ", " #temp "	\n\t"\"pavgb " #temp ", " #a "	\n\t"\"mov" #size " " #a ", " #b "	\n\t"QPEL_H264(put_,       PUT_OP, 3dnow)QPEL_H264(avg_, AVG_3DNOW_OP, 3dnow)QPEL_H264(put_,       PUT_OP, mmx2)QPEL_H264(avg_,  AVG_MMX2_OP, mmx2)H264_MC(put_, 4, 3dnow)H264_MC(put_, 8, 3dnow)H264_MC(put_, 16,3dnow)H264_MC(avg_, 4, 3dnow)H264_MC(avg_, 8, 3dnow)H264_MC(avg_, 16,3dnow)H264_MC(put_, 4, mmx2)H264_MC(put_, 8, mmx2)H264_MC(put_, 16,mmx2)H264_MC(avg_, 4, mmx2)H264_MC(avg_, 8, mmx2)H264_MC(avg_, 16,mmx2)#define H264_CHROMA_OP(S,D)#define H264_CHROMA_OP4(S,D,T)#define H264_CHROMA_MC8_TMPL put_h264_chroma_mc8_mmx#define H264_CHROMA_MC4_TMPL put_h264_chroma_mc4_mmx#define H264_CHROMA_MC8_MV0 put_pixels8_mmx#include "dsputil_h264_template_mmx.c"#undef H264_CHROMA_OP#undef H264_CHROMA_OP4#undef H264_CHROMA_MC8_TMPL#undef H264_CHROMA_MC4_TMPL#undef H264_CHROMA_MC8_MV0#define H264_CHROMA_OP(S,D) "pavgb " #S ", " #D " \n\t"#define H264_CHROMA_OP4(S,D,T) "movd  " #S ", " #T " \n\t"\                               "pavgb " #T ", " #D " \n\t"#define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_mmx2#define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_mmx2#define H264_CHROMA_MC8_MV0 avg_pixels8_mmx2#include "dsputil_h264_template_mmx.c"#undef H264_CHROMA_OP#undef H264_CHROMA_OP4#undef H264_CHROMA_MC8_TMPL#undef H264_CHROMA_MC4_TMPL#undef H264_CHROMA_MC8_MV0#define H264_CHROMA_OP(S,D) "pavgusb " #S ", " #D " \n\t"#define H264_CHROMA_OP4(S,D,T) "movd " #S ", " #T " \n\t"\                               "pavgusb " #T ", " #D " \n\t"#define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_3dnow#define H264_CHROMA_MC4_TMPL avg_h264_chroma_mc4_3dnow#define H264_CHROMA_MC8_MV0 avg_pixels8_3dnow#include "dsputil_h264_template_mmx.c"#undef H264_CHROMA_OP#undef H264_CHROMA_OP4#undef H264_CHROMA_MC8_TMPL#undef H264_CHROMA_MC4_TMPL#undef H264_CHROMA_MC8_MV0/***********************************//* weighted prediction */static inline void ff_h264_weight_WxH_mmx2(uint8_t *dst, int stride, int log2_denom, int weight, int offset, int w, int h){    int x, y;    offset <<= log2_denom;    offset += (1 << log2_denom) >> 1;    asm volatile(        "movd    %0, %%mm4        \n\t"        "movd    %1, %%mm5        \n\t"        "movd    %2, %%mm6        \n\t"        "pshufw  $0, %%mm4, %%mm4 \n\t"        "pshufw  $0, %%mm5, %%mm5 \n\t"        "pxor    %%mm7, %%mm7     \n\t"        :: "g"(weight), "g"(offset), "g"(log2_denom)    );    for(y=0; y<h; y+=2){        for(x=0; x<w; x+=4){            asm volatile(                "movd      %0,    %%mm0 \n\t"                "movd      %1,    %%mm1 \n\t"                "punpcklbw %%mm7, %%mm0 \n\t"                "punpcklbw %%mm7, %%mm1 \n\t"                "pmullw    %%mm4, %%mm0 \n\t"                "pmullw    %%mm4, %%mm1 \n\t"                "paddsw    %%mm5, %%mm0 \n\t"                "paddsw    %%mm5, %%mm1 \n\t"                "psraw     %%mm6, %%mm0 \n\t"                "psraw     %%mm6, %%mm1 \n\t"                "packuswb  %%mm7, %%mm0 \n\t"                "packuswb  %%mm7, %%mm1 \n\t"                "movd      %%mm0, %0    \n\t"                "movd      %%mm1, %1    \n\t"                : "+m"(*(uint32_t*)(dst+x)),                  "+m"(*(uint32_t*)(dst+x+stride))            );        }        dst += 2*stride;    }}static inline void ff_h264_biweight_WxH_mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset, int w, int h){    int x, y;    offset = ((offset + 1) | 1) << log2_denom;    asm volatile(        "movd    %0, %%mm3        \n\t"        "movd    %1, %%mm4        \n\t"        "movd    %2, %%mm5        \n\t"        "movd    %3, %%mm6        \n\t"        "pshufw  $0, %%mm3, %%mm3 \n\t"        "pshufw  $0, %%mm4, %%mm4 \n\t"        "pshufw  $0, %%mm5, %%mm5 \n\t"        "pxor    %%mm7, %%mm7     \n\t"        :: "g"(weightd), "g"(weights), "g"(offset), "g"(log2_denom+1)    );    for(y=0; y<h; y++){        for(x=0; x<w; x+=4){            asm volatile(                "movd      %0,    %%mm0 \n\t"                "movd      %1,    %%mm1 \n\t"                "punpcklbw %%mm7, %%mm0 \n\t"                "punpcklbw %%mm7, %%mm1 \n\t"                "pmullw    %%mm3, %%mm0 \n\t"                "pmullw    %%mm4, %%mm1 \n\t"                "paddsw    %%mm1, %%mm0 \n\t"                "paddsw    %%mm5, %%mm0 \n\t"                "psraw     %%mm6, %%mm0 \n\t"                "packuswb  %%mm0, %%mm0 \n\t"                "movd      %%mm0, %0    \n\t"                : "+m"(*(uint32_t*)(dst+x))                :  "m"(*(uint32_t*)(src+x))            );        }        src += stride;        dst += stride;    }}#define H264_WEIGHT(W,H) \static void ff_h264_biweight_ ## W ## x ## H ## _mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset){ \    ff_h264_biweight_WxH_mmx2(dst, src, stride, log2_denom, weightd, weights, offset, W, H); \} \static void ff_h264_weight_ ## W ## x ## H ## _mmx2(uint8_t *dst, int stride, int log2_denom, int weight, int offset){ \    ff_h264_weight_WxH_mmx2(dst, stride, log2_denom, weight, offset, W, H); \}H264_WEIGHT(16,16)H264_WEIGHT(16, 8)H264_WEIGHT( 8,16)H264_WEIGHT( 8, 8)H264_WEIGHT( 8, 4)H264_WEIGHT( 4, 8)H264_WEIGHT( 4, 4)H264_WEIGHT( 4, 2)

⌨️ 快捷键说明

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