From: Lynne <dev@lynne.ee>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/4] avcodec/lpc: Don't use AAC defines directly
Date: Sun, 3 Mar 2024 22:44:55 +0100 (CET)
Message-ID: <Ns5Gitu--3-9@lynne.ee> (raw)
In-Reply-To: <AS8P250MB07446F5F20BA28B9B5802A928F5C2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
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".
prev parent reply other threads:[~2024-03-03 21:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ns5Gitu--3-9@lynne.ee \
--to=dev@lynne.ee \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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