[FFmpeg-devel] [PATCH] avformat/aacdec: don't immediately abort if an ADTS frame is not found
Hendrik Leppkes
h.leppkes at gmail.com
Tue Sep 5 23:30:27 EEST 2017
On Mon, Sep 4, 2017 at 4:47 AM, James Almer <jamrial at gmail.com> wrote:
> Skip the invalid data in an attempt to find one instead, and continue decoding from there.
>
> Fixes ticket #6634
>
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> libavformat/aacdec.c | 41 +++++++++++++++++++++++++++++------------
> 1 file changed, 29 insertions(+), 12 deletions(-)
>
> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> index 364b33404f..7aacc88560 100644
> --- a/libavformat/aacdec.c
> +++ b/libavformat/aacdec.c
> @@ -77,10 +77,29 @@ static int adts_aac_probe(AVProbeData *p)
> return 0;
> }
>
> +static int resync(AVFormatContext *s)
> +{
> + uint16_t state;
> +
> + state = avio_r8(s->pb);
> + while (!avio_feof(s->pb) && avio_tell(s->pb) < s->probesize) {
> + state = (state << 8) | avio_r8(s->pb);
> + if ((state >> 4) != 0xFFF)
> + continue;
> + avio_seek(s->pb, -2, SEEK_CUR);
> + break;
> + }
> +
The ADTS sync code isn't that much of a sync code, maybe it might be
more resilient if you try to read the frame size and check if after
that the next frame also starts with a valid code?
- Hendrik
More information about the ffmpeg-devel
mailing list