Skip to content

Commit

Permalink
avformat/aacdec: enable probesize-sized resyncs mid-stream
Browse files Browse the repository at this point in the history
Before adts_aac_resync would always bail out after probesize amount
of bytes had been progressed from the start of the input.

Now just query the current position when entering resync, and at most
advance probesize amount of data from that start position.

Fixes #9433
  • Loading branch information
jeeb committed Sep 28, 2021
1 parent 855014f commit c205778
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libavformat/aacdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ static int adts_aac_probe(const AVProbeData *p)
static int adts_aac_resync(AVFormatContext *s)
{
uint16_t state;
int64_t start_pos = avio_tell(s->pb);

// skip data until an ADTS frame is found
state = avio_r8(s->pb);
while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) {
while (!avio_feof(s->pb) &&
(avio_tell(s->pb) - start_pos) < s->probesize) {
state = (state << 8) | avio_r8(s->pb);
if ((state >> 4) != 0xFFF)
continue;
Expand Down

0 comments on commit c205778

Please sign in to comment.