summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2015-07-09 19:17:56 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-09 19:17:57 +0000
commitbdc55b4b0f337e03dcdbc58db3adc49209d0c3a2 (patch)
treed2862b313ee44664371776cdd78e79fb6ebee02f
parentd91ea14b659bb8e386f92c7bf77e9e052ad5b1ae (diff)
parentfd3cca76c0eef854cfe4406cfb7204e38f1adc48 (diff)
downloadandroid_system_media-bdc55b4b0f337e03dcdbc58db3adc49209d0c3a2.tar.gz
android_system_media-bdc55b4b0f337e03dcdbc58db3adc49209d0c3a2.tar.bz2
android_system_media-bdc55b4b0f337e03dcdbc58db3adc49209d0c3a2.zip
Merge "SPDIFEncoder: EAC3 fixes from NVidia" into mnc-dev
-rw-r--r--audio_utils/include/audio_utils/spdif/FrameScanner.h5
-rw-r--r--audio_utils/spdif/AC3FrameScanner.cpp11
-rw-r--r--audio_utils/spdif/AC3FrameScanner.h2
-rw-r--r--audio_utils/spdif/SPDIFEncoder.cpp6
4 files changed, 20 insertions, 4 deletions
diff --git a/audio_utils/include/audio_utils/spdif/FrameScanner.h b/audio_utils/include/audio_utils/spdif/FrameScanner.h
index 7b88ae23..6d391eed 100644
--- a/audio_utils/include/audio_utils/spdif/FrameScanner.h
+++ b/audio_utils/include/audio_utils/spdif/FrameScanner.h
@@ -97,6 +97,11 @@ public:
*/
virtual bool isLastInBurst() = 0;
+ /**
+ * Most compression types use a lengthCode expressed in bits.
+ */
+ virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const { return numBytes * 8; }
+
protected:
uint32_t mBytesSkipped; // how many bytes were skipped looking for the start of a frame
const uint8_t *mSyncBytes; // pointer to the sync word specific to a format
diff --git a/audio_utils/spdif/AC3FrameScanner.cpp b/audio_utils/spdif/AC3FrameScanner.cpp
index 7f8068d0..ffbedb52 100644
--- a/audio_utils/spdif/AC3FrameScanner.cpp
+++ b/audio_utils/spdif/AC3FrameScanner.cpp
@@ -126,6 +126,12 @@ void AC3FrameScanner::resetBurst()
}
}
+// Per IEC 61973-3:5.3.3, for E-AC3 burst-length shall be in bytes.
+uint16_t AC3FrameScanner::convertBytesToLengthCode(uint16_t numBytes) const
+{
+ return (mDataType == SPDIF_DATA_TYPE_E_AC3) ? numBytes : numBytes * 8;
+}
+
// per IEC 61973-3 Paragraph 5.3.3
// We have to send 6 audio blocks on all active substreams.
// Substream zero must be the first.
@@ -204,7 +210,10 @@ bool AC3FrameScanner::parseHeader()
// Keep track of how many audio blocks we have for each substream.
// This should be safe because mSubstreamID is ANDed with 0x07 above.
// And the array is allocated as [8].
- mSubstreamBlockCounts[mSubstreamID] += mAudioBlocksPerSyncFrame;
+ if ((mStreamType == AC3_STREAM_TYPE_0)
+ || (mStreamType == AC3_STREAM_TYPE_2)) {
+ mSubstreamBlockCounts[mSubstreamID] += mAudioBlocksPerSyncFrame;
+ }
// Print enough so we can see all the substreams.
ALOGD_IF((mFormatDumpCount < 3*8 ),
diff --git a/audio_utils/spdif/AC3FrameScanner.h b/audio_utils/spdif/AC3FrameScanner.h
index f944dcc0..1ef56108 100644
--- a/audio_utils/spdif/AC3FrameScanner.h
+++ b/audio_utils/spdif/AC3FrameScanner.h
@@ -47,6 +47,8 @@ public:
virtual bool isLastInBurst();
virtual void resetBurst();
+ virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const;
+
protected:
// Keep track of how many of each substream blocks have been accumulated.
// We need all of each substream before sending block data burst.
diff --git a/audio_utils/spdif/SPDIFEncoder.cpp b/audio_utils/spdif/SPDIFEncoder.cpp
index 7a546276..2eeeba66 100644
--- a/audio_utils/spdif/SPDIFEncoder.cpp
+++ b/audio_utils/spdif/SPDIFEncoder.cpp
@@ -175,9 +175,9 @@ void SPDIFEncoder::flushBurstBuffer()
{
const int preambleSize = 4 * sizeof(uint16_t);
if (mByteCursor > preambleSize) {
- // Set number of bits for valid payload before zeroPad.
- uint16_t lengthCode = (mByteCursor - preambleSize) * 8;
- mBurstBuffer[3] = lengthCode;
+ // Set lengthCode for valid payload before zeroPad.
+ uint16_t numBytes = (mByteCursor - preambleSize);
+ mBurstBuffer[3] = mFramer->convertBytesToLengthCode(numBytes);
sendZeroPad();
writeOutput(mBurstBuffer, mByteCursor);