Commit Graph

24246 Commits

Author SHA1 Message Date
Zane van Iperen 12f8293c02
avformat/scd: add demuxer
Adds demuxer for Square Enux SCD files.

Based off [1] and personal investigation.

This has only been tested against Drakengard 3 (PS3) *_SCD.XXX files
(big-endian). As it is highly likely that FFXIV (PC) files are little-endian,
this demuxer is marked as experimental until this can be confirmed.

[1]: http://ffxivexplorer.fragmenterworks.com/research/scd%20files.txt

Reviewed-by: Peter Ross <pross@xvid.org>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-12-02 01:41:55 +10:00
Andreas Rheinhardt 8a18db3ec6 avformat/matroskaenc: Sort cues entries by pts
Currently they are ordered as-written (i.e. by increasing position);
in case av_interleaved_write_frame() is used, this is (mostly)
the same as ordered by increasing dts.
Yet the Matroska specification strongly recommends (SHOULD) that
the CuePoints be sorted by CueTime. mkvalidator warns when they are
not. Therefore this commit sorts them accordingly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 17:42:18 +01:00
Ryoji Gyoda d9f07a506d avformat/fifo: avoid repeated scaling of timestamps on failure and recovery
If fifo_thread_recover() succeeds immediately after
fifo_thread_dispatch_message() fails, the dts of the packet is scaled
twice, causing cur_dts to be abnormally large and "Application provided
invalid, non monotonically increasing dts to muxer in stream" to occur
repeatedly.

Steps to reproduce:
1. ffmpeg -f lavfi -i testsrc -c:v libx264 -map 0:v -flags +global_header -f fifo -fifo_format flv -attempt_recovery 1 -recover_any_error 1 rtmp://example.com/livekey
2. set a breakpoint on fifo_thread_recover
3. force disconnect from the rtmp server
4. wait for break
5. reconnect to the rtmp server
6. resume execution of ffmpeg

Signed-off-by: Ryoji Gyoda <gy.cft4@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-29 22:20:20 +01:00
asilvestre 1c2dae153c avformat/flvenc: avoid 24bit timestamp truncation for FLV metadata
FLV AMF tags have a 24bit field for timestamps plus an 8bit for extended
timestamps.

All FLV AMF tags except when we write metadata handle this correctly
using the put_timestamp function.

Until now when writing metadata we were only using the first
24 bits and thus the timestamp value was wraping around 4 hours 40
minutes (16,800,000 ms, max 24 bit value 16,777,216) of playback.

This commit fixes this applying this same function put_timestamp
for the metadata FLV tag.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-29 21:30:09 +01:00
Michael Niedermayer 3a64a4c582 avformat/mov: Check channels for mov_parse_stsd_audio()
Fixes: signed integer overflow: -776522110086937600 * 16 cannot be represented in type 'long'
Fixes: 40563/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6644829447127040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-29 17:15:07 +01:00
Alex Xu (Hello71) 6fdd7fe0b8 avformat/img2dec: probe JFIF/Exif header
Due to reasons, mpv doesn't pass filename when probing. mpv also sets
default probescore threshold to 26. Since the current jpeg_probe
implementation returns 25 until EOI, it means that the whole image needs
to be probed to succeed. Worse, the whole image is not passed at once;
increasingly large buffers are tried before that. Adding it up together,
if many demuxers are enabled, moderately large JPEG files (few MB) can
take several seconds to open, despite taking less than 1 second to
actually decode.

Therefore, adjust the heuristic to be more optimistic if proper JFIF or
Exif segments are found. While not strictly required, the vast majority
of JPEG-ish files have one or the other or both.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-27 18:24:49 +01:00
Andreas Rheinhardt 2cddb2f7a8 avformat/mpegtsenc: Avoid allocation of AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Andreas Rheinhardt a81e0ee21f avformat/movenc: Avoid allocation of AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Andreas Rheinhardt 5e01fc8318 avformat/dashenc: Don't use stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Andreas Rheinhardt a5ee166327 avformat/avformat: Add AVStream parameter to check_bitstream() sig
For most check_bitstream() functions this just avoids having
to dereference s->streams[pkt->stream_index] themselves; but for
meta-muxers it will allow to forward the packet to stream with
a different stream_index (belonging to a different AVFormatContext)
without using a spare packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Limin Wang 7bf4c06809 avformat/rtp: add localaddr for network interface selection
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-27 11:21:17 +08:00
Michael Niedermayer 57adb26d05 avformat/avidec: Check read_odml_index() for failure
Fixes: Timeout
Fixes: 40950/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6478873068437504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-26 21:31:06 +01:00
Andreas Rheinhardt 7c2b9067d0 avformat/cafdec: Avoid unnecessary avio_tell() calls
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-26 18:55:58 +01:00
Limin Wang 27c9300027 avformat/udp: remove local localaddr array
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-26 17:43:48 +08:00
Marton Balint 0b9dbfab48 avformat/mpegts: fix stream index in verbose log message
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-25 19:11:24 +01:00
Marton Balint 6f10f4a479 avformat/libsrt: add missing version check for snddropdelay
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-25 19:11:24 +01:00
James Almer b46817d9c3 avformat/http: prevent truncation of sanitized_path
path1 and sanitized_path are both MAX_URL_SIZE bytes long, yet the latter is
copied from the former with the addition of one extra character.

