Browse code

Merge commit '4958f35a2ebc307049ff2104ffb944f5f457feb3'

* commit '4958f35a2ebc307049ff2104ffb944f5f457feb3':
dsputil: Move apply_window_int16 to ac3dsp

Conflicts:
libavcodec/arm/ac3dsp_init_arm.c
libavcodec/arm/ac3dsp_neon.S
libavcodec/x86/ac3dsp_init.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2013/12/09 12:12:40
Showing 13 changed files
... ...
@@ -239,6 +239,19 @@ static void ac3_downmix_c(float **samples, float (*matrix)[2],
239 239
     }
240 240
 }
241 241
 
242
+static void apply_window_int16_c(int16_t *output, const int16_t *input,
243
+                                 const int16_t *window, unsigned int len)
244
+{
245
+    int i;
246
+    int len2 = len >> 1;
247
+
248
+    for (i = 0; i < len2; i++) {
249
+        int16_t w       = window[i];
250
+        output[i]       = (MUL16(input[i],       w) + (1 << 14)) >> 15;
251
+        output[len-i-1] = (MUL16(input[len-i-1], w) + (1 << 14)) >> 15;
252
+    }
253
+}
254
+
242 255
 av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
243 256
 {
244 257
     c->ac3_exponent_min = ac3_exponent_min_c;
... ...
@@ -253,6 +266,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
253 253
     c->sum_square_butterfly_int32 = ac3_sum_square_butterfly_int32_c;
254 254
     c->sum_square_butterfly_float = ac3_sum_square_butterfly_float_c;
255 255
     c->downmix = ac3_downmix_c;
256
+    c->apply_window_int16 = apply_window_int16_c;
256 257
 
257 258
     if (ARCH_ARM)
258 259
         ff_ac3dsp_init_arm(c, bit_exact);
... ...
@@ -134,6 +134,20 @@ typedef struct AC3DSPContext {
134 134
 
135 135
     void (*downmix)(float **samples, float (*matrix)[2], int out_ch,
136 136
                     int in_ch, int len);
137
+
138
+    /**
139
+     * Apply symmetric window in 16-bit fixed-point.
140
+     * @param output destination array
141
+     *               constraints: 16-byte aligned
142
+     * @param input  source array
143
+     *               constraints: 16-byte aligned
144
+     * @param window window array
145
+     *               constraints: 16-byte aligned, at least len/2 elements
146
+     * @param len    full window length
147
+     *               constraints: multiple of ? greater than zero
148
+     */
149
+    void (*apply_window_int16)(int16_t *output, const int16_t *input,
150
+                               const int16_t *window, unsigned int len);
137 151
 } AC3DSPContext;
138 152
 
139 153
 void ff_ac3dsp_init    (AC3DSPContext *c, int bit_exact);
... ...
@@ -71,17 +71,6 @@ av_cold int AC3_NAME(mdct_init)(AC3EncodeContext *s)
71 71
 
72 72
 
73 73
 /*
74
- * Apply KBD window to input samples prior to MDCT.
75
- */
76
-static void apply_window(void *dsp, int16_t *output, const int16_t *input,
77
-                         const int16_t *window, unsigned int len)
78
-{
79
-    DSPContext *dsp0 = dsp;
80
-    dsp0->apply_window_int16(output, input, window, len);
81
-}
82
-
83
-
84
-/*
85 74
  * Normalize the input samples to use the maximum available precision.
86 75
  * This assumes signed 16-bit input samples.
87 76
  */
... ...
@@ -88,18 +88,6 @@ av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s)
88 88
 
89 89
 
90 90
 /*
91
- * Apply KBD window to input samples prior to MDCT.
92
- */
93
-static void apply_window(void *dsp, float *output,
94
-                         const float *input, const float *window,
95
-                         unsigned int len)
96
-{
97
-    AVFloatDSPContext *fdsp = dsp;
98
-    fdsp->vector_fmul(output, input, window, len);
99
-}
100
-
101
-
102
-/*
103 91
  * Normalize the input samples.
104 92
  * Not needed for the floating-point encoder.
105 93
  */
