Commit Graph

17 Commits

Author SHA1 Message Date
Andreas Rheinhardt 491a30c79c avformat/aadec: Replace strncpy by av_strlcpy
While this usage of strncpy is correct, said function nevertheless has
the disadvantage of not automatically ensuring that the destination
string is zero-terminated. So av_strlcpy should be preferred.
This also removes a -Wstringop-truncation warning from GCC (it doesn't
matter whether the buffer is truncated, as long as it can fit all
the names of the supported codecs).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-05 09:16:00 +01:00
Andreas Rheinhardt 80038fd524 avformat/aadec: Use smaller scope for variables, remove initializations
avio_get_str always zero terminates the strings it reads.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-05 09:16:00 +01:00
Michael Niedermayer bcc7d14453 avformat/aadec: Check for EOF while reading chapters
Fixes: timeout
Fixes: 28199/clusterfuzz-testcase-minimized-ffmpeg_dem_AA_fuzzer-4896162657861632

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-01 20:19:15 +01:00
Michael Niedermayer daa2482871 avformat/aadec: Check toc_size to contain the minimum to demuxer uses
Fixes: out of array access
Fixes: stack-buffer-overflow-READ-0x0831fff1

Found-by: GalyCannon <galycannon@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-21 09:31:08 +02:00
Michael Niedermayer ed188f6dcd avformat/aadec: Check for scanf() failure
Fixes: use of uninitialized variables
Fixes: blank.aa

Found-by: Chamal De Silva <chamal.desilva@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-04-24 17:05:02 +02:00
Carl Eugen Hoyos 4d8875ec23 lavf: Constify the probe function argument.
Reviewed-by: Lauri Kasanen
Reviewed-by: Tomas Härdin
2019-03-21 11:42:17 +01:00
Karsten Otto c5329d64b1 aadec: improve seeking in mp3 content
MP3 frames may not be aligned to aa chunk boundaries. When seeking,
calculate the expected frame offset in the target chunk. Adjust the
timestamp and truncate the next packet accordingly.

This solution works for the majority of tested audio material. For
some rare encodings with mp3 padding or embedded id3 tags, it will
mispredict the correct offset, and at worst skip an extra frame.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-07-14 19:04:48 +02:00
Karsten Otto 6cc6b619b9 aadec: add chapters and seeking
read_packet reads content in chunks. Thus seek must be clamped to valid
chunk positions in the file, which in turn are relative to chapter start
positions.

So in read_header, scan for chapter headers once by skipping through the
content. Set stream time_base based on bitrate in bytes/s, for easy
timestamp to position conversion.

Then in read_seek, find the chapter containing the seek position, calculate
the nearest chunk position, and reinit the read_seek state accordingly.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-07-09 03:25:53 +02:00
Karsten Otto c126065947 aadec: improve eof detection
Remember the end position of audio content in the file and check it during
read_packet. There always seems to be other data beyond it, which could be
misinterpreted as more audio. Also add some extra avio_read error checks,
to bail early in case of a broken/truncated file.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-07-08 11:14:53 +02:00
Clément Bœsch 549045254c Fix all -Wformat warnings raised by DJGPP 2017-03-29 14:49:29 +02:00
Paul B Mahol 591be9e384 avformat/aadec: use avio_get_str()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-16 10:24:02 +01:00
Paul B Mahol e0665d385e avformat/aadec: stop ignoring file metadata
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-16 10:24:01 +01:00
Paul B Mahol 40cf943714 avcodec: add SIPR parser
Fixes #2056.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-16 10:24:01 +01:00
Derek Buitenhuis 6f69f7a8bf Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-10 20:59:55 +01:00
Vesselin Bontchev 8e28e0721c avformat/aa: initialize "header_seed" and "header_key"
Fixes CID 1322364, CID 1322363

Signed-off-by: Vesselin Bontchev <vesselin.bontchev@yandex.com>
2015-09-10 09:06:13 +02:00
Vesselin Bontchev 4cd1d2314b avformat/aa: use correct format specifier in sscanf
This demuxer was broken on a large number of platforms due to usage of wrong
format specifier in sscanf. This patch fixes the problem, and also adds some
debug logging to reduce future debugging pain.
2015-08-25 12:44:20 +00:00
Vesselin Bontchev e32a99264b Add support for Audible AA files
https://en.wikipedia.org/wiki/Audible.com#Quality
2015-08-21 04:24:58 +00:00