summaryrefslogtreecommitdiffstats
path: root/libSBRdec
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2014-05-20 17:39:03 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2014-05-20 17:39:03 -0700
commit6792cf6361ff339e336287affb0bfe54bf6957a9 (patch)
tree6c4e2434c706bb4b13763a097c1ae2c160eb96c0 /libSBRdec
parent8e087bf394c5ceddcdb8b1d029795aff3026eea0 (diff)
downloadandroid_external_aac-6792cf6361ff339e336287affb0bfe54bf6957a9.tar.gz
android_external_aac-6792cf6361ff339e336287affb0bfe54bf6957a9.tar.bz2
android_external_aac-6792cf6361ff339e336287affb0bfe54bf6957a9.zip
Revise decoder output delay determination. The output delay consisted of concealment and limiter delay. SBR delay was not covered but must be considered for gapless playback delay compensation. Bug 9428126 Change-Id: I67483712c284de9b5378694f9db7acbed2547dd7
Diffstat (limited to 'libSBRdec')
-rw-r--r--libSBRdec/include/sbrdecoder.h7
-rw-r--r--libSBRdec/src/env_extr.h1
-rw-r--r--libSBRdec/src/sbrdecoder.cpp35
3 files changed, 42 insertions, 1 deletions
diff --git a/libSBRdec/include/sbrdecoder.h b/libSBRdec/include/sbrdecoder.h
index 36a4739..174fb5c 100644
--- a/libSBRdec/include/sbrdecoder.h
+++ b/libSBRdec/include/sbrdecoder.h
@@ -331,6 +331,13 @@ SBR_ERROR sbrDecoder_Close ( HANDLE_SBRDECODER *self );
*/
INT sbrDecoder_GetLibInfo( LIB_INFO *info );
+/**
+ * \brief Determine the modules output signal delay in samples.
+ * \param self SBR decoder handle.
+ * \return The number of samples signal delay added by the module.
+ */
+UINT sbrDecoder_GetDelay( const HANDLE_SBRDECODER self );
+
#ifdef __cplusplus
}
diff --git a/libSBRdec/src/env_extr.h b/libSBRdec/src/env_extr.h
index ddbfa18..ab6b704 100644
--- a/libSBRdec/src/env_extr.h
+++ b/libSBRdec/src/env_extr.h
@@ -179,6 +179,7 @@ typedef FREQ_BAND_DATA *HANDLE_FREQ_BAND_DATA;
#define SBRDEC_LOW_POWER 16 /* Flag indicating that Low Power QMF mode shall be used. */
#define SBRDEC_PS_DECODED 32 /* Flag indicating that PS was decoded and rendered. */
#define SBRDEC_LD_MPS_QMF 512 /* Flag indicating that the LD-MPS QMF shall be used. */
+#define SBRDEC_DOWNSAMPLE 8192 /* Flag indicating that the downsampling mode is used. */
#define SBRDEC_FLUSH 16384 /* Flag is used to flush all elements in use. */
#define SBRDEC_FORCE_RESET 32768 /* Flag is used to force a reset of all elements in use. */
diff --git a/libSBRdec/src/sbrdecoder.cpp b/libSBRdec/src/sbrdecoder.cpp
index bed23c7..16b0bbc 100644
--- a/libSBRdec/src/sbrdecoder.cpp
+++ b/libSBRdec/src/sbrdecoder.cpp
@@ -137,7 +137,7 @@ amm-info@iis.fraunhofer.de
/* Decoder library info */
#define SBRDECODER_LIB_VL0 2
#define SBRDECODER_LIB_VL1 2
-#define SBRDECODER_LIB_VL2 5
+#define SBRDECODER_LIB_VL2 6
#define SBRDECODER_LIB_TITLE "SBR Decoder"
#define SBRDECODER_LIB_BUILD_DATE __DATE__
#define SBRDECODER_LIB_BUILD_TIME __TIME__
@@ -251,8 +251,10 @@ SBR_ERROR sbrDecoder_ResetElement (
if ( sampleRateIn == sampleRateOut ) {
synDownsampleFac = 2;
+ self->flags |= SBRDEC_DOWNSAMPLE;
} else {
synDownsampleFac = 1;
+ self->flags &= ~SBRDEC_DOWNSAMPLE;
}
self->synDownsampleFac = synDownsampleFac;
@@ -1582,3 +1584,34 @@ INT sbrDecoder_GetLibInfo( LIB_INFO *info )
return 0;
}
+
+UINT sbrDecoder_GetDelay( const HANDLE_SBRDECODER self )
+{
+ UINT outputDelay = 0;
+
+ if ( self != NULL) {
+ UINT flags = self->flags;
+
+ /* See chapter 1.6.7.2 of ISO/IEC 14496-3 for the GA-SBR figures below. */
+
+ /* Are we initialized? */
+ if ( (self->numSbrChannels > 0)
+ && (self->numSbrElements > 0) )
+ {
+ /* Add QMF synthesis delay */
+ if ( (flags & SBRDEC_ELD_GRID)
+ && IS_LOWDELAY(self->coreCodec) ) {
+ /* Low delay SBR: */
+ {
+ outputDelay += (flags & SBRDEC_DOWNSAMPLE) ? 32 : 64; /* QMF synthesis */
+ }
+ }
+ else if (!IS_USAC(self->coreCodec)) {
+ /* By the method of elimination this is the GA (AAC-LC, HE-AAC, ...) branch: */
+ outputDelay += (flags & SBRDEC_DOWNSAMPLE) ? 481 : 962;
+ }
+ }
+ }
+
+ return (outputDelay);
+}