|
|
|
@ -52,6 +52,8 @@ int ff_sse16_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, |
|
|
|
|
int line_size, int h); |
|
|
|
|
int ff_sse16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, |
|
|
|
|
int line_size, int h); |
|
|
|
|
int ff_hf_noise8_mmx(uint8_t *pix1, int lsize, int h); |
|
|
|
|
int ff_hf_noise16_mmx(uint8_t *pix1, int lsize, int h); |
|
|
|
|
|
|
|
|
|
#define hadamard_func(cpu) \ |
|
|
|
|
int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, uint8_t *src1, \
|
|
|
|
@ -64,255 +66,8 @@ hadamard_func(mmxext) |
|
|
|
|
hadamard_func(sse2) |
|
|
|
|
hadamard_func(ssse3) |
|
|
|
|
|
|
|
|
|
#if HAVE_INLINE_ASM |
|
|
|
|
|
|
|
|
|
#if HAVE_YASM |
|
|
|
|
|
|
|
|
|
static int hf_noise8_mmx(uint8_t *pix1, int line_size, int h) |
|
|
|
|
{ |
|
|
|
|
int tmp; |
|
|
|
|
|
|
|
|
|
__asm__ volatile ( |
|
|
|
|
"movl %3, %%ecx\n" |
|
|
|
|
"pxor %%mm7, %%mm7\n" |
|
|
|
|
"pxor %%mm6, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"movq (%0), %%mm0\n" |
|
|
|
|
"movq %%mm0, %%mm1\n" |
|
|
|
|
"psllq $8, %%mm0\n" |
|
|
|
|
"psrlq $8, %%mm1\n" |
|
|
|
|
"psrlq $8, %%mm0\n" |
|
|
|
|
"movq %%mm0, %%mm2\n" |
|
|
|
|
"movq %%mm1, %%mm3\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm0\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm1\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm2\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm3\n" |
|
|
|
|
"psubw %%mm1, %%mm0\n" |
|
|
|
|
"psubw %%mm3, %%mm2\n" |
|
|
|
|
|
|
|
|
|
"add %2, %0\n" |
|
|
|
|
|
|
|
|
|
"movq (%0), %%mm4\n" |
|
|
|
|
"movq %%mm4, %%mm1\n" |
|
|
|
|
"psllq $8, %%mm4\n" |
|
|
|
|
"psrlq $8, %%mm1\n" |
|
|
|
|
"psrlq $8, %%mm4\n" |
|
|
|
|
"movq %%mm4, %%mm5\n" |
|
|
|
|
"movq %%mm1, %%mm3\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm4\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm1\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm5\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm3\n" |
|
|
|
|
"psubw %%mm1, %%mm4\n" |
|
|
|
|
"psubw %%mm3, %%mm5\n" |
|
|
|
|
"psubw %%mm4, %%mm0\n" |
|
|
|
|
"psubw %%mm5, %%mm2\n" |
|
|
|
|
"pxor %%mm3, %%mm3\n" |
|
|
|
|
"pxor %%mm1, %%mm1\n" |
|
|
|
|
"pcmpgtw %%mm0, %%mm3\n\t" |
|
|
|
|
"pcmpgtw %%mm2, %%mm1\n\t" |
|
|
|
|
"pxor %%mm3, %%mm0\n" |
|
|
|
|
"pxor %%mm1, %%mm2\n" |
|
|
|
|
"psubw %%mm3, %%mm0\n" |
|
|
|
|
"psubw %%mm1, %%mm2\n" |
|
|
|
|
"paddw %%mm0, %%mm2\n" |
|
|
|
|
"paddw %%mm2, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"add %2, %0\n" |
|
|
|
|
"1:\n" |
|
|
|
|
|
|
|
|
|
"movq (%0), %%mm0\n" |
|
|
|
|
"movq %%mm0, %%mm1\n" |
|
|
|
|
"psllq $8, %%mm0\n" |
|
|
|
|
"psrlq $8, %%mm1\n" |
|
|
|
|
"psrlq $8, %%mm0\n" |
|
|
|
|
"movq %%mm0, %%mm2\n" |
|
|
|
|
"movq %%mm1, %%mm3\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm0\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm1\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm2\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm3\n" |
|
|
|
|
"psubw %%mm1, %%mm0\n" |
|
|
|
|
"psubw %%mm3, %%mm2\n" |
|
|
|
|
"psubw %%mm0, %%mm4\n" |
|
|
|
|
"psubw %%mm2, %%mm5\n" |
|
|
|
|
"pxor %%mm3, %%mm3\n" |
|
|
|
|
"pxor %%mm1, %%mm1\n" |
|
|
|
|
"pcmpgtw %%mm4, %%mm3\n\t" |
|
|
|
|
"pcmpgtw %%mm5, %%mm1\n\t" |
|
|
|
|
"pxor %%mm3, %%mm4\n" |
|
|
|
|
"pxor %%mm1, %%mm5\n" |
|
|
|
|
"psubw %%mm3, %%mm4\n" |
|
|
|
|
"psubw %%mm1, %%mm5\n" |
|
|
|
|
"paddw %%mm4, %%mm5\n" |
|
|
|
|
"paddw %%mm5, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"add %2, %0\n" |
|
|
|
|
|
|
|
|
|
"movq (%0), %%mm4\n" |
|
|
|
|
"movq %%mm4, %%mm1\n" |
|
|
|
|
"psllq $8, %%mm4\n" |
|
|
|
|
"psrlq $8, %%mm1\n" |
|
|
|
|
"psrlq $8, %%mm4\n" |
|
|
|
|
"movq %%mm4, %%mm5\n" |
|
|
|
|
"movq %%mm1, %%mm3\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm4\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm1\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm5\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm3\n" |
|
|
|
|
"psubw %%mm1, %%mm4\n" |
|
|
|
|
"psubw %%mm3, %%mm5\n" |
|
|
|
|
"psubw %%mm4, %%mm0\n" |
|
|
|
|
"psubw %%mm5, %%mm2\n" |
|
|
|
|
"pxor %%mm3, %%mm3\n" |
|
|
|
|
"pxor %%mm1, %%mm1\n" |
|
|
|
|
"pcmpgtw %%mm0, %%mm3\n\t" |
|
|
|
|
"pcmpgtw %%mm2, %%mm1\n\t" |
|
|
|
|
"pxor %%mm3, %%mm0\n" |
|
|
|
|
"pxor %%mm1, %%mm2\n" |
|
|
|
|
"psubw %%mm3, %%mm0\n" |
|
|
|
|
"psubw %%mm1, %%mm2\n" |
|
|
|
|
"paddw %%mm0, %%mm2\n" |
|
|
|
|
"paddw %%mm2, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"add %2, %0\n" |
|
|
|
|
"subl $2, %%ecx\n" |
|
|
|
|
" jnz 1b\n" |
|
|
|
|
|
|
|
|
|
"movq %%mm6, %%mm0\n" |
|
|
|
|
"punpcklwd %%mm7, %%mm0\n" |
|
|
|
|
"punpckhwd %%mm7, %%mm6\n" |
|
|
|
|
"paddd %%mm0, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"movq %%mm6, %%mm0\n" |
|
|
|
|
"psrlq $32, %%mm6\n" |
|
|
|
|
"paddd %%mm6, %%mm0\n" |
|
|
|
|
"movd %%mm0, %1\n" |
|
|
|
|
: "+r" (pix1), "=r" (tmp) |
|
|
|
|
: "r" ((x86_reg) line_size), "g" (h - 2) |
|
|
|
|
: "%ecx"); |
|
|
|
|
|
|
|
|
|
return tmp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int hf_noise16_mmx(uint8_t *pix1, int line_size, int h) |
|
|
|
|
{ |
|
|
|
|
int tmp; |
|
|
|
|
uint8_t *pix = pix1; |
|
|
|
|
|
|
|
|
|
__asm__ volatile ( |
|
|
|
|
"movl %3, %%ecx\n" |
|
|
|
|
"pxor %%mm7, %%mm7\n" |
|
|
|
|
"pxor %%mm6, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"movq (%0), %%mm0\n" |
|
|
|
|
"movq 1(%0), %%mm1\n" |
|
|
|
|
"movq %%mm0, %%mm2\n" |
|
|
|
|
"movq %%mm1, %%mm3\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm0\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm1\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm2\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm3\n" |
|
|
|
|
"psubw %%mm1, %%mm0\n" |
|
|
|
|
"psubw %%mm3, %%mm2\n" |
|
|
|
|
|
|
|
|
|
"add %2, %0\n" |
|
|
|
|
|
|
|
|
|
"movq (%0), %%mm4\n" |
|
|
|
|
"movq 1(%0), %%mm1\n" |
|
|
|
|
"movq %%mm4, %%mm5\n" |
|
|
|
|
"movq %%mm1, %%mm3\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm4\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm1\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm5\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm3\n" |
|
|
|
|
"psubw %%mm1, %%mm4\n" |
|
|
|
|
"psubw %%mm3, %%mm5\n" |
|
|
|
|
"psubw %%mm4, %%mm0\n" |
|
|
|
|
"psubw %%mm5, %%mm2\n" |
|
|
|
|
"pxor %%mm3, %%mm3\n" |
|
|
|
|
"pxor %%mm1, %%mm1\n" |
|
|
|
|
"pcmpgtw %%mm0, %%mm3\n\t" |
|
|
|
|
"pcmpgtw %%mm2, %%mm1\n\t" |
|
|
|
|
"pxor %%mm3, %%mm0\n" |
|
|
|
|
"pxor %%mm1, %%mm2\n" |
|
|
|
|
"psubw %%mm3, %%mm0\n" |
|
|
|
|
"psubw %%mm1, %%mm2\n" |
|
|
|
|
"paddw %%mm0, %%mm2\n" |
|
|
|
|
"paddw %%mm2, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"add %2, %0\n" |
|
|
|
|
"1:\n" |
|
|
|
|
|
|
|
|
|
"movq (%0), %%mm0\n" |
|
|
|
|
"movq 1(%0), %%mm1\n" |
|
|
|
|
"movq %%mm0, %%mm2\n" |
|
|
|
|
"movq %%mm1, %%mm3\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm0\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm1\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm2\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm3\n" |
|
|
|
|
"psubw %%mm1, %%mm0\n" |
|
|
|
|
"psubw %%mm3, %%mm2\n" |
|
|
|
|
"psubw %%mm0, %%mm4\n" |
|
|
|
|
"psubw %%mm2, %%mm5\n" |
|
|
|
|
"pxor %%mm3, %%mm3\n" |
|
|
|
|
"pxor %%mm1, %%mm1\n" |
|
|
|
|
"pcmpgtw %%mm4, %%mm3\n\t" |
|
|
|
|
"pcmpgtw %%mm5, %%mm1\n\t" |
|
|
|
|
"pxor %%mm3, %%mm4\n" |
|
|
|
|
"pxor %%mm1, %%mm5\n" |
|
|
|
|
"psubw %%mm3, %%mm4\n" |
|
|
|
|
"psubw %%mm1, %%mm5\n" |
|
|
|
|
"paddw %%mm4, %%mm5\n" |
|
|
|
|
"paddw %%mm5, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"add %2, %0\n" |
|
|
|
|
|
|
|
|
|
"movq (%0), %%mm4\n" |
|
|
|
|
"movq 1(%0), %%mm1\n" |
|
|
|
|
"movq %%mm4, %%mm5\n" |
|
|
|
|
"movq %%mm1, %%mm3\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm4\n" |
|
|
|
|
"punpcklbw %%mm7, %%mm1\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm5\n" |
|
|
|
|
"punpckhbw %%mm7, %%mm3\n" |
|
|
|
|
"psubw %%mm1, %%mm4\n" |
|
|
|
|
"psubw %%mm3, %%mm5\n" |
|
|
|
|
"psubw %%mm4, %%mm0\n" |
|
|
|
|
"psubw %%mm5, %%mm2\n" |
|
|
|
|
"pxor %%mm3, %%mm3\n" |
|
|
|
|
"pxor %%mm1, %%mm1\n" |
|
|
|
|
"pcmpgtw %%mm0, %%mm3\n\t" |
|
|
|
|
"pcmpgtw %%mm2, %%mm1\n\t" |
|
|
|
|
"pxor %%mm3, %%mm0\n" |
|
|
|
|
"pxor %%mm1, %%mm2\n" |
|
|
|
|
"psubw %%mm3, %%mm0\n" |
|
|
|
|
"psubw %%mm1, %%mm2\n" |
|
|
|
|
"paddw %%mm0, %%mm2\n" |
|
|
|
|
"paddw %%mm2, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"add %2, %0\n" |
|
|
|
|
"subl $2, %%ecx\n" |
|
|
|
|
" jnz 1b\n" |
|
|
|
|
|
|
|
|
|
"movq %%mm6, %%mm0\n" |
|
|
|
|
"punpcklwd %%mm7, %%mm0\n" |
|
|
|
|
"punpckhwd %%mm7, %%mm6\n" |
|
|
|
|
"paddd %%mm0, %%mm6\n" |
|
|
|
|
|
|
|
|
|
"movq %%mm6, %%mm0\n" |
|
|
|
|
"psrlq $32, %%mm6\n" |
|
|
|
|
"paddd %%mm6, %%mm0\n" |
|
|
|
|
"movd %%mm0, %1\n" |
|
|
|
|
: "+r" (pix1), "=r" (tmp) |
|
|
|
|
: "r" ((x86_reg) line_size), "g" (h - 2) |
|
|
|
|
: "%ecx"); |
|
|
|
|
|
|
|
|
|
return tmp + hf_noise8_mmx(pix + 8, line_size, h); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, |
|
|
|
|
int line_size, int h) |
|
|
|
|
{ |
|
|
|
@ -322,8 +77,8 @@ static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, |
|
|
|
|
score1 = c->dsp.sse[0](c, pix1, pix2, line_size, h); |
|
|
|
|
else |
|
|
|
|
score1 = ff_sse16_mmx(c, pix1, pix2, line_size, h); |
|
|
|
|
score2 = hf_noise16_mmx(pix1, line_size, h) - |
|
|
|
|
hf_noise16_mmx(pix2, line_size, h); |
|
|
|
|
score2 = ff_hf_noise16_mmx(pix1, line_size, h) + ff_hf_noise8_mmx(pix1+8, line_size, h) |
|
|
|
|
- ff_hf_noise16_mmx(pix2, line_size, h) - ff_hf_noise8_mmx(pix2+8, line_size, h); |
|
|
|
|
|
|
|
|
|
if (c) |
|
|
|
|
return score1 + FFABS(score2) * c->avctx->nsse_weight; |
|
|
|
@ -335,8 +90,8 @@ static int nsse8_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, |
|
|
|
|
int line_size, int h) |
|
|
|
|
{ |
|
|
|
|
int score1 = ff_sse8_mmx(c, pix1, pix2, line_size, h); |
|
|
|
|
int score2 = hf_noise8_mmx(pix1, line_size, h) - |
|
|
|
|
hf_noise8_mmx(pix2, line_size, h); |
|
|
|
|
int score2 = ff_hf_noise8_mmx(pix1, line_size, h) - |
|
|
|
|
ff_hf_noise8_mmx(pix2, line_size, h); |
|
|
|
|
|
|
|
|
|
if (c) |
|
|
|
|
return score1 + FFABS(score2) * c->avctx->nsse_weight; |
|
|
|
@ -346,6 +101,8 @@ static int nsse8_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2, |
|
|
|
|
|
|
|
|
|
#endif /* HAVE_YASM */ |
|
|
|
|
|
|
|
|
|
#if HAVE_INLINE_ASM |
|
|
|
|
|
|
|
|
|
static int vsad_intra16_mmx(MpegEncContext *v, uint8_t *pix, uint8_t *dummy, |
|
|
|
|
int line_size, int h) |
|
|
|
|
{ |
|
|
|
@ -689,10 +446,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, |
|
|
|
|
|
|
|
|
|
c->vsad[4] = vsad_intra16_mmx; |
|
|
|
|
|
|
|
|
|
#if HAVE_YASM |
|
|
|
|
c->nsse[0] = nsse16_mmx; |
|
|
|
|
c->nsse[1] = nsse8_mmx; |
|
|
|
|
#endif /* HAVE_YASM */ |
|
|
|
|
if (!(avctx->flags & CODEC_FLAG_BITEXACT)) { |
|
|
|
|
c->vsad[0] = vsad16_mmx; |
|
|
|
|
c->try_8x8basis = try_8x8basis_mmx; |
|
|
|
@ -741,6 +494,8 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, |
|
|
|
|
c->sum_abs_dctelem = ff_sum_abs_dctelem_mmx; |
|
|
|
|
c->sse[0] = ff_sse16_mmx; |
|
|
|
|
c->sse[1] = ff_sse8_mmx; |
|
|
|
|
c->nsse[0] = nsse16_mmx; |
|
|
|
|
c->nsse[1] = nsse8_mmx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (EXTERNAL_MMXEXT(cpu_flags)) { |
|
|
|
|