FFmpeg
mpegaudiodsp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Mans Rullgard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "config.h"
22 #include "libavutil/attributes.h"
23 #include "libavutil/thread.h"
24 #include "mpegaudio.h"
25 #include "mpegaudiodsp.h"
26 #include "dct32.h"
27 
29 
30 static av_cold void mpadsp_init_tabs(void)
31 {
32  int i, j;
33  /* compute mdct windows */
34  for (i = 0; i < 36; i++) {
35  for (j = 0; j < 4; j++) {
36  double d;
37 
38  if (j == 2 && i % 3 != 1)
39  continue;
40 
41  d = sin(M_PI * (i + 0.5) / 36.0);
42  if (j == 1) {
43  if (i >= 30) d = 0;
44  else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0);
45  else if (i >= 18) d = 1;
46  } else if (j == 3) {
47  if (i < 6) d = 0;
48  else if (i < 12) d = sin(M_PI * (i - 6 + 0.5) / 12.0);
49  else if (i < 18) d = 1;
50  }
51  //merge last stage of imdct into the window coefficients
52  d *= 0.5 * IMDCT_SCALAR / cos(M_PI * (2 * i + 19) / 72);
53 
54  if (j == 2) {
55  ff_mdct_win_float[j][i/3] = d / (1 << 5);
56  ff_mdct_win_fixed[j][i/3] = d / (1 << 5) * (1LL << 32) + 0.5;
57  } else {
58  int idx = i < 18 ? i : i + (MDCT_BUF_SIZE/2 - 18);
59  ff_mdct_win_float[j][idx] = d / (1 << 5);
60  ff_mdct_win_fixed[j][idx] = d / (1 << 5) * (1LL << 32) + 0.5;
61  }
62  }
63  }
64 
65  /* NOTE: we do frequency inversion after the MDCT by changing
66  the sign of the right window coefs */
67  for (j = 0; j < 4; j++) {
68  for (i = 0; i < MDCT_BUF_SIZE; i += 2) {
69  ff_mdct_win_float[j + 4][i ] = ff_mdct_win_float[j][i ];
70  ff_mdct_win_float[j + 4][i + 1] = -ff_mdct_win_float[j][i + 1];
71  ff_mdct_win_fixed[j + 4][i ] = ff_mdct_win_fixed[j][i ];
72  ff_mdct_win_fixed[j + 4][i + 1] = -ff_mdct_win_fixed[j][i + 1];
73  }
74  }
75 
76 #if ARCH_X86
78 #endif
79 }
80 
82 {
84 
85  s->apply_window_float = ff_mpadsp_apply_window_float;
86  s->apply_window_fixed = ff_mpadsp_apply_window_fixed;
87 
88  s->dct32_float = ff_dct32_float;
89  s->dct32_fixed = ff_dct32_fixed;
90 
91  s->imdct36_blocks_float = ff_imdct36_blocks_float;
92  s->imdct36_blocks_fixed = ff_imdct36_blocks_fixed;
93 
94 #if ARCH_AARCH64
96 #elif ARCH_ARM
98 #elif ARCH_PPC
100 #elif ARCH_X86
102 #endif
103 #if HAVE_MIPSFPU
105 #endif
106 #if HAVE_MIPSDSP
108 #endif
109 }
mpadsp_table_init
static AVOnce mpadsp_table_init
Definition: mpegaudiodsp.c:28
ff_imdct36_blocks_float
void ff_imdct36_blocks_float(float *out, float *buf, float *in, int count, int switch_point, int block_type)
ff_mdct_win_fixed
int ff_mdct_win_fixed[8][MDCT_BUF_SIZE]
thread.h
IMDCT_SCALAR
#define IMDCT_SCALAR
Definition: mpegaudio.h:56
ff_mpadsp_init
av_cold void ff_mpadsp_init(MPADSPContext *s)
Definition: mpegaudiodsp.c:81
ff_mpadsp_init_mipsdsp
void ff_mpadsp_init_mipsdsp(MPADSPContext *s)
Definition: mpegaudiodsp_mips_fixed.c:911
MPADSPContext
Definition: mpegaudiodsp.h:27
ff_mpadsp_init_x86
av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
Definition: mpegaudiodsp.c:259
ff_dct32_fixed
void ff_dct32_fixed(int *dst, const int *src)
ff_mpadsp_apply_window_float
void ff_mpadsp_apply_window_float(float *synth_buf, float *window, int *dither_state, float *samples, ptrdiff_t incr)
ff_thread_once
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:203
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_imdct36_blocks_fixed
void ff_imdct36_blocks_fixed(int *out, int *buf, int *in, int count, int switch_point, int block_type)
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:201
ff_mpadsp_init_arm
av_cold void ff_mpadsp_init_arm(MPADSPContext *s)
Definition: mpegaudiodsp_init_arm.c:31
dct32.h
AVOnce
#define AVOnce
Definition: thread.h:200
ff_mpadsp_apply_window_fixed
void ff_mpadsp_apply_window_fixed(int32_t *synth_buf, int32_t *window, int *dither_state, int16_t *samples, ptrdiff_t incr)
mpadsp_init_tabs
static av_cold void mpadsp_init_tabs(void)
Definition: mpegaudiodsp.c:30
attributes.h
M_PI
#define M_PI
Definition: mathematics.h:67
ff_mpadsp_init_aarch64
av_cold void ff_mpadsp_init_aarch64(MPADSPContext *s)
Definition: mpegaudiodsp_init.c:32
ff_dct32_float
void ff_dct32_float(float *dst, const float *src)
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
mpegaudio.h
ff_mpadsp_init_mipsfpu
void ff_mpadsp_init_mipsfpu(MPADSPContext *s)
Definition: mpegaudiodsp_mips_float.c:1249
ff_mpadsp_init_x86_tabs
av_cold void ff_mpadsp_init_x86_tabs(void)
Definition: mpegaudiodsp.c:242
mpegaudiodsp.h
MDCT_BUF_SIZE
#define MDCT_BUF_SIZE
For SSE implementation, MDCT_BUF_SIZE/2 should be 128-bit aligned.
Definition: mpegaudiodsp.h:87
ff_mpadsp_init_ppc
void ff_mpadsp_init_ppc(MPADSPContext *s)
Definition: mpegaudiodsp_altivec.c:136
ff_mdct_win_float
float ff_mdct_win_float[8][MDCT_BUF_SIZE]
d
d
Definition: ffmpeg_filter.c:368