diff options
| author | 2011-01-19 00:13:55 -0800 | |
|---|---|---|
| committer | 2011-01-19 10:20:59 -0800 | |
| commit | cbb488d67826dd38f665bc8626b55dfe2f0e135f (patch) | |
| tree | 6459bf3a21e2e653b05880e77de5c0212ded6479 | |
| parent | 4061c9aa6d77bd7ad3b43d898b3e55fd62f57f18 (diff) | |
Expose average video frame rate via MPEG4Extractor
bug - 3362483
Change-Id: Ifcbb75c1e8b80cb06c4b8fe7f5ff99bc6f18af69
| -rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index aca701d40498..e6e98aa3e422 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -1040,8 +1040,23 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { // have a 4 byte header (0x00 0x00 0x00 0x01) after conversion, // and thus will grow by 2 bytes per fragment. mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size + 10 * 2); - *offset += chunk_size; + + // Calculate average frame rate. + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); + if (!strncasecmp("video/", mime, 6)) { + size_t nSamples = mLastTrack->sampleTable->countSamples(); + int64_t durationUs; + if (mLastTrack->meta->findInt64(kKeyDuration, &durationUs)) { + if (durationUs > 0) { + int32_t frameRate = (nSamples * 1000000LL + + (durationUs >> 1)) / durationUs; + mLastTrack->meta->setInt32(kKeyFrameRate, frameRate); + } + } + } + break; } |