Commit 696e34a6 authored by Nedeljko Babic's avatar Nedeljko Babic Committed by Michael Niedermayer

libavcodec: Implementation of AC3 fixedpoint decoder

Signed-off-by: 's avatarNedeljko Babic <nbabic@mips.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent d506deae
...@@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, ...@@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest. releases are sorted from youngest to oldest.
version <next>: version <next>:
- added AC3 fixed-point decoding
- shuffleplanes filter - shuffleplanes filter
- subfile protocol - subfile protocol
- Phantom Cine demuxer - Phantom Cine demuxer
......
...@@ -1951,6 +1951,7 @@ aac_decoder_select="mdct sinewin" ...@@ -1951,6 +1951,7 @@ aac_decoder_select="mdct sinewin"
aac_encoder_select="audio_frame_queue mdct sinewin" aac_encoder_select="audio_frame_queue mdct sinewin"
aac_latm_decoder_select="aac_decoder aac_latm_parser" aac_latm_decoder_select="aac_decoder aac_latm_parser"
ac3_decoder_select="mdct ac3dsp ac3_parser dsputil" ac3_decoder_select="mdct ac3dsp ac3_parser dsputil"
ac3_fixed_decoder_select="mdct ac3dsp ac3_parser dsputil"
ac3_encoder_select="mdct ac3dsp dsputil" ac3_encoder_select="mdct ac3dsp dsputil"
ac3_fixed_encoder_select="mdct ac3dsp dsputil" ac3_fixed_encoder_select="mdct ac3dsp dsputil"
aic_decoder_select="dsputil golomb" aic_decoder_select="dsputil golomb"
......
...@@ -820,7 +820,7 @@ following image formats are supported: ...@@ -820,7 +820,7 @@ following image formats are supported:
@tab encoding supported through external library libaacplus @tab encoding supported through external library libaacplus
@item AAC @tab E @tab X @item AAC @tab E @tab X
@tab encoding supported through external library libfaac and libvo-aacenc @tab encoding supported through external library libfaac and libvo-aacenc
@item AC-3 @tab IX @tab X @item AC-3 @tab IX @tab IX
@item ADPCM 4X Movie @tab @tab X @item ADPCM 4X Movie @tab @tab X
@item ADPCM CDROM XA @tab @tab X @item ADPCM CDROM XA @tab @tab X
@item ADPCM Creative Technology @tab @tab X @item ADPCM Creative Technology @tab @tab X
......
...@@ -94,7 +94,8 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ ...@@ -94,7 +94,8 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
psymodel.o iirfilter.o \ psymodel.o iirfilter.o \
mpeg4audio.o kbdwin.o mpeg4audio.o kbdwin.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o kbdwin.o OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o kbdwin.o
OBJS-$(CONFIG_AC3_FIXED_DECODER) += ac3dec_fixed.o ac3dec_data.o ac3.o kbdwin.o
OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3enc.o ac3tab.o \ OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3enc.o ac3tab.o \
ac3.o kbdwin.o ac3.o kbdwin.o
OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o
......
...@@ -51,6 +51,52 @@ ...@@ -51,6 +51,52 @@
#define EXP_D25 2 #define EXP_D25 2
#define EXP_D45 3 #define EXP_D45 3
#ifndef CONFIG_AC3_FIXED
#define CONFIG_AC3_FIXED 0
#endif
#if CONFIG_AC3_FIXED
#define FFT_FLOAT 0
#define FIXR(a) ((int)((a) * 0 + 0.5))
#define FIXR12(a) ((int)((a) * 4096 + 0.5))
#define FIXR15(a) ((int)((a) * 32768 + 0.5))
#define ROUND15(x) ((x) + 16384) >> 15
#define AC3_RENAME(x) x ## _fixed
#define AC3_NORM(norm) (1<<24)/(norm)
#define AC3_MUL(a,b) ((((int64_t) (a)) * (b))>>12)
#define AC3_RANGE(x) (x)
#define AC3_DYNAMIC_RANGE(x) (x)
#define AC3_SPX_BLEND(x) (x)
#define AC3_DYNAMIC_RANGE1 0
#define INTFLOAT int
#define SHORTFLOAT int16_t
#else /* CONFIG_AC3_FIXED */
#define FIXR(x) ((float)(x))
#define FIXR12(x) ((float)(x))
#define FIXR15(x) ((float)(x))
#define ROUND15(x) (x)
#define AC3_RENAME(x) x
#define AC3_NORM(norm) (1.0f/(norm))
#define AC3_MUL(a,b) ((a) * (b))
#define AC3_RANGE(x) (dynamic_range_tab[(x)])
#define AC3_DYNAMIC_RANGE(x) (powf(x, s->drc_scale))
#define AC3_SPX_BLEND(x) (x)* (1.0f/32)
#define AC3_DYNAMIC_RANGE1 1.0f
#define INTFLOAT float
#define SHORTFLOAT float
#endif /* CONFIG_AC3_FIXED */
#define AC3_LEVEL(x) ROUND15((x) * FIXR15(0.7071067811865476))
/* pre-defined gain values */ /* pre-defined gain values */
#define LEVEL_PLUS_3DB 1.4142135623730950 #define LEVEL_PLUS_3DB 1.4142135623730950
#define LEVEL_PLUS_1POINT5DB 1.1892071150027209 #define LEVEL_PLUS_1POINT5DB 1.1892071150027209
......
This diff is collapsed.
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#define AVCODEC_AC3DEC_H #define AVCODEC_AC3DEC_H
#include "libavutil/float_dsp.h" #include "libavutil/float_dsp.h"
#include "libavutil/fixed_dsp.h"
#include "libavutil/lfg.h" #include "libavutil/lfg.h"
#include "ac3.h" #include "ac3.h"
#include "ac3dsp.h" #include "ac3dsp.h"
...@@ -138,8 +139,8 @@ typedef struct AC3DecodeContext { ...@@ -138,8 +139,8 @@ typedef struct AC3DecodeContext {
int num_spx_bands; ///< number of spx bands (nspxbnds) int num_spx_bands; ///< number of spx bands (nspxbnds)
uint8_t spx_band_sizes[SPX_MAX_BANDS]; ///< number of bins in each spx band uint8_t spx_band_sizes[SPX_MAX_BANDS]; ///< number of bins in each spx band
uint8_t first_spx_coords[AC3_MAX_CHANNELS]; ///< first spx coordinates states (firstspxcos) uint8_t first_spx_coords[AC3_MAX_CHANNELS]; ///< first spx coordinates states (firstspxcos)
float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; ///< spx noise blending factor (nblendfact) INTFLOAT spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; ///< spx noise blending factor (nblendfact)
float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact) INTFLOAT spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact)
///@} ///@}
///@name Adaptive hybrid transform ///@name Adaptive hybrid transform
...@@ -151,15 +152,15 @@ typedef struct AC3DecodeContext { ...@@ -151,15 +152,15 @@ typedef struct AC3DecodeContext {
int fbw_channels; ///< number of full-bandwidth channels int fbw_channels; ///< number of full-bandwidth channels
int channels; ///< number of total channels int channels; ///< number of total channels
int lfe_ch; ///< index of LFE channel int lfe_ch; ///< index of LFE channel
float downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients SHORTFLOAT downmix_coeffs[AC3_MAX_CHANNELS][2]; ///< stereo downmix coefficients
int downmixed; ///< indicates if coeffs are currently downmixed int downmixed; ///< indicates if coeffs are currently downmixed
int output_mode; ///< output channel configuration int output_mode; ///< output channel configuration
int out_channels; ///< number of output channels int out_channels; ///< number of output channels
///@} ///@}
///@name Dynamic range ///@name Dynamic range
float dynamic_range[2]; ///< dynamic range INTFLOAT dynamic_range[2]; ///< dynamic range
float drc_scale; ///< percentage of dynamic range compression to be applied INTFLOAT drc_scale; ///< percentage of dynamic range compression to be applied
///@} ///@}
///@name Bandwidth ///@name Bandwidth
...@@ -207,22 +208,26 @@ typedef struct AC3DecodeContext { ...@@ -207,22 +208,26 @@ typedef struct AC3DecodeContext {
///@name Optimization ///@name Optimization
DSPContext dsp; ///< for optimization DSPContext dsp; ///< for optimization
#if CONFIG_AC3_FIXED
AVFixedDSPContext *fdsp;
#else
AVFloatDSPContext fdsp; AVFloatDSPContext fdsp;
#endif
AC3DSPContext ac3dsp; AC3DSPContext ac3dsp;
FmtConvertContext fmt_conv; ///< optimized conversion functions FmtConvertContext fmt_conv; ///< optimized conversion functions
///@} ///@}
float *outptr[AC3_MAX_CHANNELS]; SHORTFLOAT *outptr[AC3_MAX_CHANNELS];
float *xcfptr[AC3_MAX_CHANNELS]; INTFLOAT *xcfptr[AC3_MAX_CHANNELS];
float *dlyptr[AC3_MAX_CHANNELS]; INTFLOAT *dlyptr[AC3_MAX_CHANNELS];
///@name Aligned arrays ///@name Aligned arrays
DECLARE_ALIGNED(16, int32_t, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients
DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients DECLARE_ALIGNED(32, INTFLOAT, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients
DECLARE_ALIGNED(32, float, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block DECLARE_ALIGNED(32, INTFLOAT, delay)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< delay - added to the next block
DECLARE_ALIGNED(32, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients DECLARE_ALIGNED(32, INTFLOAT, window)[AC3_BLOCK_SIZE]; ///< window coefficients
DECLARE_ALIGNED(32, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing DECLARE_ALIGNED(32, INTFLOAT, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing
DECLARE_ALIGNED(32, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing DECLARE_ALIGNED(32, SHORTFLOAT, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing
DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread DECLARE_ALIGNED(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread
///@} ///@}
} AC3DecodeContext; } AC3DecodeContext;
......
/*
* Copyright (c) 2012
* MIPS Technologies, Inc., California.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Stanislav Ocovaj (socovaj@mips.com)
*
* AC3 fixed-point decoder for MIPS platforms
*
* 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
*/
#define FFT_FLOAT 0
#define CONFIG_AC3_FIXED 1
#define FFT_FIXED_32 1
#include "ac3dec.h"
/**
* Table for center mix levels
* reference: Section 5.4.2.4 cmixlev
*/
static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
/**
* Table for surround mix levels
* reference: Section 5.4.2.5 surmixlev
*/
static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
int end_freq_inv_tab[8] =
{
50529027, 44278013, 39403370, 32292987, 27356480, 23729101, 20951060, 18755316
};
static void scale_coefs (
int32_t *dst,
const int32_t *src,
int dynrng,
int len)
{
int i, shift, round;
int16_t mul;
int temp, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
mul = (dynrng & 0x1f) + 0x20;
shift = 4 - ((dynrng << 24) >> 29);
round = 1 << (shift-1);
for (i=0; i<len; i+=8) {
temp = src[i] * mul;
temp1 = src[i+1] * mul;
temp = temp + round;
temp2 = src[i+2] * mul;
temp1 = temp1 + round;
dst[i] = temp >> shift;
temp3 = src[i+3] * mul;
temp2 = temp2 + round;
dst[i+1] = temp1 >> shift;
temp4 = src[i + 4] * mul;
temp3 = temp3 + round;
dst[i+2] = temp2 >> shift;
temp5 = src[i+5] * mul;
temp4 = temp4 + round;
dst[i+3] = temp3 >> shift;
temp6 = src[i+6] * mul;
dst[i+4] = temp4 >> shift;
temp5 = temp5 + round;
temp7 = src[i+7] * mul;
temp6 = temp6 + round;
dst[i+5] = temp5 >> shift;
temp7 = temp7 + round;
dst[i+6] = temp6 >> shift;
dst[i+7] = temp7 >> shift;
}
}
/**
* Downmix samples from original signal to stereo or mono (this is for 16-bit samples
* and fixed point decoder - original (for 32-bit samples) is in ac3dsp.c).
*/
static void ac3_downmix_c_fixed16(int16_t **samples, int16_t (*matrix)[2],
int out_ch, int in_ch, int len)
{
int i, j;
int v0, v1;
if (out_ch == 2) {
for (i = 0; i < len; i++) {
v0 = v1 = 0;
for (j = 0; j < in_ch; j++) {
v0 += samples[j][i] * matrix[j][0];
v1 += samples[j][i] * matrix[j][1];
}
samples[0][i] = (v0+2048)>>12;
samples[1][i] = (v1+2048)>>12;
}
} else if (out_ch == 1) {
for (i = 0; i < len; i++) {
v0 = 0;
for (j = 0; j < in_ch; j++)
v0 += samples[j][i] * matrix[j][0];
samples[0][i] = (v0+2048)>>12;
}
}
}
#include "ac3dec.c"
static const AVOption options[] = {
{ NULL},
};
static const AVClass ac3_decoder_class = {
.class_name = "Fixed-Point AC-3 Decoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_ac3_fixed_decoder = {
.name = "ac3_fixed",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_AC3,
.priv_data_size = sizeof (AC3DecodeContext),
.init = ac3_decode_init,
.close = ac3_decode_end,
.decode = ac3_decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_NONE },
.priv_class = &ac3_decoder_class,
};
/*
* AC-3 Audio Decoder
* This code was developed as part of Google Summer of Code 2006.
* E-AC-3 support was added as part of Google Summer of Code 2007.
*
* Copyright (c) 2006 Kartikey Mahendra BHATT (bhattkm at gmail dot com)
* Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
* Copyright (c) 2007 Justin Ruggles <justin.ruggles@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
*/
/**
* Upmix delay samples from stereo to original channel layout.
*/
#include "ac3dec.h"
#include "ac3dec.c"
static const AVOption options[] = {
{ "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0, PAR },
{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 2, 0, "dmix_mode"},
{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
{ NULL},
};
static const AVClass ac3_decoder_class = {
.class_name = "AC3 decoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_ac3_decoder = {
.name = "ac3",
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_AC3,
.priv_data_size = sizeof (AC3DecodeContext),
.init = ac3_decode_init,
.close = ac3_decode_end,
.decode = ac3_decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
.priv_class = &ac3_decoder_class,
};
#if CONFIG_EAC3_DECODER
static const AVClass eac3_decoder_class = {
.class_name = "E-AC3 decoder",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_eac3_decoder = {
.name = "eac3",
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_EAC3,
.priv_data_size = sizeof (AC3DecodeContext),
.init = ac3_decode_init,
.close = ac3_decode_end,
.decode = ac3_decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
.priv_class = &eac3_decoder_class,
};
#endif
...@@ -239,6 +239,31 @@ static void ac3_downmix_c(float **samples, float (*matrix)[2], ...@@ -239,6 +239,31 @@ static void ac3_downmix_c(float **samples, float (*matrix)[2],
} }
} }
static void ac3_downmix_c_fixed(int32_t **samples, int16_t (*matrix)[2],
int out_ch, int in_ch, int len)
{
int i, j;
int64_t v0, v1;
if (out_ch == 2) {
for (i = 0; i < len; i++) {
v0 = v1 = 0;
for (j = 0; j < in_ch; j++) {
v0 += (int64_t)samples[j][i] * matrix[j][0];
v1 += (int64_t)samples[j][i] * matrix[j][1];
}
samples[0][i] = (v0+2048)>>12;
samples[1][i] = (v1+2048)>>12;
}
} else if (out_ch == 1) {
for (i = 0; i < len; i++) {
v0 = 0;
for (j = 0; j < in_ch; j++)
v0 += (int64_t)samples[j][i] * matrix[j][0];
samples[0][i] = (v0+2048)>>12;
}
}
}
static void apply_window_int16_c(int16_t *output, const int16_t *input, static void apply_window_int16_c(int16_t *output, const int16_t *input,
const int16_t *window, unsigned int len) const int16_t *window, unsigned int len)
{ {
...@@ -266,6 +291,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact) ...@@ -266,6 +291,7 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
c->sum_square_butterfly_int32 = ac3_sum_square_butterfly_int32_c; c->sum_square_butterfly_int32 = ac3_sum_square_butterfly_int32_c;
c->sum_square_butterfly_float = ac3_sum_square_butterfly_float_c; c->sum_square_butterfly_float = ac3_sum_square_butterfly_float_c;
c->downmix = ac3_downmix_c; c->downmix = ac3_downmix_c;
c->downmix_fixed = ac3_downmix_c_fixed;
c->apply_window_int16 = apply_window_int16_c; c->apply_window_int16 = apply_window_int16_c;
if (ARCH_ARM) if (ARCH_ARM)
......
...@@ -135,6 +135,9 @@ typedef struct AC3DSPContext { ...@@ -135,6 +135,9 @@ typedef struct AC3DSPContext {
void (*downmix)(float **samples, float (*matrix)[2], int out_ch, void (*downmix)(float **samples, float (*matrix)[2], int out_ch,
int in_ch, int len); int in_ch, int len);
void (*downmix_fixed)(int32_t **samples, int16_t (*matrix)[2], int out_ch,
int in_ch, int len);
/** /**
* Apply symmetric window in 16-bit fixed-point. * Apply symmetric window in 16-bit fixed-point.
* @param output destination array * @param output destination array
......
...@@ -323,7 +323,7 @@ void avcodec_register_all(void) ...@@ -323,7 +323,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (AAC, aac); REGISTER_ENCDEC (AAC, aac);
REGISTER_DECODER(AAC_LATM, aac_latm); REGISTER_DECODER(AAC_LATM, aac_latm);
REGISTER_ENCDEC (AC3, ac3); REGISTER_ENCDEC (AC3, ac3);
REGISTER_ENCODER(AC3_FIXED, ac3_fixed); REGISTER_ENCDEC (AC3_FIXED, ac3_fixed);
REGISTER_ENCDEC (ALAC, alac); REGISTER_ENCDEC (ALAC, alac);
REGISTER_DECODER(ALS, als); REGISTER_DECODER(ALS, als);
REGISTER_DECODER(AMRNB, amrnb); REGISTER_DECODER(AMRNB, amrnb);
......
...@@ -45,3 +45,13 @@ av_cold void ff_kbd_window_init(float *window, float alpha, int n) ...@@ -45,3 +45,13 @@ av_cold void ff_kbd_window_init(float *window, float alpha, int n)
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
window[i] = sqrt(local_window[i] / sum); window[i] = sqrt(local_window[i] / sum);
} }
av_cold void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n)
{
int i;
float local_window[FF_KBD_WINDOW_MAX];
ff_kbd_window_init(local_window, alpha, n);
for (i = 0; i < n; i++)
window[i] = (int)floor(2147483647.0 * local_window[i] + 0.5);
}
...@@ -31,5 +31,6 @@ ...@@ -31,5 +31,6 @@
* @param n size of half window, max FF_KBD_WINDOW_MAX * @param n size of half window, max FF_KBD_WINDOW_MAX
*/ */
void ff_kbd_window_init(float *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 */ #endif /* AVCODEC_KBDWIN_H */
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "libavutil/version.h" #include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 55 #define LIBAVCODEC_VERSION_MAJOR 55
#define LIBAVCODEC_VERSION_MINOR 55 #define LIBAVCODEC_VERSION_MINOR 56
#define LIBAVCODEC_VERSION_MICRO 107 #define LIBAVCODEC_VERSION_MICRO 107
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment