1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

24962 Commits

Author SHA1 Message Date
Michael Niedermayer
db31b3ea86 avformat/aaxdec: Check for empty segments
Fixes: Timeout
Fixes: 48154/clusterfuzz-testcase-minimized-ffmpeg_dem_AAX_fuzzer-5149094353436672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer
ba0c3d1db4 avformat/avienc: Check video dimensions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Michael Niedermayer
0740641e93 avformat/iff: simplify duration calculation
Fixes: signed integer overflow: 315680096256 * 134215943 cannot be represented in type 'long long'
Fixes: 48713/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5886272312311808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
ShuangxiLi
046b05082d avformat/mov: fix possible crash in cenc_scheme_decrypt
Data does not have to be decrypted in 16-byte blocks for AES-CTR mode, so
existing buggy code can be hugely simplified.

Fixes ticket #9829.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-12 18:48:54 +02:00
Andreas Rheinhardt
6f5e0a7294 avformat/flvenc: Add deinit function
Fixes memleaks when the trailer is never written or when shift_data()
fails when writing the trailer.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:16:39 +02:00
Andreas Rheinhardt
a256426411 avformat/movenc: Ensure packet is writable before modifying it
Fixes e.g.

ffmpeg -i fate-suite/h264/bbc2.sample.h264 -c:v rawvideo -map 0:v -frames:v 10 -pix_fmt gray8 -f tee "first.mov|second.mov"

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt
d5a0eba8a2 av(format|device): Add const to muxer packet data pointers
The packets given to muxers need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt
417554bdd6 avformat/apngenc: Add const where possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt
05e96e6933 avformat/apngenc: Don't modify input packet
It might not be writable at this point.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt
f89446eaff avformat/apngenc: Check fcTL size
The remaining code relies on it having the value it should have.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt
3204572a1a avformat/apngenc: Check for incomplete chunks
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:52 +02:00
Andreas Rheinhardt
e4a10dd637 avcodec/apng: Add APNG_FCTL_CHUNK_SIZE define
Also use it where appropriate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:52 +02:00
Brion Vibber
66a251e836 Support for 16:9 DV in QuickTime
Some files I have from circa year 2000 are 16:9 NTSC DV video
encoded as QuickTime with Radius SoftDV. This marked 4:3 videos
with the box 'dvc ' for NTSC or 'dvcp' for PAL, which are already
supported, but 16:9 videos as 'dvl ' or 'dvlp', which were not.

Adding these to the list for DV codec processing gives the
expected metadata and playback.

I have not tested PAL as I have no sample data, only NTSC.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-09 19:03:28 +02:00
Michael Niedermayer
c9a2996544 avformat/sctp: close socket on errors
This is untested as i have no testcase

Fixes: CID1302709

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Michael Niedermayer
884a108121 avformat/cinedec: Check size and pos more
Fixes: signed integer overflow: 9223372036848019263 + 134232320 cannot be represented in type 'long'
Fixes: 48155/clusterfuzz-testcase-minimized-ffmpeg_dem_CINE_fuzzer-5751429207293952

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-07 21:52:52 +02:00
Marton Balint
b54f3e32fa avformat/img2enc: use unmatched filename for an invalid or missing sequence pattern
Also warn the user that for single images -update should be used, for sequences
a proper pattern should be specified.

Fixes ticket #9748.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-07 20:23:06 +02:00
Marton Balint
3f2de562c3 avformat/img2enc: fix first image check
Start image number was hardcoded to 1 for the first image check.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-07 20:23:06 +02:00
Marton Balint
03d81a044a avformat/mov: disallow a zero sample size in trun atoms
In order to not generate 0 sized packets or create a huge index table
needlessly.

Fixes: Timeout
Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304
Fixes: 45738/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6142535657979904

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-06 23:37:29 +02:00
Marton Balint
7acc124121 Revert "avformat/demux: Make read_frame_internal() return AVERREOR(EAGAIN) on stuck empty input parser"
Hides the underlying real problem with a demuxer returning 0 sized packets.