... ...
@@ -34,10 +34,6 @@
34 34
 
35 35
 static void scale_coefficients(AC3EncodeContext *s);
36 36
 
37
-static void apply_window(void *dsp, SampleType *output,
38
-                         const SampleType *input, const SampleType *window,
39
-                         unsigned int len);
40
-
41 37
 static int normalize_samples(AC3EncodeContext *s);
42 38
 
43 39
 static void clip_coefficients(DSPContext *dsp, CoefType *coef, unsigned int len);
... ...
@@ -105,11 +101,11 @@ static void apply_mdct(AC3EncodeContext *s)
105 105
             const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
106 106
 
107 107
 #if CONFIG_AC3ENC_FLOAT
108
-            apply_window(&s->fdsp, s->windowed_samples, input_samples,
109
-                         s->mdct_window, AC3_WINDOW_SIZE);
108
+            s->fdsp.vector_fmul(s->windowed_samples, input_samples,
109
+                                s->mdct_window, AC3_WINDOW_SIZE);
110 110
 #else
111
-            apply_window(&s->dsp, s->windowed_samples, input_samples,
112
-                         s->mdct_window, AC3_WINDOW_SIZE);
111
+            s->ac3dsp.apply_window_int16(s->windowed_samples, input_samples,
112
+                                         s->mdct_window, AC3_WINDOW_SIZE);
113 113
 #endif
114 114
 
115 115
             if (s->fixed_point)
... ...
@@ -31,6 +31,8 @@ void ff_ac3_lshift_int16_neon(int16_t *src, unsigned len, unsigned shift);
31 31
 void ff_ac3_rshift_int32_neon(int32_t *src, unsigned len, unsigned shift);
32 32
 void ff_float_to_fixed24_neon(int32_t *dst, const float *src, unsigned int len);
33 33
 void ff_ac3_extract_exponents_neon(uint8_t *exp, int32_t *coef, int nb_coefs);
34
+void ff_apply_window_int16_neon(int16_t *dst, const int16_t *src,
35
+                                const int16_t *window, unsigned n);
34 36
 void ff_ac3_sum_square_butterfly_int32_neon(int64_t sum[4],
35 37
                                             const int32_t *coef0,
36 38
                                             const int32_t *coef1,
... ...
@@ -64,6 +66,7 @@ av_cold void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact)
64 64
         c->ac3_rshift_int32      = ff_ac3_rshift_int32_neon;
65 65
         c->float_to_fixed24      = ff_float_to_fixed24_neon;
66 66
         c->extract_exponents     = ff_ac3_extract_exponents_neon;
67
+        c->apply_window_int16    = ff_apply_window_int16_neon;
67 68
         c->sum_square_butterfly_int32 = ff_ac3_sum_square_butterfly_int32_neon;
68 69
         c->sum_square_butterfly_float = ff_ac3_sum_square_butterfly_float_neon;
69 70
     }
... ...
@@ -109,6 +109,29 @@ function ff_ac3_extract_exponents_neon, export=1
109 109
         bx              lr
110 110
 endfunc
111 111
 
112
+function ff_apply_window_int16_neon, export=1
113
+        push            {r4,lr}
114
+        add             r4,  r1,  r3,  lsl #1
115
+        add             lr,  r0,  r3,  lsl #1
116
+        sub             r4,  r4,  #16
117
+        sub             lr,  lr,  #16
118
+        mov             r12, #-16
119
+1:
120
+        vld1.16         {q0},     [r1,:128]!
121
+        vld1.16         {q2},     [r2,:128]!
122
+        vld1.16         {q1},     [r4,:128], r12
123
+        vrev64.16       q3,  q2
124
+        vqrdmulh.s16    q0,  q0,  q2
125
+        vqrdmulh.s16    d2,  d2,  d7
126
+        vqrdmulh.s16    d3,  d3,  d6
127
+        vst1.16         {q0},     [r0,:128]!
128
+        vst1.16         {q1},     [lr,:128], r12
129
+        subs            r3,  r3,  #16
130
+        bgt             1b
131
+
132
+        pop             {r4,pc}
133
+endfunc
134
+
112 135
 function ff_ac3_sum_square_butterfly_int32_neon, export=1
