This patch has seen testing for a couple of weeks in ubuntu maverick and debian/experimental w/o negative feedback so far. Originally committed as revision 24576 to svn://svn.ffmpeg.org/ffmpeg/branches/0.6tags/v0.6.1
@@ -43,7 +43,7 @@ OBJS-$(CONFIG_VAAPI) += vaapi.o | |||
OBJS-$(CONFIG_VDPAU) += vdpau.o | |||
# decoders/encoders/hardware accelerators | |||
OBJS-$(CONFIG_AAC_DECODER) += aac.o aactab.o aacsbr.o | |||
OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o | |||
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ | |||
aacpsy.o aactab.o \ | |||
psymodel.o iirfilter.o \ | |||
@@ -38,12 +38,6 @@ | |||
#include <stdint.h> | |||
#define AAC_INIT_VLC_STATIC(num, size) \ | |||
INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ | |||
ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \ | |||
ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \ | |||
size); | |||
#define MAX_CHANNELS 64 | |||
#define MAX_ELEM_ID 16 | |||
@@ -241,7 +235,7 @@ typedef struct { | |||
* main AAC context | |||
*/ | |||
typedef struct { | |||
AVCodecContext * avccontext; | |||
AVCodecContext *avctx; | |||
MPEG4AudioConfig m4ac; | |||
@@ -255,8 +249,9 @@ typedef struct { | |||
enum ChannelPosition che_pos[4][MAX_ELEM_ID]; /**< channel element channel mapping with the | |||
* first index as the first 4 raw data block types | |||
*/ | |||
ChannelElement * che[4][MAX_ELEM_ID]; | |||
ChannelElement * tag_che_map[4][MAX_ELEM_ID]; | |||
ChannelElement *che[4][MAX_ELEM_ID]; | |||
ChannelElement *tag_che_map[4][MAX_ELEM_ID]; | |||
uint8_t tags_seen_this_frame[4][MAX_ELEM_ID]; | |||
int tags_mapped; | |||
/** @} */ | |||
@@ -0,0 +1,39 @@ | |||
/* | |||
* Generate a header file for hardcoded AAC tables | |||
* | |||
* Copyright (c) 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 | |||
*/ | |||
#include <stdlib.h> | |||
#define CONFIG_HARDCODED_TABLES 0 | |||
#include "aac_tablegen.h" | |||
#include "tableprint.h" | |||
int main(void) | |||
{ | |||
ff_aac_tableinit(); | |||
write_fileheader(); | |||
printf("const float ff_aac_pow2sf_tab[428] = {\n"); | |||
write_float_array(ff_aac_pow2sf_tab, 428); | |||
printf("};\n"); | |||
return 0; | |||
} |
@@ -0,0 +1,42 @@ | |||
/* | |||
* Header file for hardcoded AAC tables | |||
* | |||
* Copyright (c) 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 | |||
*/ | |||
#ifndef AAC_TABLEGEN_H | |||
#define AAC_TABLEGEN_H | |||
#include "aac_tablegen_decl.h" | |||
#if CONFIG_HARDCODED_TABLES | |||
#include "libavcodec/aac_tables.h" | |||
#else | |||
#include "../libavutil/mathematics.h" | |||
float ff_aac_pow2sf_tab[428]; | |||
void ff_aac_tableinit(void) | |||
{ | |||
int i; | |||
for (i = 0; i < 428; i++) | |||
ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.); | |||
} | |||
#endif /* CONFIG_HARDCODED_TABLES */ | |||
#endif /* AAC_TABLEGEN_H */ |
@@ -0,0 +1,34 @@ | |||
/* | |||
* Header file for hardcoded AAC tables | |||
* | |||
* Copyright (c) 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 | |||
*/ | |||
#ifndef AAC_TABLEGEN_INIT_H | |||
#define AAC_TABLEGEN_INIT_H | |||
#if CONFIG_HARDCODED_TABLES | |||
#define ff_aac_tableinit() | |||
extern const float ff_aac_pow2sf_tab[428]; | |||
#else | |||
void ff_aac_tableinit(void); | |||
extern float ff_aac_pow2sf_tab[428]; | |||
#endif /* CONFIG_HARDCODED_TABLES */ | |||
#endif /* AAC_TABLEGEN_INIT_H */ |
@@ -67,7 +67,7 @@ | |||
* Y (not in this code) Layer-2 | |||
* Y (not in this code) Layer-3 | |||
* N SinuSoidal Coding (Transient, Sinusoid, Noise) | |||
* N (planned) Parametric Stereo | |||
* Y Parametric Stereo | |||
* N Direct Stream Transfer | |||
* | |||
* Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. | |||
@@ -113,6 +113,22 @@ static const char overread_err[] = "Input buffer exhausted before END element fo | |||
static ChannelElement *get_che(AACContext *ac, int type, int elem_id) | |||
{ | |||
/* Some buggy encoders appear to set all elem_ids to zero and rely on | |||
channels always occurring in the same order. This is expressly forbidden | |||
by the spec but we will try to work around it. | |||
*/ | |||
int err_printed = 0; | |||
while (ac->tags_seen_this_frame[type][elem_id] && elem_id < MAX_ELEM_ID) { | |||
if (ac->output_configured < OC_LOCKED && !err_printed) { | |||
av_log(ac->avctx, AV_LOG_WARNING, "Duplicate channel tag found, attempting to remap.\n"); | |||
err_printed = 1; | |||
} | |||
elem_id++; | |||
} | |||
if (elem_id == MAX_ELEM_ID) | |||
return NULL; | |||
ac->tags_seen_this_frame[type][elem_id] = 1; | |||
if (ac->tag_che_map[type][elem_id]) { | |||
return ac->tag_che_map[type][elem_id]; | |||
} | |||
@@ -127,8 +143,8 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id) | |||
} | |||
case 6: | |||
/* Some streams incorrectly code 5.1 audio as SCE[0] CPE[0] CPE[1] SCE[1] | |||
instead of SCE[0] CPE[0] CPE[0] LFE[0]. If we seem to have | |||
encountered such a stream, transfer the LFE[0] element to SCE[1] */ | |||
instead of SCE[0] CPE[0] CPE[1] LFE[0]. If we seem to have | |||
encountered such a stream, transfer the LFE[0] element to the SCE[1]'s mapping */ | |||
if (ac->tags_mapped == tags_per_config[ac->m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) { | |||
ac->tags_mapped++; | |||
return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0]; | |||
@@ -184,7 +200,8 @@ static av_cold int che_configure(AACContext *ac, | |||
ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr); | |||
if (type != TYPE_CCE) { | |||
ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret; | |||
if (type == TYPE_CPE) { | |||
if (type == TYPE_CPE || | |||
(type == TYPE_SCE && ac->m4ac.ps == 1)) { | |||
ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret; | |||
} | |||
} | |||
@@ -209,9 +226,10 @@ static av_cold int output_configure(AACContext *ac, | |||
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], | |||
int channel_config, enum OCStatus oc_type) | |||
{ | |||
AVCodecContext *avctx = ac->avccontext; | |||
AVCodecContext *avctx = ac->avctx; | |||
int i, type, channels = 0, ret; | |||
if (new_che_pos != che_pos) | |||
memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); | |||
if (channel_config) { | |||
@@ -292,7 +310,7 @@ static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_EL | |||
sampling_index = get_bits(gb, 4); | |||
if (ac->m4ac.sampling_index != sampling_index) | |||
av_log(ac->avccontext, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n"); | |||
av_log(ac->avctx, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n"); | |||
num_front = get_bits(gb, 4); | |||
num_side = get_bits(gb, 4); | |||
@@ -323,7 +341,7 @@ static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_EL | |||
/* comment field, first byte is length */ | |||
comment_len = get_bits(gb, 8) * 8; | |||
if (get_bits_left(gb) < comment_len) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, overread_err); | |||
av_log(ac->avctx, AV_LOG_ERROR, overread_err); | |||
return -1; | |||
} | |||
skip_bits_long(gb, comment_len); | |||
@@ -343,7 +361,7 @@ static av_cold int set_default_channel_config(AACContext *ac, | |||
int channel_config) | |||
{ | |||
if (channel_config < 1 || channel_config > 7) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "invalid default channel configuration (%d)\n", | |||
av_log(ac->avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n", | |||
channel_config); | |||
return -1; | |||
} | |||
@@ -388,7 +406,7 @@ static int decode_ga_specific_config(AACContext *ac, GetBitContext *gb, | |||
int extension_flag, ret; | |||
if (get_bits1(gb)) { // frameLengthFlag | |||
av_log_missing_feature(ac->avccontext, "960/120 MDCT window is", 1); | |||
av_log_missing_feature(ac->avctx, "960/120 MDCT window is", 1); | |||
return -1; | |||
} | |||
@@ -452,9 +470,11 @@ static int decode_audio_specific_config(AACContext *ac, void *data, | |||
if ((i = ff_mpeg4audio_get_config(&ac->m4ac, data, data_size)) < 0) | |||
return -1; | |||
if (ac->m4ac.sampling_index > 12) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); | |||
av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); | |||
return -1; | |||
} | |||
if (ac->m4ac.sbr == 1 && ac->m4ac.ps == -1) | |||
ac->m4ac.ps = 1; | |||
skip_bits_long(&gb, i); | |||
@@ -465,7 +485,7 @@ static int decode_audio_specific_config(AACContext *ac, void *data, | |||
return -1; | |||
break; | |||
default: | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n", | |||
av_log(ac->avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n", | |||
ac->m4ac.sbr == 1? "SBR+" : "", ac->m4ac.object_type); | |||
return -1; | |||
} | |||
@@ -508,20 +528,25 @@ static void reset_predictor_group(PredictorState *ps, int group_num) | |||
reset_predict_state(&ps[i]); | |||
} | |||
static av_cold int aac_decode_init(AVCodecContext *avccontext) | |||
#define AAC_INIT_VLC_STATIC(num, size) \ | |||
INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \ | |||
ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \ | |||
ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \ | |||
size); | |||
static av_cold int aac_decode_init(AVCodecContext *avctx) | |||
{ | |||
AACContext *ac = avccontext->priv_data; | |||
int i; | |||
AACContext *ac = avctx->priv_data; | |||
ac->avccontext = avccontext; | |||
ac->m4ac.sample_rate = avccontext->sample_rate; | |||
ac->avctx = avctx; | |||
ac->m4ac.sample_rate = avctx->sample_rate; | |||
if (avccontext->extradata_size > 0) { | |||
if (decode_audio_specific_config(ac, avccontext->extradata, avccontext->extradata_size)) | |||
if (avctx->extradata_size > 0) { | |||
if (decode_audio_specific_config(ac, avctx->extradata, avctx->extradata_size)) | |||
return -1; | |||
} | |||
avccontext->sample_fmt = SAMPLE_FMT_S16; | |||
avctx->sample_fmt = SAMPLE_FMT_S16; | |||
AAC_INIT_VLC_STATIC( 0, 304); | |||
AAC_INIT_VLC_STATIC( 1, 270); | |||
@@ -537,7 +562,7 @@ static av_cold int aac_decode_init(AVCodecContext *avccontext) | |||
ff_aac_sbr_init(); | |||
dsputil_init(&ac->dsp, avccontext); | |||
dsputil_init(&ac->dsp, avctx); | |||
ac->random_state = 0x1f2e3d4c; | |||
@@ -555,10 +580,7 @@ static av_cold int aac_decode_init(AVCodecContext *avccontext) | |||
ac->sf_offset = 60; | |||
} | |||
#if !CONFIG_HARDCODED_TABLES | |||
for (i = 0; i < 428; i++) | |||
ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.); | |||
#endif /* CONFIG_HARDCODED_TABLES */ | |||
ff_aac_tableinit(); | |||
INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code), | |||
ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]), | |||
@@ -591,7 +613,7 @@ static int skip_data_stream_element(AACContext *ac, GetBitContext *gb) | |||
align_get_bits(gb); | |||
if (get_bits_left(gb) < 8 * count) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, overread_err); | |||
av_log(ac->avctx, AV_LOG_ERROR, overread_err); | |||
return -1; | |||
} | |||
skip_bits_long(gb, 8 * count); | |||
@@ -605,7 +627,7 @@ static int decode_prediction(AACContext *ac, IndividualChannelStream *ics, | |||
if (get_bits1(gb)) { | |||
ics->predictor_reset_group = get_bits(gb, 5); | |||
if (ics->predictor_reset_group == 0 || ics->predictor_reset_group > 30) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n"); | |||
return -1; | |||
} | |||
} | |||
@@ -624,7 +646,7 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, | |||
GetBitContext *gb, int common_window) | |||
{ | |||
if (get_bits1(gb)) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Reserved bit set.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); | |||
memset(ics, 0, sizeof(IndividualChannelStream)); | |||
return -1; | |||
} | |||
@@ -665,11 +687,11 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, | |||
return -1; | |||
} | |||
} else if (ac->m4ac.object_type == AOT_AAC_LC) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n"); | |||
memset(ics, 0, sizeof(IndividualChannelStream)); | |||
return -1; | |||
} else { | |||
av_log_missing_feature(ac->avccontext, "Predictor bit set but LTP is", 1); | |||
av_log_missing_feature(ac->avctx, "Predictor bit set but LTP is", 1); | |||
memset(ics, 0, sizeof(IndividualChannelStream)); | |||
return -1; | |||
} | |||
@@ -677,7 +699,7 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, | |||
} | |||
if (ics->max_sfb > ics->num_swb) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Number of scalefactor bands in group (%d) exceeds limit (%d).\n", | |||
ics->max_sfb, ics->num_swb); | |||
memset(ics, 0, sizeof(IndividualChannelStream)); | |||
@@ -708,18 +730,18 @@ static int decode_band_types(AACContext *ac, enum BandType band_type[120], | |||
int sect_len_incr; | |||
int sect_band_type = get_bits(gb, 4); | |||
if (sect_band_type == 12) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "invalid band type\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); | |||
return -1; | |||
} | |||
while ((sect_len_incr = get_bits(gb, bits)) == (1 << bits) - 1) | |||
sect_end += sect_len_incr; | |||
sect_end += sect_len_incr; | |||
if (get_bits_left(gb) < 0) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, overread_err); | |||
av_log(ac->avctx, AV_LOG_ERROR, overread_err); | |||
return -1; | |||
} | |||
if (sect_end > ics->max_sfb) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Number of bands (%d) exceeds limit (%d).\n", | |||
sect_end, ics->max_sfb); | |||
return -1; | |||
@@ -764,7 +786,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, | |||
for (; i < run_end; i++, idx++) { | |||
offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; | |||
if (offset[2] > 255U) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"%s (%d) out of range.\n", sf_str[2], offset[2]); | |||
return -1; | |||
} | |||
@@ -777,7 +799,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, | |||
else | |||
offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; | |||
if (offset[1] > 255U) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"%s (%d) out of range.\n", sf_str[1], offset[1]); | |||
return -1; | |||
} | |||
@@ -787,7 +809,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, | |||
for (; i < run_end; i++, idx++) { | |||
offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; | |||
if (offset[0] > 255U) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"%s (%d) out of range.\n", sf_str[0], offset[0]); | |||
return -1; | |||
} | |||
@@ -844,7 +866,7 @@ static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, | |||
tns->length[w][filt] = get_bits(gb, 6 - 2 * is8); | |||
if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n", | |||
av_log(ac->avctx, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n", | |||
tns->order[w][filt], tns_max_order); | |||
tns->order[w][filt] = 0; | |||
return -1; | |||
@@ -1163,7 +1185,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], | |||
b = 31 - av_log2(~b); | |||
if (b > 8) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); | |||
return -1; | |||
} | |||
@@ -1216,7 +1238,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], | |||
return 0; | |||
err_cb_overflow: | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Read beyond end of ff_aac_codebook_vectors[%d][]. index %d >= %d\n", | |||
band_type[idx], err_idx, ff_aac_spectral_sizes[band_type[idx]]); | |||
return -1; | |||
@@ -1337,18 +1359,18 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce, | |||
if (!scale_flag) { | |||
if ((pulse_present = get_bits1(gb))) { | |||
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n"); | |||
return -1; | |||
} | |||
if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n"); | |||
return -1; | |||
} | |||
} | |||
if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics)) | |||
return -1; | |||
if (get_bits1(gb)) { | |||
av_log_missing_feature(ac->avccontext, "SSR", 1); | |||
av_log_missing_feature(ac->avctx, "SSR", 1); | |||
return -1; | |||
} | |||
} | |||
@@ -1448,7 +1470,7 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) | |||
cpe->ch[1].ics.use_kb_window[1] = i; | |||
ms_present = get_bits(gb, 2); | |||
if (ms_present == 3) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "ms_present = 3 is reserved.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n"); | |||
return -1; | |||
} else if (ms_present) | |||
decode_mid_side_stereo(cpe, gb, ms_present); | |||
@@ -1635,16 +1657,20 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, | |||
crc_flag++; | |||
case EXT_SBR_DATA: | |||
if (!che) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "SBR was found before the first channel element.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n"); | |||
return res; | |||
} else if (!ac->m4ac.sbr) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); | |||
skip_bits_long(gb, 8 * cnt - 4); | |||
return res; | |||
} else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); | |||
skip_bits_long(gb, 8 * cnt - 4); | |||
return res; | |||
} else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac->avctx->channels == 1) { | |||
ac->m4ac.sbr = 1; | |||
ac->m4ac.ps = 1; | |||
output_configure(ac, ac->che_pos, ac->che_pos, ac->m4ac.chan_config, ac->output_configured); | |||
} else { | |||
ac->m4ac.sbr = 1; | |||
} | |||
@@ -1728,7 +1754,7 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float | |||
// imdct | |||
if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { | |||
if (ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) | |||
av_log(ac->avccontext, AV_LOG_WARNING, | |||
av_log(ac->avctx, AV_LOG_WARNING, | |||
"Transition from an ONLY_LONG or LONG_STOP to an EIGHT_SHORT sequence detected. " | |||
"If you heard an audible artifact, please submit the sample to the FFmpeg developers.\n"); | |||
for (i = 0; i < 1024; i += 128) | |||
@@ -1794,7 +1820,7 @@ static void apply_dependent_coupling(AACContext *ac, | |||
const float *src = cce->ch[0].coeffs; | |||
int g, i, group, k, idx = 0; | |||
if (ac->m4ac.object_type == AOT_AAC_LTP) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Dependent coupling is not supported together with LTP\n"); | |||
return; | |||
} | |||
@@ -1924,58 +1950,65 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) | |||
} else if (ac->output_configured != OC_LOCKED) { | |||
ac->output_configured = OC_NONE; | |||
} | |||
if (ac->output_configured != OC_LOCKED) | |||
if (ac->output_configured != OC_LOCKED) { | |||
ac->m4ac.sbr = -1; | |||
ac->m4ac.ps = -1; | |||
} | |||
ac->m4ac.sample_rate = hdr_info.sample_rate; | |||
ac->m4ac.sampling_index = hdr_info.sampling_index; | |||
ac->m4ac.object_type = hdr_info.object_type; | |||
if (!ac->avccontext->sample_rate) | |||
ac->avccontext->sample_rate = hdr_info.sample_rate; | |||
if (!ac->avctx->sample_rate) | |||
ac->avctx->sample_rate = hdr_info.sample_rate; | |||
if (hdr_info.num_aac_frames == 1) { | |||
if (!hdr_info.crc_absent) | |||
skip_bits(gb, 16); | |||
} else { | |||
av_log_missing_feature(ac->avccontext, "More than one AAC RDB per ADTS frame is", 0); | |||
av_log_missing_feature(ac->avctx, "More than one AAC RDB per ADTS frame is", 0); | |||
return -1; | |||
} | |||
} | |||
return size; | |||
} | |||
static int aac_decode_frame(AVCodecContext *avccontext, void *data, | |||
static int aac_decode_frame(AVCodecContext *avctx, void *data, | |||
int *data_size, AVPacket *avpkt) | |||
{ | |||
const uint8_t *buf = avpkt->data; | |||
int buf_size = avpkt->size; | |||
AACContext *ac = avccontext->priv_data; | |||
AACContext *ac = avctx->priv_data; | |||
ChannelElement *che = NULL, *che_prev = NULL; | |||
GetBitContext gb; | |||
enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; | |||
int err, elem_id, data_size_tmp; | |||
int buf_consumed; | |||
int samples = 1024, multiplier; | |||
int samples = 0, multiplier; | |||
int buf_offset; | |||
init_get_bits(&gb, buf, buf_size * 8); | |||
if (show_bits(&gb, 12) == 0xfff) { | |||
if (parse_adts_frame_header(ac, &gb) < 0) { | |||
av_log(avccontext, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); | |||
av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n"); | |||
return -1; | |||
} | |||
if (ac->m4ac.sampling_index > 12) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); | |||
av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); | |||
return -1; | |||
} | |||
} | |||
memset(ac->tags_seen_this_frame, 0, sizeof(ac->tags_seen_this_frame)); | |||
// parse | |||
while ((elem_type = get_bits(&gb, 3)) != TYPE_END) { | |||
elem_id = get_bits(&gb, 4); | |||
if (elem_type < TYPE_DSE && !(che=get_che(ac, elem_type, elem_id))) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", elem_type, elem_id); | |||
return -1; | |||
if (elem_type < TYPE_DSE) { | |||
if (!(che=get_che(ac, elem_type, elem_id))) { | |||
av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", | |||
elem_type, elem_id); | |||
return -1; | |||
} | |||
samples = 1024; | |||
} | |||
switch (elem_type) { | |||
@@ -2006,7 +2039,7 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, | |||
if ((err = decode_pce(ac, new_che_pos, &gb))) | |||
break; | |||
if (ac->output_configured > OC_TRIAL_PCE) | |||
av_log(avccontext, AV_LOG_ERROR, | |||
av_log(avctx, AV_LOG_ERROR, | |||
"Not evaluating a further program_config_element as this construct is dubious at best.\n"); | |||
else | |||
err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE); | |||
@@ -2017,7 +2050,7 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, | |||
if (elem_id == 15) | |||
elem_id += get_bits(&gb, 8) - 1; | |||
if (get_bits_left(&gb) < 8 * elem_id) { | |||
av_log(avccontext, AV_LOG_ERROR, overread_err); | |||
av_log(avctx, AV_LOG_ERROR, overread_err); | |||
return -1; | |||
} | |||
while (elem_id > 0) | |||
@@ -2037,7 +2070,7 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, | |||
return err; | |||
if (get_bits_left(&gb) < 3) { | |||
av_log(avccontext, AV_LOG_ERROR, overread_err); | |||
av_log(avctx, AV_LOG_ERROR, overread_err); | |||
return -1; | |||
} | |||
} | |||
@@ -2047,20 +2080,21 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, | |||
multiplier = (ac->m4ac.sbr == 1) ? ac->m4ac.ext_sample_rate > ac->m4ac.sample_rate : 0; | |||
samples <<= multiplier; | |||
if (ac->output_configured < OC_LOCKED) { | |||
avccontext->sample_rate = ac->m4ac.sample_rate << multiplier; | |||
avccontext->frame_size = samples; | |||
avctx->sample_rate = ac->m4ac.sample_rate << multiplier; | |||
avctx->frame_size = samples; | |||
} | |||
data_size_tmp = samples * avccontext->channels * sizeof(int16_t); | |||
data_size_tmp = samples * avctx->channels * sizeof(int16_t); | |||
if (*data_size < data_size_tmp) { | |||
av_log(avccontext, AV_LOG_ERROR, | |||
av_log(avctx, AV_LOG_ERROR, | |||
"Output buffer too small (%d) or trying to output too many samples (%d) for this frame.\n", | |||
*data_size, data_size_tmp); | |||
return -1; | |||
} | |||
*data_size = data_size_tmp; | |||
ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avccontext->channels); | |||
if (samples) | |||
ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels); | |||
if (ac->output_configured) | |||
ac->output_configured = OC_LOCKED; | |||
@@ -2073,9 +2107,9 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data, | |||
return buf_size > buf_offset ? buf_consumed : buf_size; | |||
} | |||
static av_cold int aac_decode_close(AVCodecContext *avccontext) | |||
static av_cold int aac_decode_close(AVCodecContext *avctx) | |||
{ | |||
AACContext *ac = avccontext->priv_data; | |||
AACContext *ac = avctx->priv_data; | |||
int i, type; | |||
for (i = 0; i < MAX_ELEM_ID; i++) { |
@@ -201,13 +201,11 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) | |||
lengths[1] = ff_aac_num_swb_128[i]; | |||
ff_psy_init(&s->psy, avctx, 2, sizes, lengths); | |||
s->psypp = ff_psy_preprocess_init(avctx); | |||
s->coder = &ff_aac_coders[0]; | |||
s->coder = &ff_aac_coders[2]; | |||
s->lambda = avctx->global_quality ? avctx->global_quality : 120; | |||
#if !CONFIG_HARDCODED_TABLES | |||
for (i = 0; i < 428; i++) | |||
ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.); | |||
#endif /* CONFIG_HARDCODED_TABLES */ | |||
ff_aac_tableinit(); | |||
if (avctx->channels > 5) | |||
av_log(avctx, AV_LOG_ERROR, "This encoder does not yet enforce the restrictions on LFEs. " | |||
@@ -234,25 +232,21 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, | |||
s->output[i] = sce->saved[i]; | |||
} | |||
if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) { | |||
j = channel; | |||
for (i = 0; i < 1024; i++, j += avctx->channels) { | |||
for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) { | |||
s->output[i+1024] = audio[j] * lwindow[1024 - i - 1]; | |||
sce->saved[i] = audio[j] * lwindow[i]; | |||
} | |||
} else { | |||
j = channel; | |||
for (i = 0; i < 448; i++, j += avctx->channels) | |||
for (i = 0, j = channel; i < 448; i++, j += avctx->channels) | |||
s->output[i+1024] = audio[j]; | |||
for (i = 448; i < 576; i++, j += avctx->channels) | |||
for (; i < 576; i++, j += avctx->channels) | |||
s->output[i+1024] = audio[j] * swindow[576 - i - 1]; | |||
memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448); | |||
j = channel; | |||
for (i = 0; i < 1024; i++, j += avctx->channels) | |||
for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) | |||
sce->saved[i] = audio[j]; | |||
} | |||
ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output); | |||
} else { | |||
j = channel; | |||
for (k = 0; k < 1024; k += 128) { | |||
for (i = 448 + k; i < 448 + k + 256; i++) | |||
s->output[i - 448 - k] = (i < 1024) | |||
@@ -262,8 +256,7 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, | |||
s->dsp.vector_fmul_reverse(s->output+128, s->output+128, swindow, 128); | |||
ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output); | |||
} | |||
j = channel; | |||
for (i = 0; i < 1024; i++, j += avctx->channels) | |||
for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) | |||
sce->saved[i] = audio[j]; | |||
} | |||
} | |||
@@ -562,6 +555,7 @@ static int aac_encode_frame(AVCodecContext *avctx, | |||
cpe = &s->cpe[i]; | |||
for (j = 0; j < chans; j++) { | |||
s->cur_channel = start_ch + j; | |||
ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]); | |||
s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda); | |||
} | |||
cpe->common_window = 0; | |||
@@ -592,7 +586,6 @@ static int aac_encode_frame(AVCodecContext *avctx, | |||
} | |||
for (j = 0; j < chans; j++) { | |||
s->cur_channel = start_ch + j; | |||
ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]); | |||
encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window); | |||
} | |||
start_ch += chans; | |||
@@ -64,7 +64,7 @@ typedef struct AACEncContext { | |||
int cur_channel; | |||
int last_frame; | |||
float lambda; | |||
DECLARE_ALIGNED(16, int, qcoefs)[96][2]; ///< quantized coefficients | |||
DECLARE_ALIGNED(16, int, qcoefs)[96]; ///< quantized coefficients | |||
DECLARE_ALIGNED(16, float, scoefs)[1024]; ///< scaled coefficients | |||
} AACEncContext; | |||
@@ -0,0 +1,82 @@ | |||
/* | |||
* MPEG-4 Parametric Stereo definitions and declarations | |||
* Copyright (c) 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 | |||
*/ | |||
#ifndef AVCODEC_PS_H | |||
#define AVCODEC_PS_H | |||
#include <stdint.h> | |||
#include "avcodec.h" | |||
#include "get_bits.h" | |||
#define PS_MAX_NUM_ENV 5 | |||
#define PS_MAX_NR_IIDICC 34 | |||
#define PS_MAX_NR_IPDOPD 17 | |||
#define PS_MAX_SSB 91 | |||
#define PS_MAX_AP_BANDS 50 | |||
#define PS_QMF_TIME_SLOTS 32 | |||
#define PS_MAX_DELAY 14 | |||
#define PS_AP_LINKS 3 | |||
#define PS_MAX_AP_DELAY 5 | |||
typedef struct { | |||
int start; | |||
int enable_iid; | |||
int iid_quant; | |||
int nr_iid_par; | |||
int nr_ipdopd_par; | |||
int enable_icc; | |||
int icc_mode; | |||
int nr_icc_par; | |||
int enable_ext; | |||
int frame_class; | |||
int num_env_old; | |||
int num_env; | |||
int enable_ipdopd; | |||
int border_position[PS_MAX_NUM_ENV+1]; | |||
int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //<Inter-channel Intensity Difference Parameters | |||
int8_t icc_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //<Inter-Channel Coherence Parameters | |||
/* ipd/opd is iid/icc sized so that the same functions can handle both */ | |||
int8_t ipd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //<Inter-channel Phase Difference Parameters | |||
int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; //<Overall Phase Difference Parameters | |||
int is34bands; | |||
int is34bands_old; | |||
float in_buf[5][44][2]; | |||
float delay[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2]; | |||
float ap_delay[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2]; | |||
float peak_decay_nrg[34]; | |||
float power_smooth[34]; | |||
float peak_decay_diff_smooth[34]; | |||
float H11[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; | |||
float H12[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; | |||
float H21[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; | |||
float H22[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC]; | |||
int8_t opd_hist[PS_MAX_NR_IIDICC]; | |||
int8_t ipd_hist[PS_MAX_NR_IIDICC]; | |||
} PSContext; | |||
void ff_ps_init(void); | |||
void ff_ps_ctx_init(PSContext *ps); | |||
int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left); | |||
int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top); | |||
#endif /* AVCODEC_PS_H */ |
@@ -0,0 +1,93 @@ | |||
/* | |||
* Generate a header file for hardcoded Parametric Stereo tables | |||
* | |||
* Copyright (c) 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 | |||
*/ | |||
#include <stdlib.h> | |||
#define CONFIG_HARDCODED_TABLES 0 | |||
#include "aacps_tablegen.h" | |||
#include "tableprint.h" | |||
void write_float_3d_array (const void *p, int b, int c, int d) | |||
{ | |||
int i; | |||
const float *f = p; | |||
for (i = 0; i < b; i++) { | |||
printf("{\n"); | |||
write_float_2d_array(f, c, d); | |||
printf("},\n"); | |||
f += c * d; | |||
} | |||
} | |||
void write_float_4d_array (const void *p, int a, int b, int c, int d) | |||
{ | |||
int i; | |||
const float *f = p; | |||
for (i = 0; i < a; i++) { | |||
printf("{\n"); | |||
write_float_3d_array(f, b, c, d); | |||
printf("},\n"); | |||
f += b * c * d; | |||
} | |||
} | |||
int main(void) | |||
{ | |||
ps_tableinit(); | |||
write_fileheader(); | |||
printf("static const float pd_re_smooth[8*8*8] = {\n"); | |||
write_float_array(pd_re_smooth, 8*8*8); | |||
printf("};\n"); | |||
printf("static const float pd_im_smooth[8*8*8] = {\n"); | |||
write_float_array(pd_im_smooth, 8*8*8); | |||
printf("};\n"); | |||
printf("static const float HA[46][8][4] = {\n"); | |||
write_float_3d_array(HA, 46, 8, 4); | |||
printf("};\n"); | |||
printf("static const float HB[46][8][4] = {\n"); | |||
write_float_3d_array(HB, 46, 8, 4); | |||
printf("};\n"); | |||
printf("static const float f20_0_8[8][7][2] = {\n"); | |||
write_float_3d_array(f20_0_8, 8, 7, 2); | |||
printf("};\n"); | |||
printf("static const float f34_0_12[12][7][2] = {\n"); | |||
write_float_3d_array(f34_0_12, 12, 7, 2); | |||
printf("};\n"); | |||
printf("static const float f34_1_8[8][7][2] = {\n"); | |||
write_float_3d_array(f34_1_8, 8, 7, 2); | |||
printf("};\n"); | |||
printf("static const float f34_2_4[4][7][2] = {\n"); | |||
write_float_3d_array(f34_2_4, 4, 7, 2); | |||
printf("};\n"); | |||
printf("static const float Q_fract_allpass[2][50][3][2] = {\n"); | |||
write_float_4d_array(Q_fract_allpass, 2, 50, 3, 2); | |||
printf("};\n"); | |||
printf("static const float phi_fract[2][50][2] = {\n"); | |||
write_float_3d_array(phi_fract, 2, 50, 2); | |||
printf("};\n"); | |||
return 0; | |||
} |
@@ -0,0 +1,212 @@ | |||
/* | |||
* Header file for hardcoded Parametric Stereo tables | |||
* | |||
* Copyright (c) 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 | |||
*/ | |||
#ifndef AACPS_TABLEGEN_H | |||
#define AACPS_TABLEGEN_H | |||
#include <stdint.h> | |||
#if CONFIG_HARDCODED_TABLES | |||
#define ps_tableinit() | |||
#include "libavcodec/aacps_tables.h" | |||
#else | |||
#include "../libavutil/common.h" | |||
#include "../libavutil/mathematics.h" | |||
#define NR_ALLPASS_BANDS20 30 | |||
#define NR_ALLPASS_BANDS34 50 | |||
#define PS_AP_LINKS 3 | |||
static float pd_re_smooth[8*8*8]; | |||
static float pd_im_smooth[8*8*8]; | |||
static float HA[46][8][4]; | |||
static float HB[46][8][4]; | |||
static float f20_0_8 [ 8][7][2]; | |||
static float f34_0_12[12][7][2]; | |||
static float f34_1_8 [ 8][7][2]; | |||
static float f34_2_4 [ 4][7][2]; | |||
static float Q_fract_allpass[2][50][3][2]; | |||
static float phi_fract[2][50][2]; | |||
static const float g0_Q8[] = { | |||
0.00746082949812f, 0.02270420949825f, 0.04546865930473f, 0.07266113929591f, | |||
0.09885108575264f, 0.11793710567217f, 0.125f | |||
}; | |||
static const float g0_Q12[] = { | |||
0.04081179924692f, 0.03812810994926f, 0.05144908135699f, 0.06399831151592f, | |||
0.07428313801106f, 0.08100347892914f, 0.08333333333333f | |||
}; | |||
static const float g1_Q8[] = { | |||
0.01565675600122f, 0.03752716391991f, 0.05417891378782f, 0.08417044116767f, | |||
0.10307344158036f, 0.12222452249753f, 0.125f | |||
}; | |||
static const float g2_Q4[] = { | |||
-0.05908211155639f, -0.04871498374946f, 0.0f, 0.07778723915851f, | |||
0.16486303567403f, 0.23279856662996f, 0.25f | |||
}; | |||
static void make_filters_from_proto(float (*filter)[7][2], const float *proto, int bands) | |||
{ | |||
int q, n; | |||
for (q = 0; q < bands; q++) { | |||
for (n = 0; n < 7; n++) { | |||
double theta = 2 * M_PI * (q + 0.5) * (n - 6) / bands; | |||
filter[q][n][0] = proto[n] * cos(theta); | |||
filter[q][n][1] = proto[n] * -sin(theta); | |||
} | |||
} | |||
} | |||
static void ps_tableinit(void) | |||
{ | |||
static const float ipdopd_sin[] = { 0, M_SQRT1_2, 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2 }; | |||
static const float ipdopd_cos[] = { 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2, 0, M_SQRT1_2 }; | |||
int pd0, pd1, pd2; | |||
static const float iid_par_dequant[] = { | |||
//iid_par_dequant_default | |||
0.05623413251903, 0.12589254117942, 0.19952623149689, 0.31622776601684, | |||
0.44668359215096, 0.63095734448019, 0.79432823472428, 1, | |||
1.25892541179417, 1.58489319246111, 2.23872113856834, 3.16227766016838, | |||
5.01187233627272, 7.94328234724282, 17.7827941003892, | |||
//iid_par_dequant_fine | |||
0.00316227766017, 0.00562341325190, 0.01, 0.01778279410039, | |||
0.03162277660168, 0.05623413251903, 0.07943282347243, 0.11220184543020, | |||
0.15848931924611, 0.22387211385683, 0.31622776601684, 0.39810717055350, | |||
0.50118723362727, 0.63095734448019, 0.79432823472428, 1, | |||
1.25892541179417, 1.58489319246111, 1.99526231496888, 2.51188643150958, | |||
3.16227766016838, 4.46683592150963, 6.30957344480193, 8.91250938133745, | |||
12.5892541179417, 17.7827941003892, 31.6227766016838, 56.2341325190349, | |||
100, 177.827941003892, 316.227766016837, | |||
}; | |||
static const float icc_invq[] = { | |||
1, 0.937, 0.84118, 0.60092, 0.36764, 0, -0.589, -1 | |||
}; | |||
static const float acos_icc_invq[] = { | |||
0, 0.35685527, 0.57133466, 0.92614472, 1.1943263, M_PI/2, 2.2006171, M_PI | |||
}; | |||
int iid, icc; | |||
int k, m; | |||
static const int8_t f_center_20[] = { | |||
-3, -1, 1, 3, 5, 7, 10, 14, 18, 22, | |||
}; | |||
static const int8_t f_center_34[] = { | |||
2, 6, 10, 14, 18, 22, 26, 30, | |||
34,-10, -6, -2, 51, 57, 15, 21, | |||
27, 33, 39, 45, 54, 66, 78, 42, | |||
102, 66, 78, 90,102,114,126, 90, | |||
}; | |||
static const float fractional_delay_links[] = { 0.43f, 0.75f, 0.347f }; | |||
const float fractional_delay_gain = 0.39f; | |||
for (pd0 = 0; pd0 < 8; pd0++) { | |||
float pd0_re = ipdopd_cos[pd0]; | |||
float pd0_im = ipdopd_sin[pd0]; | |||
for (pd1 = 0; pd1 < 8; pd1++) { | |||
float pd1_re = ipdopd_cos[pd1]; | |||
float pd1_im = ipdopd_sin[pd1]; | |||
for (pd2 = 0; pd2 < 8; pd2++) { | |||
float pd2_re = ipdopd_cos[pd2]; | |||
float pd2_im = ipdopd_sin[pd2]; | |||
float re_smooth = 0.25f * pd0_re + 0.5f * pd1_re + pd2_re; | |||
float im_smooth = 0.25f * pd0_im + 0.5f * pd1_im + pd2_im; | |||
float pd_mag = 1 / sqrt(im_smooth * im_smooth + re_smooth * re_smooth); | |||
pd_re_smooth[pd0*64+pd1*8+pd2] = re_smooth * pd_mag; | |||
pd_im_smooth[pd0*64+pd1*8+pd2] = im_smooth * pd_mag; | |||
} | |||
} | |||
} | |||
for (iid = 0; iid < 46; iid++) { | |||
float c = iid_par_dequant[iid]; //<Linear Inter-channel Intensity Difference | |||
float c1 = (float)M_SQRT2 / sqrtf(1.0f + c*c); | |||
float c2 = c * c1; | |||
for (icc = 0; icc < 8; icc++) { | |||
/*if (PS_BASELINE || ps->icc_mode < 3)*/ { | |||
float alpha = 0.5f * acos_icc_invq[icc]; | |||
float beta = alpha * (c1 - c2) * (float)M_SQRT1_2; | |||
HA[iid][icc][0] = c2 * cosf(beta + alpha); | |||
HA[iid][icc][1] = c1 * cosf(beta - alpha); | |||
HA[iid][icc][2] = c2 * sinf(beta + alpha); | |||
HA[iid][icc][3] = c1 * sinf(beta - alpha); | |||
} /* else */ { | |||
float alpha, gamma, mu, rho; | |||
float alpha_c, alpha_s, gamma_c, gamma_s; | |||
rho = FFMAX(icc_invq[icc], 0.05f); | |||
alpha = 0.5f * atan2f(2.0f * c * rho, c*c - 1.0f); | |||
mu = c + 1.0f / c; | |||
mu = sqrtf(1 + (4 * rho * rho - 4)/(mu * mu)); | |||
gamma = atanf(sqrtf((1.0f - mu)/(1.0f + mu))); | |||
if (alpha < 0) alpha += M_PI/2; | |||
alpha_c = cosf(alpha); | |||
alpha_s = sinf(alpha); | |||
gamma_c = cosf(gamma); | |||
gamma_s = sinf(gamma); | |||
HB[iid][icc][0] = M_SQRT2 * alpha_c * gamma_c; | |||
HB[iid][icc][1] = M_SQRT2 * alpha_s * gamma_c; | |||
HB[iid][icc][2] = -M_SQRT2 * alpha_s * gamma_s; | |||
HB[iid][icc][3] = M_SQRT2 * alpha_c * gamma_s; | |||
} | |||
} | |||
} | |||
for (k = 0; k < NR_ALLPASS_BANDS20; k++) { | |||
double f_center, theta; | |||
if (k < FF_ARRAY_ELEMS(f_center_20)) | |||
f_center = f_center_20[k] * 0.125; | |||
else | |||
f_center = k - 6.5f; | |||
for (m = 0; m < PS_AP_LINKS; m++) { | |||
theta = -M_PI * fractional_delay_links[m] * f_center; | |||
Q_fract_allpass[0][k][m][0] = cos(theta); | |||
Q_fract_allpass[0][k][m][1] = sin(theta); | |||
} | |||
theta = -M_PI*fractional_delay_gain*f_center; | |||
phi_fract[0][k][0] = cos(theta); | |||
phi_fract[0][k][1] = sin(theta); | |||
} | |||
for (k = 0; k < NR_ALLPASS_BANDS34; k++) { | |||
double f_center, theta; | |||
if (k < FF_ARRAY_ELEMS(f_center_34)) | |||
f_center = f_center_34[k] / 24.; | |||
else | |||
f_center = k - 26.5f; | |||
for (m = 0; m < PS_AP_LINKS; m++) { | |||
theta = -M_PI * fractional_delay_links[m] * f_center; | |||
Q_fract_allpass[1][k][m][0] = cos(theta); | |||
Q_fract_allpass[1][k][m][1] = sin(theta); | |||
} | |||
theta = -M_PI*fractional_delay_gain*f_center; | |||
phi_fract[1][k][0] = cos(theta); | |||
phi_fract[1][k][1] = sin(theta); | |||
} | |||
make_filters_from_proto(f20_0_8, g0_Q8, 8); | |||
make_filters_from_proto(f34_0_12, g0_Q12, 12); | |||
make_filters_from_proto(f34_1_8, g1_Q8, 8); | |||
make_filters_from_proto(f34_2_4, g2_Q4, 4); | |||
} | |||
#endif /* CONFIG_HARDCODED_TABLES */ | |||
#endif /* AACPS_TABLEGEN_H */ |
@@ -0,0 +1,163 @@ | |||
/* | |||
* MPEG-4 Parametric Stereo data tables | |||
* Copyright (c) 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 const uint8_t huff_iid_df1_bits[] = { | |||
18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 17, 17, 16, 16, 15, 14, 14, | |||
13, 12, 12, 11, 10, 10, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7, | |||
8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16, 17, 17, 18, 17, 18, 18, | |||
18, 18, 18, 18, 18, 18, 18, | |||
}; | |||
static const uint32_t huff_iid_df1_codes[] = { | |||
0x01FEB4, 0x01FEB5, 0x01FD76, 0x01FD77, 0x01FD74, 0x01FD75, 0x01FE8A, | |||
0x01FE8B, 0x01FE88, 0x00FE80, 0x01FEB6, 0x00FE82, 0x00FEB8, 0x007F42, | |||
0x007FAE, 0x003FAF, 0x001FD1, 0x001FE9, 0x000FE9, 0x0007EA, 0x0007FB, | |||
0x0003FB, 0x0001FB, 0x0001FF, 0x00007C, 0x00003C, 0x00001C, 0x00000C, | |||
0x000000, 0x000001, 0x000001, 0x000002, 0x000001, 0x00000D, 0x00001D, | |||
0x00003D, 0x00007D, 0x0000FC, 0x0001FC, 0x0003FC, 0x0003F4, 0x0007EB, | |||
0x000FEA, 0x001FEA, 0x001FD6, 0x003FD0, 0x007FAF, 0x007F43, 0x00FEB9, | |||
0x00FE83, 0x01FEB7, 0x00FE81, 0x01FE89, 0x01FE8E, 0x01FE8F, 0x01FE8C, | |||
0x01FE8D, 0x01FEB2, 0x01FEB3, 0x01FEB0, 0x01FEB1, | |||
}; | |||
static const uint8_t huff_iid_dt1_bits[] = { | |||
16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 13, | |||
13, 13, 12, 12, 11, 10, 9, 9, 7, 6, 5, 3, 1, 2, 5, 6, 7, 8, | |||
9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, | |||
16, 16, 16, 16, 16, 16, 16, | |||
}; | |||
static const uint16_t huff_iid_dt1_codes[] = { | |||
0x004ED4, 0x004ED5, 0x004ECE, 0x004ECF, 0x004ECC, 0x004ED6, 0x004ED8, | |||
0x004F46, 0x004F60, 0x002718, 0x002719, 0x002764, 0x002765, 0x00276D, | |||
0x0027B1, 0x0013B7, 0x0013D6, 0x0009C7, 0x0009E9, 0x0009ED, 0x0004EE, | |||
0x0004F7, 0x000278, 0x000139, 0x00009A, 0x00009F, 0x000020, 0x000011, | |||
0x00000A, 0x000003, 0x000001, 0x000000, 0x00000B, 0x000012, 0x000021, | |||
0x00004C, 0x00009B, 0x00013A, 0x000279, 0x000270, 0x0004EF, 0x0004E2, | |||
0x0009EA, 0x0009D8, 0x0013D7, 0x0013D0, 0x0027B2, 0x0027A2, 0x00271A, | |||
0x00271B, 0x004F66, 0x004F67, 0x004F61, 0x004F47, 0x004ED9, 0x004ED7, | |||
0x004ECD, 0x004ED2, 0x004ED3, 0x004ED0, 0x004ED1, | |||
}; | |||
static const uint8_t huff_iid_df0_bits[] = { | |||
17, 17, 17, 17, 16, 15, 13, 10, 9, 7, 6, 5, 4, 3, 1, 3, 4, 5, | |||
6, 6, 8, 11, 13, 14, 14, 15, 17, 18, 18, | |||
}; | |||
static const uint32_t huff_iid_df0_codes[] = { | |||
0x01FFFB, 0x01FFFC, 0x01FFFD, 0x01FFFA, 0x00FFFC, 0x007FFC, 0x001FFD, | |||
0x0003FE, 0x0001FE, 0x00007E, 0x00003C, 0x00001D, 0x00000D, 0x000005, | |||
0x000000, 0x000004, 0x00000C, 0x00001C, 0x00003D, 0x00003E, 0x0000FE, | |||
0x0007FE, 0x001FFC, 0x003FFC, 0x003FFD, 0x007FFD, 0x01FFFE, 0x03FFFE, | |||
0x03FFFF, | |||
}; | |||
static const uint8_t huff_iid_dt0_bits[] = { | |||
19, 19, 19, 20, 20, 20, 17, 15, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, | |||
9, 11, 13, 14, 17, 19, 20, 20, 20, 20, 20, | |||
}; | |||
static const uint32_t huff_iid_dt0_codes[] = { | |||
0x07FFF9, 0x07FFFA, 0x07FFFB, 0x0FFFF8, 0x0FFFF9, 0x0FFFFA, 0x01FFFD, | |||
0x007FFE, 0x000FFE, 0x0003FE, 0x0000FE, 0x00003E, 0x00000E, 0x000002, | |||
0x000000, 0x000006, 0x00001E, 0x00007E, 0x0001FE, 0x0007FE, 0x001FFE, | |||
0x003FFE, 0x01FFFC, 0x07FFF8, 0x0FFFFB, 0x0FFFFC, 0x0FFFFD, 0x0FFFFE, | |||
0x0FFFFF, | |||
}; | |||
static const uint8_t huff_icc_df_bits[] = { | |||
14, 14, 12, 10, 7, 5, 3, 1, 2, 4, 6, 8, 9, 11, 13, | |||
}; | |||
static const uint16_t huff_icc_df_codes[] = { | |||
0x3FFF, 0x3FFE, 0x0FFE, 0x03FE, 0x007E, 0x001E, 0x0006, 0x0000, | |||
0x0002, 0x000E, 0x003E, 0x00FE, 0x01FE, 0x07FE, 0x1FFE, | |||
}; | |||
static const uint8_t huff_icc_dt_bits[] = { | |||
14, 13, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, | |||
}; | |||
static const uint16_t huff_icc_dt_codes[] = { | |||
0x3FFE, 0x1FFE, 0x07FE, 0x01FE, 0x007E, 0x001E, 0x0006, 0x0000, | |||
0x0002, 0x000E, 0x003E, 0x00FE, 0x03FE, 0x0FFE, 0x3FFF, | |||
}; | |||
static const uint8_t huff_ipd_df_bits[] = { | |||
1, 3, 4, 4, 4, 4, 4, 4, | |||
}; | |||
static const uint8_t huff_ipd_df_codes[] = { | |||
0x01, 0x00, 0x06, 0x04, 0x02, 0x03, 0x05, 0x07, | |||
}; | |||
static const uint8_t huff_ipd_dt_bits[] = { | |||
1, 3, 4, 5, 5, 4, 4, 3, | |||
}; | |||
static const uint8_t huff_ipd_dt_codes[] = { | |||
0x01, 0x02, 0x02, 0x03, 0x02, 0x00, 0x03, 0x03, | |||
}; | |||
static const uint8_t huff_opd_df_bits[] = { | |||
1, 3, 4, 4, 5, 5, 4, 3, | |||
}; | |||
static const uint8_t huff_opd_df_codes[] = { | |||
0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x05, 0x00, | |||
}; | |||
static const uint8_t huff_opd_dt_bits[] = { | |||
1, 3, 4, 5, 5, 4, 4, 3, | |||
}; | |||
static const uint8_t huff_opd_dt_codes[] = { | |||
0x01, 0x02, 0x01, 0x07, 0x06, 0x00, 0x02, 0x03, | |||
}; | |||
static const int8_t huff_offset[] = { | |||
30, 30, | |||
14, 14, | |||
7, 7, | |||
0, 0, | |||
0, 0, | |||
}; | |||
///Table 8.48 | |||
static const int8_t k_to_i_20[] = { | |||
1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 15, | |||
15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, | |||
18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, | |||
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 | |||
}; | |||
///Table 8.49 | |||
static const int8_t k_to_i_34[] = { | |||
0, 1, 2, 3, 4, 5, 6, 6, 7, 2, 1, 0, 10, 10, 4, 5, 6, 7, 8, | |||
9, 10, 11, 12, 9, 14, 11, 12, 13, 14, 15, 16, 13, 16, 17, 18, 19, 20, 21, | |||
22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, | |||
30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, | |||
33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 | |||
}; | |||
static const float g1_Q2[] = { | |||
0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f, | |||
0.0f, 0.30596630545168f, 0.5f | |||
}; |
@@ -31,6 +31,7 @@ | |||
#include "aacsbr.h" | |||
#include "aacsbrdata.h" | |||
#include "fft.h" | |||
#include "aacps.h" | |||
#include <stdint.h> | |||
#include <float.h> | |||
@@ -71,9 +72,6 @@ enum { | |||
static VLC vlc_sbr[10]; | |||
static const int8_t vlc_sbr_lav[10] = | |||
{ 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }; | |||
static DECLARE_ALIGNED(16, float, analysis_cos_pre)[64]; | |||
static DECLARE_ALIGNED(16, float, analysis_sin_pre)[64]; | |||
static DECLARE_ALIGNED(16, float, analysis_cossin_post)[32][2]; | |||
static const DECLARE_ALIGNED(16, float, zero64)[64]; | |||
#define SBR_INIT_VLC_STATIC(num, size) \ | |||
@@ -87,7 +85,7 @@ static const DECLARE_ALIGNED(16, float, zero64)[64]; | |||
av_cold void ff_aac_sbr_init(void) | |||
{ | |||
int n, k; | |||
int n; | |||
static const struct { | |||
const void *sbr_codes, *sbr_bits; | |||
const unsigned int table_size, elem_size; | |||
@@ -116,16 +114,6 @@ av_cold void ff_aac_sbr_init(void) | |||
SBR_INIT_VLC_STATIC(8, 592); | |||
SBR_INIT_VLC_STATIC(9, 512); | |||
for (n = 0; n < 64; n++) { | |||
float pre = M_PI * n / 64; | |||
analysis_cos_pre[n] = cosf(pre); | |||
analysis_sin_pre[n] = sinf(pre); | |||
} | |||
for (k = 0; k < 32; k++) { | |||
float post = M_PI * (k + 0.5) / 128; | |||
analysis_cossin_post[k][0] = 4.0 * cosf(post); | |||
analysis_cossin_post[k][1] = -4.0 * sinf(post); | |||
} | |||
for (n = 1; n < 320; n++) | |||
sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n]; | |||
sbr_qmf_window_us[384] = -sbr_qmf_window_us[384]; | |||
@@ -133,6 +121,8 @@ av_cold void ff_aac_sbr_init(void) | |||
for (n = 0; n < 320; n++) | |||
sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; | |||
ff_ps_init(); | |||
} | |||
av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) | |||
@@ -142,13 +132,14 @@ av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) | |||
sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); | |||
sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); | |||
ff_mdct_init(&sbr->mdct, 7, 1, 1.0/64); | |||
ff_rdft_init(&sbr->rdft, 6, IDFT_R2C); | |||
ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0); | |||
ff_ps_ctx_init(&sbr->ps); | |||
} | |||
av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) | |||
{ | |||
ff_mdct_end(&sbr->mdct); | |||
ff_rdft_end(&sbr->rdft); | |||
ff_mdct_end(&sbr->mdct_ana); | |||
} | |||
static int qsort_comparison_function_int16(const void *a, const void *b) | |||
@@ -293,15 +284,15 @@ static void make_bands(int16_t* bands, int start, int stop, int num_bands) | |||
bands[num_bands-1] = stop - previous; | |||
} | |||
static int check_n_master(AVCodecContext *avccontext, int n_master, int bs_xover_band) | |||
static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band) | |||
{ | |||
// Requirements (14496-3 sp04 p205) | |||
if (n_master <= 0) { | |||
av_log(avccontext, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); | |||
av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master); | |||
return -1; | |||
} | |||
if (bs_xover_band >= n_master) { | |||
av_log(avccontext, AV_LOG_ERROR, | |||
av_log(avctx, AV_LOG_ERROR, | |||
"Invalid bitstream, crossover band index beyond array bounds: %d\n", | |||
bs_xover_band); | |||
return -1; | |||
@@ -349,7 +340,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, | |||
sbr_offset_ptr = sbr_offset[5]; | |||
break; | |||
default: | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Unsupported sample rate for SBR: %d\n", sbr->sample_rate); | |||
return -1; | |||
} | |||
@@ -367,7 +358,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, | |||
} else if (spectrum->bs_stop_freq == 15) { | |||
sbr->k[2] = 3*sbr->k[0]; | |||
} else { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq); | |||
return -1; | |||
} | |||
@@ -382,18 +373,17 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, | |||
max_qmf_subbands = 32; | |||
if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]); | |||
return -1; | |||
} | |||
if (!spectrum->bs_freq_scale) { | |||
unsigned int dk; | |||
int k2diff; | |||
int dk, k2diff; | |||
dk = spectrum->bs_alter_scale + 1; | |||
sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; | |||
if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band)) | |||
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) | |||
return -1; | |||
for (k = 1; k <= sbr->n_master; k++) | |||
@@ -428,7 +418,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, | |||
num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2; | |||
if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205) | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0); | |||
return -1; | |||
} | |||
@@ -442,7 +432,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, | |||
vk0[0] = sbr->k[0]; | |||
for (k = 1; k <= num_bands_0; k++) { | |||
if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205) | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]); | |||
return -1; | |||
} | |||
vk0[k] += vk0[k-1]; | |||
@@ -472,14 +462,14 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, | |||
vk1[0] = sbr->k[1]; | |||
for (k = 1; k <= num_bands_1; k++) { | |||
if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205) | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]); | |||
return -1; | |||
} | |||
vk1[k] += vk1[k-1]; | |||
} | |||
sbr->n_master = num_bands_0 + num_bands_1; | |||
if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band)) | |||
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) | |||
return -1; | |||
memcpy(&sbr->f_master[0], vk0, | |||
(num_bands_0 + 1) * sizeof(sbr->f_master[0])); | |||
@@ -488,7 +478,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, | |||
} else { | |||
sbr->n_master = num_bands_0; | |||
if (check_n_master(ac->avccontext, sbr->n_master, sbr->spectrum_params.bs_xover_band)) | |||
if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band)) | |||
return -1; | |||
memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0])); | |||
} | |||
@@ -524,7 +514,7 @@ static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr) | |||
// illegal however the Coding Technologies decoder check stream has a final | |||
// count of 6 patches | |||
if (sbr->num_patches > 5) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches); | |||
return -1; | |||
} | |||
@@ -563,12 +553,12 @@ static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) | |||
// Requirements (14496-3 sp04 p205) | |||
if (sbr->kx[1] + sbr->m[1] > 64) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]); | |||
return -1; | |||
} | |||
if (sbr->kx[1] > 32) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]); | |||
return -1; | |||
} | |||
@@ -580,7 +570,7 @@ static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr) | |||
sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands * | |||
log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3 | |||
if (sbr->n_q > 5) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q); | |||
return -1; | |||
} | |||
@@ -638,7 +628,7 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, | |||
ch_data->bs_amp_res = 0; | |||
if (ch_data->bs_num_env > 4) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n", | |||
ch_data->bs_num_env); | |||
return -1; | |||
@@ -693,7 +683,7 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, | |||
ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1; | |||
if (ch_data->bs_num_env > 5) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n", | |||
ch_data->bs_num_env); | |||
return -1; | |||
@@ -714,7 +704,7 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, | |||
} | |||
if (bs_pointer > ch_data->bs_num_env + 1) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n", | |||
bs_pointer); | |||
return -1; | |||
@@ -722,7 +712,7 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, | |||
for (i = 1; i <= ch_data->bs_num_env; i++) { | |||
if (ch_data->t_env[i-1] > ch_data->t_env[i]) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Non monotone time borders\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n"); | |||
return -1; | |||
} | |||
} | |||
@@ -903,25 +893,24 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, | |||
GetBitContext *gb, | |||
int bs_extension_id, int *num_bits_left) | |||
{ | |||
//TODO - implement ps_data for parametric stereo parsing | |||
switch (bs_extension_id) { | |||
case EXTENSION_ID_PS: | |||
if (!ac->m4ac.ps) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); | |||
av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n"); | |||
skip_bits_long(gb, *num_bits_left); // bs_fill_bits | |||
*num_bits_left = 0; | |||
} else { | |||
#if 0 | |||
*num_bits_left -= ff_ps_data(gb, ps); | |||
#if 1 | |||
*num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); | |||
#else | |||
av_log_missing_feature(ac->avccontext, "Parametric Stereo is", 0); | |||
av_log_missing_feature(ac->avctx, "Parametric Stereo is", 0); | |||
skip_bits_long(gb, *num_bits_left); // bs_fill_bits | |||
*num_bits_left = 0; | |||
#endif | |||
} | |||
break; | |||
default: | |||
av_log_missing_feature(ac->avccontext, "Reserved SBR extensions are", 1); | |||
av_log_missing_feature(ac->avctx, "Reserved SBR extensions are", 1); | |||
skip_bits_long(gb, *num_bits_left); // bs_fill_bits | |||
*num_bits_left = 0; | |||
break; | |||
@@ -1006,7 +995,7 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, | |||
return get_bits_count(gb) - cnt; | |||
} | |||
} else { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Invalid bitstream - cannot apply SBR to element type %d\n", id_aac); | |||
sbr->start = 0; | |||
return get_bits_count(gb) - cnt; | |||
@@ -1021,6 +1010,11 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, | |||
num_bits_left -= 2; | |||
read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id | |||
} | |||
if (num_bits_left < 0) { | |||
av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); | |||
} | |||
if (num_bits_left > 0) | |||
skip_bits(gb, num_bits_left); | |||
} | |||
return get_bits_count(gb) - cnt; | |||
@@ -1033,7 +1027,7 @@ static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr) | |||
if (err >= 0) | |||
err = sbr_make_f_derived(ac, sbr); | |||
if (err < 0) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"SBR reset failed. Switching SBR to pure upsampling mode.\n"); | |||
sbr->start = 0; | |||
} | |||
@@ -1085,7 +1079,7 @@ int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, | |||
bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3); | |||
if (bytes_read > cnt) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read); | |||
} | |||
return cnt; | |||
@@ -1139,7 +1133,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) | |||
* @param x pointer to the beginning of the first sample window | |||
* @param W array of complex-valued samples split into subbands | |||
*/ | |||
static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in, float *x, | |||
static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, float *x, | |||
float z[320], float W[2][32][32][2], | |||
float scale) | |||
{ | |||
@@ -1152,23 +1146,23 @@ static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in | |||
memcpy(x+288, in, 1024*sizeof(*x)); | |||
for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames | |||
// are not supported | |||
float re, im; | |||
dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); | |||
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 * analysis_cos_pre[k]; | |||
z[k+64] = f; | |||
z[k] = f; | |||
} | |||
ff_rdft_calc(rdft, z); | |||
re = z[0] * 0.5f; | |||
im = 0.5f * dsp->scalarproduct_float(z+64, analysis_sin_pre, 64); | |||
W[1][i][0][0] = re * analysis_cossin_post[0][0] - im * analysis_cossin_post[0][1]; | |||
W[1][i][0][1] = re * analysis_cossin_post[0][1] + im * analysis_cossin_post[0][0]; | |||
//Shuffle to IMDCT | |||
z[64] = z[0]; | |||
for (k = 1; k < 32; k++) { | |||
re = z[2*k ] - re; | |||
im = z[2*k+1] - im; | |||
W[1][i][k][0] = re * analysis_cossin_post[k][0] - im * analysis_cossin_post[k][1]; | |||
W[1][i][k][1] = re * analysis_cossin_post[k][1] + im * analysis_cossin_post[k][0]; | |||
z[64+2*k-1] = z[ k]; | |||
z[64+2*k ] = -z[64-k]; | |||
} | |||
z[64+63] = z[32]; | |||
ff_imdct_half(mdct, z, z+64); | |||
for (k = 0; k < 32; k++) { | |||
W[1][i][k][0] = -z[63-k]; | |||
W[1][i][k][1] = z[k]; | |||
} | |||
x += 32; | |||
} | |||
@@ -1179,7 +1173,7 @@ static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in | |||
* (14496-3 sp04 p206) | |||
*/ | |||
static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, | |||
float *out, float X[2][32][64], | |||
float *out, float X[2][38][64], | |||
float mdct_buf[2][64], | |||
float *v0, int *v_off, const unsigned int div, | |||
float bias, float scale) | |||
@@ -1197,21 +1191,22 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, | |||
*v_off -= 128 >> div; | |||
} | |||
v = v0 + *v_off; | |||
for (n = 1; n < 64 >> div; n+=2) { | |||
X[1][i][n] = -X[1][i][n]; | |||
} | |||
if (div) { | |||
memset(X[0][i]+32, 0, 32*sizeof(float)); | |||
memset(X[1][i]+32, 0, 32*sizeof(float)); | |||
} | |||
ff_imdct_half(mdct, mdct_buf[0], X[0][i]); | |||
ff_imdct_half(mdct, mdct_buf[1], X[1][i]); | |||
if (div) { | |||
for (n = 0; n < 32; n++) { | |||
v[ n] = -mdct_buf[0][63 - 2*n] + mdct_buf[1][2*n ]; | |||
v[ 63 - n] = mdct_buf[0][62 - 2*n] + mdct_buf[1][2*n + 1]; | |||
X[0][i][ n] = -X[0][i][n]; | |||
X[0][i][32+n] = X[1][i][31-n]; | |||
} | |||
ff_imdct_half(mdct, mdct_buf[0], X[0][i]); | |||
for (n = 0; n < 32; n++) { | |||
v[ n] = mdct_buf[0][63 - 2*n]; | |||
v[63 - n] = -mdct_buf[0][62 - 2*n]; | |||
} | |||
} else { | |||
for (n = 1; n < 64; n+=2) { | |||
X[1][i][n] = -X[1][i][n]; | |||
} | |||
ff_imdct_half(mdct, mdct_buf[0], X[0][i]); | |||
ff_imdct_half(mdct, mdct_buf[1], X[1][i]); | |||
for (n = 0; n < 64; n++) { | |||
v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ]; | |||
v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ]; | |||
@@ -1380,7 +1375,7 @@ static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, | |||
g--; | |||
if (g < 0) { | |||
av_log(ac->avccontext, AV_LOG_ERROR, | |||
av_log(ac->avctx, AV_LOG_ERROR, | |||
"ERROR : no subband found for frequency %d\n", k); | |||
return -1; | |||
} | |||
@@ -1414,7 +1409,7 @@ static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, | |||
} | |||
/// Generate the subband filtered lowband | |||
static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64], | |||
static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], | |||
const float X_low[32][40][2], const float Y[2][38][64][2], | |||
int ch) | |||
{ | |||
@@ -1436,7 +1431,7 @@ static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64], | |||
} | |||
for (k = 0; k < sbr->kx[1]; k++) { | |||
for (i = i_Temp; i < i_f; i++) { | |||
for (i = i_Temp; i < 38; i++) { | |||
X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; | |||
X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; | |||
} | |||
@@ -1730,7 +1725,7 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, | |||
} | |||
for (ch = 0; ch < nch; ch++) { | |||
/* decode channel */ | |||
sbr_qmf_analysis(&ac->dsp, &sbr->rdft, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, | |||
sbr_qmf_analysis(&ac->dsp, &sbr->mdct_ana, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, | |||
(float*)sbr->qmf_filter_scratch, | |||
sbr->data[ch].W, 1/(-1024 * ac->sf_scale)); | |||
sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W); | |||
@@ -1752,6 +1747,16 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, | |||
/* synthesis */ | |||
sbr_x_gen(sbr, sbr->X[ch], sbr->X_low, sbr->data[ch].Y, ch); | |||
} | |||
if (ac->m4ac.ps == 1) { | |||
if (sbr->ps.start) { | |||
ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); | |||
} else { | |||
memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); | |||
} | |||
nch = 2; | |||
} | |||
sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, L, sbr->X[0], sbr->qmf_filter_scratch, | |||
sbr->data[0].synthesis_filterbank_samples, | |||
&sbr->data[0].synthesis_filterbank_samples_offset, | |||
@@ -29,6 +29,7 @@ | |||
#include "libavutil/mem.h" | |||
#include "aac.h" | |||
#include "aac_tablegen.h" | |||
#include <stdint.h> | |||
@@ -1204,129 +1205,3 @@ const uint8_t ff_tns_max_bands_128[] = { | |||
9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 | |||
}; | |||
// @} | |||
#if CONFIG_HARDCODED_TABLES | |||
/** | |||
* Table of pow(2, (i - 200)/4.) used for different purposes depending on the | |||
* range of indices to the table: | |||
* [ 0, 255] scale factor decoding when using C dsp.float_to_int16 | |||
* [60, 315] scale factor decoding when using SIMD dsp.float_to_int16 | |||
* [45, 300] intensity stereo position decoding mapped in reverse order i.e. 0->300, 1->299, ..., 254->46, 255->45 | |||
*/ | |||
const float ff_aac_pow2sf_tab[428] = { | |||
8.88178420e-16, 1.05622810e-15, 1.25607397e-15, 1.49373210e-15, | |||
1.77635684e-15, 2.11245619e-15, 2.51214793e-15, 2.98746420e-15, | |||
3.55271368e-15, 4.22491238e-15, 5.02429587e-15, 5.97492839e-15, | |||
7.10542736e-15, 8.44982477e-15, 1.00485917e-14, 1.19498568e-14, | |||
1.42108547e-14, 1.68996495e-14, 2.00971835e-14, 2.38997136e-14, | |||
2.84217094e-14, 3.37992991e-14, 4.01943669e-14, 4.77994272e-14, | |||
5.68434189e-14, 6.75985982e-14, 8.03887339e-14, 9.55988543e-14, | |||
1.13686838e-13, 1.35197196e-13, 1.60777468e-13, 1.91197709e-13, | |||
2.27373675e-13, 2.70394393e-13, 3.21554936e-13, 3.82395417e-13, | |||
4.54747351e-13, 5.40788785e-13, 6.43109871e-13, 7.64790834e-13, | |||
9.09494702e-13, 1.08157757e-12, 1.28621974e-12, 1.52958167e-12, | |||
1.81898940e-12, 2.16315514e-12, 2.57243948e-12, 3.05916334e-12, | |||
3.63797881e-12, 4.32631028e-12, 5.14487897e-12, 6.11832668e-12, | |||
7.27595761e-12, 8.65262056e-12, 1.02897579e-11, 1.22366534e-11, | |||
1.45519152e-11, 1.73052411e-11, 2.05795159e-11, 2.44733067e-11, | |||
2.91038305e-11, 3.46104823e-11, 4.11590317e-11, 4.89466134e-11, | |||
5.82076609e-11, 6.92209645e-11, 8.23180635e-11, 9.78932268e-11, | |||
1.16415322e-10, 1.38441929e-10, 1.64636127e-10, 1.95786454e-10, | |||
2.32830644e-10, 2.76883858e-10, 3.29272254e-10, 3.91572907e-10, | |||
4.65661287e-10, 5.53767716e-10, 6.58544508e-10, 7.83145814e-10, | |||
9.31322575e-10, 1.10753543e-09, 1.31708902e-09, 1.56629163e-09, | |||
1.86264515e-09, 2.21507086e-09, 2.63417803e-09, 3.13258326e-09, | |||
3.72529030e-09, 4.43014173e-09, 5.26835606e-09, 6.26516652e-09, | |||
7.45058060e-09, 8.86028346e-09, 1.05367121e-08, 1.25303330e-08, | |||
1.49011612e-08, 1.77205669e-08, 2.10734243e-08, 2.50606661e-08, | |||
2.98023224e-08, 3.54411338e-08, 4.21468485e-08, 5.01213321e-08, | |||
5.96046448e-08, 7.08822677e-08, 8.42936970e-08, 1.00242664e-07, | |||
1.19209290e-07, 1.41764535e-07, 1.68587394e-07, 2.00485328e-07, | |||
2.38418579e-07, 2.83529071e-07, 3.37174788e-07, 4.00970657e-07, | |||
4.76837158e-07, 5.67058141e-07, 6.74349576e-07, 8.01941314e-07, | |||
9.53674316e-07, 1.13411628e-06, 1.34869915e-06, 1.60388263e-06, | |||
1.90734863e-06, 2.26823256e-06, 2.69739830e-06, 3.20776526e-06, | |||
3.81469727e-06, 4.53646513e-06, 5.39479661e-06, 6.41553051e-06, | |||
7.62939453e-06, 9.07293026e-06, 1.07895932e-05, 1.28310610e-05, | |||
1.52587891e-05, 1.81458605e-05, 2.15791864e-05, 2.56621220e-05, | |||
3.05175781e-05, 3.62917210e-05, 4.31583729e-05, 5.13242441e-05, | |||
6.10351562e-05, 7.25834421e-05, 8.63167458e-05, 1.02648488e-04, | |||
1.22070312e-04, 1.45166884e-04, 1.72633492e-04, 2.05296976e-04, | |||
2.44140625e-04, 2.90333768e-04, 3.45266983e-04, 4.10593953e-04, | |||
4.88281250e-04, 5.80667537e-04, 6.90533966e-04, 8.21187906e-04, | |||
9.76562500e-04, 1.16133507e-03, 1.38106793e-03, 1.64237581e-03, | |||
1.95312500e-03, 2.32267015e-03, 2.76213586e-03, 3.28475162e-03, | |||
3.90625000e-03, 4.64534029e-03, 5.52427173e-03, 6.56950324e-03, | |||
7.81250000e-03, 9.29068059e-03, 1.10485435e-02, 1.31390065e-02, | |||
1.56250000e-02, 1.85813612e-02, 2.20970869e-02, 2.62780130e-02, | |||
3.12500000e-02, 3.71627223e-02, 4.41941738e-02, 5.25560260e-02, | |||
6.25000000e-02, 7.43254447e-02, 8.83883476e-02, 1.05112052e-01, | |||
1.25000000e-01, 1.48650889e-01, 1.76776695e-01, 2.10224104e-01, | |||
2.50000000e-01, 2.97301779e-01, 3.53553391e-01, 4.20448208e-01, | |||
5.00000000e-01, 5.94603558e-01, 7.07106781e-01, 8.40896415e-01, | |||
1.00000000e+00, 1.18920712e+00, 1.41421356e+00, 1.68179283e+00, | |||
2.00000000e+00, 2.37841423e+00, 2.82842712e+00, 3.36358566e+00, | |||
4.00000000e+00, 4.75682846e+00, 5.65685425e+00, 6.72717132e+00, | |||
8.00000000e+00, 9.51365692e+00, 1.13137085e+01, 1.34543426e+01, | |||
1.60000000e+01, 1.90273138e+01, 2.26274170e+01, 2.69086853e+01, | |||
3.20000000e+01, 3.80546277e+01, 4.52548340e+01, 5.38173706e+01, | |||
6.40000000e+01, 7.61092554e+01, 9.05096680e+01, 1.07634741e+02, | |||
1.28000000e+02, 1.52218511e+02, 1.81019336e+02, 2.15269482e+02, | |||
2.56000000e+02, 3.04437021e+02, 3.62038672e+02, 4.30538965e+02, | |||
5.12000000e+02, 6.08874043e+02, 7.24077344e+02, 8.61077929e+02, | |||
1.02400000e+03, 1.21774809e+03, 1.44815469e+03, 1.72215586e+03, | |||
2.04800000e+03, 2.43549617e+03, 2.89630938e+03, 3.44431172e+03, | |||
4.09600000e+03, 4.87099234e+03, 5.79261875e+03, 6.88862343e+03, | |||
8.19200000e+03, 9.74198469e+03, 1.15852375e+04, 1.37772469e+04, | |||
1.63840000e+04, 1.94839694e+04, 2.31704750e+04, 2.75544937e+04, | |||
3.27680000e+04, 3.89679387e+04, 4.63409500e+04, 5.51089875e+04, | |||
6.55360000e+04, 7.79358775e+04, 9.26819000e+04, 1.10217975e+05, | |||
1.31072000e+05, 1.55871755e+05, 1.85363800e+05, 2.20435950e+05, | |||
2.62144000e+05, 3.11743510e+05, 3.70727600e+05, 4.40871900e+05, | |||
5.24288000e+05, 6.23487020e+05, 7.41455200e+05, 8.81743800e+05, | |||
1.04857600e+06, 1.24697404e+06, 1.48291040e+06, 1.76348760e+06, | |||
2.09715200e+06, 2.49394808e+06, 2.96582080e+06, 3.52697520e+06, | |||
4.19430400e+06, 4.98789616e+06, 5.93164160e+06, 7.05395040e+06, | |||
8.38860800e+06, 9.97579232e+06, 1.18632832e+07, 1.41079008e+07, | |||
1.67772160e+07, 1.99515846e+07, 2.37265664e+07, 2.82158016e+07, | |||
3.35544320e+07, 3.99031693e+07, 4.74531328e+07, 5.64316032e+07, | |||
6.71088640e+07, 7.98063385e+07, 9.49062656e+07, 1.12863206e+08, | |||
1.34217728e+08, 1.59612677e+08, 1.89812531e+08, 2.25726413e+08, | |||
2.68435456e+08, 3.19225354e+08, 3.79625062e+08, 4.51452825e+08, | |||
5.36870912e+08, 6.38450708e+08, 7.59250125e+08, 9.02905651e+08, | |||
1.07374182e+09, 1.27690142e+09, 1.51850025e+09, 1.80581130e+09, | |||
2.14748365e+09, 2.55380283e+09, 3.03700050e+09, 3.61162260e+09, | |||
4.29496730e+09, 5.10760567e+09, 6.07400100e+09, 7.22324521e+09, | |||
8.58993459e+09, 1.02152113e+10, 1.21480020e+10, 1.44464904e+10, | |||
1.71798692e+10, 2.04304227e+10, 2.42960040e+10, 2.88929808e+10, | |||
3.43597384e+10, 4.08608453e+10, 4.85920080e+10, 5.77859616e+10, | |||
6.87194767e+10, 8.17216907e+10, 9.71840160e+10, 1.15571923e+11, | |||
1.37438953e+11, 1.63443381e+11, 1.94368032e+11, 2.31143847e+11, | |||
2.74877907e+11, 3.26886763e+11, 3.88736064e+11, 4.62287693e+11, | |||
5.49755814e+11, 6.53773525e+11, 7.77472128e+11, 9.24575386e+11, | |||
1.09951163e+12, 1.30754705e+12, 1.55494426e+12, 1.84915077e+12, | |||
2.19902326e+12, 2.61509410e+12, 3.10988851e+12, 3.69830155e+12, | |||
4.39804651e+12, 5.23018820e+12, 6.21977702e+12, 7.39660309e+12, | |||
8.79609302e+12, 1.04603764e+13, 1.24395540e+13, 1.47932062e+13, | |||
1.75921860e+13, 2.09207528e+13, 2.48791081e+13, 2.95864124e+13, | |||
3.51843721e+13, 4.18415056e+13, 4.97582162e+13, 5.91728247e+13, | |||
7.03687442e+13, 8.36830112e+13, 9.95164324e+13, 1.18345649e+14, | |||
1.40737488e+14, 1.67366022e+14, 1.99032865e+14, 2.36691299e+14, | |||
2.81474977e+14, 3.34732045e+14, 3.98065730e+14, 4.73382598e+14, | |||
5.62949953e+14, 6.69464090e+14, 7.96131459e+14, 9.46765196e+14, | |||
1.12589991e+15, 1.33892818e+15, 1.59226292e+15, 1.89353039e+15, | |||
2.25179981e+15, 2.67785636e+15, 3.18452584e+15, 3.78706078e+15, | |||
4.50359963e+15, 5.35571272e+15, 6.36905167e+15, 7.57412156e+15, | |||
9.00719925e+15, 1.07114254e+16, 1.27381033e+16, 1.51482431e+16, | |||
1.80143985e+16, 2.14228509e+16, 2.54762067e+16, 3.02964863e+16, | |||
3.60287970e+16, 4.28457018e+16, 5.09524134e+16, 6.05929725e+16, | |||
7.20575940e+16, 8.56914035e+16, 1.01904827e+17, 1.21185945e+17, | |||
}; | |||
#else | |||
float ff_aac_pow2sf_tab[428]; | |||
#endif /* CONFIG_HARDCODED_TABLES */ |
@@ -32,6 +32,7 @@ | |||
#include "libavutil/mem.h" | |||
#include "aac.h" | |||
#include "aac_tablegen_decl.h" | |||
#include <stdint.h> | |||
@@ -73,10 +74,4 @@ extern const uint16_t * const ff_swb_offset_128 [13]; | |||
extern const uint8_t ff_tns_max_bands_1024[13]; | |||
extern const uint8_t ff_tns_max_bands_128 [13]; | |||
#if CONFIG_HARDCODED_TABLES | |||
extern const float ff_aac_pow2sf_tab[428]; | |||
#else | |||
extern float ff_aac_pow2sf_tab[428]; | |||
#endif /* CONFIG_HARDCODED_TABLES */ | |||
#endif /* AVCODEC_AACTAB_H */ |
@@ -31,6 +31,7 @@ | |||
#include <stdint.h> | |||
#include "fft.h" | |||
#include "aacps.h" | |||
/** | |||
* Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header. | |||
@@ -133,6 +134,7 @@ typedef struct { | |||
///The number of frequency bands in f_master | |||
unsigned n_master; | |||
SBRData data[2]; | |||
PSContext ps; | |||
///N_Low and N_High respectively, the number of frequency bands for low and high resolution | |||
unsigned n[2]; | |||
///Number of noise floor bands | |||
@@ -157,7 +159,7 @@ typedef struct { | |||
///QMF output of the HF generator | |||
float X_high[64][40][2]; | |||
///QMF values of the reconstructed signal | |||
DECLARE_ALIGNED(16, float, X)[2][2][32][64]; | |||
DECLARE_ALIGNED(16, float, X)[2][2][38][64]; | |||
///Zeroth coefficient used to filter the subband signals | |||
float alpha0[64][2]; | |||
///First coefficient used to filter the subband signals | |||
@@ -176,7 +178,7 @@ typedef struct { | |||
float s_m[7][48]; | |||
float gain[7][48]; | |||
DECLARE_ALIGNED(16, float, qmf_filter_scratch)[5][64]; | |||
RDFTContext rdft; | |||
FFTContext mdct_ana; | |||
FFTContext mdct; | |||
} SpectralBandReplication; | |||