This reverts commit 02699490c1.
2022-07-06 23:37:29 +02:00
Marton Balint
dbc3b5a902 Revert "avformat/demux: Count EAGAIN as 100 bytes in relation to read limit in avformat_find_stream_info()"
Modifying avformat_find_stream_info() behaviour based on the number of EAGAINs
it encounters is a hack which usually only hides the real issue if such thing
happen.

This reverts commit b0cac7082d.
2022-07-06 23:37:29 +02:00
Martijn van Beurden
c8d839df73 avformat/mov: prevent potential use of uninitialized value 2022-07-05 14:11:23 +02:00
Martijn van Beurden
056a9fac5b avformat/cafdec: Implement FLAC-in-CAF parsing
The afconvert utility shipped with MacOS supports muxing of FLAC
in CAF, see afconvert help output on a recent Mac here:
https://hydrogenaud.io/index.php?topic=122509.0 A file created
with afconvert free of copyright (licensed CC0) can be found here:
http://www.audiograaf.nl/misc_stuff/afconvert-FLAC-in-CAF.caf
2022-07-05 14:11:20 +02:00
James Almer
94901a9518 avformat/matroskadec: fix setting channel layout using the Channels element
If the stream's channel layout is first set into a native layout using codec
private parameters, this code here could potentially result in an invalid
native layout where popcnt(ch_layout.u.mask) != ch_layout.nb_channels being
propagated.

Fixes: Timeout printing a billion channels
Fixes: 48099/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-6754782204788736

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-07-04 14:00:25 -03:00
Andreas Rheinhardt
1fc5d327e4 avformat/(mpeg|mpegts|mxf|sup)enc: Use const uint8_t* to access pkt data
The packets muxers receive are not guaranteed to be writable,
so they must not be modified. Ergo only access the packet's data
via a const uint8_t*.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-04 14:56:43 +02:00
Paul B Mahol
ff1450e449 avcodec: add PHM decoder and encoder 2022-07-03 15:16:31 +02:00
Andreas Rheinhardt
309ead7067 avformat/mlpdec: Remove unused-but-set variable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-03 11:41:23 +02:00
Andreas Rheinhardt
204a72d7c4 avformat/bintext: Remove set-but-unused variable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-03 11:41:23 +02:00
Michael Niedermayer
c6f1e48b86 avformat/aiffdec: cleanup size handling for extreem cases
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-02 19:22:36 +02:00
Andreas Rheinhardt
e4be88704f avformat/movenc: Fix invalid check
Regression since c9de096851.
Fixes Coverity ID 1506839.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-30 22:19:54 +02:00
Jan Ekström
5eb8da6a81 avformat/movenc: limit ISOBMFF AC-3 mapping to bsids <=8
This leaves out RealAudio DolbyNet, which utilizes bsids 9 and 10,

It is not clear whether the interpreted bit rate value (divided by
2 or 4 depending on the variant), or the original bit rate value
should be utilized to receive the bit_rate_code index.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2022-06-30 16:14:05 +03:00
Jan Ekström
c9de096851 avformat/movenc: handle OOM situations when parsing AC-3 headers
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2022-06-30 16:14:05 +03:00
Jan Ekström
3854c58d9e avformat/movenc: utilize existing AC-3 parsing workflow for AC-3
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2022-06-30 16:14:05 +03:00
Jan Ekström
b6897e9c08 avformat/movenc: move eac3_info definition so that it can be used for AC-3
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2022-06-30 16:14:05 +03:00
Jan Ekström
ad1672529f avformat/movenc: enable handle_eac3 to handle AC-3 tracks
Add the AC-3 frame type, as well as early exit from additional packet
parsing in case of AC-3, as only a single packet is required to get
the required information.

Additionally, expose ac3_bit_rate_code via the eac3_info struct as
it is required for AC3SpecificBox.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2022-06-30 16:14:05 +03:00
Jan Ekström
3bb23a8b3c {configure,avformat/movenc}: enable AC-3 parser for movenc
This simplifies the code to no longer have #ifs in a manner which
does not require handling avpriv_ac3_parse_header returning ENOSYS.

As an existing example, the MPEG-TS muxer already requires the AC-3
parser, and in order to fix existing issues with the current AC-3
movenc code, switching to use the AC-3 parser is required, so this
is an enabling change for that.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2022-06-30 16:14:05 +03:00
Vignesh Venkatasubramanian
be4d1caad4 avformat/mov: Only read the primary item for AVIF
Update the still AVIF parser to only read the primary item. With this
patch, AVIF still images with exif/icc/alpha channel will no longer
fail to parse.

