]> git.sesse.net Git - ffmpeg/commitdiff
opusenc: use float_dsp for transient mdcts
authorRostislav Pehlivanov <atomnuker@gmail.com>
Wed, 12 Jul 2017 03:49:21 +0000 (04:49 +0100)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Thu, 13 Jul 2017 18:53:52 +0000 (19:53 +0100)
vector_fmul_reverse requires padding the window at the front

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
libavcodec/opus_celt.h
libavcodec/opusenc.c
libavcodec/opustab.c
libavcodec/opustab.h

index b80ade84f2f3cf37c1cdad61e1cf3353ca861fb0..31299912bd7eb84cdac48d9e32a955ac87336a8d 100644 (file)
@@ -75,8 +75,8 @@ typedef struct CeltBlock {
     DECLARE_ALIGNED(32, float, coeffs)[CELT_MAX_FRAME_SIZE];
 
     /* Used by the encoder */
-    DECLARE_ALIGNED(32, float, overlap)[120];
-    DECLARE_ALIGNED(32, float, samples)[CELT_MAX_FRAME_SIZE];
+    DECLARE_ALIGNED(32, float, overlap)[FFALIGN(CELT_OVERLAP, 16)];
+    DECLARE_ALIGNED(32, float, samples)[FFALIGN(CELT_MAX_FRAME_SIZE, 16)];
 
     /* postfilter parameters */
     int   pf_period_new;
index 8aba291e7eaf4ddc444571a26368796cf743a56c..6cefd3388451e83302679072e26c9de3c1ac3282 100644 (file)
@@ -210,17 +210,15 @@ static void celt_frame_mdct(OpusEncContext *s, CeltFrame *f)
     int i, t, ch;
     float *win = s->scratch;
 
-    /* I think I can use s->dsp->vector_fmul_window for transients at least */
     if (f->transient) {
         for (ch = 0; ch < f->channels; ch++) {
             CeltBlock *b = &f->block[ch];
             float *src1 = b->overlap;
             for (t = 0; t < f->blocks; t++) {
                 float *src2 = &b->samples[CELT_OVERLAP*t];
-                for (i = 0; i < CELT_OVERLAP; i++) {
-                    win[               i] = src1[i]*ff_celt_window[i];
-                    win[CELT_OVERLAP + i] = src2[i]*ff_celt_window[CELT_OVERLAP - i - 1];
-                }
+                s->dsp->vector_fmul(win, src1, ff_celt_window, CELT_OVERLAP);
+                s->dsp->vector_fmul_reverse(&win[CELT_OVERLAP], src2,
+                                            ff_celt_window - 8, CELT_OVERLAP + 8);
                 src1 = src2;
                 s->mdct[0]->mdct(s->mdct[0], b->coeffs + t, win, f->blocks);
             }
index 635cc363e2cc3e214962aa893cce702c9677c68b..b31705297e12e49573c1037e96ab3f80f146d1d9 100644 (file)
@@ -1096,7 +1096,9 @@ const float ff_celt_postfilter_taps[3][3] = {
     { 0.7998046875f, 0.1000976562f, 0.0           }
 };
 
-DECLARE_ALIGNED(32, const float, ff_celt_window)[120] = {
+DECLARE_ALIGNED(32, static const float, ff_celt_window_padded)[136] = {
+    0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
+    0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
     6.7286966e-05f, 0.00060551348f, 0.0016815970f, 0.0032947962f, 0.0054439943f,
     0.0081276923f, 0.011344001f, 0.015090633f, 0.019364886f, 0.024163635f,
     0.029483315f, 0.035319905f, 0.041668911f, 0.048525347f, 0.055883718f,
@@ -1120,9 +1122,13 @@ DECLARE_ALIGNED(32, const float, ff_celt_window)[120] = {
     0.99499004f, 0.99592297f, 0.99672162f, 0.99739874f, 0.99796667f,
     0.99843728f, 0.99882195f, 0.99913147f, 0.99937606f, 0.99956527f,
     0.99970802f, 0.99981248f, 0.99988613f, 0.99993565f, 0.99996697f,
-    0.99998518f, 0.99999457f, 0.99999859f, 0.99999982f, 1.0000000f,
+    0.99998518f, 0.99999457f, 0.99999859f, 0.99999982f, 1.00000000f,
+    1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
+    1.00000000f, 1.00000000f, 1.00000000f,
 };
 
+const float *ff_celt_window = &ff_celt_window_padded[8];
+
 /* square of the window, used for the postfilter */
 const float ff_celt_window2[120] = {
     4.5275357e-09f, 3.66647e-07f, 2.82777e-06f, 1.08557e-05f, 2.96371e-05f, 6.60594e-05f,
index b4589869efc3c0d7b038c08f48ad705bdcfcb68f..bce5a4283084ed79c6e0b0d6fd73337516826728 100644 (file)
@@ -154,8 +154,7 @@ extern const uint32_t ff_celt_pvq_u[1272];
 extern const float    ff_celt_postfilter_taps[3][3];
 
 extern const float    ff_celt_window2[120];
-
-DECLARE_ALIGNED(32, extern const float, ff_celt_window)[120];
+extern const float   *ff_celt_window;
 
 extern const uint32_t * const ff_celt_pvq_u_row[15];