Skip to content

Commit

Permalink
Fix AAC/LATM playback for streams with changing config
Browse files Browse the repository at this point in the history
Refs #10079.

Signed-off-by: Gavin Hurlbut <ghurlbut@mythtv.org>
  • Loading branch information
jyavenard authored and Beirdo committed Oct 18, 2011
1 parent e89d6a9 commit 274470c
Show file tree
Hide file tree
Showing 6 changed files with 694 additions and 213 deletions.
2 changes: 1 addition & 1 deletion mythtv/configure
Expand Up @@ -1471,7 +1471,7 @@ rdft_select="fft"
# decoders / encoders / hardware accelerators
aac_decoder_select="mdct rdft"
aac_encoder_select="mdct"
aac_latm_decoder_select="aac_decoder"
aac_latm_decoder_select="aac_decoder aac_latm_parser"
ac3_decoder_select="mdct ac3_parser"
alac_encoder_select="lpc"
amrnb_decoder_select="lsp"
Expand Down
1 change: 0 additions & 1 deletion mythtv/external/FFmpeg/libavcodec/Makefile
Expand Up @@ -61,7 +61,6 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
aacpsy.o aactab.o \
psymodel.o iirfilter.o \
mpeg4audio.o
OBJS-$(CONFIG_AAC_LATM_DECODER) += aaclatmdec.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
OBJS-$(CONFIG_AC3_DECODER) += ac3dec.o ac3dec_data.o ac3.o
OBJS-$(CONFIG_AC3_ENCODER) += ac3enc.o ac3tab.o ac3.o
Expand Down
36 changes: 25 additions & 11 deletions mythtv/external/FFmpeg/libavcodec/aac.h
Expand Up @@ -42,6 +42,7 @@
#define MAX_ELEM_ID 16

#define TNS_MAX_ORDER 20
#define MAX_LTP_LONG_SFB 40

enum RawDataBlockType {
TYPE_SCE,
Expand Down Expand Up @@ -128,6 +129,17 @@ typedef struct {
#define SCALE_MAX_POS 255 ///< scalefactor index maximum value
#define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard
#define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference
#define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0);

/**
* Long Term Prediction
*/
typedef struct {
int8_t present;
int16_t lag;
float coef;
int8_t used[MAX_LTP_LONG_SFB];
} LongTermPrediction;

/**
* Individual Channel Stream
Expand All @@ -138,6 +150,7 @@ typedef struct {
uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sinus window.
int num_window_groups;
uint8_t group_len[8];
LongTermPrediction ltp;
const uint16_t *swb_offset; ///< table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular window
const uint8_t *swb_sizes; ///< table of scalefactor band sizes for a particular window
int num_swb; ///< number of scalefactor window bands
Expand Down Expand Up @@ -205,14 +218,15 @@ typedef struct {
IndividualChannelStream ics;
TemporalNoiseShaping tns;
Pulse pulse;
enum BandType band_type[128]; ///< band types
int band_type_run_end[120]; ///< band type run end points
float sf[120]; ///< scalefactors
int sf_idx[128]; ///< scalefactor indices (used by encoder)
uint8_t zeroes[128]; ///< band is not coded (used by encoder)
DECLARE_ALIGNED(16, float, coeffs)[1024]; ///< coefficients for IMDCT
DECLARE_ALIGNED(16, float, saved)[1024]; ///< overlap
DECLARE_ALIGNED(16, float, ret)[2048]; ///< PCM output
enum BandType band_type[128]; ///< band types
int band_type_run_end[120]; ///< band type run end points
float sf[120]; ///< scalefactors
int sf_idx[128]; ///< scalefactor indices (used by encoder)
uint8_t zeroes[128]; ///< band is not coded (used by encoder)
DECLARE_ALIGNED(16, float, coeffs)[1024]; ///< coefficients for IMDCT
DECLARE_ALIGNED(16, float, saved)[1024]; ///< overlap
DECLARE_ALIGNED(16, float, ret)[2048]; ///< PCM output
DECLARE_ALIGNED(16, int16_t, ltp_state)[3072]; ///< time signal for LTP
PredictorState predictor_state[MAX_PREDICTORS];
} SingleChannelElement;

Expand Down Expand Up @@ -251,15 +265,14 @@ typedef struct {
*/
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;
/** @} */

/**
* @defgroup temporary aligned temporary buffers (We do not want to have these on the stack.)
* @{
*/
DECLARE_ALIGNED(16, float, buf_mdct)[1024];
DECLARE_ALIGNED(16, float, buf_mdct)[2048];
/** @} */

/**
Expand All @@ -268,7 +281,9 @@ typedef struct {
*/
FFTContext mdct;
FFTContext mdct_small;
FFTContext mdct_ltp;
DSPContext dsp;
// FmtConvertContext fmt_conv;
int random_state;
/** @} */

Expand All @@ -277,7 +292,6 @@ typedef struct {
* @{
*/
float *output_data[MAX_CHANNELS]; ///< Points to each element's 'ret' buffer (PCM output).
float add_bias; ///< offset for dsp.float_to_int16
float sf_scale; ///< Pre-scale for correct IMDCT and dsp.float_to_int16.
int sf_offset; ///< offset into pow2sf_tab as appropriate for dsp.float_to_int16
/** @} */
Expand Down

0 comments on commit 274470c

Please sign in to comment.