For example, this patch enables parsing of files in:
https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft

Adding two fate tests:
1) demuxing of still image with 1 item - this test will pass regardless
   of this patch.
2) demuxing of still image with 2 items - this test will fail without
   this patch and will pass with patch applied.

Partially fixes trac ticket #7621

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: James Zern <jzern@google.com>
2022-06-29 12:16:40 -07:00
huheng
8d4bdf99e5 avformat/hlsenc: Add resend_headers option
Add pat and pmt table at start of each segment in single_file mode enhanced
compatibility of hls stream. Because some hls clients separate parsing segment
of hls stream, the absence of pat/pmt will cause parsing to fail.

Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: huheng <heng.hu.1989@gmail.com>
2022-06-29 14:07:03 +08:00
Li Kai
df8ad4e391 avformat/hls: add #EXT-X-START tag support by prefer_x_start opt
Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: Li Kai <wolfleekay@gmail.com>
2022-06-29 14:03:36 +08:00
Lucy
1af3698296 avformat/hlsenc: Use HLS version 2 if rounded durations are enabled
This allows for wider compatibility with older devices, such as those
running iOS 3. The only difference between HLS version 2 and version 3 is
that version 3 supports non-integer EXTINF values, and as such, we can
default to version 2 if we're using whole-integer EXTINFs anyways, when
`-hls_flags round_durations` is set.

As this code seems to otherwise consistently use the lowest compatible
version, this seems to fit in properly with existing behavior.

Testing confirms with that this patch, HLS output can work all the way back
to iOS 3.

Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: Lucy <lucy@absolucy.moe>
2022-06-29 14:03:32 +08:00
Ivan Baykalov
cbe216d3a6 avformat/mov: read PCM audio configuration box ('pcmC') if available
For ipcm and fpcm streams, big-endian format is the default, but it can be changed
with additional 'pcmC' sub-atom of audio sample description.

Details can be found in ISO/IEC 23003-5:2020

Fixes ticket #9763.
Fixes ticket #9790.

Patch simplified by Marton Balint.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-27 20:29:47 +02:00
Marton Balint
cd83383f4d avformat/mov: factorize setting little endian PCM streams
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-27 20:29:47 +02:00
Vignesh Venkatasubramanian
2a3640de84 avformat/movenc: Support alpha channel for AVIF
AVIF specification allows for alpha channel as an auxiliary item (in
case of still images) or as an auxiliary track (in case of animated
images).  Add support for both of these. The AVIF muxer will take
exactly two streams (when alpha is present) as input (first one being
the YUV planes and the second one being the alpha plane).

The input has to come from two different images (one of it color and
the other one being alpha), or it can come from a single file
source with the alpha channel extracted using the "alphaextract"
filter.

Example using alphaextract:
ffmpeg -i rgba.png -filter_complex "[0:v]alphaextract[a]" -map 0 -map "[a]" -still-picture 1 avif_with_alpha.avif

Example using two sources (first source can be in any pixel format and
the second source has to be in monochrome grey pixel format):
ffmpeg -i color.avif -i grey.avif -map 0 -map 1 -c copy avif_with_alpha.avif

The generated files pass the compliance checks in Compliance Warden:
https://github.com/gpac/ComplianceWarden

libavif (the reference avif library) is able to decode the files
generated using this patch.

