mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
avcodec: Template creation for AAC decoder (SBR-module)
Move the existing code to a new template file. Signed-off-by: Nedeljko Babic <nedeljko.babic@imgtec.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
a927aacbe6
commit
5499467d5d
1428
libavcodec/aacsbr.c
1428
libavcodec/aacsbr.c
File diff suppressed because it is too large
Load Diff
@ -33,6 +33,51 @@
|
||||
#include "aac.h"
|
||||
#include "sbr.h"
|
||||
|
||||
#define ENVELOPE_ADJUSTMENT_OFFSET 2
|
||||
#define NOISE_FLOOR_OFFSET FIXR(6.0f)
|
||||
|
||||
/**
|
||||
* SBR VLC tables
|
||||
*/
|
||||
enum {
|
||||
T_HUFFMAN_ENV_1_5DB,
|
||||
F_HUFFMAN_ENV_1_5DB,
|
||||
T_HUFFMAN_ENV_BAL_1_5DB,
|
||||
F_HUFFMAN_ENV_BAL_1_5DB,
|
||||
T_HUFFMAN_ENV_3_0DB,
|
||||
F_HUFFMAN_ENV_3_0DB,
|
||||
T_HUFFMAN_ENV_BAL_3_0DB,
|
||||
F_HUFFMAN_ENV_BAL_3_0DB,
|
||||
T_HUFFMAN_NOISE_3_0DB,
|
||||
T_HUFFMAN_NOISE_BAL_3_0DB,
|
||||
};
|
||||
|
||||
/**
|
||||
* bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98)
|
||||
*/
|
||||
enum {
|
||||
FIXFIX,
|
||||
FIXVAR,
|
||||
VARFIX,
|
||||
VARVAR,
|
||||
};
|
||||
|
||||
enum {
|
||||
EXTENSION_ID_PS = 2,
|
||||
};
|
||||
|
||||
static const int8_t vlc_sbr_lav[10] =
|
||||
{ 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 };
|
||||
|
||||
#define SBR_INIT_VLC_STATIC(num, size) \
|
||||
INIT_VLC_STATIC(&vlc_sbr[num], 9, sbr_tmp[num].table_size / sbr_tmp[num].elem_size, \
|
||||
sbr_tmp[num].sbr_bits , 1, 1, \
|
||||
sbr_tmp[num].sbr_codes, sbr_tmp[num].elem_size, sbr_tmp[num].elem_size, \
|
||||
size)
|
||||
|
||||
#define SBR_VLC_ROW(name) \
|
||||
{ name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
|
||||
|
||||
/** Initialize SBR. */
|
||||
void ff_aac_sbr_init(void);
|
||||
/** Initialize one SBR context. */
|
||||
|
1410
libavcodec/aacsbr_template.c
Normal file
1410
libavcodec/aacsbr_template.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -25,15 +25,6 @@
|
||||
#include "libavutil/intfloat.h"
|
||||
#include "sbrdsp.h"
|
||||
|
||||
static void sbr_sum64x5_c(float *z)
|
||||
{
|
||||
int k;
|
||||
for (k = 0; k < 64; k++) {
|
||||
float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256];
|
||||
z[k] = f;
|
||||
}
|
||||
}
|
||||
|
||||
static float sbr_sum_square_c(float (*x)[2], int n)
|
||||
{
|
||||
float sum0 = 0.0f, sum1 = 0.0f;
|
||||
@ -101,16 +92,6 @@ static void sbr_qmf_deint_neg_c(float *v, const float *src)
|
||||
}
|
||||
}
|
||||
|
||||
static void sbr_qmf_deint_bfly_c(float *v, const float *src0, const float *src1)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 64; i++) {
|
||||
v[ i] = src0[i] - src1[63 - i];
|
||||
v[127 - i] = src0[i] + src1[63 - i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* This code is slower because it multiplies memory accesses.
|
||||
* It is left for educational purposes and because it may offer
|
||||
@ -238,58 +219,4 @@ static av_always_inline void sbr_hf_apply_noise(float (*Y)[2],
|
||||
}
|
||||
}
|
||||
|
||||
static void sbr_hf_apply_noise_0(float (*Y)[2], const float *s_m,
|
||||
const float *q_filt, int noise,
|
||||
int kx, int m_max)
|
||||
{
|
||||
sbr_hf_apply_noise(Y, s_m, q_filt, noise, 1.0, 0.0, m_max);
|
||||
}
|
||||
|
||||
static void sbr_hf_apply_noise_1(float (*Y)[2], const float *s_m,
|
||||
const float *q_filt, int noise,
|
||||
int kx, int m_max)
|
||||
{
|
||||
float phi_sign = 1 - 2 * (kx & 1);
|
||||
sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, phi_sign, m_max);
|
||||
}
|
||||
|
||||
static void sbr_hf_apply_noise_2(float (*Y)[2], const float *s_m,
|
||||
const float *q_filt, int noise,
|
||||
int kx, int m_max)
|
||||
{
|
||||
sbr_hf_apply_noise(Y, s_m, q_filt, noise, -1.0, 0.0, m_max);
|
||||
}
|
||||
|
||||
static void sbr_hf_apply_noise_3(float (*Y)[2], const float *s_m,
|
||||
const float *q_filt, int noise,
|
||||
int kx, int m_max)
|
||||
{
|
||||
float phi_sign = 1 - 2 * (kx & 1);
|
||||
sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, -phi_sign, m_max);
|
||||
}
|
||||
|
||||
av_cold void ff_sbrdsp_init(SBRDSPContext *s)
|
||||
{
|
||||
s->sum64x5 = sbr_sum64x5_c;
|
||||
s->sum_square = sbr_sum_square_c;
|
||||
s->neg_odd_64 = sbr_neg_odd_64_c;
|
||||
s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_c;
|
||||
s->qmf_post_shuffle = sbr_qmf_post_shuffle_c;
|
||||
s->qmf_deint_neg = sbr_qmf_deint_neg_c;
|
||||
s->qmf_deint_bfly = sbr_qmf_deint_bfly_c;
|
||||
s->autocorrelate = sbr_autocorrelate_c;
|
||||
s->hf_gen = sbr_hf_gen_c;
|
||||
s->hf_g_filt = sbr_hf_g_filt_c;
|
||||
|
||||
s->hf_apply_noise[0] = sbr_hf_apply_noise_0;
|
||||
s->hf_apply_noise[1] = sbr_hf_apply_noise_1;
|
||||
s->hf_apply_noise[2] = sbr_hf_apply_noise_2;
|
||||
s->hf_apply_noise[3] = sbr_hf_apply_noise_3;
|
||||
|
||||
if (ARCH_ARM)
|
||||
ff_sbrdsp_init_arm(s);
|
||||
if (ARCH_X86)
|
||||
ff_sbrdsp_init_x86(s);
|
||||
if (ARCH_MIPS)
|
||||
ff_sbrdsp_init_mips(s);
|
||||
}
|
||||
#include "sbrdsp_template.c"
|
||||
|
95
libavcodec/sbrdsp_template.c
Normal file
95
libavcodec/sbrdsp_template.c
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* AAC Spectral Band Replication decoding functions
|
||||
* Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
|
||||
* Copyright (c) 2009-2010 Alex Converse <alex.converse@gmail.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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.
|
||||
*
|
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
static void sbr_sum64x5_c(float *z)
|
||||
{
|
||||
int k;
|
||||
for (k = 0; k < 64; k++) {
|
||||
float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256];
|
||||
z[k] = f;
|
||||
}
|
||||
}
|
||||
|
||||
static void sbr_qmf_deint_bfly_c(float *v, const float *src0, const float *src1)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 64; i++) {
|
||||
v[ i] = src0[i] - src1[63 - i];
|
||||
v[127 - i] = src0[i] + src1[63 - i];
|
||||
}
|
||||
}
|
||||
|
||||
static void sbr_hf_apply_noise_0(float (*Y)[2], const float *s_m,
|
||||
const float *q_filt, int noise,
|
||||
int kx, int m_max)
|
||||
{
|
||||
sbr_hf_apply_noise(Y, s_m, q_filt, noise, 1.0, 0.0, m_max);
|
||||
}
|
||||
|
||||
static void sbr_hf_apply_noise_1(float (*Y)[2], const float *s_m,
|
||||
const float *q_filt, int noise,
|
||||
int kx, int m_max)
|
||||
{
|
||||
float phi_sign = 1 - 2 * (kx & 1);
|
||||
sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, phi_sign, m_max);
|
||||
}
|
||||
|
||||
static void sbr_hf_apply_noise_2(float (*Y)[2], const float *s_m,
|
||||
const float *q_filt, int noise,
|
||||
int kx, int m_max)
|
||||
{
|
||||
sbr_hf_apply_noise(Y, s_m, q_filt, noise, -1.0, 0.0, m_max);
|
||||
}
|
||||
|
||||
static void sbr_hf_apply_noise_3(float (*Y)[2], const float *s_m,
|
||||
const float *q_filt, int noise,
|
||||
int kx, int m_max)
|
||||
{
|
||||
float phi_sign = 1 - 2 * (kx & 1);
|
||||
sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, -phi_sign, m_max);
|
||||
}
|
||||
|
||||
av_cold void ff_sbrdsp_init(SBRDSPContext *s)
|
||||
{
|
||||
s->sum64x5 = sbr_sum64x5_c;
|
||||
s->sum_square = sbr_sum_square_c;
|
||||
s->neg_odd_64 = sbr_neg_odd_64_c;
|
||||
s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_c;
|
||||
s->qmf_post_shuffle = sbr_qmf_post_shuffle_c;
|
||||
s->qmf_deint_neg = sbr_qmf_deint_neg_c;
|
||||
s->qmf_deint_bfly = sbr_qmf_deint_bfly_c;
|
||||
s->autocorrelate = sbr_autocorrelate_c;
|
||||
s->hf_gen = sbr_hf_gen_c;
|
||||
s->hf_g_filt = sbr_hf_g_filt_c;
|
||||
|
||||
s->hf_apply_noise[0] = sbr_hf_apply_noise_0;
|
||||
s->hf_apply_noise[1] = sbr_hf_apply_noise_1;
|
||||
s->hf_apply_noise[2] = sbr_hf_apply_noise_2;
|
||||
s->hf_apply_noise[3] = sbr_hf_apply_noise_3;
|
||||
|
||||
if (ARCH_ARM)
|
||||
ff_sbrdsp_init_arm(s);
|
||||
if (ARCH_X86)
|
||||
ff_sbrdsp_init_x86(s);
|
||||
if (ARCH_MIPS)
|
||||
ff_sbrdsp_init_mips(s);
|
||||
}
|
Loading…
Reference in New Issue
Block a user