---
 libavresample/x86/dither.asm    |   33 +++++++++++++++++++++++++++++++++
 libavresample/x86/dither_init.c |   10 ++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/libavresample/x86/dither.asm b/libavresample/x86/dither.asm
index f914255..50e8446 100644
--- a/libavresample/x86/dither.asm
+++ b/libavresample/x86/dither.asm
@@ -102,3 +102,36 @@ cglobal quantize_float, 4,4,3, dst, src, dither, len
     add         lenq, mmsize
     jl .loop
     REP_RET
+
+;------------------------------------------------------------------------------
+; void ff_dither_int_to_float(float *dst, int *src0, int len)
+;------------------------------------------------------------------------------
+
+%macro DITHER_INT_TO_FLOAT 0
+cglobal dither_int_to_float, 3,4,5, dst, src0, len, src1
+    lea         lenq, [4*lend]
+    lea        src1q, [src0q+2*lenq]
+    add        src0q, lenq
+    add         dstq, lenq
+    neg         lenq
+    mova          m0, [pf_dither_scale]
+.loop:
+    cvtdq2ps      m1, [src0q+lenq]
+    cvtdq2ps      m2, [src0q+lenq+mmsize]
+    cvtdq2ps      m3, [src1q+lenq]
+    cvtdq2ps      m4, [src1q+lenq+mmsize]
+    addps         m1, m1, m3
+    addps         m2, m2, m4
+    mulps         m1, m1, m0
+    mulps         m2, m2, m0
+    mova  [dstq+lenq], m1
+    mova  [dstq+lenq+mmsize], m2
+    add         lenq, 2*mmsize
+    jl .loop
+    REP_RET
+%endmacro
+
+INIT_XMM sse2
+DITHER_INT_TO_FLOAT
+INIT_YMM avx
+DITHER_INT_TO_FLOAT
diff --git a/libavresample/x86/dither_init.c b/libavresample/x86/dither_init.c
index 998e21c..6c77c1e 100644
--- a/libavresample/x86/dither_init.c
+++ b/libavresample/x86/dither_init.c
@@ -36,6 +36,9 @@ extern void ff_quantize_int_triangular_fma4(int16_t *dst, 
const float *src,
 extern void ff_quantize_float_sse2(int16_t *dst, const float *src, void 
*dither,
                                    int len);
 
+extern void ff_dither_int_to_float_sse2(float *dst, int *src0, int len);
+extern void ff_dither_int_to_float_avx(float *dst, int *src0, int len);
+
 av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
                                 enum AVResampleDitherMethod method)
 {
@@ -72,6 +75,13 @@ av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
             ddsp->ptr_align     = 16;
             ddsp->samples_align = 8;
         }
+    case AV_RESAMPLE_DITHER_TRIANGULAR_NS:
+        if (EXTERNAL_SSE2(mm_flags)) {
+            ddsp->dither_int_to_float = ff_dither_int_to_float_sse2;
+        }
+        if (EXTERNAL_AVX(mm_flags)) {
+            ddsp->dither_int_to_float = ff_dither_int_to_float_avx;
+        }
         break;
     }
 }
-- 
1.7.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to