Skip to content

Commit 133e6a9

Browse files
committed
HeaderParserAAC check end of frame
1 parent 1bf72ac commit 133e6a9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/AudioTools/AudioCodecs/HeaderParserAAC.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ class HeaderParserAAC {
2020
bool isValid(const uint8_t* data, int len) {
2121
if (len < 7) return false;
2222
parser.begin();
23-
return parser.parse((uint8_t*)data);
23+
// regular validation
24+
if (!parser.parse((uint8_t*)data)) return false;
25+
// check if we have a valid 2nd frame
26+
if (len > getFrameLength()) {
27+
int pos = findSyncWord(data, len, getFrameLength());
28+
if (pos == -1) return false;
29+
}
30+
return true;
2431
}
2532

26-
int getSampleRate() { return parser.getSampleRate(); }
33+
int getSampleRate() { return parser.getSampleRate(); }
2734

28-
uint8_t getChannels() { return parser.data().channel_cfg; }
35+
uint8_t getChannels() { return parser.data().channel_cfg; }
2936

3037
/// Determines the frame length
3138
int getFrameLength() { return parser.getFrameLength(); }

0 commit comments

Comments
 (0)