Revision a45fbda9

View differences:

libavcodec/Makefile
49 49
OBJS-$(CONFIG_A64MULTI_ENCODER)        += a64multienc.o elbg.o
50 50
OBJS-$(CONFIG_A64MULTI5_ENCODER)       += a64multienc.o elbg.o
51 51
OBJS-$(CONFIG_AAC_DECODER)             += aacdec.o aactab.o aacsbr.o aacps.o \
52
                                          aacadtsdec.o mpeg4audio.o
52
                                          aacadtsdec.o mpeg4audio.o kbdwin.o
53 53
OBJS-$(CONFIG_AAC_ENCODER)             += aacenc.o aaccoder.o    \
54 54
                                          aacpsy.o aactab.o      \
55 55
                                          psymodel.o iirfilter.o \
56
                                          mpeg4audio.o
56
                                          mpeg4audio.o kbdwin.o
57 57
OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
58 58
OBJS-$(CONFIG_AC3_DECODER)             += ac3dec.o ac3dec_data.o ac3.o
59
OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3tab.o ac3.o
59
OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc_float.o ac3tab.o ac3.o kbdwin.o
60 60
OBJS-$(CONFIG_AC3_FIXED_ENCODER)       += ac3enc_fixed.o ac3tab.o ac3.o
61 61
OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
62 62
OBJS-$(CONFIG_ALAC_ENCODER)            += alacenc.o
libavcodec/aacdec.c
87 87
#include "fft.h"
88 88
#include "fmtconvert.h"
89 89
#include "lpc.h"
90
#include "kbdwin.h"
90 91

  
91 92
#include "aac.h"
92 93
#include "aactab.h"
libavcodec/aacenc.c
34 34
#include "put_bits.h"
35 35
#include "dsputil.h"
36 36
#include "mpeg4audio.h"
37
#include "kbdwin.h"
37 38

  
38 39
#include "aac.h"
39 40
#include "aactab.h"
libavcodec/ac3dec.c
35 35
#include "ac3_parser.h"
36 36
#include "ac3dec.h"
37 37
#include "ac3dec_data.h"
38
#include "kbdwin.h"
38 39

  
39 40
/** Large enough for maximum possible frame size when the specification limit is ignored */
40 41
#define AC3_FRAME_BUFFER_SIZE 32768
libavcodec/ac3enc_float.c
28 28

  
29 29
#define CONFIG_AC3ENC_FLOAT 1
30 30
#include "ac3enc.c"
31
#include "kbdwin.h"
31 32

  
32 33

  
33 34
/**
libavcodec/fft.h
125 125
void ff_fft_end(FFTContext *s);
126 126

  
127 127
/**
128
 * Maximum window size for ff_kbd_window_init.
129
 */
130
#define FF_KBD_WINDOW_MAX 1024
131

  
132
/**
133
 * Generate a Kaiser-Bessel Derived Window.
134
 * @param   window  pointer to half window
135
 * @param   alpha   determines window shape
136
 * @param   n       size of half window, max FF_KBD_WINDOW_MAX
137
 */
138
void ff_kbd_window_init(float *window, float alpha, int n);
139

  
140
/**
141 128
 * Generate a sine window.
142 129
 * @param   window  pointer to half window
143 130
 * @param   n       size of half window
libavcodec/kbdwin.c
1
/*
2
 * This file is part of Libav.
3
 *
4
 * Libav is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * Libav is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with Libav; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 */
18

  
19
#include <assert.h>
20
#include <libavutil/mathematics.h>
21
#include "libavutil/attributes.h"
22
#include "kbdwin.h"
23

  
24
#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
25

  
26
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
27
{
28
   int i, j;
29
   double sum = 0.0, bessel, tmp;
30
   double local_window[FF_KBD_WINDOW_MAX];
31
   double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
32

  
33
   assert(n <= FF_KBD_WINDOW_MAX);
34

  
35
   for (i = 0; i < n; i++) {
36
       tmp = i * (n - i) * alpha2;
37
       bessel = 1.0;
38
       for (j = BESSEL_I0_ITER; j > 0; j--)
39
           bessel = bessel * tmp / (j * j) + 1;
40
       sum += bessel;
41
       local_window[i] = sum;
42
   }
43

  
44
   sum++;
45
   for (i = 0; i < n; i++)
46
       window[i] = sqrt(local_window[i] / sum);
47
}
48

  
libavcodec/kbdwin.h
1
/*
2
 * This file is part of Libav.
3
 *
4
 * Libav is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * Libav is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with Libav; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 */
18

  
19
#ifndef AVCODEC_KBDWIN_H
20
#define AVCODEC_KBDWIN_H
21

  
22
/**
23
 * Maximum window size for ff_kbd_window_init.
24
 */
25
#define FF_KBD_WINDOW_MAX 1024
26

  
27
/**
28
 * Generate a Kaiser-Bessel Derived Window.
29
 * @param   window  pointer to half window
30
 * @param   alpha   determines window shape
31
 * @param   n       size of half window, max FF_KBD_WINDOW_MAX
32
 */
33
void ff_kbd_window_init(float *window, float alpha, int n);
34

  
35
#endif
libavcodec/mdct.c
30 30
 * MDCT/IMDCT transforms.
31 31
 */
32 32

  
33
// Generate a Kaiser-Bessel Derived Window.
34
#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
35
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
36
{
37
   int i, j;
38
   double sum = 0.0, bessel, tmp;
39
   double local_window[FF_KBD_WINDOW_MAX];
40
   double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
41

  
42
   assert(n <= FF_KBD_WINDOW_MAX);
43

  
44
   for (i = 0; i < n; i++) {
45
       tmp = i * (n - i) * alpha2;
46
       bessel = 1.0;
47
       for (j = BESSEL_I0_ITER; j > 0; j--)
48
           bessel = bessel * tmp / (j * j) + 1;
49
       sum += bessel;
50
       local_window[i] = sum;
51
   }
52

  
53
   sum++;
54
   for (i = 0; i < n; i++)
55
       window[i] = sqrt(local_window[i] / sum);
56
}
57

  
58 33
#include "mdct_tablegen.h"
59 34

  
60 35
/**

Also available in: Unified diff