mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
avcodec/aacsbr: Make ff_aac_sbr_* funcs accept ChannelElement*
Each ChannelElement contains exactly one SpectralBandReplication structure; the latter structure contains lots of buffers whose size depend upon USE_FIXED (i.e. AAC_FLOAT arrays). This complicates deduplicating the parts of the AAC decoder that are duplicated between the fixed-point and the floating point decoder. In order to fix this, the SpectralBandReplication structure will be moved from the part of ChannelElement visible to the common code. Therefore the ff_aac_sbr_* functions are ported to accept a ChannelElement*; they will then have to translate that to the corresponding SpectralBandReplication* themselves (which is possible, because there are floating-point and fixed-point versions of these functions). While just at it, also ensure that these functions are properly namespaced. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
3600f757db
commit
6975d965fc
@ -50,7 +50,6 @@
|
||||
#include "aac/aacdec_tab.h"
|
||||
#include "adts_header.h"
|
||||
#include "cbrt_data.h"
|
||||
#include "sbr.h"
|
||||
#include "aacsbr.h"
|
||||
#include "mpeg4audio.h"
|
||||
#include "profiles.h"
|
||||
|
@ -75,7 +75,6 @@
|
||||
#include "aac/aacdec_tab.h"
|
||||
#include "adts_header.h"
|
||||
#include "cbrt_data.h"
|
||||
#include "sbr.h"
|
||||
#include "aacsbr.h"
|
||||
#include "mpeg4audio.h"
|
||||
#include "profiles.h"
|
||||
|
@ -137,7 +137,7 @@ static av_cold int che_configure(AACDecContext *ac,
|
||||
int ret;
|
||||
if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
|
||||
return AVERROR(ENOMEM);
|
||||
ret = AAC_RENAME(ff_aac_sbr_ctx_init)(ac, &ac->che[type][id]->sbr, type);
|
||||
ret = AAC_RENAME(ff_aac_sbr_ctx_init)(ac, ac->che[type][id], type);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
@ -154,7 +154,7 @@ static av_cold int che_configure(AACDecContext *ac,
|
||||
}
|
||||
} else {
|
||||
if (ac->che[type][id])
|
||||
AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][id]->sbr);
|
||||
AAC_RENAME(ff_aac_sbr_ctx_close)(ac->che[type][id]);
|
||||
av_freep(&ac->che[type][id]);
|
||||
}
|
||||
return 0;
|
||||
@ -2461,7 +2461,7 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn
|
||||
ac->oc[1].m4ac.sbr = 1;
|
||||
ac->avctx->profile = AV_PROFILE_AAC_HE;
|
||||
}
|
||||
res = AAC_RENAME(ff_decode_sbr_extension)(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
|
||||
res = AAC_RENAME(ff_aac_sbr_decode_extension)(ac, che, gb, crc_flag, cnt, elem_type);
|
||||
if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) {
|
||||
av_log(ac->avctx, AV_LOG_VERBOSE, "Treating HE-AAC mono as stereo.\n");
|
||||
ac->warned_he_aac_mono = 1;
|
||||
@ -2942,7 +2942,7 @@ static void spectral_to_sample(AACDecContext *ac, int samples)
|
||||
ac->update_ltp(ac, &che->ch[1]);
|
||||
}
|
||||
if (ac->oc[1].m4ac.sbr > 0) {
|
||||
AAC_RENAME(ff_sbr_apply)(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
|
||||
AAC_RENAME(ff_aac_sbr_apply)(ac, che, type, che->ch[0].ret, che->ch[1].ret);
|
||||
}
|
||||
}
|
||||
if (type <= TYPE_CCE)
|
||||
@ -3382,7 +3382,7 @@ static av_cold int aac_decode_close(AVCodecContext *avctx)
|
||||
for (i = 0; i < MAX_ELEM_ID; i++) {
|
||||
for (type = 0; type < 4; type++) {
|
||||
if (ac->che[type][i])
|
||||
AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][i]->sbr);
|
||||
AAC_RENAME(ff_aac_sbr_ctx_close)(ac->che[type][i]);
|
||||
av_freep(&ac->che[type][i]);
|
||||
}
|
||||
}
|
||||
|
@ -30,14 +30,12 @@
|
||||
#define AVCODEC_AACSBR_H
|
||||
|
||||
#include "get_bits.h"
|
||||
#include "aacdec.h"
|
||||
#include "aac_defines.h"
|
||||
#include "sbr.h"
|
||||
|
||||
#define ENVELOPE_ADJUSTMENT_OFFSET 2
|
||||
#define NOISE_FLOOR_OFFSET 6
|
||||
|
||||
struct AACDecContext;
|
||||
|
||||
/**
|
||||
* SBR VLC tables
|
||||
*/
|
||||
@ -71,16 +69,14 @@ enum {
|
||||
/** Initialize SBR. */
|
||||
void AAC_RENAME(ff_aac_sbr_init)(void);
|
||||
/** Initialize one SBR context. */
|
||||
int AAC_RENAME(ff_aac_sbr_ctx_init)(struct AACDecContext *ac, SpectralBandReplication *sbr, int id_aac);
|
||||
int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, ChannelElement *che, int id_aac);
|
||||
/** Close one SBR context. */
|
||||
void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr);
|
||||
void AAC_RENAME(ff_aac_sbr_ctx_close)(ChannelElement *che);
|
||||
/** Decode one SBR element. */
|
||||
int AAC_RENAME(ff_decode_sbr_extension)(struct AACDecContext *ac, SpectralBandReplication *sbr,
|
||||
GetBitContext *gb, int crc, int cnt, int id_aac);
|
||||
int AAC_RENAME(ff_aac_sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
|
||||
GetBitContext *gb, int crc, int cnt, int id_aac);
|
||||
/** Apply one SBR element to one AAC element. */
|
||||
void AAC_RENAME(ff_sbr_apply)(struct AACDecContext *ac, SpectralBandReplication *sbr, int id_aac,
|
||||
INTFLOAT* L, INTFLOAT *R);
|
||||
|
||||
void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c);
|
||||
void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
|
||||
int id_aac, INTFLOAT* L, INTFLOAT* R);
|
||||
|
||||
#endif /* AVCODEC_AACSBR_H */
|
||||
|
@ -65,8 +65,9 @@ static void sbr_turnoff(SpectralBandReplication *sbr) {
|
||||
memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters));
|
||||
}
|
||||
|
||||
av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, SpectralBandReplication *sbr, int id_aac)
|
||||
av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, ChannelElement *che, int id_aac)
|
||||
{
|
||||
SpectralBandReplication *sbr = &che->sbr;
|
||||
int ret;
|
||||
float scale;
|
||||
|
||||
@ -103,8 +104,9 @@ av_cold int AAC_RENAME(ff_aac_sbr_ctx_init)(AACDecContext *ac, SpectralBandRepli
|
||||
return 0;
|
||||
}
|
||||
|
||||
av_cold void AAC_RENAME(ff_aac_sbr_ctx_close)(SpectralBandReplication *sbr)
|
||||
av_cold void AAC_RENAME(ff_aac_sbr_ctx_close)(ChannelElement *che)
|
||||
{
|
||||
SpectralBandReplication *sbr = &che->sbr;
|
||||
av_tx_uninit(&sbr->mdct);
|
||||
av_tx_uninit(&sbr->mdct_ana);
|
||||
}
|
||||
@ -1091,9 +1093,11 @@ static void sbr_reset(AACDecContext *ac, SpectralBandReplication *sbr)
|
||||
*
|
||||
* @return Returns number of bytes consumed from the TYPE_FIL element.
|
||||
*/
|
||||
int AAC_RENAME(ff_decode_sbr_extension)(AACDecContext *ac, SpectralBandReplication *sbr,
|
||||
GetBitContext *gb_host, int crc, int cnt, int id_aac)
|
||||
int AAC_RENAME(ff_aac_sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
|
||||
GetBitContext *gb_host, int crc,
|
||||
int cnt, int id_aac)
|
||||
{
|
||||
SpectralBandReplication *sbr = &che->sbr;
|
||||
unsigned int num_sbr_bits = 0, num_align_bits;
|
||||
unsigned bytes_read;
|
||||
GetBitContext gbc = *gb_host, *gb = &gbc;
|
||||
@ -1457,9 +1461,10 @@ static void sbr_env_estimate(AAC_FLOAT (*e_curr)[48], INTFLOAT X_high[64][40][2]
|
||||
}
|
||||
}
|
||||
|
||||
void AAC_RENAME(ff_sbr_apply)(AACDecContext *ac, SpectralBandReplication *sbr, int id_aac,
|
||||
INTFLOAT* L, INTFLOAT* R)
|
||||
void AAC_RENAME(ff_aac_sbr_apply)(AACDecContext *ac, ChannelElement *che,
|
||||
int id_aac, INTFLOAT* L, INTFLOAT* R)
|
||||
{
|
||||
SpectralBandReplication *sbr = &che->sbr;
|
||||
int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;
|
||||
int ch;
|
||||
int nch = (id_aac == TYPE_CPE) ? 2 : 1;
|
||||
|
@ -53,6 +53,7 @@
|
||||
|
||||
#include "libavcodec/aacdec.h"
|
||||
#include "libavcodec/aacsbr.h"
|
||||
#include "libavcodec/sbr.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavutil/mips/asmdefs.h"
|
||||
|
||||
|
@ -217,4 +217,6 @@ struct SpectralBandReplication {
|
||||
AACSBRContext c;
|
||||
};
|
||||
|
||||
void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c);
|
||||
|
||||
#endif /* AVCODEC_SBR_H */
|
||||
|
Loading…
Reference in New Issue
Block a user