diff options
author | John Grossman <johngro@google.com> | 2012-09-07 11:41:07 -0700 |
---|---|---|
committer | John Grossman <johngro@google.com> | 2012-09-07 13:39:12 -0700 |
commit | 7abab13f230e4c38a4c8a88c859af64d491d5e9b (patch) | |
tree | cf5626ddda47f1c89c2c8b2b4962170a3b8ed658 /media/libstagefright/MPEG4Extractor.cpp | |
parent | f98cbbeb01aa15178c7a58f3c478ec1050dbe83e (diff) | |
download | frameworks_av-7abab13f230e4c38a4c8a88c859af64d491d5e9b.zip frameworks_av-7abab13f230e4c38a4c8a88c859af64d491d5e9b.tar.gz frameworks_av-7abab13f230e4c38a4c8a88c859af64d491d5e9b.tar.bz2 |
Fix iTunSMPB parsing for AAC tracks encoded with Nero
Make sure to clear out the mean/name/data state when parsing
apple-style metadata from tracks every time we have a full set, not
just when we find an iTunSMPB set.
AAC tracks encoded from WAV by Nero tend to put in an additional apple
style metadata tag (cdec) before the iTunSMPB tag. The sequence in
the file goes something like
mean : "com.apple.iTunes"
name : "cdec"
data : "ndaudio 1.5.4.0 / -2pass -br 320000"
mean : "com.apple.iTunes"
name : "iTunSMPB"
data : " 00000000 00000A40 000000B8 <etc...>"
If the internal state was not cleared after the first set, then when
the second instance of "name" is encountered, an attempt is made to
parse the previous data entry as an iTunSMPB tag when it is actually a
cdec tag. Afterwards, mean, name and data are all cleared, and when
the second data is encountered there is no current mean or name
present, so the gapless metadata gets skipped. By clearing the
metadata state every time we have a full set of mean/name/data, we
make sure that we are always interpreting the data field as the proper
type.
Change-Id: I196e2e3f83e434f15d5ee55ae40a74a92d5a1845
Diffstat (limited to 'media/libstagefright/MPEG4Extractor.cpp')
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 7d49ef0..dc8e4a3 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -1665,15 +1665,26 @@ status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) { mLastCommentData.setTo((const char *)buffer + 8); break; } - if (mLastCommentMean == "com.apple.iTunes" - && mLastCommentName == "iTunSMPB" - && mLastCommentData.length() != 0) { - int32_t delay, padding; - if (sscanf(mLastCommentData, - " %*x %x %x %*x", &delay, &padding) == 2) { - mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); - mLastTrack->meta->setInt32(kKeyEncoderPadding, padding); + + // Once we have a set of mean/name/data info, go ahead and process + // it to see if its something we are interested in. Whether or not + // were are interested in the specific tag, make sure to clear out + // the set so we can be ready to process another tuple should one + // show up later in the file. + if ((mLastCommentMean.length() != 0) && + (mLastCommentName.length() != 0) && + (mLastCommentData.length() != 0)) { + + if (mLastCommentMean == "com.apple.iTunes" + && mLastCommentName == "iTunSMPB") { + int32_t delay, padding; + if (sscanf(mLastCommentData, + " %*x %x %x %*x", &delay, &padding) == 2) { + mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); + mLastTrack->meta->setInt32(kKeyEncoderPadding, padding); + } } + mLastCommentMean.clear(); mLastCommentName.clear(); mLastCommentData.clear(); |