Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly
@ 2024-03-01  3:04 Andreas Rheinhardt
  2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 2/4] avcodec/lpc: Split inline functions into a header of their own Andreas Rheinhardt
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2024-03-01  3:04 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It leads to defines for the AAC decoder being included
outside of the AAC decoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aac_defines.h     | 11 +++++++++--
 libavcodec/aacdec_fixed.c    |  2 +-
 libavcodec/aacdec_template.c |  2 +-
 libavcodec/lpc.h             | 27 ++++++++++++++++++---------
 4 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/libavcodec/aac_defines.h b/libavcodec/aac_defines.h
index 59528f1f0d..8765939731 100644
--- a/libavcodec/aac_defines.h
+++ b/libavcodec/aac_defines.h
@@ -71,7 +71,15 @@ typedef int                 AAC_SIGNE;
                                       ((int64_t)(y) * (z)) + \
                                         0x40000000) >> 31)
 #define AAC_HALF_SUM(x, y)  (((x) >> 1) + ((y) >> 1))
-#define AAC_SRA_R(x, y)     (int)(((x) + (1 << ((y) - 1))) >> (y))
+
+#ifdef LPC_USE_FIXED
+#error aac_defines.h must be included before lpc.h for fixed point decoder
+#endif
+
+#define LPC_USE_FIXED 1
+#define LPC_MUL26(x, y)     AAC_MUL26((x), (y))
+#define LPC_FIXR(x)         FIXR(x)
+#define LPC_SRA_R(x, y)     (int)(((x) + (1 << ((y) - 1))) >> (y))
 
 #else
 
@@ -103,7 +111,6 @@ typedef unsigned            AAC_SIGNE;
                                                (c) * (d) - (e) * (f))
 #define AAC_MSUB31_V3(x, y, z)    ((x) - (y)) * (z)
 #define AAC_HALF_SUM(x, y)  ((x) + (y)) * 0.5f
-#define AAC_SRA_R(x, y)     (x)
 
 #endif /* USE_FIXED */
 
diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c
index 57d3fc8bab..08343bf157 100644
--- a/libavcodec/aacdec_fixed.c
+++ b/libavcodec/aacdec_fixed.c
@@ -66,7 +66,6 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "get_bits.h"
-#include "lpc.h"
 #include "kbdwin.h"
 #include "sinewin_fixed_tablegen.h"
 
@@ -76,6 +75,7 @@
 #include "aacdectab.h"
 #include "adts_header.h"
 #include "cbrt_data.h"
+#include "lpc.h"
 #include "sbr.h"
 #include "aacsbr.h"
 #include "mpeg4audio.h"
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 72c6e206a6..fb3a954aad 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -2516,7 +2516,7 @@ static void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns,
                 continue;
 
             // tns_decode_coef
-            AAC_RENAME(compute_lpc_coefs)(tns->coef[w][filt], order, lpc, 0, 0, 0);
+            compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
 
             start = ics->swb_offset[FFMIN(bottom, mmm)];
             end   = ics->swb_offset[FFMIN(   top, mmm)];
diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
index 0200baea5c..907fab7508 100644
--- a/libavcodec/lpc.h
+++ b/libavcodec/lpc.h
@@ -26,7 +26,6 @@
 #include <stddef.h>
 #include "libavutil/avassert.h"
 #include "libavutil/lls.h"
-#include "aac_defines.h"
 
 #define ORDER_METHOD_EST     0
 #define ORDER_METHOD_2LEVEL  1
@@ -117,10 +116,20 @@ void ff_lpc_init_x86(LPCContext *s);
  */
 void ff_lpc_end(LPCContext *s);
 
-#if USE_FIXED
+#ifndef LPC_USE_FIXED
+#define LPC_USE_FIXED 0
+#endif
+
+#if LPC_USE_FIXED
 typedef int LPC_TYPE;
 typedef unsigned LPC_TYPE_U;
 #else
+#ifndef LPC_SRA_R
+#define LPC_SRA_R(x, y) (x)
+#define LPC_MUL26(x, y) ((x) * (y))
+#define LPC_FIXR(x)     ((float)(x))
+#endif
+
 #ifdef LPC_USE_DOUBLE
 typedef double LPC_TYPE;
 typedef double LPC_TYPE_U;
@@ -145,7 +154,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
         gen0[i] = gen1[i] = autoc[i + 1];
 
     err    = autoc[0];
-    ref[0] = -gen1[0] / ((USE_FIXED || err) ? err : 1);
+    ref[0] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
     err   +=  gen1[0] * ref[0];
     if (error)
         error[0] = err;
@@ -154,7 +163,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
             gen1[j] = gen1[j + 1] + ref[i - 1] * gen0[j];
             gen0[j] = gen1[j + 1] * ref[i - 1] + gen0[j];
         }
-        ref[i] = -gen1[0] / ((USE_FIXED || err) ? err : 1);
+        ref[i] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
         err   +=  gen1[0] * ref[i];
         if (error)
             error[i] = err;
@@ -165,7 +174,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
  * Levinson-Durbin recursion.
  * Produce LPC coefficients from autocorrelation data.
  */
