summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-10-26 15:01:03 -0700
committerAndreas Huber <andih@google.com>2010-10-26 15:06:44 -0700
commit53409d6fe668e695e92479371f0ec162723feed5 (patch)
treea1dc60a6bd38819ab63f41cd80efd72d10d0100d /media
parentb2ee05b6c453b7da24b23139489ad92bb2c79621 (diff)
downloadframeworks_av-53409d6fe668e695e92479371f0ec162723feed5.zip
frameworks_av-53409d6fe668e695e92479371f0ec162723feed5.tar.gz
frameworks_av-53409d6fe668e695e92479371f0ec162723feed5.tar.bz2
Assume that all of the decoded vorbis audio data is valid unless the source indicates otherwise.
Change-Id: Iea88e3f09955d82a9a11fbcc075db8d9c4007490
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp b/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
index 703b41e..e14fb95 100644
--- a/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
+++ b/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
@@ -112,7 +112,12 @@ status_t VorbisDecoder::start(MetaData *params) {
mAnchorTimeUs = 0;
mNumFramesOutput = 0;
- mNumFramesLeftOnPage = 0;
+
+ // If the source never limits the number of valid frames contained
+ // in the input data, we'll assume that all of the decoded frames are
+ // valid.
+ mNumFramesLeftOnPage = -1;
+
mStarted = true;
return OK;
@@ -193,12 +198,14 @@ int VorbisDecoder::decodePacket(MediaBuffer *packet, MediaBuffer *out) {
}
}
- if (numFrames > mNumFramesLeftOnPage) {
- LOGV("discarding %d frames at end of page",
- numFrames - mNumFramesLeftOnPage);
- numFrames = mNumFramesLeftOnPage;
+ if (mNumFramesLeftOnPage >= 0) {
+ if (numFrames > mNumFramesLeftOnPage) {
+ LOGV("discarding %d frames at end of page",
+ numFrames - mNumFramesLeftOnPage);
+ numFrames = mNumFramesLeftOnPage;
+ }
+ mNumFramesLeftOnPage -= numFrames;
}
- mNumFramesLeftOnPage -= numFrames;
out->set_range(0, numFrames * sizeof(int16_t) * mNumChannels);
@@ -241,6 +248,7 @@ status_t VorbisDecoder::read(
int32_t numPageSamples;
if (inputBuffer->meta_data()->findInt32(
kKeyValidSamples, &numPageSamples)) {
+ CHECK(numPageSamples >= 0);
mNumFramesLeftOnPage = numPageSamples;
}