1
0
Fork 0

avcodec/lpc: Don't use AAC defines directly

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

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-02-29 18:40:11 +01:00
parent 0aaee4741c
commit 08aa791d20
4 changed files with 29 additions and 13 deletions

View File

@ -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 */

View File

@ -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"

View File

@ -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)];

View File

@ -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)