-static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_order,
+static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
                                     LPC_TYPE *lpc, int lpc_stride, int fail,
                                     int normalize)
 {
@@ -182,7 +191,7 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
         return -1;
 
     for(i=0; i<max_order; i++) {
-        LPC_TYPE r = AAC_SRA_R(-autoc[i], 5);
+        LPC_TYPE r = LPC_SRA_R(-autoc[i], 5);
 
         if (normalize) {
             for(j=0; j<i; j++)
@@ -190,7 +199,7 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
 
             if (err)
                 r /= err;
-            err *= FIXR(1.0) - (r * r);
+            err *= LPC_FIXR(1.0) - (r * r);
         }
 
         lpc[i] = r;
@@ -198,8 +207,8 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
         for(j=0; j < (i+1)>>1; j++) {
             LPC_TYPE f = lpc_last[    j];
             LPC_TYPE b = lpc_last[i-1-j];
-            lpc[    j] = f + (LPC_TYPE_U)AAC_MUL26(r, b);
-            lpc[i-1-j] = b + (LPC_TYPE_U)AAC_MUL26(r, f);
+            lpc[    j] = f + (LPC_TYPE_U)LPC_MUL26(r, b);
+            lpc[i-1-j] = b + (LPC_TYPE_U)LPC_MUL26(r, f);
         }
 
         if (fail && err < 0)
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 2/4] avcodec/lpc: Split inline functions into a header of their own
  2024-03-01  3:04 [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
@ 2024-03-01  3:08 ` Andreas Rheinhardt
  2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 3/4] avcodec/aacdec: Move buffer to reduce padding Andreas Rheinhardt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2024-03-01  3:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

And move compute_ref_coefs() to its only user: lpc.c
There is no overlap between the users of compute_lpc_coefs()
and lpc proper.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aac_defines.h     |   2 +-
 libavcodec/aacdec.c          |   1 -
 libavcodec/aacdec_fixed.c    |   1 -
 libavcodec/aacdec_template.c |   1 +
 libavcodec/aacenc_tns.c      |   1 +
 libavcodec/cngenc.c          |   1 +
 libavcodec/lpc.c             |  31 ++++++++++
 libavcodec/lpc.h             | 106 -----------------------------------
 libavcodec/lpc_functions.h   | 100 +++++++++++++++++++++++++++++++++
 libavcodec/ra288.c           |   2 +-
 10 files changed, 136 insertions(+), 110 deletions(-)
 create mode 100644 libavcodec/lpc_functions.h

diff --git a/libavcodec/aac_defines.h b/libavcodec/aac_defines.h
index 8765939731..a0c23c33ff 100644
--- a/libavcodec/aac_defines.h
+++ b/libavcodec/aac_defines.h
@@ -73,7 +73,7 @@ typedef int                 AAC_SIGNE;
 #define AAC_HALF_SUM(x, y)  (((x) >> 1) + ((y) >> 1))
 
 #ifdef LPC_USE_FIXED
-#error aac_defines.h must be included before lpc.h for fixed point decoder
+#error aac_defines.h must be included before lpc_functions.h for fixed point decoder
 #endif
 
 #define LPC_USE_FIXED 1
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index b1bce7542b..fa2187b61a 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -40,7 +40,6 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "get_bits.h"
-#include "lpc.h"
 #include "kbdwin.h"
 #include "sinewin.h"
 
diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c
index 08343bf157..2abe6acb6b 100644
--- a/libavcodec/aacdec_fixed.c
+++ b/libavcodec/aacdec_fixed.c
@@ -75,7 +75,6 @@
 #include "aacdectab.h"
 #include "adts_header.h"
 #include "cbrt_data.h"
-#include "lpc.h"
 #include "sbr.h"
 #include "aacsbr.h"
 #include "mpeg4audio.h"
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index fb3a954aad..6561abb14e 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -93,6 +93,7 @@
 #include "libavutil/thread.h"
 #include "decode.h"
 #include "internal.h"
+#include "lpc_functions.h"
 
 static int output_configure(AACDecContext *ac,
                             uint8_t layout_map[MAX_ELEM_ID*4][3], int tags,
diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c
index 8dc6dfcf62..b2418a0236 100644
--- a/libavcodec/aacenc_tns.c
+++ b/libavcodec/aacenc_tns.c
@@ -30,6 +30,7 @@
 #include "aacenc_tns.h"
 #include "aactab.h"
 #include "aacenc_utils.h"
+#include "lpc_functions.h"
 
 /* Could be set to 3 to save an additional bit at the cost of little quality */
 #define TNS_Q_BITS 4
diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c
index 596d6f8c2a..15a410ea50 100644
--- a/libavcodec/cngenc.c
+++ b/libavcodec/cngenc.c
@@ -21,6 +21,7 @@
 
 #include <math.h>
 
+#include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "avcodec.h"
 #include "codec_internal.h"
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index 9e2fd0f128..53f5c3d379 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -25,8 +25,39 @@
 
 #define LPC_USE_DOUBLE
 #include "lpc.h"
+#include "lpc_functions.h"
 #include "libavutil/avassert.h"
 
+/**
+ * Schur recursion.
+ * Produces reflection coefficients from autocorrelation data.
+ */
+static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
+                                     LPC_TYPE *ref, LPC_TYPE *error)
+{
+    LPC_TYPE err;
+    LPC_TYPE gen0[MAX_LPC_ORDER], gen1[MAX_LPC_ORDER];
+
+    for (int i = 0; i < max_order; i++)
+        gen0[i] = gen1[i] = autoc[i + 1];
+
+    err    = autoc[0];
+    ref[0] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
+    err   +=  gen1[0] * ref[0];
+    if (error)
+        error[0] = err;
+    for (int i = 1; i < max_order; i++) {
+        for (int j = 0; j < max_order - i; j++) {
+            gen1[j] = gen1[j + 1] + ref[i - 1] * gen0[j];
+            gen0[j] = gen1[j + 1] * ref[i - 1] + gen0[j];
+        }
+        ref[i] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
+        err   +=  gen1[0] * ref[i];
+        if (error)
+            error[i] = err;
+    }
+}
+
 
 /**
  * Apply Welch window function to audio block
diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
index 907fab7508..6d62707a59 100644
--- a/libavcodec/lpc.h
+++ b/libavcodec/lpc.h
@@ -24,7 +24,6 @@
 
 #include <stdint.h>
 #include <stddef.h>
-#include "libavutil/avassert.h"
 #include "libavutil/lls.h"
 
 #define ORDER_METHOD_EST     0
@@ -116,109 +115,4 @@ void ff_lpc_init_x86(LPCContext *s);
  */
 void ff_lpc_end(LPCContext *s);
 
-#ifndef LPC_USE_FIXED
-#define LPC_USE_FIXED 0
-#endif
-
-#if LPC_USE_FIXED
-typedef int LPC_TYPE;
-typedef unsigned LPC_TYPE_U;
-#else
-#ifndef LPC_SRA_R
-#define LPC_SRA_R(x, y) (x)
-#define LPC_MUL26(x, y) ((x) * (y))
-#define LPC_FIXR(x)     ((float)(x))
-#endif
-
-#ifdef LPC_USE_DOUBLE
-typedef double LPC_TYPE;
-typedef double LPC_TYPE_U;
-#else
-typedef float LPC_TYPE;
-typedef float LPC_TYPE_U;
-#endif
-#endif // USE_FIXED
-
-/**
- * Schur recursion.
- * Produces reflection coefficients from autocorrelation data.
- */
-static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
-                                     LPC_TYPE *ref, LPC_TYPE *error)
-{
-    int i, j;
-    LPC_TYPE err;
-    LPC_TYPE gen0[MAX_LPC_ORDER], gen1[MAX_LPC_ORDER];
-
-    for (i = 0; i < max_order; i++)
-        gen0[i] = gen1[i] = autoc[i + 1];
-
-    err    = autoc[0];
-    ref[0] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
-    err   +=  gen1[0] * ref[0];
-    if (error)
-        error[0] = err;
-    for (i = 1; i < max_order; i++) {
-        for (j = 0; j < max_order - i; j++) {
-            gen1[j] = gen1[j + 1] + ref[i - 1] * gen0[j];
-            gen0[j] = gen1[j + 1] * ref[i - 1] + gen0[j];
-        }
-        ref[i] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
-        err   +=  gen1[0] * ref[i];
-        if (error)
-            error[i] = err;
-    }
-}
-
-/**
- * Levinson-Durbin recursion.
- * Produce LPC coefficients from autocorrelation data.
- */
-static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
-                                    LPC_TYPE *lpc, int lpc_stride, int fail,
-                                    int normalize)
-{
-    int i, j;
-    LPC_TYPE err = 0;
-    LPC_TYPE *lpc_last = lpc;
-
-    av_assert2(normalize || !fail);
-
-    if (normalize)
-        err = *autoc++;
-
-    if (fail && (autoc[max_order - 1] == 0 || err <= 0))
-        return -1;
-
-    for(i=0; i<max_order; i++) {
-        LPC_TYPE r = LPC_SRA_R(-autoc[i], 5);
-
-        if (normalize) {
-            for(j=0; j<i; j++)
-                r -= lpc_last[j] * autoc[i-j-1];
-
-            if (err)
-                r /= err;
-            err *= LPC_FIXR(1.0) - (r * r);
-        }
-
-        lpc[i] = r;
-
-        for(j=0; j < (i+1)>>1; j++) {
-            LPC_TYPE f = lpc_last[    j];
-            LPC_TYPE b = lpc_last[i-1-j];
-            lpc[    j] = f + (LPC_TYPE_U)LPC_MUL26(r, b);
-            lpc[i-1-j] = b + (LPC_TYPE_U)LPC_MUL26(r, f);
-        }
-
-        if (fail && err < 0)
-            return -1;
-
-        lpc_last = lpc;
-        lpc += lpc_stride;
-    }
-
-    return 0;
-}
-
 #endif /* AVCODEC_LPC_H */
diff --git a/libavcodec/lpc_functions.h b/libavcodec/lpc_functions.h
new file mode 100644
index 0000000000..57bcfab900
--- /dev/null
+++ b/libavcodec/lpc_functions.h
@@ -0,0 +1,100 @@
+/*
+ * LPC utility functions
+ * Copyright (c) 2006  Justin Ruggles <justin.ruggles@gmail.com>
+ *
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_LPC_FUNCTIONS_H
+#define AVCODEC_LPC_FUNCTIONS_H
+
+#include "libavutil/avassert.h"
+
+#ifndef LPC_USE_FIXED
+#define LPC_USE_FIXED 0
+#endif
+
+#if LPC_USE_FIXED
+typedef int LPC_TYPE;
+typedef unsigned LPC_TYPE_U;
+#else
+#ifndef LPC_SRA_R
+#define LPC_SRA_R(x, y) (x)
+#define LPC_MUL26(x, y) ((x) * (y))
+#define LPC_FIXR(x)     ((float)(x))
+#endif
+
+#ifdef LPC_USE_DOUBLE
+typedef double LPC_TYPE;
+typedef double LPC_TYPE_U;
+#else
+typedef float LPC_TYPE;
+typedef float LPC_TYPE_U;
+#endif
+#endif // USE_FIXED
+
+/**
+ * Levinson-Durbin recursion.
+ * Produce LPC coefficients from autocorrelation data.
+ */
+static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
+                                    LPC_TYPE *lpc, int lpc_stride, int fail,
+                                    int normalize)
+{
+    LPC_TYPE err = 0;
+    LPC_TYPE *lpc_last = lpc;
+
+    av_assert2(normalize || !fail);
+
+    if (normalize)
+        err = *autoc++;
+
+    if (fail && (autoc[max_order - 1] == 0 || err <= 0))
+        return -1;
+
+    for(int i = 0; i < max_order; i++) {
+        LPC_TYPE r = LPC_SRA_R(-autoc[i], 5);
+
+        if (normalize) {
+            for(int j = 0; j < i; j++)
+                r -= lpc_last[j] * autoc[i-j-1];
+
+            if (err)
+                r /= err;
+            err *= LPC_FIXR(1.0) - (r * r);
+        }
+
+        lpc[i] = r;
+
+        for(int j = 0; j < (i + 1) >> 1; j++) {
+            LPC_TYPE f = lpc_last[    j];
+            LPC_TYPE b = lpc_last[i-1-j];
+            lpc[    j] = f + (LPC_TYPE_U)LPC_MUL26(r, b);
+            lpc[i-1-j] = b + (LPC_TYPE_U)LPC_MUL26(r, f);
+        }
+
+        if (fail && err < 0)
+            return -1;
+
+        lpc_last = lpc;
+        lpc += lpc_stride;
+    }
+
+    return 0;
+}
+
+#endif /* AVCODEC_LPC_FUNCTIONS_H */
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index c8c20e4884..e4b14ef2a2 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -30,7 +30,7 @@
 #include "codec_internal.h"
 #include "decode.h"
 #include "get_bits.h"
-#include "lpc.h"
+#include "lpc_functions.h"
 #include "ra288.h"
 
 #define MAX_BACKWARD_FILTER_ORDER  36
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 3/4] avcodec/aacdec: Move buffer to reduce padding
  2024-03-01  3:04 [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
  2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 2/4] avcodec/lpc: Split inline functions into a header of their own Andreas Rheinhardt
@ 2024-03-01  3:08 ` Andreas Rheinhardt
  2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 4/4] avcodec/aactab: Deduplicate ltp_coef and tns_tmp2_map tables Andreas Rheinhardt
  2024-03-03 18:45 ` [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
  3 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2024-03-01  3:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aacdec.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/aacdec.h b/libavcodec/aacdec.h
index e23310b5b1..1b245f9258 100644
--- a/libavcodec/aacdec.h
+++ b/libavcodec/aacdec.h
@@ -207,6 +207,7 @@ typedef struct AACDecContext {
      * @{
      */
     DECLARE_ALIGNED(32, INTFLOAT, buf_mdct)[1024];
+    DECLARE_ALIGNED(32, INTFLOAT, temp)[128];
     /** @} */
 
     /**
@@ -254,8 +255,6 @@ typedef struct AACDecContext {
 
     enum AACOutputChannelOrder output_channel_order;
 
-    DECLARE_ALIGNED(32, INTFLOAT, temp)[128];
-
     OutputConfiguration oc[2];
     int warned_num_aac_frames;
     int warned_960_sbr;
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 4/4] avcodec/aactab: Deduplicate ltp_coef and tns_tmp2_map tables
  2024-03-01  3:04 [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
  2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 2/4] avcodec/lpc: Split inline functions into a header of their own Andreas Rheinhardt
  2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 3/4] avcodec/aacdec: Move buffer to reduce padding Andreas Rheinhardt
@ 2024-03-01  3:08 ` Andreas Rheinhardt
  2024-03-03 18:45 ` [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
  3 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2024-03-01  3:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This will allow to make aac_defines.h decoder-only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aacdec_fixed.c    | 43 ++++++++++++++++++++++++++++++++++++
 libavcodec/aacdec_template.c |  4 ++--
 libavcodec/aacenc_ltp.c      |  4 ++--
 libavcodec/aacenc_tns.c      |  2 +-
 libavcodec/aactab.c          | 39 ++++++++++++++++++++++++++++++++
 libavcodec/aactab.h          | 36 ++----------------------------
 6 files changed, 89 insertions(+), 39 deletions(-)

diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c
index 2abe6acb6b..5d5ae34838 100644
--- a/libavcodec/aacdec_fixed.c
+++ b/libavcodec/aacdec_fixed.c
@@ -89,6 +89,49 @@ DECLARE_ALIGNED(32, static int, AAC_RENAME2(aac_kbd_short_128))[128];
 DECLARE_ALIGNED(32, static int, AAC_RENAME2(aac_kbd_long_960))[960];
 DECLARE_ALIGNED(32, static int, AAC_RENAME2(aac_kbd_short_120))[120];
 
+/* @name ltp_coef
+ * Table of the LTP coefficients
+ */
+static const int ltp_coef_fixed[8] = {
+    Q30(0.570829), Q30(0.696616), Q30(0.813004), Q30(0.911304),
+    Q30(0.984900), Q30(1.067894), Q30(1.194601), Q30(1.369533),
+};
+
+/* @name tns_tmp2_map
+ * Tables of the tmp2[] arrays of LPC coefficients used for TNS.
+ * The suffix _M_N[] indicate the values of coef_compress and coef_res
+ * respectively.
+ * @{
+ */
+static const int tns_tmp2_map_1_3[4] = {
+    Q31(0.00000000), Q31(-0.43388373),  Q31(0.64278758),  Q31(0.34202015),
+};
+
+static const int tns_tmp2_map_0_3[8] = {
+    Q31(0.00000000), Q31(-0.43388373), Q31(-0.78183150), Q31(-0.97492790),
+    Q31(0.98480773), Q31( 0.86602539), Q31( 0.64278758), Q31( 0.34202015),
+};
+
+static const int tns_tmp2_map_1_4[8] = {
+    Q31(0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524),
+    Q31(0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951),
+};
+
+static const int tns_tmp2_map_0_4[16] = {
+    Q31( 0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524),
+    Q31(-0.74314481), Q31(-0.86602539), Q31(-0.95105654), Q31(-0.99452192),
+    Q31( 0.99573416), Q31( 0.96182561), Q31( 0.89516330), Q31( 0.79801720),
+    Q31( 0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951),
+};
+
+static const int * const tns_tmp2_map_fixed[4] = {
+    tns_tmp2_map_0_3,
+    tns_tmp2_map_0_4,
+    tns_tmp2_map_1_3,
+    tns_tmp2_map_1_4
+};
+// @}
+
 static av_always_inline void reset_predict_state(PredictorState *ps)
 {
     ps->r0.mant   = 0;
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 6561abb14e..3d96ed6f29 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -1298,7 +1298,7 @@ static void decode_ltp(LongTermPrediction *ltp,
     int sfb;
 
     ltp->lag  = get_bits(gb, 11);
-    ltp->coef = ltp_coef[get_bits(gb, 3)];
+    ltp->coef = AAC_RENAME2(ltp_coef)[get_bits(gb, 3)];
     for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
         ltp->used[sfb] = get_bits1(gb);
 }
@@ -1611,7 +1611,7 @@ static int decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns,
                     tmp2_idx = 2 * coef_compress + coef_res;
 
                     for (i = 0; i < tns->order[w][filt]; i++)
-                        tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
+                        tns->coef[w][filt][i] = AAC_RENAME2(tns_tmp2_map)[tmp2_idx][get_bits(gb, coef_len)];
                 }
             }
         }
diff --git a/libavcodec/aacenc_ltp.c b/libavcodec/aacenc_ltp.c
index f3075f0e71..9901891d68 100644
--- a/libavcodec/aacenc_ltp.c
+++ b/libavcodec/aacenc_ltp.c
@@ -92,8 +92,8 @@ static void get_lag(float *buf, const float *new, LongTermPrediction *ltp)
         }
     }
     ltp->lag = FFMAX(av_clip_uintp2(lag, 11), 0);
-    ltp->coef_idx = quant_array_idx(max_ratio, ltp_coef, 8);
-    ltp->coef = ltp_coef[ltp->coef_idx];
+    ltp->coef_idx = quant_array_idx(max_ratio, ff_ltp_coef, 8);
+    ltp->coef     = ff_ltp_coef[ltp->coef_idx];
 }
 
 static void generate_samples(float *buf, LongTermPrediction *ltp)
diff --git a/libavcodec/aacenc_tns.c b/libavcodec/aacenc_tns.c
index b2418a0236..60888fece7 100644
--- a/libavcodec/aacenc_tns.c
+++ b/libavcodec/aacenc_tns.c
@@ -148,7 +148,7 @@ static inline void quantize_coefs(double *coef, int *idx, float *lpc, int order,
                                   int c_bits)
 {
     int i;
-    const float *quant_arr = tns_tmp2_map[c_bits];
+    const float *quant_arr = ff_tns_tmp2_map[c_bits];
     for (i = 0; i < order; i++) {
         idx[i] = quant_array_idx(coef[i], quant_arr, c_bits ? 16 : 8);
         lpc[i] = quant_arr[idx[i]];
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index 63a478f33f..020267f389 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -105,6 +105,45 @@ av_cold void ff_aac_float_common_init(void)
     static AVOnce init_static_once = AV_ONCE_INIT;
     ff_thread_once(&init_static_once, aac_float_common_init);
 }
+
+const float ff_ltp_coef[8] = {
+    0.570829, 0.696616, 0.813004, 0.911304,
+    0.984900, 1.067894, 1.194601, 1.369533,
+};
+
+/* @name tns_tmp2_map
+ * Tables of the tmp2[] arrays of LPC coefficients used for TNS.
+ * The suffix _M_N[] indicate the values of coef_compress and coef_res
+ * respectively.
+ * @{
+ */
+static const float tns_tmp2_map_1_3[4] = {
+    0.00000000, -0.43388373,  0.64278758,  0.34202015,
+};
+
+static const float tns_tmp2_map_0_3[8] = {
+    0.00000000, -0.43388373, -0.78183150, -0.97492790,
+    0.98480773,  0.86602539,  0.64278758,  0.34202015,
+};
+
+static const float tns_tmp2_map_1_4[8] = {
+    0.00000000, -0.20791170, -0.40673664, -0.58778524,
+    0.67369562,  0.52643216,  0.36124167,  0.18374951,
+};
+
+static const float tns_tmp2_map_0_4[16] = {
+     0.00000000, -0.20791170, -0.40673664, -0.58778524,
+    -0.74314481, -0.86602539, -0.95105654, -0.99452192,
+     0.99573416,  0.96182561,  0.89516330,  0.79801720,
+     0.67369562,  0.52643216,  0.36124167,  0.18374951,
+};
+
+const float * const ff_tns_tmp2_map[4] = {
+    tns_tmp2_map_0_3,
+    tns_tmp2_map_0_4,
+    tns_tmp2_map_1_3,
+    tns_tmp2_map_1_4
+};
 #endif
 
 const uint8_t ff_aac_num_swb_1024[] = {
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 81db29a4e4..e1a2d8b9a1 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -31,7 +31,6 @@
 #define AVCODEC_AACTAB_H
 
 #include "libavutil/mem_internal.h"
-#include "aac_defines.h"
 
 #include <stdint.h>
 
@@ -45,44 +44,13 @@ extern float ff_aac_pow34sf_tab[428];
 /* @name ltp_coef
  * Table of the LTP coefficients
  */
-static const INTFLOAT ltp_coef[8] = {
-    Q30(0.570829), Q30(0.696616), Q30(0.813004), Q30(0.911304),
-    Q30(0.984900), Q30(1.067894), Q30(1.194601), Q30(1.369533),
-};
+extern const float ff_ltp_coef[8];
 
 /* @name tns_tmp2_map
  * Tables of the tmp2[] arrays of LPC coefficients used for TNS.
- * The suffix _M_N[] indicate the values of coef_compress and coef_res
- * respectively.
  * @{
  */
-static const INTFLOAT tns_tmp2_map_1_3[4] = {
-    Q31(0.00000000), Q31(-0.43388373),  Q31(0.64278758),  Q31(0.34202015),
-};
-
-static const INTFLOAT tns_tmp2_map_0_3[8] = {
-    Q31(0.00000000), Q31(-0.43388373), Q31(-0.78183150), Q31(-0.97492790),
-    Q31(0.98480773), Q31( 0.86602539), Q31( 0.64278758), Q31( 0.34202015),
-};
-
-static const INTFLOAT tns_tmp2_map_1_4[8] = {
-    Q31(0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524),
-    Q31(0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951),
-};
-
-static const INTFLOAT tns_tmp2_map_0_4[16] = {
-    Q31( 0.00000000), Q31(-0.20791170), Q31(-0.40673664), Q31(-0.58778524),
-    Q31(-0.74314481), Q31(-0.86602539), Q31(-0.95105654), Q31(-0.99452192),
-    Q31( 0.99573416), Q31( 0.96182561), Q31( 0.89516330), Q31( 0.79801720),
-    Q31( 0.67369562), Q31( 0.52643216), Q31( 0.36124167), Q31( 0.18374951),
-};
-
-static const INTFLOAT * const tns_tmp2_map[4] = {
-    tns_tmp2_map_0_3,
-    tns_tmp2_map_0_4,
-    tns_tmp2_map_1_3,
-    tns_tmp2_map_1_4
-};
+extern const float *const ff_tns_tmp2_map[4];
 // @}
 
 /* @name window coefficients
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly
  2024-03-01  3:04 [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 4/4] avcodec/aactab: Deduplicate ltp_coef and tns_tmp2_map tables Andreas Rheinhardt
@ 2024-03-03 18:45 ` Andreas Rheinhardt
  2024-03-03 21:44   ` Lynne
  3 siblings, 1 reply; 6+ messages in thread
From: Andreas Rheinhardt @ 2024-03-03 18:45 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> It leads to defines for the AAC decoder being included
> outside of the AAC decoder.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/aac_defines.h     | 11 +++++++++--
>  libavcodec/aacdec_fixed.c    |  2 +-
>  libavcodec/aacdec_template.c |  2 +-
>  libavcodec/lpc.h             | 27 ++++++++++++++++++---------
>  4 files changed, 29 insertions(+), 13 deletions(-)
> 
> diff --git a/libavcodec/aac_defines.h b/libavcodec/aac_defines.h
> index 59528f1f0d..8765939731 100644
> --- a/libavcodec/aac_defines.h
> +++ b/libavcodec/aac_defines.h
> @@ -71,7 +71,15 @@ typedef int                 AAC_SIGNE;
>                                        ((int64_t)(y) * (z)) + \
>                                          0x40000000) >> 31)
>  #define AAC_HALF_SUM(x, y)  (((x) >> 1) + ((y) >> 1))
> -#define AAC_SRA_R(x, y)     (int)(((x) + (1 << ((y) - 1))) >> (y))
> +
> +#ifdef LPC_USE_FIXED
> +#error aac_defines.h must be included before lpc.h for fixed point decoder
> +#endif
> +
> +#define LPC_USE_FIXED 1
> +#define LPC_MUL26(x, y)     AAC_MUL26((x), (y))
> +#define LPC_FIXR(x)         FIXR(x)
> +#define LPC_SRA_R(x, y)     (int)(((x) + (1 << ((y) - 1))) >> (y))
>  
>  #else
>  
> @@ -103,7 +111,6 @@ typedef unsigned            AAC_SIGNE;
>                                                 (c) * (d) - (e) * (f))
>  #define AAC_MSUB31_V3(x, y, z)    ((x) - (y)) * (z)
>  #define AAC_HALF_SUM(x, y)  ((x) + (y)) * 0.5f
> -#define AAC_SRA_R(x, y)     (x)
>  
>  #endif /* USE_FIXED */
>  
> diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c
> index 57d3fc8bab..08343bf157 100644
> --- a/libavcodec/aacdec_fixed.c
> +++ b/libavcodec/aacdec_fixed.c
> @@ -66,7 +66,6 @@
>  #include "avcodec.h"
>  #include "codec_internal.h"
>  #include "get_bits.h"
> -#include "lpc.h"
>  #include "kbdwin.h"
>  #include "sinewin_fixed_tablegen.h"
>  
> @@ -76,6 +75,7 @@
>  #include "aacdectab.h"
>  #include "adts_header.h"
>  #include "cbrt_data.h"
> +#include "lpc.h"
>  #include "sbr.h"
>  #include "aacsbr.h"
>  #include "mpeg4audio.h"
> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> index 72c6e206a6..fb3a954aad 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -2516,7 +2516,7 @@ static void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns,
>                  continue;
>  
>              // tns_decode_coef
> -            AAC_RENAME(compute_lpc_coefs)(tns->coef[w][filt], order, lpc, 0, 0, 0);
> +            compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
>  
>              start = ics->swb_offset[FFMIN(bottom, mmm)];
>              end   = ics->swb_offset[FFMIN(   top, mmm)];
> diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
> index 0200baea5c..907fab7508 100644
> --- a/libavcodec/lpc.h
> +++ b/libavcodec/lpc.h
> @@ -26,7 +26,6 @@
>  #include <stddef.h>
>  #include "libavutil/avassert.h"
>  #include "libavutil/lls.h"
> -#include "aac_defines.h"
>  
>  #define ORDER_METHOD_EST     0
>  #define ORDER_METHOD_2LEVEL  1
> @@ -117,10 +116,20 @@ void ff_lpc_init_x86(LPCContext *s);
>   */
>  void ff_lpc_end(LPCContext *s);
>  
> -#if USE_FIXED
> +#ifndef LPC_USE_FIXED
> +#define LPC_USE_FIXED 0
> +#endif
> +
> +#if LPC_USE_FIXED
>  typedef int LPC_TYPE;
>  typedef unsigned LPC_TYPE_U;
>  #else
> +#ifndef LPC_SRA_R
> +#define LPC_SRA_R(x, y) (x)
> +#define LPC_MUL26(x, y) ((x) * (y))
> +#define LPC_FIXR(x)     ((float)(x))
> +#endif
> +
>  #ifdef LPC_USE_DOUBLE
>  typedef double LPC_TYPE;
>  typedef double LPC_TYPE_U;
> @@ -145,7 +154,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
>          gen0[i] = gen1[i] = autoc[i + 1];
>  
>      err    = autoc[0];
> -    ref[0] = -gen1[0] / ((USE_FIXED || err) ? err : 1);
> +    ref[0] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
>      err   +=  gen1[0] * ref[0];
>      if (error)
>          error[0] = err;
> @@ -154,7 +163,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
>              gen1[j] = gen1[j + 1] + ref[i - 1] * gen0[j];
>              gen0[j] = gen1[j + 1] * ref[i - 1] + gen0[j];
>          }
> -        ref[i] = -gen1[0] / ((USE_FIXED || err) ? err : 1);
> +        ref[i] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
>          err   +=  gen1[0] * ref[i];
>          if (error)
>              error[i] = err;
> @@ -165,7 +174,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
>   * Levinson-Durbin recursion.
>   * Produce LPC coefficients from autocorrelation data.
>   */
> -static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_order,
> +static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
>                                      LPC_TYPE *lpc, int lpc_stride, int fail,
>                                      int normalize)
>  {
> @@ -182,7 +191,7 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
>          return -1;
>  
>      for(i=0; i<max_order; i++) {
> -        LPC_TYPE r = AAC_SRA_R(-autoc[i], 5);
> +        LPC_TYPE r = LPC_SRA_R(-autoc[i], 5);
>  
>          if (normalize) {
>              for(j=0; j<i; j++)
> @@ -190,7 +199,7 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
>  
>              if (err)
>                  r /= err;
> -            err *= FIXR(1.0) - (r * r);
> +            err *= LPC_FIXR(1.0) - (r * r);
>          }
>  
>          lpc[i] = r;
> @@ -198,8 +207,8 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
>          for(j=0; j < (i+1)>>1; j++) {
>              LPC_TYPE f = lpc_last[    j];
>              LPC_TYPE b = lpc_last[i-1-j];
> -            lpc[    j] = f + (LPC_TYPE_U)AAC_MUL26(r, b);
> -            lpc[i-1-j] = b + (LPC_TYPE_U)AAC_MUL26(r, f);
> +            lpc[    j] = f + (LPC_TYPE_U)LPC_MUL26(r, b);
> +            lpc[i-1-j] = b + (LPC_TYPE_U)LPC_MUL26(r, f);
>          }
>  
>          if (fail && err < 0)

Will apply this patchset tomorrow unless there are objections.

- Andreas

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly
  2024-03-03 18:45 ` [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
@ 2024-03-03 21:44   ` Lynne
  0 siblings, 0 replies; 6+ messages in thread
From: Lynne @ 2024-03-03 21:44 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Mar 3, 2024, 19:43 by andreas.rheinhardt@outlook.com:

> Andreas Rheinhardt:
>
>> It leads to defines for the AAC decoder being included
>> outside of the AAC decoder.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavcodec/aac_defines.h     | 11 +++++++++--
>>  libavcodec/aacdec_fixed.c    |  2 +-
>>  libavcodec/aacdec_template.c |  2 +-
>>  libavcodec/lpc.h             | 27 ++++++++++++++++++---------
>>  4 files changed, 29 insertions(+), 13 deletions(-)
>>
>> diff --git a/libavcodec/aac_defines.h b/libavcodec/aac_defines.h
>> index 59528f1f0d..8765939731 100644
>> --- a/libavcodec/aac_defines.h
>> +++ b/libavcodec/aac_defines.h
>> @@ -71,7 +71,15 @@ typedef int                 AAC_SIGNE;
>>  ((int64_t)(y) * (z)) + \
>>  0x40000000) >> 31)
>>  #define AAC_HALF_SUM(x, y)  (((x) >> 1) + ((y) >> 1))
>> -#define AAC_SRA_R(x, y)     (int)(((x) + (1 << ((y) - 1))) >> (y))
>> +
>> +#ifdef LPC_USE_FIXED
>> +#error aac_defines.h must be included before lpc.h for fixed point decoder
>> +#endif
>> +
>> +#define LPC_USE_FIXED 1
>> +#define LPC_MUL26(x, y)     AAC_MUL26((x), (y))
>> +#define LPC_FIXR(x)         FIXR(x)
>> +#define LPC_SRA_R(x, y)     (int)(((x) + (1 << ((y) - 1))) >> (y))
>>  
>>  #else
>>  
>> @@ -103,7 +111,6 @@ typedef unsigned            AAC_SIGNE;
>>  (c) * (d) - (e) * (f))
>>  #define AAC_MSUB31_V3(x, y, z)    ((x) - (y)) * (z)
>>  #define AAC_HALF_SUM(x, y)  ((x) + (y)) * 0.5f
>> -#define AAC_SRA_R(x, y)     (x)
>>  
>>  #endif /* USE_FIXED */
>>  
>> diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c
>> index 57d3fc8bab..08343bf157 100644
>> --- a/libavcodec/aacdec_fixed.c
>> +++ b/libavcodec/aacdec_fixed.c
>> @@ -66,7 +66,6 @@
>>  #include "avcodec.h"
>>  #include "codec_internal.h"
>>  #include "get_bits.h"
>> -#include "lpc.h"
>>  #include "kbdwin.h"
>>  #include "sinewin_fixed_tablegen.h"
>>  
>> @@ -76,6 +75,7 @@
>>  #include "aacdectab.h"
>>  #include "adts_header.h"
>>  #include "cbrt_data.h"
>> +#include "lpc.h"
>>  #include "sbr.h"
>>  #include "aacsbr.h"
>>  #include "mpeg4audio.h"
>> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
>> index 72c6e206a6..fb3a954aad 100644
>> --- a/libavcodec/aacdec_template.c
>> +++ b/libavcodec/aacdec_template.c
>> @@ -2516,7 +2516,7 @@ static void apply_tns(INTFLOAT coef_param[1024], TemporalNoiseShaping *tns,
>>  continue;
>>  
>>  // tns_decode_coef
>> -            AAC_RENAME(compute_lpc_coefs)(tns->coef[w][filt], order, lpc, 0, 0, 0);
>> +            compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
>>  
>>  start = ics->swb_offset[FFMIN(bottom, mmm)];
>>  end   = ics->swb_offset[FFMIN(   top, mmm)];
>> diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
>> index 0200baea5c..907fab7508 100644
>> --- a/libavcodec/lpc.h
>> +++ b/libavcodec/lpc.h
>> @@ -26,7 +26,6 @@
>>  #include <stddef.h>
>>  #include "libavutil/avassert.h"
>>  #include "libavutil/lls.h"
>> -#include "aac_defines.h"
>>  
>>  #define ORDER_METHOD_EST     0
>>  #define ORDER_METHOD_2LEVEL  1
>> @@ -117,10 +116,20 @@ void ff_lpc_init_x86(LPCContext *s);
>>  */
>>  void ff_lpc_end(LPCContext *s);
>>  
>> -#if USE_FIXED
>> +#ifndef LPC_USE_FIXED
>> +#define LPC_USE_FIXED 0
>> +#endif
>> +
>> +#if LPC_USE_FIXED
>>  typedef int LPC_TYPE;
>>  typedef unsigned LPC_TYPE_U;
>>  #else
>> +#ifndef LPC_SRA_R
>> +#define LPC_SRA_R(x, y) (x)
>> +#define LPC_MUL26(x, y) ((x) * (y))
>> +#define LPC_FIXR(x)     ((float)(x))
>> +#endif
>> +
>>  #ifdef LPC_USE_DOUBLE
>>  typedef double LPC_TYPE;
>>  typedef double LPC_TYPE_U;
>> @@ -145,7 +154,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
>>  gen0[i] = gen1[i] = autoc[i + 1];
>>  
>>  err    = autoc[0];
>> -    ref[0] = -gen1[0] / ((USE_FIXED || err) ? err : 1);
>> +    ref[0] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
>>  err   +=  gen1[0] * ref[0];
>>  if (error)
>>  error[0] = err;
>> @@ -154,7 +163,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
>>  gen1[j] = gen1[j + 1] + ref[i - 1] * gen0[j];
>>  gen0[j] = gen1[j + 1] * ref[i - 1] + gen0[j];
>>  }
>> -        ref[i] = -gen1[0] / ((USE_FIXED || err) ? err : 1);
>> +        ref[i] = -gen1[0] / ((LPC_USE_FIXED || err) ? err : 1);
>>  err   +=  gen1[0] * ref[i];
>>  if (error)
>>  error[i] = err;
>> @@ -165,7 +174,7 @@ static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
>>  * Levinson-Durbin recursion.
>>  * Produce LPC coefficients from autocorrelation data.
>>  */
>> -static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_order,
>> +static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
>>  LPC_TYPE *lpc, int lpc_stride, int fail,
>>  int normalize)
>>  {
>> @@ -182,7 +191,7 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
>>  return -1;
>>  
>>  for(i=0; i<max_order; i++) {
>> -        LPC_TYPE r = AAC_SRA_R(-autoc[i], 5);
>> +        LPC_TYPE r = LPC_SRA_R(-autoc[i], 5);
>>  
>>  if (normalize) {
>>  for(j=0; j<i; j++)
>> @@ -190,7 +199,7 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
>>  
>>  if (err)
>>  r /= err;
>> -            err *= FIXR(1.0) - (r * r);
>> +            err *= LPC_FIXR(1.0) - (r * r);
>>  }
>>  
>>  lpc[i] = r;
>> @@ -198,8 +207,8 @@ static inline int AAC_RENAME(compute_lpc_coefs)(const LPC_TYPE *autoc, int max_o
>>  for(j=0; j < (i+1)>>1; j++) {
>>  LPC_TYPE f = lpc_last[    j];
>>  LPC_TYPE b = lpc_last[i-1-j];
>> -            lpc[    j] = f + (LPC_TYPE_U)AAC_MUL26(r, b);
>> -            lpc[i-1-j] = b + (LPC_TYPE_U)AAC_MUL26(r, f);
>> +            lpc[    j] = f + (LPC_TYPE_U)LPC_MUL26(r, b);
>> +            lpc[i-1-j] = b + (LPC_TYPE_U)LPC_MUL26(r, f);
>>  }
>>  
>>  if (fail && err < 0)
>>
>
> Will apply this patchset tomorrow unless there are objections.
>

Patchset LGTM
Thanks
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-03 21:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-01  3:04 [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 2/4] avcodec/lpc: Split inline functions into a header of their own Andreas Rheinhardt
2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 3/4] avcodec/aacdec: Move buffer to reduce padding Andreas Rheinhardt
2024-03-01  3:08 ` [FFmpeg-devel] [PATCH 4/4] avcodec/aactab: Deduplicate ltp_coef and tns_tmp2_map tables Andreas Rheinhardt
2024-03-03 18:45 ` [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly Andreas Rheinhardt
2024-03-03 21:44   ` Lynne

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git