]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/simple_idct10.asm
Merge commit 'd2e56cf753a6c462041dee897d9d0c90f349988c'
[ffmpeg] / libavcodec / x86 / simple_idct10.asm
1 ;******************************************************************************
2 ;* x86-SIMD-optimized IDCT for prores
3 ;* this is identical to "simple" IDCT written by Michael Niedermayer
4 ;* except for the clip range
5 ;*
6 ;* Copyright (c) 2011 Ronald S. Bultje <rsbultje@gmail.com>
7 ;* Copyright (c) 2015 Christophe Gisquet
8 ;*
9 ;* This file is part of FFmpeg.
10 ;*
11 ;* FFmpeg is free software; you can redistribute it and/or
12 ;* modify it under the terms of the GNU Lesser General Public
13 ;* License as published by the Free Software Foundation; either
14 ;* version 2.1 of the License, or (at your option) any later version.
15 ;*
16 ;* FFmpeg is distributed in the hope that it will be useful,
17 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;* Lesser General Public License for more details.
20 ;*
21 ;* You should have received a copy of the GNU Lesser General Public
22 ;* License along with FFmpeg; if not, write to the Free Software
23 ;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 ;******************************************************************************
25
26 %include "libavutil/x86/x86util.asm"
27
28 %if ARCH_X86_64
29
30 SECTION_RODATA
31
32 cextern pw_2
33 cextern pw_16
34 cextern pw_1023
35 cextern pw_4095
36 pd_round_12: times 4 dd 1<<(12-1)
37 pd_round_15: times 4 dd 1<<(15-1)
38 pd_round_19: times 4 dd 1<<(19-1)
39
40 %macro CONST_DEC  3
41 const %1
42 times 4 dw %2, %3
43 %endmacro
44
45 %define W1sh2 22725 ; W1 = 90901 = 22725<<2 + 1
46 %define W2sh2 21407 ; W2 = 85627 = 21407<<2 - 1
47 %define W3sh2 19265 ; W3 = 77062 = 19265<<2 + 2
48 %define W4sh2 16384 ; W4 = 65535 = 16384<<2 - 1
49 %define W5sh2 12873 ; W5 = 51491 = 12873<<2 - 1
50 %define W6sh2  8867 ; W6 = 35468 =  8867<<2
51 %define W7sh2  4520 ; W7 = 18081 =  4520<<2 + 1
52
53 CONST_DEC  w4_plus_w2,   W4sh2, +W2sh2
54 CONST_DEC  w4_min_w2,    W4sh2, -W2sh2
55 CONST_DEC  w4_plus_w6,   W4sh2, +W6sh2
56 CONST_DEC  w4_min_w6,    W4sh2, -W6sh2
57 CONST_DEC  w1_plus_w3,   W1sh2, +W3sh2
58 CONST_DEC  w3_min_w1,    W3sh2, -W1sh2
59 CONST_DEC  w7_plus_w3,   W7sh2, +W3sh2
60 CONST_DEC  w3_min_w7,    W3sh2, -W7sh2
61 CONST_DEC  w1_plus_w5,   W1sh2, +W5sh2
62 CONST_DEC  w5_min_w1,    W5sh2, -W1sh2
63 CONST_DEC  w5_plus_w7,   W5sh2, +W7sh2
64 CONST_DEC  w7_min_w5,    W7sh2, -W5sh2
65
66 %include "libavcodec/x86/simple_idct10_template.asm"
67
68 SECTION .text
69
70 %macro idct_fn 0
71 cglobal simple_idct10, 1, 1, 16
72     IDCT_FN    "", 12, "", 19
73     RET
74
75 cglobal simple_idct10_put, 3, 3, 16
76     IDCT_FN    "", 12, "", 19, 0, pw_1023
77     RET
78
79 cglobal simple_idct12, 1, 1, 16
80     ; coeffs are already 15bits, adding the offset would cause
81     ; overflow in the input
82     IDCT_FN    "", 15, pw_2, 16
83     RET
84
85 cglobal simple_idct12_put, 3, 3, 16
86     ; range isn't known, so the C simple_idct range is used
87     ; Also, using a bias on input overflows, so use the bias
88     ; on output of the first butterfly instead
89     IDCT_FN    "", 15, pw_2, 16, 0, pw_4095
90     RET
91 %endmacro
92
93 INIT_XMM sse2
94 idct_fn
95 %if HAVE_AVX_EXTERNAL
96 INIT_XMM avx
97 idct_fn
98 %endif
99
100 %endif