Browse Source

Move ff_kbd_window_init() to a separate file

This function is not tightly coupled to mdct, and it's in the way
of making a fixed-point mdct implementation.

Signed-off-by: Mans Rullgard <mans@mansr.com>
tags/n0.8
Mans Rullgard 14 years ago
parent
commit
a45fbda994
9 changed files with 90 additions and 41 deletions
  1. +3
    -3
      libavcodec/Makefile
  2. +1
    -0
      libavcodec/aacdec.c
  3. +1
    -0
      libavcodec/aacenc.c
  4. +1
    -0
      libavcodec/ac3dec.c
  5. +1
    -0
      libavcodec/ac3enc_float.c
  6. +0
    -13
      libavcodec/fft.h
  7. +48
    -0
      libavcodec/kbdwin.c
  8. +35
    -0
      libavcodec/kbdwin.h
  9. +0
    -25
      libavcodec/mdct.c

+ 3
- 3
libavcodec/Makefile View File

@@ -49,14 +49,14 @@ OBJS-$(CONFIG_VDPAU) += vdpau.o
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \
aacadtsdec.o mpeg4audio.o
aacadtsdec.o mpeg4audio.o kbdwin.o
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
aacpsy.o aactab.o \
psymodel.o iirfilter.o \
mpeg4audio.o
mpeg4audio.o kbdwin.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o
OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o
OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o kbdwin.o
OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3tab.o ac3.o
OBJS-$(CONFIG_ALAC_DECODER) += alac.o
OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o


+ 1
- 0
libavcodec/aacdec.c View File

@@ -87,6 +87,7 @@
#include "fft.h"
#include "fmtconvert.h"
#include "lpc.h"
#include "kbdwin.h"

#include "aac.h"
#include "aactab.h"


+ 1
- 0
libavcodec/aacenc.c View File

@@ -34,6 +34,7 @@
#include "put_bits.h"
#include "dsputil.h"
#include "mpeg4audio.h"
#include "kbdwin.h"

#include "aac.h"
#include "aactab.h"


+ 1
- 0
libavcodec/ac3dec.c View File

@@ -35,6 +35,7 @@
#include "ac3_parser.h"
#include "ac3dec.h"
#include "ac3dec_data.h"
#include "kbdwin.h"

/** Large enough for maximum possible frame size when the specification limit is ignored */
#define AC3_FRAME_BUFFER_SIZE 32768


+ 1
- 0
libavcodec/ac3enc_float.c View File

@@ -28,6 +28,7 @@

#define CONFIG_AC3ENC_FLOAT 1
#include "ac3enc.c"
#include "kbdwin.h"


/**


+ 0
- 13
libavcodec/fft.h View File

@@ -124,19 +124,6 @@ void ff_dct_init_mmx(DCTContext *s);

void ff_fft_end(FFTContext *s);

/**
* Maximum window size for ff_kbd_window_init.
*/
#define FF_KBD_WINDOW_MAX 1024

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

/**
* Generate a sine window.
* @param window pointer to half window


+ 48
- 0
libavcodec/kbdwin.c View File

@@ -0,0 +1,48 @@
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <assert.h>
#include <libavutil/mathematics.h>
#include "libavutil/attributes.h"
#include "kbdwin.h"

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

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

assert(n <= FF_KBD_WINDOW_MAX);

for (i = 0; i < n; i++) {
tmp = i * (n - i) * alpha2;
bessel = 1.0;
for (j = BESSEL_I0_ITER; j > 0; j--)
bessel = bessel * tmp / (j * j) + 1;
sum += bessel;
local_window[i] = sum;
}

sum++;
for (i = 0; i < n; i++)
window[i] = sqrt(local_window[i] / sum);
}


+ 35
- 0
libavcodec/kbdwin.h View File

@@ -0,0 +1,35 @@
/*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef AVCODEC_KBDWIN_H
#define AVCODEC_KBDWIN_H

/**
* Maximum window size for ff_kbd_window_init.
*/
#define FF_KBD_WINDOW_MAX 1024

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

#endif

+ 0
- 25
libavcodec/mdct.c View File

@@ -30,31 +30,6 @@
* MDCT/IMDCT transforms.
*/

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

assert(n <= FF_KBD_WINDOW_MAX);

for (i = 0; i < n; i++) {
tmp = i * (n - i) * alpha2;
bessel = 1.0;
for (j = BESSEL_I0_ITER; j > 0; j--)
bessel = bessel * tmp / (j * j) + 1;
sum += bessel;
local_window[i] = sum;
}

sum++;
for (i = 0; i < n; i++)
window[i] = sqrt(local_window[i] / sum);
}

#include "mdct_tablegen.h"

/**


Loading…
Cancel
Save