Should fix a -Wformat-truncation warning.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-25 12:06:15 -03:00
Limin Wang 522f577d7e avformat/rtp: support RGB/BGR for rfc4175
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:07:19 +08:00
Limin Wang 7b55f95f71 avformat: suppport YUV 4:2:2 10-bit for rfc4175
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:07:15 +08:00
Limin Wang 4f5352d5fe avformat/rtpenc: adds partial support for the RFC 4175
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:04:35 +08:00
Limin Wang 05b0c66313 avformat/rtpdec_rfc4175: support for yuv420p format
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:04:35 +08:00
Limin Wang 3399bbab4d avformat/rtpdec_rfc4175: use rawvideo for uyvy422
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:04:35 +08:00
Gyan Doshi 203b0e3561 avformat/mov: make STTS duration unsigned int
As per 8.6.1.2.2 of ISO/IEC 14496-12:2015(E), STTS sample offsets
are to be always stored as uint32_t. So far, they have been signed ints
which led to desync in files with very large offsets.

The MOVStts struct was used to store CTTS offsets as well. These can be
negative in version 1. So a new struct MOVCtts was created and all
declarations for CTTS usage changed to MOVCtts.
2021-11-22 15:18:42 +05:30
Andreas Rheinhardt 53c8b16c19 avformat/utils: Remove duplicated AV_DISPOSITION_FOO <-> "foo" table
Instead reuse stream_options.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 20:35:07 +01:00
Andreas Rheinhardt b9a26b9d55 avformat/mxfenc: Remove redundant DNXHD frame size checks
The actual frame_size is no longer used since commit
3d38e45eb85c7a2420cb48a9cd45625c28644b2e; and the check for
"< 0" is equivalent to the CID being valid. But this is already
checked by avpriv_dnxhd_get_interlaced() (and is actually already
ensured by mxf_dnxhd_codec_uls containing this CID).

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 20:32:19 +01:00
Andreas Rheinhardt 4586de94a7 avformat/mxfenc: Store locally whether DNXHD profile is interlaced
It is just a flag per supported CID. So there is no reason to use
an avpriv function for this purpose.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 20:26:27 +01:00
Andreas Rheinhardt ce8f77a903 avformat/nullenc: Use ff_interleave_packet_passthrough()
It avoids the overhead of the packet list; furthermore, using
ff_interleave_packet_per_dts() is wrong for the null muxer anyway,
because said muxer accepts packets without timestamps, which
ff_interleave_packet_per_dts() can't handle.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 18:11:46 +01:00
Andreas Rheinhardt 52d13d54e1 avformat/mux: Avoid overhead of packet list in case of single streams
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 17:56:12 +01:00
Andreas Rheinhardt c03e53aea7 avformat/mux: Store pointer to interleavement func in FFFormatContext
It avoids branches lateron and will allow to easily avoid the overhead
of the linked list currently in use in case there is only one stream.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 17:47:04 +01:00
Gijs Peskens 9b15f43cf8 avformat/librist: correctly initialize logging_settings
Correct solution as suggested by Marton Balint on ffmpeg-devel

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-18 20:40:24 +01:00
Andreas Rheinhardt 419d93c379 avformat/utils: Remove unused shorthand feature for auto-inserted BSF
Besides being unused it should not be used at all:
The order of options of bitstream filters is not guaranteed
to be stable at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 06:01:59 +01:00
Andreas Rheinhardt 5f4b0ace4b avformat/mxfenc: Make init function out of write_header
The MXF muxers only write the header after they have received
a packet; the actual write_header function does not write anything.
So make an init function out of it.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 06:01:33 +01:00
Andreas Rheinhardt ea81c23c94 avformat/mxfenc: Remove redundant check
None of the muxers here has the AVFMT_NOSTREAMS flag set,
so it is checked generically that there are streams.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 05:59:32 +01:00
Andreas Rheinhardt 96fe44e2e8 avformat/hlsenc: Only write something if there is something to write
This is especially important in case avio_write() would be switched
to an unsigned type like size_t, then a potential error from avio_read()
(with negative return value) would no longer be handled gracefully by
avio_write().

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 04:53:07 +01:00
Andreas Rheinhardt 7596b6530d avformat/hlsenc: Remove nonsense memset
The memset here is both unnecessary (avio_read() ignores the previous
content of the destination buffer) as well as nonsense (for a char
buf[BUFSIZE] sizeof(buf) and sizeof(BUFSIZE) are not the same; the
latter is sizeof(int)).
Fixes Coverity issue #1465863.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 04:51:24 +01:00
Derek Buitenhuis a35101aae3 avformat/http: Add short_seek_size option
In 45bfe8b838, short_seek_threshold was removed
from the public AVIO struct. Although this option was private and not intended
to be used by public API users, it was nonetheless, because it provided functionality
that could otherwise not be gained via public API.

