summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MP3Extractor.cpp
diff options
context:
space:
mode:
authorDongwon Kang <dwkang@google.com>2011-08-18 15:24:27 +0900
committerDongwon Kang <dwkang@google.com>2011-08-18 15:24:27 +0900
commit97f2fb5bc753f021bfa51f58129bc1a36c047c47 (patch)
tree217c71649c578f0cf3fb37585a902a8be9ccd212 /media/libstagefright/MP3Extractor.cpp
parentee0846f97cf07f5f18d19161526743330aabb44e (diff)
downloadframeworks_av-97f2fb5bc753f021bfa51f58129bc1a36c047c47.zip
frameworks_av-97f2fb5bc753f021bfa51f58129bc1a36c047c47.tar.gz
frameworks_av-97f2fb5bc753f021bfa51f58129bc1a36c047c47.tar.bz2
To make SniffMP3() more concrete so that we can remove false-positve responses from MPEG-PS streams.
Note: current resync logic keeps searching mp3 frames until it meets a valid one. This resync logic works well with seek() operation, but in SniffMP3(), this may cause false-positive classification for the following MPEG-PS file format. A possible MPEG-PS video file: [PS header]...[mp3 frame][mp3 frame] ... MP3 files: [ID3 tag][mp3 frame][mp3 frame] ... BUG: 5104562 Change-Id: Idd5020723f7bdb2fefc2a63fc8651580fd644399
Diffstat (limited to 'media/libstagefright/MP3Extractor.cpp')
-rw-r--r--media/libstagefright/MP3Extractor.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 92e84c2..09f91f5 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -52,7 +52,10 @@ static bool Resync(
*post_id3_pos = 0;
}
+ bool resync_from_head = false;
if (*inout_pos == 0) {
+ resync_from_head = true;
+
// Skip an optional ID3 header if syncing at the very beginning
// of the datasource.
@@ -137,22 +140,20 @@ static bool Resync(
uint32_t header = U32_AT(tmp);
- if (match_header != 0 && (header & kMask) != (match_header & kMask)) {
- ++pos;
- ++tmp;
- --remainingBytes;
- continue;
- }
-
size_t frame_size;
- int sample_rate, num_channels, bitrate;
- if (!GetMPEGAudioFrameSize(
- header, &frame_size,
- &sample_rate, &num_channels, &bitrate)) {
- ++pos;
- ++tmp;
- --remainingBytes;
- continue;
+ if ((match_header != 0 && (header & kMask) != (match_header & kMask))
+ || !GetMPEGAudioFrameSize(header, &frame_size)) {
+ if (resync_from_head) {
+ // This isn't a valid mp3 file because it failed to detect
+ // a header while a valid mp3 file should have a valid
+ // header here.
+ break;
+ } else {
+ ++pos;
+ ++tmp;
+ --remainingBytes;
+ continue;
+ }
}
LOGV("found possible 1st frame at %lld (header = 0x%08x)", pos, header);