Re: [FFmpeg-devel] [PATCH 3/9] x86: simple_idct_put: 10bits versions

2015-10-10 Thread Michael Niedermayer
On Fri, Oct 09, 2015 at 11:53:40PM +0200, Christophe Gisquet wrote:
> Modeled from the prores version. Clips to [0;1023] and is bitexact.
> Bitexactness requires to add an offset in a different place compared
> to prores or C, and makes the function approximately 2% slower.
> 
> For 16 frames of a DNxHD 4:2:2 10bits test sequence:
> 
> C:60861 decicycles in idct, 1048205 runs,371 skips
> sse2: 27567 decicycles in idct, 1048216 runs,360 skips
> avx:  26272 decicycles in idct, 1048171 runs,405 skips
> ---
>  libavcodec/x86/Makefile   |  1 +
>  libavcodec/x86/idctdsp_init.c | 16 ++
>  libavcodec/x86/simple_idct.h  |  3 ++
>  libavcodec/x86/simple_idct10.asm  | 53 
> +++
>  libavcodec/x86/simple_idct10_template.asm | 12 +++
>  5 files changed, 85 insertions(+)
>  create mode 100644 libavcodec/x86/simple_idct10.asm
> 
> diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
> index a9d8032..ef7628e 100644
> --- a/libavcodec/x86/Makefile
> +++ b/libavcodec/x86/Makefile
> @@ -126,6 +126,7 @@ YASM-OBJS-$(CONFIG_QPELDSP)+= x86/qpeldsp.o   
>   \
>x86/fpel.o\
>x86/qpel.o
>  YASM-OBJS-$(CONFIG_RV34DSP)+= x86/rv34dsp.o
> +YASM-OBJS-$(CONFIG_IDCTDSP)+= x86/simple_idct10.o
>  YASM-OBJS-$(CONFIG_VIDEODSP)   += x86/videodsp.o
>  YASM-OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp.o
>  YASM-OBJS-$(CONFIG_VP8DSP) += x86/vp8dsp.o  \
> diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c
> index 2c26a98..17ddc9e 100644
> --- a/libavcodec/x86/idctdsp_init.c
> +++ b/libavcodec/x86/idctdsp_init.c
> @@ -85,4 +85,20 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, 
> AVCodecContext *avctx,
>  c->put_pixels_clamped= ff_put_pixels_clamped_sse2;
>  c->add_pixels_clamped= ff_add_pixels_clamped_sse2;
>  }
> +
> +if (ARCH_X86_64 &&
> +avctx->bits_per_raw_sample == 10 && avctx->lowres == 0 &&
> +(avctx->idct_algo == FF_IDCT_AUTO ||
> + avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
> + avctx->idct_algo == FF_IDCT_SIMPLE)) {
> +if (EXTERNAL_SSE2(cpu_flags)) {
> +c->idct_put  = ff_simple_idct10_put_sse2;
> +c->perm_type = FF_IDCT_PERM_TRANSPOSE;

perm_type represents the permutation for idct_put, idct_add and idct
setting just one of them risks having a wrong permutation for the
other 2
if some cases are unused they could be set to NULL to avoid hard to
debug artifacts if they become used though setting the to a matching
idct seems more correct

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

DNS cache poisoning attacks, popular search engine, Google internet authority
dont be evil, please


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/9] x86: simple_idct_put: 10bits versions

2015-10-09 Thread Michael Niedermayer
On Thu, Oct 08, 2015 at 08:22:50AM +0200, Christophe Gisquet wrote:
> Modeled from the prores version. Clips to [0;1023] and is bitexact.
> Bitexactness requires to add an offset in a different place compared
> to prores or C, and makes the function approximately 2% slower.
> 
> For 16 frames of a DNxHD 4:2:2 10bits test sequence:
> 
> C:60861 decicycles in idct, 1048205 runs,371 skips
> sse2: 27567 decicycles in idct, 1048216 runs,360 skips
> avx:  26272 decicycles in idct, 1048171 runs,405 skips
> ---
>  libavcodec/x86/Makefile   |  1 +
>  libavcodec/x86/idctdsp_init.c | 16 ++
>  libavcodec/x86/simple_idct.h  |  3 ++
>  libavcodec/x86/simple_idct10.asm  | 53 
> +++
>  libavcodec/x86/simple_idct10_template.asm | 12 +++
>  5 files changed, 85 insertions(+)
>  create mode 100644 libavcodec/x86/simple_idct10.asm

breaks (something with scantables from how it looks)
./ffplay -f lavfi  testsrc -vf spp=1:40,format=yuv420p10

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/9] x86: simple_idct_put: 10bits versions

2015-10-08 Thread Christophe Gisquet
Modeled from the prores version. Clips to [0;1023] and is bitexact.
Bitexactness requires to add an offset in a different place compared
to prores or C, and makes the function approximately 2% slower.