113 136
         vmov.i64        q0,  #0
114 137
         vmov.i64        q1,  #0
... ...
@@ -45,9 +45,6 @@ int32_t ff_scalarproduct_int16_neon(const int16_t *v1, const int16_t *v2, int le
45 45
 int32_t ff_scalarproduct_and_madd_int16_neon(int16_t *v1, const int16_t *v2,
46 46
                                              const int16_t *v3, int len, int mul);
47 47
 
48
-void ff_apply_window_int16_neon(int16_t *dst, const int16_t *src,
49
-                                const int16_t *window, unsigned n);
50
-
51 48
 av_cold void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
52 49
 {
53 50
     const int high_bit_depth = avctx->bits_per_raw_sample > 8;
... ...
@@ -76,6 +73,4 @@ av_cold void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
76 76
 
77 77
     c->scalarproduct_int16 = ff_scalarproduct_int16_neon;
78 78
     c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_neon;
79
-
80
-    c->apply_window_int16 = ff_apply_window_int16_neon;
81 79
 }
... ...
@@ -169,29 +169,6 @@ NOVFP   ldr             r2,  [sp]
169 169
         bx              lr
170 170
 endfunc
171 171
 
172
-function ff_apply_window_int16_neon, export=1
173
-        push            {r4,lr}
174
-        add             r4,  r1,  r3,  lsl #1
175
-        add             lr,  r0,  r3,  lsl #1
176
-        sub             r4,  r4,  #16
177
-        sub             lr,  lr,  #16
178
-        mov             r12, #-16
179
-1:
180
-        vld1.16         {q0},     [r1,:128]!
181
-        vld1.16         {q2},     [r2,:128]!
182
-        vld1.16         {q1},     [r4,:128], r12
183
-        vrev64.16       q3,  q2
184
-        vqrdmulh.s16    q0,  q0,  q2
185
-        vqrdmulh.s16    d2,  d2,  d7
186
-        vqrdmulh.s16    d3,  d3,  d6
187
-        vst1.16         {q0},     [r0,:128]!
188
-        vst1.16         {q1},     [lr,:128], r12
189
-        subs            r3,  r3,  #16
190
-        bgt             1b
191
-
192
-        pop             {r4,pc}
193
-endfunc
194
-
195 172
 function ff_vector_clip_int32_neon, export=1
196 173
         vdup.32         q0,  r2
197 174
         vdup.32         q1,  r3
... ...
@@ -2495,19 +2495,6 @@ static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, co
2495 2495
     return res;
2496 2496
 }
2497 2497
 
2498
-static void apply_window_int16_c(int16_t *output, const int16_t *input,
2499
-                                 const int16_t *window, unsigned int len)
2500
-{
2501
-    int i;
2502
-    int len2 = len >> 1;
2503
-
2504
-    for (i = 0; i < len2; i++) {
2505
-        int16_t w       = window[i];
2506
-        output[i]       = (MUL16(input[i],       w) + (1 << 14)) >> 15;
2507
-        output[len-i-1] = (MUL16(input[len-i-1], w) + (1 << 14)) >> 15;
2508
-    }
2509
-}
2510
-
2511 2498
 static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
2512 2499
                                 int32_t max, unsigned int len)