They also play back properly (with transparent background) in:
1) Chrome
2) Firefox (only still AVIF, no animation support)

Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2022-06-27 13:46:33 -03:00
Andreas Rheinhardt
2cce1d8528 avformat/matroskaenc: Fix use of uninitialized value
Regression since 67eea6cf02.
Affects only WebVTT when muxing WebM. (This is covered
by the webm-webvtt-remux FATE test which fails for several
FATE boxes on fate-ffmpeg.org.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-26 06:12:32 +02:00
Michael Niedermayer
e6cad01122 avformat/matroskadec: avoid integer overflows in SAR computation
This ignores >64bit
Alternatively we could support that if it occurs in reality

Fixes: negation of -9223372036854775808
Fixes: integer overflows
Fixes: 46072/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5029840966778880

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-25 21:36:32 +02:00
James Almer
c7ce03d826 avformat/http: include version.h
This is needed to get LIBAVFORMAT_VERSION, used as part of the user agent.
Fixes a recent regression.

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-06-24 23:07:33 -03:00
Andreas Rheinhardt
cf30b538e5 avformat/matroskaenc: Reuse dynamic buffer
Avoids some allocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-24 18:33:18 +02:00
Andreas Rheinhardt
745966ab81 avformat/matroskaenc: Fix outdated comment
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-24 18:33:18 +02:00
Andreas Rheinhardt
e689a1171d avformat/matroskaenc: Improve handling of AV1 extradata
Up until now, only the first four bytes (the ones preceding
the OBU) were written because not enough space has been reserved
for the complete CodecPrivate. This commit changes this
by increasing the space reserved for the CodecPrivate (it is big
enough for every sane sequence header plus something extra);
the code falls back to writing four bytes in case the increased
space turns out to be insufficient.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-24 18:33:18 +02:00
Andreas Rheinhardt
67eea6cf02 avformat/matroskaenc: Split updating CodecPrivate from writing it
Up until now, updating extradata was very ad-hoc: The amount of
space reserved for extradata was not recorded when writing the
header; instead the AAC code simply presumed that it was enough.
This commit changes this by recording how much space is available.

This brings with it that the code for writing of and reserving space
for the CodecPrivate and for updating it diverges. They are therefore
split; this allows to put other common tasks like seeking to
right offset as well as writing padding (in case the new extradata did
not fill the whole reserved space) to this common function.

The code for filling up the reserved space is smarter than the code
it replaces; therefore it is no longer necessary to reserve more
than necessary just to be sure that one can add an EBML Void element
(whose minimum size is two) lateron. This is the reason for the change
to the aac-autobsf-adtstoasc test.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-24 18:33:18 +02:00
Andreas Rheinhardt
3a00a1a800 avformat/matroskaenc: Avoid swapping codecpar->extradata temporarily
Instead pass extradata and extradata_size explicitly.

(It is not perfect, as ff_put_(wav|bmp)_header() still uses
the extradata embedded in codecpar, but this is not an issue
as long as their CodecPrivate isn't updated.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-24 18:33:18 +02:00
Andreas Rheinhardt
1056f9a21e avformat/matroskaenc: Split assembling CodecPrivate from writing it
This is in preparation for splitting writing and updating
extradata more thoroughly later.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-24 18:33:18 +02:00
Zhao Zhili
2e6e28ebc1 avformat/movenc: enable compressorname for mp4 mode
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-06-24 15:37:23 +08:00
Michael Niedermayer
d8ee014254 avformat/hls: Limit start_seq_no to one bit less
This avoids overflow checks on additions with 32bit numbers

Fixes: signed integer overflow: 9223372036854775806 + 2 cannot be represented in type 'long'
Fixes: 44012/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-4747770734444544
Fixes: 48065/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5372410355908608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-23 22:03:02 +02:00
Nil Admirari
c381f5412f libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()
1. getenv() is replaced with getenv_utf8() across libavformat.
2. New versions of AviSynth+ are now called with UTF-8 filenames.
3. Old versions of AviSynth are still using ANSI strings,
   but MAX_PATH limit on filename is removed.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-21 13:27:46 +03:00
Andreas Rheinhardt
fe662516a5 avformat/matroskaenc: Don't check twice whether to write tags
Because not all metadata is written as tags, the Matroska muxer
filters out the tags that are not written as tags.
Therefore the code first checks whether a Tag master element
needs to be opened for a given stream/chapter/attachment/global
metadata. If the answer turns out to be yes, it is checked again
whether a given AVDictionaryEntry is written as a tag.
This commit changes this: The Tag element is opened unconditionally
and in case it turns out that it was unneeded, it is discarded again.
This is possible because the Tag element is written into its own
dynamic buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-20 23:42:28 +02:00
Andreas Rheinhardt
b468ddc75d avformat/matroskaenc: Don't waste bytes to Write Tag length fields
This is possible by using a dynamic buffer to write them;
said dynamic buffer is (re)used and reset as appropriate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-20 23:42:28 +02:00
Marton Balint
58df81b027 avformat/mpegts: remove obsolate hacks for detecting streams with bad PMTs
Ffmpeg/ffprobe/ffplay sets scan_all_pmts to 1 when finding the streams, that
should be enough to handle files for which some early PMTs miss some streams.

Fixes ticket #9782.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-20 23:36:37 +02:00
Marton Balint
b3cca50638 avformat/librist: bump required version to 0.2.7
This is the first version for which fifo size setting actually works.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-18 16:32:23 +02:00
Michael Niedermayer
6a02de2127 avformat/aiffdec: avoid integer overflow in get_meta()
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 45891/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6159183893889024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-17 01:54:05 +02:00
Michael Niedermayer
c16a0ed242 avformat/aaxdec: Check for overlaping segments
Fixes: Timeout
Fixes: 45875/clusterfuzz-testcase-minimized-ffmpeg_dem_AAX_fuzzer-6121689903136768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-17 01:54:05 +02:00
Michael Niedermayer
b0cac7082d avformat/demux: Count EAGAIN as 100 bytes in relation to read limit in avformat_find_stream_info()
Fixes: Timeout
Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304
Fixes: 45738/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6142535657979904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-17 01:54:05 +02:00
Michael Niedermayer
02699490c1 avformat/demux: Make read_frame_internal() return AVERREOR(EAGAIN) on stuck empty input parser
Fixes: read_frame_internal() which does not return even though both demuxer and parser do return
Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-17 01:54:05 +02:00
Andreas Rheinhardt
672987b2db avformat/matroskaenc: Convert chapter metadata
It is no longer converted since mkv_write_chapters() is called
before mkv_write_tags() which happens since commit
4ebfc13c33. Given the fact that
chapters can also be written late, mkv_write_chapters() has to
convert the metadata itself.

Fixes ticket #9812.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-16 19:18:48 +02:00
Andreas Rheinhardt
49a63c6c66 avformat/matroskaenc: Reset cur_master_element when discarding master
Before this patch the muxer writes an invalid file
(namely one in which the Projection master is a child of
the Colour element) if the following conditions are met:
a) The stream contains AVMasteringDisplayMetadata without primaries
and luminance (i.e. useless AVMasteringDisplayMetadata).
b) The stream contains AV_PKT_DATA_SPHERICAL side data.
c) All the colour elements of the stream are equal to default
(i.e. unknown).
Fortunately these conditions are very unlikely to be met.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-16 19:06:10 +02:00
Andreas Rheinhardt
9ff0fbbc0a avformat/mxfdec: Offload allocating string to av_dict_set()
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-16 18:39:46 +02:00
Andreas Rheinhardt
6b5e3590c7 avformat/mxfdec: Use ff_data_to_hex() for data->hex conversion
In this case it also stops pretending that the length of
the output string is somehow checked (which is currently
being done by using snprintf that is called with the amount
of space needed instead of the amount of space actually available).

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-16 18:39:25 +02:00
Andreas Rheinhardt
8823900b14 avformat/mxfdec: Don't duplicate av_uuid_unparse
Also don't allocate the string ourselves, let av_dict_set()
do it.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-16 18:39:09 +02:00
Andreas Rheinhardt
41365fdf5c avformat/mxf: Use AVUUID for uids
This is in preparation for using av_uuid functions directly.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-16 18:38:50 +02:00
Michael Niedermayer
e5f6707a7b avformat/ape: more bits in size for less overflows
Fixes: signed integer overflow: 2147483647 + 3 cannot be represented in type 'int'
Fixes: 46184/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-4678059519770624

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-14 16:46:28 +02:00
Michael Niedermayer
9274fb2532 avformat/mov: Non overflowing ambisonic order check
Fixes: signed integer overflow: 536870913 * 536870913 cannot be represented in type 'int'
Fixes: 45862/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4730373768085504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-14 16:46:28 +02:00
Stefano Sabatini
7cae3d8b76 lavf/avio: add avio_vprintf()
This new function makes it possible to use avio_printf() functionality from
a function taking a variable list of arguments.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-13 22:42:55 +02:00
Pierre-Anthony Lemieux
751549af9b
avformat/imf: refactor to use avutil/uuid 2022-06-12 18:34:37 +10:00
Pierre-Anthony Lemieux
1fd6758178
avformat/smoothstreamingenc: refactor to use avutil/uuid 2022-06-12 18:34:37 +10:00
Pierre-Anthony Lemieux
a2c1a439b3
avformat/mov: refactor to use avutil/uuid 2022-06-12 18:34:37 +10:00
softworkz
3b3c567ad3 avformat/os_support: use windows stat structs with 64bit time_t
Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-11 11:11:12 +03:00
Gijs Peskens
7f3f3539e8 avformat/librist: allow setting fifo size and fail on overflow
Introduce fifo_size and overrun_nonfatal params to configure fifo buffer
behavior.

