1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Revert "avcodec: Rename ff_kbd_window_init() as it will be needed from outside libavcodec"

This reverts commits fd5aa93a37
and cf00f60bab
("avcodec/kbdwin: Support arbitrary sized windows").

The change in question has only been made for libavradio.
in anticipation of merging it into the main tree. This has
not happened, so this commit reverts the changes to kbdwin
that are not used for anything else. In particular, these
functions are no longer exported (as avpriv functions);
notice that the fixed-point function has been exported
despite having never been used outside of lavc.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-01-28 14:49:26 +01:00 committed by James Almer
parent 7b11fd585f
commit bb81c60927
8 changed files with 23 additions and 32 deletions

View File

@ -1126,8 +1126,8 @@ static av_cold void aac_static_table_init(void)
ff_aacdec_common_init_once();
// window initialization
AAC_RENAME(avpriv_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
AAC_RENAME(avpriv_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
#if !USE_FIXED
AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960);
@ -1135,8 +1135,8 @@ static av_cold void aac_static_table_init(void)
AAC_RENAME(ff_init_ff_sine_windows)(9);
ff_aac_float_common_init();
#else
AAC_RENAME(avpriv_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
AAC_RENAME(avpriv_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
init_sine_windows_fixed();
#endif

View File

@ -94,8 +94,8 @@ static av_cold void aac_float_common_init(void)
{
aac_tableinit();
avpriv_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
avpriv_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
ff_init_ff_sine_windows(10);
ff_init_ff_sine_windows(7);
}

View File

@ -220,7 +220,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
if ((ret = av_tx_init(&s->tx_256, &s->tx_fn_256, IMDCT_TYPE, 1, 256, &scale, 0)))
return ret;
AC3_RENAME(avpriv_kbd_window_init)(s->window, 5.0, 256);
AC3_RENAME(ff_kbd_window_init)(s->window, 5.0, 256);
ff_bswapdsp_init(&s->bdsp);
#if (USE_FIXED)

View File

@ -82,7 +82,7 @@ static av_cold int ac3_fixed_mdct_init(AC3EncodeContext *s)
if (!iwin)
return AVERROR(ENOMEM);
avpriv_kbd_window_init(fwin, 5.0, AC3_BLOCK_SIZE);
ff_kbd_window_init(fwin, 5.0, AC3_BLOCK_SIZE);
for (int i = 0; i < AC3_BLOCK_SIZE; i++)
iwin[i] = lrintf(fwin[i] * (1 << 22));

View File

@ -92,7 +92,7 @@ static av_cold int ac3_float_mdct_init(AC3EncodeContext *s)
return AVERROR(ENOMEM);
}
avpriv_kbd_window_init(window, 5.0, AC3_BLOCK_SIZE);
ff_kbd_window_init(window, 5.0, AC3_BLOCK_SIZE);
s->mdct_window = window;
return av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_MDCT, 0,

View File

@ -1200,7 +1200,7 @@ static av_cold void init_tables(void)
gain_tab[i] = exp2f((i - 960) / 64.0f);
// short 1
avpriv_kbd_window_init(window, 3.0f, 128);
ff_kbd_window_init(window, 3.0f, 128);
for (i = 0; i < 128; i++)
window[128 + i] = window[127 - i];
@ -1227,7 +1227,7 @@ static av_cold void init_tables(void)
window[1088 + i] = 1.0f;
// long
avpriv_kbd_window_init(window + 1408, 3.0f, 256);
ff_kbd_window_init(window + 1408, 3.0f, 256);
for (i = 0; i < 640; i++)
window[1664 + i] = 1.0f;
for (i = 0; i < 256; i++)

View File

@ -17,27 +17,23 @@
*/
#include "libavutil/avassert.h"
#include "libavutil/error.h"
#include "libavutil/libm.h"
#include "libavutil/mathematics.h"
#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#include "kbdwin.h"
av_cold static int kbd_window_init(float *float_window, int *int_window, float alpha, int n)
av_cold static void kbd_window_init(float *float_window, int *int_window, float alpha, int n)
{
int i;
double sum = 0.0, tmp;
double scale = 0.0;
double temp_small[FF_KBD_WINDOW_MAX / 2 + 1];
double *temp= n<=FF_KBD_WINDOW_MAX ? temp_small : av_malloc((n/2+1) * sizeof(*temp));
double temp[FF_KBD_WINDOW_MAX / 2 + 1];
double alpha2 = 4 * (alpha * M_PI / n) * (alpha * M_PI / n);
if (!temp)
return AVERROR(ENOMEM);
av_assert0(n <= FF_KBD_WINDOW_MAX);
for (i = 0; i <= n / 2; i++) {
tmp = alpha2 * i * (n - i);
tmp = i * (n - i) * alpha2;
temp[i] = av_bessel_i0(sqrt(tmp));
scale += temp[i] * (1 + (i && i<n/2));
}
@ -53,17 +49,14 @@ av_cold static int kbd_window_init(float *float_window, int *int_window, float a
if (float_window) float_window[i] = sqrt(sum * scale);
else int_window[i] = lrint(2147483647 * sqrt(sum * scale));
}
if (temp != temp_small)
av_free(temp);
return 0;
}
av_cold int avpriv_kbd_window_init(float *window, float alpha, int n)
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
{
return kbd_window_init(window, NULL, alpha, n);
kbd_window_init(window, NULL, alpha, n);
}
av_cold int avpriv_kbd_window_init_fixed(int32_t *window, float alpha, int n)
av_cold void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n)
{
return kbd_window_init(NULL, window, alpha, n);
kbd_window_init(NULL, window, alpha, n);
}

View File

@ -22,7 +22,7 @@
#include <stdint.h>
/**
* Maximum window size for avpriv_kbd_window_init.
* Maximum window size for ff_kbd_window_init.
*/
#define FF_KBD_WINDOW_MAX 1024
@ -30,11 +30,9 @@
* Generate a Kaiser-Bessel Derived Window.
* @param window pointer to half window
* @param alpha determines window shape
* @param n size of half window
*
* @return if n is larger than FF_KBD_WINDOW_MAX then AVERROR(ENOMEM) is possible
* @param n size of half window, max FF_KBD_WINDOW_MAX
*/
int avpriv_kbd_window_init(float *window, float alpha, int n);
int avpriv_kbd_window_init_fixed(int32_t *window, float alpha, int n);
void ff_kbd_window_init(float *window, float alpha, int n);
void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n);
#endif /* AVCODEC_KBDWIN_H */