Commit 9fb7e146 authored by Alex Converse's avatar Alex Converse

aacdec: More robust output configuration.

Save the old output configuration (if it has been used
successfully) when trying a new configuration. If the new configuration
fails to decode, restore the last successful configuration.
parent af2f655c
......@@ -112,6 +112,15 @@ enum OCStatus {
OC_LOCKED, ///< Output configuration locked in place
};
typedef struct {
MPEG4AudioConfig m4ac;
uint8_t layout_map[MAX_ELEM_ID*4][3];
int layout_map_tags;
int channels;
uint64_t channel_layout;
enum OCStatus status;
} OutputConfiguration;
/**
* Predictor State
*/
......@@ -254,8 +263,6 @@ typedef struct {
AVCodecContext *avctx;
AVFrame frame;
MPEG4AudioConfig m4ac;
int is_saved; ///< Set if elements have stored overlap from previous frame.
DynamicRangeControl che_drc;
......@@ -263,8 +270,6 @@ typedef struct {
* @name Channel element related data
* @{
*/
uint8_t layout_map[MAX_ELEM_ID*4][3];
int layout_map_tags;
ChannelElement *che[4][MAX_ELEM_ID];
ChannelElement *tag_che_map[4][MAX_ELEM_ID];
int tags_mapped;
......@@ -299,7 +304,7 @@ typedef struct {
DECLARE_ALIGNED(32, float, temp)[128];
enum OCStatus output_configured;
OutputConfiguration oc[2];
} AACContext;
#endif /* AVCODEC_AAC_H */
This diff is collapsed.
......@@ -914,7 +914,7 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
{
switch (bs_extension_id) {
case EXTENSION_ID_PS:
if (!ac->m4ac.ps) {
if (!ac->oc[1].m4ac.ps) {
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;
......@@ -1071,9 +1071,9 @@ int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
sbr->reset = 0;
if (!sbr->sample_rate)
sbr->sample_rate = 2 * ac->m4ac.sample_rate; //TODO use the nominal sample rate for arbitrary sample rate support
if (!ac->m4ac.ext_sample_rate)
ac->m4ac.ext_sample_rate = 2 * ac->m4ac.sample_rate;
sbr->sample_rate = 2 * ac->oc[1].m4ac.sample_rate; //TODO use the nominal sample rate for arbitrary sample rate support
if (!ac->oc[1].m4ac.ext_sample_rate)
ac->oc[1].m4ac.ext_sample_rate = 2 * ac->oc[1].m4ac.sample_rate;
if (crc) {
skip_bits(gb, 10); // bs_sbr_crc_bits; TODO - implement CRC check
......@@ -1648,7 +1648,7 @@ static void sbr_hf_assemble(float Y1[38][64][2],
void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
float* L, float* R)
{
int downsampled = ac->m4ac.ext_sample_rate < sbr->sample_rate;
int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;
int ch;
int nch = (id_aac == TYPE_CPE) ? 2 : 1;
int err;
......@@ -1695,7 +1695,7 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
sbr->X_low, ch);
}
if (ac->m4ac.ps == 1) {
if (ac->oc[1].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 {
......
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