Use newly introduced RIST_DATA_FLAGS_OVERFLOW flag to check for overrun
and error out in that case.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-09 23:57:20 +02:00
Michael Niedermayer
c4b130e876 avformat/aviobuf: Check buf_size in ffio_ensure_seekback()
buffer_size is an int

Fixes: signed integer overflow: 9223372036854775754 + 32767 cannot be represented in type 'long'
Fixes: 45691/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5263458831040512

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-09 20:46:21 +02:00
Michael Niedermayer
35dc93ab44 avformat/bfi: Check offsets better
Fixes: signed integer overflow: -2145378272 - 538976288 cannot be represented in type 'int'
Fixes: 45690/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5015496544616448

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-09 20:46:10 +02:00
Michael Niedermayer
ffc8772150 avformat/asfdec_f: Check packet_frag_timestamp
Fixes: signed integer overflow: -9223372036854775808 - 4607 cannot be represented in type 'long'
Fixes: 45685/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5280102802391040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-06-09 20:45:36 +02:00
softworkz
5d5a014199 avformat/file: remove _WIN32 condition
stat is now re-mapped with long path support
in os_support.h

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-09 13:03:55 +03:00
softworkz
bc8f1bbe23 avformat/os_support: Support long file names on Windows
Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-09 13:03:51 +03:00
Matthieu Bouron
6dd6c58d89 libavformat/tls_libtls: handle TLS_WANT_{POLLIN, POLLOUT} in read/write functions
According to the tls documentation: tls_read() and tls_write() can
return TLS_WANT_POLLIN and TLS_WANT_POLLOUT which indicates that the
same operation must be repeated immediately.