2513 2500
 {
... ...
@@ -2799,7 +2786,6 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
2799 2799
     c->vector_clipf = vector_clipf_c;
2800 2800
     c->scalarproduct_int16 = scalarproduct_int16_c;
2801 2801
     c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
2802
-    c->apply_window_int16 = apply_window_int16_c;
2803 2802
     c->vector_clip_int32 = vector_clip_int32_c;
2804 2803
 
2805 2804
     c->shrink[0]= av_image_copy_plane;
... ...
@@ -275,20 +275,6 @@ typedef struct DSPContext {
275 275
     int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, const int16_t *v2, const int16_t *v3, int len, int mul);
276 276
 
277 277
     /**
278
-     * Apply symmetric window in 16-bit fixed-point.
279
-     * @param output destination array
280
-     *               constraints: 16-byte aligned
281
-     * @param input  source array
282
-     *               constraints: 16-byte aligned
283
-     * @param window window array
284
-     *               constraints: 16-byte aligned, at least len/2 elements
285
-     * @param len    full window length
286
-     *               constraints: multiple of ? greater than zero
287
-     */
288
-    void (*apply_window_int16)(int16_t *output, const int16_t *input,
289
-                               const int16_t *window, unsigned int len);
290
-
291
-    /**
292 278
      * Clip each element in an array of int32_t to a given minimum and maximum value.
293 279
      * @param dst  destination array
294 280
      *             constraints: 16-byte aligned
... ...
@@ -51,6 +51,19 @@ void ff_ac3_extract_exponents_3dnow(uint8_t *exp, int32_t *coef, int nb_coefs);
51 51
 void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs);
52 52
 void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs);
53 53
 
54
+void ff_apply_window_int16_round_mmxext(int16_t *output, const int16_t *input,
55
+                                        const int16_t *window, unsigned int len);
56
+void ff_apply_window_int16_round_sse2(int16_t *output, const int16_t *input,
57
+                                      const int16_t *window, unsigned int len);
58
+void ff_apply_window_int16_mmxext(int16_t *output, const int16_t *input,
59
+                                  const int16_t *window, unsigned int len);
60
+void ff_apply_window_int16_sse2(int16_t *output, const int16_t *input,
61
+                                const int16_t *window, unsigned int len);
62
+void ff_apply_window_int16_ssse3(int16_t *output, const int16_t *input,
63
+                                 const int16_t *window, unsigned int len);
64
+void ff_apply_window_int16_ssse3_atom(int16_t *output, const int16_t *input,
65
+                                      const int16_t *window, unsigned int len);
66
+
54 67
 #if ARCH_X86_32 && defined(__INTEL_COMPILER)
55 68
 #       undef HAVE_7REGS
56 69
 #       define HAVE_7REGS 0
... ...
@@ -201,6 +214,11 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
201 201
     if (EXTERNAL_MMXEXT(cpu_flags)) {
202 202
         c->ac3_exponent_min = ff_ac3_exponent_min_mmxext;
203 203
         c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmxext;
204
+        if (bit_exact) {
205
+            c->apply_window_int16 = ff_apply_window_int16_mmxext;
206
+        } else {
207
+            c->apply_window_int16 = ff_apply_window_int16_round_mmxext;
208
+        }
204 209
     }
205 210
     if (EXTERNAL_SSE(cpu_flags)) {
206 211
         c->float_to_fixed24 = ff_float_to_fixed24_sse;
... ...
@@ -215,11 +233,19 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
215 215
             c->ac3_lshift_int16 = ff_ac3_lshift_int16_sse2;
216 216
             c->ac3_rshift_int32 = ff_ac3_rshift_int32_sse2;
217 217
         }
218
+        if (bit_exact) {
219
+            c->apply_window_int16 = ff_apply_window_int16_sse2;
220
+        } else if (!(cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
221
+            c->apply_window_int16 = ff_apply_window_int16_round_sse2;
222
+        }
218 223
     }
219 224
     if (EXTERNAL_SSSE3(cpu_flags)) {
220 225
         c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_ssse3;
221
-        if (!(cpu_flags & AV_CPU_FLAG_ATOM)) {
226
+        if (cpu_flags & AV_CPU_FLAG_ATOM) {
227
+            c->apply_window_int16 = ff_apply_window_int16_ssse3_atom;
228
+        } else {
222 229
             c->extract_exponents = ff_ac3_extract_exponents_ssse3;
230
+            c->apply_window_int16 = ff_apply_window_int16_ssse3;
223 231
         }
224 232
     }
225 233
 
... ...
@@ -86,19 +86,6 @@ int32_t ff_scalarproduct_and_madd_int16_ssse3(int16_t *v1, const int16_t *v2,
86 86
                                               const int16_t *v3,
87 87
                                               int order, int mul);
88 88
 
89
-void ff_apply_window_int16_round_mmxext(int16_t *output, const int16_t *input,
90
-                                        const int16_t *window, unsigned int len);
91
-void ff_apply_window_int16_round_sse2(int16_t *output, const int16_t *input,
92
-                                      const int16_t *window, unsigned int len);
93
-void ff_apply_window_int16_mmxext(int16_t *output, const int16_t *input,
94
-                                  const int16_t *window, unsigned int len);
95
-void ff_apply_window_int16_sse2(int16_t *output, const int16_t *input,
96
-                                const int16_t *window, unsigned int len);
97
-void ff_apply_window_int16_ssse3(int16_t *output, const int16_t *input,
98
-                                 const int16_t *window, unsigned int len);
99
-void ff_apply_window_int16_ssse3_atom(int16_t *output, const int16_t *input,
100
-                                      const int16_t *window, unsigned int len);
101
-
102 89
 void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w);
103 90
 void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w);
104 91
 
... ...
@@ -586,12 +573,6 @@ static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
586 586
 
587 587
     c->scalarproduct_int16          = ff_scalarproduct_int16_mmxext;
588 588
     c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_mmxext;
589
-
590
-    if (avctx->flags & CODEC_FLAG_BITEXACT) {
591
-        c->apply_window_int16 = ff_apply_window_int16_mmxext;
592
-    } else {
593
-        c->apply_window_int16 = ff_apply_window_int16_round_mmxext;
594
-    }
595 589
 #endif /* HAVE_MMXEXT_EXTERNAL */
596 590
 }