This was especially important for networked I/O like HTTP, where the internal
size for lavf could be way to small depending on the specifics of a user's
usecase, such as reading interlavd media files from cloud storage.

Add an AVOption to make this functionality accessible to the HTTP client.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-11-17 14:32:17 +00:00
Anton Khirnov a4c5d241ec lavf: add "disposition" AVOption to AVStream AVClass
Use it to remove custom disposition parsing code from ffmpeg.c
2021-11-16 10:51:32 +01:00
Anton Khirnov b731fb5104 lavf: add public functions converting dispositions to/from strings 2021-11-16 10:51:32 +01:00
Anton Khirnov ed75a08d36 lavf: add an AVClass to AVStream on next major bump
Also add a function to retrieve that class, analogously to
avformat_get_class().

This will be useful for adding an AVOption for dispositions.
2021-11-16 10:51:32 +01:00
Anton Khirnov 85433fb937 lavf: improve AV_DISPOSITION_* doxy
Also switch the values definition to the (1 << N) style, which is easier
to read.
2021-11-16 10:51:32 +01:00
Anton Khirnov db932241ee */version.h: define FF_API macros unconditionally
There is no reason to wrap them in #ifndef guards, they should only be
defined here and nowhere else. The define guards just add the
possibility to accidentally use the same FF_API name in different
libraries.
2021-11-15 16:24:58 +01:00
Googleplex 23a1f11d02 avformat/concatdec: fix NEEDS_UNSAFE flag value
NEEDS_UNSAFE has the same value as NEEDS_FILE,
causing "duration not allowed if safe" error
while duration directive doesn't require unsafe mode.

Signed-off-by: Googleplex <yyoung2001@gmail.com>
2021-11-14 19:25:11 +01:00
Marton Balint 406ffd9b9b avformat/demux: allow total size of packets in raw_packet_buffer to reach probesize
Previously this was hardcoded to 2500000 bytes, so probing of the stream codecs
was always limited by this, and not probesize.

Also keep track of the actual size of packets in raw_packet_buffer and not the
remaining size for simplicity.

Fixes ticket #5860.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-14 18:30:57 +01:00
Michael Niedermayer 97c3053d59 avformat/dhav: Limit get_duration() iterations
Fixes: Timeout
Fixes: 39971/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5756969890217984
Fixes: 39977/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-5327123053674496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-14 17:51:35 +01:00
Andreas Rheinhardt 945b2dcc63 avformat/hls_sample_encryption: Fix precedence
Fixes Coverity ticket #1492869.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-09 15:44:17 +01:00
Andreas Rheinhardt e5199eebb4 avformat/apngenc: Use UINT16_MAX instead of USHRT_MAX
The latter needn't be 16 bits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-09 15:40:36 +01:00
Andreas Rheinhardt 9139dc6140 avformat/matroskadec: Don't unnecessarily reduce aspect ratio
Fixes ticket #9497.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 15:38:03 +01:00
Alex Shumsky 1728127e8c avformat/mpegtsenc: do not include adaptation field in teletext TS packets
From ETSI EN 300 472 V1.3.1 (2003-05) Specification for conveying ITU-R System
B Teletext in DVB bitstreams:

4.1 Transport Stream (TS) packet format
The standard TS packet syntax and semantics are followed, noting the following
constraint:
- adaptation_field_control only the values "01" and "10" are permitted.

Some set top boxes (Motorola, Arris, Zyxel) refuse non-conforming packets.

Signed-off-by: Alex Shumsky <alexthreed@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-06 20:35:39 +01:00
Maksym Veremeyenko a085418303 avformat/mpegtsenc: fix first_pcr initial update
Commit 6f36eb0da7 claim it fixes endless loop on
package generation if muxrate specified and copyts used. But actually it does
not work properly if -mpegts_copyts 1 is specified:

ffmpeg -y -copyts -i loewe.ts -c:v libx264 -x264opts nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize 1000k  -c:a mp2 -f mpegts -mpegts_copyts 1 -muxrate 4500k -vframes 1000 test.ts

ffmpeg generate huge file until it reach zero-based pcr value equal to first dts.

Attached patch fixes it.

Reviewed-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-06 20:35:19 +01:00
Zhao Zhili a0f9650046 avformat/dashenc: enabling streaming and hls_playlist for lhls
Try to make the feature easier to use, especially since the user
have enabled -strict experimental manually. The user shouldn't
be surprised that hls_playlist is enabled for lhls automatically,
so change the log level from warning to info for that.
2021-11-05 15:32:11 -03:00