This commit prevents the libtls backend from failing when libtls returns
TLS_WANT_POLLIN or TLS_WANT_POLLOUT with the following error:

    [tls @ 0x7f6e20005a00] (null)

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-06-08 23:09:47 +02:00
Anton Khirnov
38df63f967 lavf/matroskadec: stop mapping text/plain attachments to AV_CODEC_ID_TEXT
There is no reason to think that an attachment will contain text
subtitles. Furthermore, attachments are exported in extradata, so the
AV_CODEC_ID_TEXT decoder would not do anything useful with them anyway.
2022-06-08 09:27:54 +02:00
Ivan Baykalov
58880a8ea8 libavformat/isom: Add more language mappings
mov_mdhd_language_map table doesn't contain ISO 639 codes for some of
the languages. I added a few which have no contradictory mappings

Fixes ticket #9743

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-06-07 11:12:05 +02:00
Paul B Mahol
973fab5653 avcodec: add QOI decoder and demuxer and parser and encoder and muxer 2022-06-05 13:06:54 +02:00
Michael Niedermayer
d84f03609e avformat/matroskadec: assert non NULL buf
The code is only called if size is > 0 so buf should not be NULL

Helps: CID610554

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-05-26 11:54:05 +02:00
Michael Niedermayer
5982da87e3 avformat/act: Check ff_get_wav_header() for failure
Fixes: missing error check
Fixes: CID717495

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-05-26 11:54:05 +02:00
Michael Niedermayer
cb5be590cd avformat/jpegxl_probe: Check init_get_bits8() for failure
Fixes: missing error check
Fixes: CID1504270

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-05-26 11:54:05 +02:00
Martin Storsjö
6076dbcb55 Switch uses of av_fopen_utf8 to avpriv_fopen_utf8
The former has been deprecated.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-05-23 13:52:45 +03:00
Limin Wang
8e828ee1ad avformat/sccenc: avoid potential invalid access
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-05-19 21:17:31 +08:00
Limin Wang
4607868b98 Makefile: remove sccenc dependency on subtitles
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-05-19 21:17:31 +08:00
Vignesh Venkatasubramanian
dd99d34d67 avformat/img2: Add support for AVIF mux in image2
Add support for AVIF muxing in the image2 muxer.

