Skip to content

Commit a57c639

Browse files
Dave BurkeAndroid (Google) Code Review
authored andcommitted
Merge "Revert "To make SniffMP3() more concrete so that we can remove false-positve responses from MPEG-PS streams.""
2 parents b4a431f + 30856a7 commit a57c639

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

media/libstagefright/MP3Extractor.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ static bool Resync(
5252
*post_id3_pos = 0;
5353
}
5454

55-
bool resync_from_head = false;
5655
if (*inout_pos == 0) {
57-
resync_from_head = true;
58-
5956
// Skip an optional ID3 header if syncing at the very beginning
6057
// of the datasource.
6158

@@ -140,20 +137,22 @@ static bool Resync(
140137

141138
uint32_t header = U32_AT(tmp);
142139

140+
if (match_header != 0 && (header & kMask) != (match_header & kMask)) {
141+
++pos;
142+
++tmp;
143+
--remainingBytes;
144+
continue;
145+
}
146+
143147
size_t frame_size;
144-
if ((match_header != 0 && (header & kMask) != (match_header & kMask))
145-
|| !GetMPEGAudioFrameSize(header, &frame_size)) {
146-
if (resync_from_head) {
147-
// This isn't a valid mp3 file because it failed to detect
148-
// a header while a valid mp3 file should have a valid
149-
// header here.
150-
break;
151-
} else {
152-
++pos;
153-
++tmp;
154-
--remainingBytes;
155-
continue;
156-
}
148+
int sample_rate, num_channels, bitrate;
149+
if (!GetMPEGAudioFrameSize(
150+
header, &frame_size,
151+
&sample_rate, &num_channels, &bitrate)) {
152+
++pos;
153+
++tmp;
154+
--remainingBytes;
155+
continue;
157156
}
158157

159158
LOGV("found possible 1st frame at %lld (header = 0x%08x)", pos, header);

0 commit comments

Comments
 (0)