For 16 frames of a DNxHD 4:2:2 10bits test sequence:

C:60861 decicycles in idct, 1048205 runs,371 skips
sse2: 27567 decicycles in idct, 1048216 runs,360 skips
avx:  26272 decicycles in idct, 1048171 runs,405 skips
---
 libavcodec/x86/Makefile   |  1 +
 libavcodec/x86/idctdsp_init.c | 16 ++
 libavcodec/x86/simple_idct.h  |  3 ++
 libavcodec/x86/simple_idct10.asm  | 53 +++
 libavcodec/x86/simple_idct10_template.asm | 12 +++
 5 files changed, 85 insertions(+)
 create mode 100644 libavcodec/x86/simple_idct10.asm

diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index d8b091a..3897886 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -125,6 +125,7 @@ YASM-OBJS-$(CONFIG_QPELDSP)+= x86/qpeldsp.o 
\
   x86/fpel.o\
   x86/qpel.o
 YASM-OBJS-$(CONFIG_RV34DSP)+= x86/rv34dsp.o
+YASM-OBJS-$(CONFIG_IDCTDSP)+= x86/simple_idct10.o
 YASM-OBJS-$(CONFIG_VIDEODSP)   += x86/videodsp.o
 YASM-OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp.o
 YASM-OBJS-$(CONFIG_VP8DSP) += x86/vp8dsp.o  \
diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c
index 2c26a98..17ddc9e 100644
--- a/libavcodec/x86/idctdsp_init.c
+++ b/libavcodec/x86/idctdsp_init.c
@@ -85,4 +85,20 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, 
AVCodecContext *avctx,
 c->put_pixels_clamped= ff_put_pixels_clamped_sse2;
 c->add_pixels_clamped= ff_add_pixels_clamped_sse2;
 }
+
+if (ARCH_X86_64 &&
+avctx->bits_per_raw_sample == 10 && avctx->lowres == 0 &&
+(avctx->idct_algo == FF_IDCT_AUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLE)) {
+if (EXTERNAL_SSE2(cpu_flags)) {
+c->idct_put  = ff_simple_idct10_put_sse2;
+c->perm_type = FF_IDCT_PERM_TRANSPOSE;
+
+}
+if (EXTERNAL_AVX(cpu_flags)) {
+c->idct_put  = ff_simple_idct10_put_avx;
+c->perm_type = FF_IDCT_PERM_TRANSPOSE;
+}
+}
 }
diff --git a/libavcodec/x86/simple_idct.h b/libavcodec/x86/simple_idct.h
index 4a98732..d886434 100644
--- a/libavcodec/x86/simple_idct.h
+++ b/libavcodec/x86/simple_idct.h
@@ -25,4 +25,7 @@ void ff_simple_idct_mmx(int16_t *block);
 void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
 void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
 
+void ff_simple_idct10_put_sse2(uint8_t *dest, int line_size, int16_t *block);
+void ff_simple_idct10_put_avx(uint8_t *dest, int line_size, int16_t *block);
+
 #endif /* AVCODEC_X86_SIMPLE_IDCT_H */
diff --git a/libavcodec/x86/simple_idct10.asm b/libavcodec/x86/simple_idct10.asm
new file mode 100644
index 000..77db0a7
--- /dev/null
+++ b/libavcodec/x86/simple_idct10.asm
@@ -0,0 +1,53 @@
+;**
+;* x86-SIMD-optimized IDCT for prores
+;* this is identical to "simple" IDCT written by Michael Niedermayer
+;* except for the clip range
+;*
+;* Copyright (c) 2011 Ronald S. Bultje 
+;* Copyright (c) 2015 Christophe Gisquet
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 of the License, or (at your option) any later version.
+;*
+;* FFmpeg is distributed in the hope that it will be useful,
+;* but WITHOUT ANY WARRANTY; without even the implied warranty of
+;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser General Public
+;* License along with FFmpeg; if not, write to the Free Software
+;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;**
+
+%include "libavutil/x86/x86util.asm"
+
+%if ARCH_X86_64
+
+SECTION_RODATA
+
+cextern pw_8
+cextern pw_1023
+pd_round: times 4 dd 1<<(13-1)
+
+%include "libavcodec/x86/simple_idct10_template.asm"
+
+section .text align=16
+
+%macro idct_put_fn 1
+cglobal simple_idct10_put, 3, 3, %1
+IDCT_PUT_FN"", 13, pw_8, 18, 0, pw_1023
+RET
+%endmacro
+
+INIT_XMM sse2
+idct_put_fn 16
+%if HAVE_AVX_EXTERNAL
+INIT_XMM avx
+idct_put_fn 16
+%endif
+
+%endif
diff --git a/libavcodec/x86/simple_idct10_template.asm