Tested with this example:
ffmpeg -lavfi testsrc=duration=1:size=320x320 -g 1 -flags global_header -c:v libaom-av1 -f image2 img-%2d.avif

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2022-05-19 14:22:52 +05:30
Andreas Rheinhardt
e3580f6077 avformat/hls, dashdec: Don't use AV_OPT flags in av_dict_set()
av_dict_set() expects a different set of flags, namely the AV_DICT_*
flags. Using AV_OPT_FLAG_DECODING_PARAM (or any AV_OPT_FLAG_*) ic
av_dict_set() is therefore completely wrong and given that av_dict_set()
just doesn't care about whether the string it receives has anything
to do with a decoding parameter or not, it should just be removed
without replacement.
(The numerical value of AV_OPT_FLAG_DECODING_PARAM currently coincides
with AV_DICT_IGNORE_SUFFIX. Given that the dictionaries we are dealing
with here are always empty (i.e. NULL) before the calls to
av_dict_set(), this flag changes nothing. It would be different if
it were equal to one of the AV_DICT_DONT_STRDUP_* values.)

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-16 10:56:34 +02:00
Andreas Rheinhardt
104abea646 avcodec/ac3: Move non-(de|en)coder-only parts out of ac3.h
Move AC3HeaderInfo into ac3_parser_internal.h and the rest
into a new header ac3defs.h.

This also breaks an include cycle of ac3.h and ac3tab.h
(the latter now only needs ac3defs.h).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-15 18:13:56 +02:00
Gyan Doshi
8b64d8d9aa avformat/dashdec: accept and relay CENC decryption key
Allows to process CENC-encrypted media segments.
Option arg syntax is same as that for option decryption_key in MOV demuxer
2022-05-14 14:46:01 +05:30
Vignesh Venkatasubramanian
84241e63cf avformat/movenc: Add support for AVIF muxing
Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specification: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -still-picture 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
   animated AVIF yet).
3) Verified to be valid by Compliance Warden:
   https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2022-05-13 12:46:21 +05:30
Vignesh Venkatasubramanian
98ec4261fd avformat/av1: Add a parameter to av1c to omit seq header
Add a parameter to omit seq header when generating the av1C atom.

For now, this does not change any behavior. This will be used by a
follow-up patch to add AVIF support.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2022-05-13 12:45:17 +05:30
Steven Liu
ea6ed838c3 avformat/hlsenc: check discont_program_date_time before use it in parse_playlist
Fix ticket: 9238
In parse_playlist, the discont_program_date_time should be used after
EXT-X-PROGRAM-DATE-TIME tag parsed.

Tested-by: pero
Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2022-05-12 16:21:27 +08:00
Andreas Rheinhardt
439ca8b5f4 avformat/internal: Hide BSF stuff only used by the core APIs
The general demuxing API uses bitstream filters to extract extradata
and the muxing API uses them in order to transform packets into
the format desired by the target format. Therefore FFStream contains
pointers to AVBSFContexts and lavf/internal.h includes lavc/bsf.h.

Yet actually, only a few files files are supposed to use these,
namely avformat.c, demux.c and mux.c. For all the other files,
it should be an opaque type that they should not touch and that
they need not know anything about. This can be achieved by not
including these headers and using the structs instead of the
corresponding typedefs.
This also forces translation units that really use the BSF API
themselves to include lavc/bsf.h directly instead of relying on
indirect inclusions (a few other files also use the BSF API;
they already abided by this).
Of course, it also avoids unnecessary rebuilds when bsf.h changes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-12 08:52:59 +02:00
Andreas Rheinhardt
aaeb37f385 avformat/internal: Move FFERROR_REDO to demux.h
It is demuxer-only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-12 08:52:59 +02:00