597 591
 
... ...
@@ -647,11 +628,6 @@ static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
647 647
     } else {
648 648
         c->vector_clip_int32 = ff_vector_clip_int32_sse2;
649 649
     }
650
-    if (avctx->flags & CODEC_FLAG_BITEXACT) {
651
-        c->apply_window_int16 = ff_apply_window_int16_sse2;
652
-    } else if (!(cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
653
-        c->apply_window_int16 = ff_apply_window_int16_round_sse2;
654
-    }
655 650
     c->bswap_buf = ff_bswap32_buf_sse2;
656 651
 #endif /* HAVE_SSE2_EXTERNAL */
657 652
 }
... ...
@@ -664,10 +640,6 @@ static av_cold void dsputil_init_ssse3(DSPContext *c, AVCodecContext *avctx,
664 664
     if (cpu_flags & AV_CPU_FLAG_SSE4) // not really SSE4, just slow on Conroe
665 665
         c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_sse4;
666 666
 
667
-    if (cpu_flags & AV_CPU_FLAG_ATOM)
668
-        c->apply_window_int16 = ff_apply_window_int16_ssse3_atom;
669
-    else
670
-        c->apply_window_int16 = ff_apply_window_int16_ssse3;
671 667
     if (!(cpu_flags & (AV_CPU_FLAG_SSE42 | AV_CPU_FLAG_3DNOW))) // cachesplit
672 668
         c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_ssse3;
673 669
     c->bswap_buf = ff_bswap32_buf_ssse3;