1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
Commit Graph

25416 Commits

Author SHA1 Message Date
James Almer
19c2dc677f avformat/concatf: check if any nodes were allocated
Fixes ticket #10304

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-14 10:04:47 -03:00
Zhao Zhili
c8e1955408 avformat/flvenc: avoid an extra allocate
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-04-15 04:21:33 +08:00
Zhao Zhili
d5fdfbac4a avformat/flvenc: use local variable to shorten code
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-04-15 04:21:33 +08:00
Anton Khirnov
be3b1e27e5 lavf/rawdec: mark raw demuxers as having no timestamps
Changes the result of the h264_redundant_pps-mov test, where the output
timebase is now 1001/24000 instead of 1/24. This is more correct, as the
source file actually is 23.98fps.
2023-04-13 15:34:07 +02:00
Anton Khirnov
7b827a0293 lavf/demux: treat streams with AVSTREAM_PARSE_FULL_RAW as having timestamps
In this case the timestamps are set by the parser.
Cf. a6b3471c44

Required by the following commit.
2023-04-13 15:34:07 +02:00
Anton Khirnov
ba4b73c977 lavf/rawdec: set avg_frame_rate
Timestamps in two FATE H.264 conformance tests now start at 1 instead
of 0, which also happens in some other H.264 tests before this commit
and so is not a big issue.
Conversely, timestamps in some HEVC conformance tests start from a
smaller value now.
Ideally this should be addressed later in a more general way.

h264-conformance-frext-frext2_panasonic_b no longer requires -vsync
passthrough.
2023-04-13 15:34:07 +02:00
James Almer
1a7df525f6 avformat/matroskaenc: fix memory leak in fail codepath
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-10 22:12:13 -03:00
James Almer
c558fcf41e avformat/matroskadec: also export non-HDR10+ ITU-T T.35 payloads as BlockAdditional side data
Partially reverts a change from 88de01d878, and
2133cadfcf.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-10 18:52:08 -03:00
Zhao Zhili
34b8af7963 avformat/flvenc: use extract_extradata bsf when necessary
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-04-09 21:44:29 +08:00
James Almer
82a14f3602 avformat/matroskadec: also validate the mapping when BlockAddIDType is 0
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-08 15:24:44 -03:00
James Almer
bda44f0f39 avformat/matroskaenc: support writing Dynamic HDR10+ packet side data
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-08 10:28:41 -03:00
James Almer
e1f691b2e8 avformat/matroskadec: remove itu_t_t35 flag from MatroskaTrack
It's no longer needed after 88de01d878.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-08 10:21:56 -03:00
James Almer
6d31619af2 avformat/matroskadec: validate MaxBlockAdditionID in the presence of BlockAdditions
The Matroska spec requires it to be equal to the highest BlockAddID value in a
BlockAdditions, but being purely an informative element, only abort if strict
compliance is requested, as demuxing is otherwise unaffected.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-07 14:13:03 -03:00
James Almer
2133cadfcf avformat/matroskadec: reindent after the previous commit
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-07 11:57:17 -03:00
James Almer
88de01d878 avformat/matroskadec: parse all BlockAdditionMapping elements and export the correct value as BlockAdditional side data
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-07 11:55:47 -03:00
Jerome Martinez
feeeefc3db
avformat/mxfenc: reject unsupported ffv1 versions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-06 00:50:01 +02:00
Marton Balint
8f534618b5 avformat/mxfdec: treat Random Index Pack as end of file
RIP, if exists is the last KLV item in the MXF files therefore we can stop
parsing the file if it is encountered. This allows us to support files created by
broken muxers such as OpenCube MXFTk Advanced 2.8.0.0.1. which dumps some extra
garbage after the RIP.

Signed-off-by: Marton Balint <cus@passwd.hu>
2023-04-06 00:40:42 +02:00
James Almer
1c2a1e0750 avformat/matroskaenc: write a MaxBlockAdditionID element
A non zero value is mandatory for Matroska if the track has blocks with BlockAdditions.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
James Almer
00fde8063a avformat/matroska: add a few more Block Addition ID Type enum values
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
James Almer
c73cf41f1e avformat/matroskadec: export Dynamic HDR10+ packet side data
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
James Almer
6def862559 avformat/matroskadec: set the default value for BlockAddIDType
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
James Almer
44513156e3 avformat/matroskadec: support parsing more than one BlockMore element
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
Anton Khirnov
1d3f7178ae lavf/mux: clarify log messages when choosing oformat fails
Current log messages talk about 'suitable' output formats. This is
confusing, because it suggests that some formats are suitable, while
others are not, which is not the case.

Also, suggest possible user actions when format cannot be guessed from a
filename.
2023-04-04 11:44:54 +02:00
Anton Khirnov
dffb058f3b lavf: fall back to a more meaningful log instance name
An uninitialized AVFormatContext instance with neither iformat nor
oformat set will currently log as 'NULL', which is confusing and
unhelpful. Print 'AVFormatContext' instead, which provides more
information.

This happens e.g. if choosing an output format fails in
avformat_alloc_output_context2().

E.g. with the following commandline:
 ffmpeg -i <input> -f foobar -y /dev/null
before: [NULL @ 0x5580377834c0] Requested output format 'foobar' is not a suitable output format
after:  [AVFormatContext @ 0x55fa15bb34c0] Requested output format 'foobar' is not a suitable output format
2023-04-04 11:42:52 +02:00
Gyan Doshi
6941788d24 avformat/movenc: correct loci parameter handling
3GPP TS 26.244 Table 8.10 specifies that longitude is written before
latitude. The MOV demuxer already expects the correct order. So, write
them in that order.

However, the user supplied string may also be used in MOV mode which
requires ISO 6709 format which specifies latitude first. The demuxer
also exports the loci value in that format. So parser adjusted as well.
2023-04-03 15:00:16 +05:30
Marton Balint
5f92a19231 avformat/assenc: avoid incorrect copy of null terminator
When writing a subtitle SSA/ASS subtitle file, the AVCodecParameters::extradata
buffer is written directly to the output.  In the case where the buffer is
filled from a matroska source file produced by some older versions of
Handbrake, this buffer ends with a null terminating character, which is then
erroneously copied into the middle of the output file. The change here avoids
this problem by treating it as a string rather than a raw buffer. This way it
is agnostic as to whether the source buffer was null terminated or not.

Fixes ticket #10203.

Reported-by: Tim Angus <tim at ngus.net>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-04-02 21:31:05 +02:00
Gyan Doshi
dd7e30724b avformat/tcp: correct strdup check
Fixes CID 1524608.
2023-04-02 10:18:56 +05:30
Martin Storsjö
c221036502 libavformat: Improve ff_configure_buffers_for_index for excessive deltas
Previously, the ff_configure_buffers_for_index function had
upper sanity limits of 16 MB (1<<24) for buffer_size and
8 MB (1<<23) for short_seek_threshold.

However, if the index contained entries with a much larger
delta, setting pos_delta to a value larger than the sanity
limit, we would end up not increasing the buffer size at all.

Instead, ignore the individual deltas that are excessive, but
increase the buffer size based on the deltas that are below the
sanity limit.

Only count deltas that are below 1<<23, 8 MB; pos_delta gets doubled
before setting the buffer size - this matches the previous maximum
buffer size of 1<<24, 16 MB.

This can happen e.g. with a mov file with some tracks containing
some samples that belong in the start of the file, at the end of
the mdat, while the rest of the file is mostly reasonably interleaved;
previously those samples caused the maximum pos_delta to skyrocket,
skipping any buffer size enlargement.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-04-02 00:34:53 +03:00
Martin Storsjö
33d06de638 libavformat: Account for negative position differences in ff_configure_buffers_for_index
When scanning through the index, account for the fact that the
compared samples may be located in an unexpected order in the file;
this function is mainly interested in the absolute difference between
file locations.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-04-02 00:34:46 +03:00
jackarain
4d216654ca libavformat/tcp: add local_addr/local_port for network option
Signed-off-by: jackarain <jack.wgm@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-03-30 12:09:49 +02:00
rcombs
57271e4a68 lavf/oggdec: fix demux with unrecognized header packets
Fixes ticket #10289.

Co-authored-by: James Almer <jamrial@gmail.com>
2023-03-28 16:46:03 -04:00
TADANO Tokumei
38bb137e99 lavf/mpegts.c: set some properties for ARIB caption
Some additional properties are set for ARIB caption.
* need_parsing = 0
  ARIB caption doesn't require any parser.
  This avoids "parser not found" warning message.
* need_context_update = 1
  When any profiles are changed, set this flag to notify.

Signed-off-by: rcombs <rcombs@rcombs.me>
2023-03-28 12:04:52 -04:00
Anton Khirnov
3f4c41839d lavf: return AVERROR_EOF rather than EIO on EOF 2023-03-27 17:14:31 +02:00
Jerome Martinez
174ca11d91 avformat/mxfenc: fix stored/sampled/displayed width/height
According to MXF specs the Stored Rectangle corresponds to the data which is
passed to the compressor and received from the decompressor, so they should
contain the width / height extended to the macroblock boundary.

In practice however width and height values rounded to the upper 16 multiples
are only seen when muxing MPEG formats. Therefore this patch changes stored
width and height values to unrounded for all non-MPEG formats, even macroblock
based ones.

For DNXHD the specs (ST 2019-4) explicitly indicates to use 1080 for 1088p.
For ProRes the specs (RDD 44) only refer to to ST 377-1 without precision but
no known commercial implementations are using rounded values.
DV is not using 16x16 macroblocks, so 16 rounding makes no sense.

The patch also fixes Sampled Width / Display Width to use unrounded values.

Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-26 22:04:44 +02:00
Marton Balint
cd954aa3c6 avformat/mxfenc: reindent after last mxfenc commit
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-26 22:02:23 +02:00
Devin Heitmueller
19798229df avformat/mpegts: add support for preserving SMPTE 2038 when transcoding MPEG-TS streams
Add the appropriate descriptors to the MPEG-TS demux and mux to
ensure that SMPTE 2038 VANC streams are properly preserved
when using codec copy (including adding the appropriate PMT
descriptors).

The focus of this patch is TS input to TS output.  A separate
patch adds support for output of 2038 VANC over decklink SDI.

Thanks to Marton Balint for feedback to preserve ABI compatibility.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-26 18:51:25 +02:00
Jerome Martinez
0fbae2178b avformat/mxfenc: SMPTE RDD 48:2018 Amd 1:2022 support 2023-03-25 19:28:36 +01:00
Jun Zhao
a53bb071fe lavf/mpeg: Add G.711 A law support
Add G.711 A law support

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2023-03-25 22:14:09 +08:00
Devin Heitmueller
6273fb36cc avformat/mpegtsenc: Restrict "async" behavior to KLV async packets
The original code would strip off the PTS/DTS of any packets
which had a stream ID of STREAM_ID_PRIVATE_STREAM_1.  While the
intent was to apply this to asynchronous KLV packets, it was
being applied to any codec that had that same stream ID (including
types such as SMPTE 2038).

Add a clause to the if() statement to ensure it only gets applied
if the codec actually is KLV.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-16 23:24:04 +01:00
Tong Wu
c3a7999099 avformat/mov: fix 2 compile errors
Compiler: MSVC 14.35.32215
Error type: error C2059: syntax error: '}'
Related commit: 9e1ffed fate/mov: add PCM in mp4 test
d7e8643 avformat/mov: parse ISO-14496-12 ChannelLayout

Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Haihao Xiang <haihao.xiang@intel.com>
2023-03-16 22:52:41 +08:00
Zhao Zhili
d4ee177a36 avformat/movenc: add PCM in mp4 support
It's defined by ISO/IEC 23003-5.

Fixes ticket #10185

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-03-15 00:12:59 +08:00
Zhao Zhili
d7e864366b avformat/mov: parse ISO-14496-12 ChannelLayout
Only support chnl version 0 now.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-03-15 00:12:59 +08:00
Zhao Zhili
a3dc677b9f avformat/isom_tags: remove ipcm from movaudio_tags
ipcm is defined by ISO/IEC 23003-5, not defined by quicktime. After
adding ISO/IEC 23003-5 support, we don't need it for ticket #9219.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-03-15 00:12:59 +08:00
Zhao Zhili
d04dbf48fc avformat/mov: fix ISO/IEC 23003-5 support
Missing floating-point formats support.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-03-15 00:12:59 +08:00
Wang Yaqiang
81bc7bc52e avformat/img2dec: fix unable to find svg format when the svg resources start with "<svg" or "<!--"
svg is xml, but <?xml is not required,
it can start with <svg and can have multiple empty lines,
or start with <!-- include some comments,
but must first line if start with <?xml.

Signed-off-by: Wang Yaqiang <wangyaqiang03@kuaishou.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-09 21:17:15 +01:00
asivery
1a4560ce4e avformat/aea: make the AEA demuxer return EOF at the end of file instead of EIO
Signed-off-by: asivery <asivery@protonmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-09 21:17:15 +01:00
Michael J. Walsh
6f1c006959 avformat/http: cookie path attribute should be optional not compulsory
The path attribute in the Set-Cookie header is optional but treated by ffmpeg as being compulsory.

Signed-off-by: Michael J. Walsh <mjfwalsh@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-08 23:40:58 +01:00
jackarain
4e3916dbce avformat/tls: check for memory allocation failure when setting options
Signed-off-by: jackarain <jack.wgm@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-08 23:19:15 +01:00
jackarain
05ea0457fc avformat/udp: check for memory allocation failure when setting localaddr
Signed-off-by: jackarain <jack.wgm@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-03-08 23:14:09 +01:00
rcombs
f758d4fcb9 lavf/matroska: add support for ARIB captions 2023-03-08 14:57:54 -06:00
Jan Ekström
912ac82a3c avformat/mov: base pcmC endianness on just the LSB
As per 23003-5:2020, the rest of the bits are reserved, and thus
in the future they may be utilized for something else.

Quote:
format_flags is a field of flags that modify the default PCM sample format.
Undefined flags are reserved and shall be zero. The following flag is defined:
  0x01 indicates little-endian format. If not present, big-endian format is used.
2023-03-05 23:58:04 +02:00
Jan Ekström
adca877acb avformat/mov: check that pcmC box is of the expected type
As per 23003-5:2020 this box is defined as
PCMConfig extends FullBox(‘pcmC’, version = 0, 0), which means
that version is 0 and flags should be zero.
2023-03-05 23:48:32 +02:00
Steven Liu
891ed24f77 avformat/hlsenc: hls_init_time should used in living stream mode
When hls_init_time should available when hls_list_size > 0.
Because the list will not refresh new top line segment when hls_list_size is 0

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2023-02-27 14:00:30 +08:00
Michael Niedermayer
2df271c78c
avformat/wavarc: Check if extradata has been fully read
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-23 23:17:09 +01:00
Michael Niedermayer
b3df7ca748
avformat/rka: Fix 1/0 with bps=1
Fixes: division by zero
Fixes: 55940/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6333107679920128

The decoder does not support bps=1 and i have no such sample so it is not
known if this duration is correct. Alternatively we could error out on all
bps we currently do not support on the decoder side or not set duration.

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-22 18:01:51 +01:00
Michael Niedermayer
53c1f5c2e2
avformat/mov: Check samplesize and offset to avoid integer overflow
Fixes: signed integer overflow: 9223372036854775584 + 536870912 cannot be represented in type 'long'
Fixes: 55844/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-510613920664780

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-22 18:01:37 +01:00
Pierre-Anthony Lemieux
15de355e62
avformat/imfdec: remove the experimental flag
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
2023-02-21 19:38:53 -08:00
John Coiner
e0cb89c354 avformat/mpegtsenc: re-emit extradata ahead of IDR pictures even if AUD is already present
Current mpegtsenc code only inserts SPS/PPS from extradata before IDR frames if
AUD is also inserted.

Unfortunately some encoders may preface a key frame with an AUD, but no
SPS/PPS. In that case current code does not repeat the "extradata" and the
resulting HLS stream may become noncompliant and unjoinable.

Fix this by always inserting SPS/PPS and moving AUD to the beginning of the
packet if it is already present.

Fixes ticket #10148.

Signed-off-by: Marton Balint <cus@passwd.hu>
2023-02-19 19:29:17 +01:00
Michael Niedermayer
47ac3e6065
version.h: Bump minor post 6.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-19 18:37:36 +01:00
Michael Niedermayer
62efa096af
version.h: Bump minor for 6.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-19 18:32:07 +01:00
Zhao Zhili
59a9727c24 avformat/flvenc: fix EOS tag
FLV spec only has AVC end of sequence tag, and the EOS tag has a
CodecID as other video data packet. MPEG4 doesn't conformance to
the spec, but it's there for a decade. So only 'fix' the EOS tag
rather than remove it completely.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-02-19 01:31:45 +08:00
Paul B Mahol
097653bae6 avformat/cdg: add probe 2023-02-18 09:56:40 +01:00
Marton Balint
927042b409 avformat: deprecate AVFormatContext io_close callback
io_close2 should be used instead.

Signed-off-by: Marton Balint <cus@passwd.hu>
2023-02-16 01:18:45 +01:00
Paul B Mahol
4113445e9d avformat/rka: improve probing 2023-02-14 22:29:33 +01:00
Jan Ekström
02ddfeadbe avformat/movenc: allow writing out channel count in MP4 and 3GP
ISOBMFF (14496-12) made this field ('channelcount') in the
AudioSampleEntry structure non-template¹ somewhere before the
release of the 2022 edition. As for ETSI TS 126 244 AKA 3GPP
file format (V16.1.0, 2020-10), it does not seem contain any
references limiting the channelcount entry in AudioSampleEntry
or in its own definition of EVSSampleEntry.

fate-mov-mp4-chapters test had to be adjusted as it output a
mono vorbis stream, which would now be properly marked as such
in the container.

1: As per 14496-12:
   Fields shown as “template” in the box descriptions are fields
   which are coded with a default value unless a derived
   specification defines their use and permits writers to use
   other values than the default.
2023-02-14 21:10:42 +02:00
Paul B Mahol
a13210ab39 avformat: add RKA demuxer 2023-02-11 21:29:35 +01:00
Paul B Mahol
385ec46424 avformat: add SDNS demuxer 2023-02-11 11:30:46 +01:00
Paul B Mahol
8ed1d6b5e4 avformat/wavarc: demux only data chunk content 2023-02-09 20:48:25 +01:00
James Almer
5bad485603 Bump major versions of all libraries
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer
c52b1c283e avformat/version: postpone the remaining API deprecations
They are either too recent, or still need work like FF_API_COMPUTE_PKT_FIELDS2.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
Leo Izen
719a93f4e4 avutil/{color_utils, csp}: merge color_utils into csp and expose API
libavutil/color_utils contains some avpriv_ symbols that map
enum AVTransferCharacteristic values to gamma-curve approximations and
to the actual transfer functions to invert them (i.e. -> linear).

There's two issues with this:
(1) avpriv is evil and should be avoided whenever possible
(2) libavutil/csp.h exposes a public API for handling color that
    already handles primaries and matricies

I don't see any reason this API has to be private, so this commit takes
the functionality from avutil/color_utils and merges it into avutil/csp
with an exposed av_ API rather than the previous avpriv_ API.

Every reference to the previous API has been updated to point to the
new one. color_utils.h has been deleted as well. This should not break
any applications as it only contained avpriv_ symbols in the first
place, so nothing in that header could be referenced by other
applications.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:35:14 +01:00
James Almer
6d6ae3595b avformat: remove FF_API_AVSTREAM_CLASS
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer
1f86fc1c5e avformat: remove FF_HLS_TS_OPTIONS
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer
9b8a398930 avformat: remove FF_API_AVIOCONTEXT_WRITTEN
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer
add33e370d avformat: remove FF_API_LAVF_PRIV_OPT
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:14 +01:00
James Almer
5f9e848e68 avcodec: remove FF_API_AVCTX_TIMEBASE
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:08 +01:00
Andreas Rheinhardt
59c9dc82f4 avformat/avformat: Move AVOutputFormat internals out of public header
This commit does for AVOutputFormat what commit
20f9727018 did for AVCodec:
It adds a new type FFOutputFormat, moves all the internals
of AVOutputFormat to it and adds a now reduced AVOutputFormat
as first member.

This does not affect/improve extensibility of both public
or private fields for muxers (it is still a mess due to lavd).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
Andreas Rheinhardt
f23ae839fc avformat/demux: Avoid stack packet when decoding frame
Possible now that avcodec_decode_subtitle2() accepts a const AVPacket*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
Andreas Rheinhardt
0281e28c37 avformat/avformat: Move codecpar up in AVStream
It is the most commonly used field and moving it to the start
e.g. allows to encode the offset in a pointer+offset addressing
mode on one byte on x86.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
Andreas Rheinhardt
145f6b2223 avformat/avformat: Remove AVOutputFormat.data_codec
No AVOutputFormat has this set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
gnattu
d09254a658 avformat/hls: Add option to retry failed segments for hls
Current HLS implementation simply skip a failed segment to catch up
the stream, but this is not optimal for some use cases like livestream
recording.
Add an option to retry a failed segment to ensure the output file is
a complete stream.

Signed-off-by: gnattu <gnattuoc@me.com>
Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
2023-02-09 14:37:23 +05:30
Paul B Mahol
df4ab69cfa avcodec/wavarc: add support for 0CPY 2023-02-07 17:13:11 +01:00
Paul B Mahol
64b242d030 avcodec/wavarc: fix 8bit decoding 2023-02-06 18:09:11 +01:00
Paul B Mahol
4b922218e9 avformat/lafdec: check for not supported bpp 2023-02-04 09:40:34 +01:00
Paul B Mahol
332a4d798d avformat/lafdec: error out on partial packet header read 2023-02-04 09:40:34 +01:00
Paul B Mahol
4e3e70c19d avformat: add WavArc demuxer 2023-02-04 09:37:19 +01:00
Michael Niedermayer
f4b4e16641
libavformat/lafdec: free data
Fixes: memleak

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-01 20:23:37 +01:00
Michael Niedermayer
ad95d9c855
avformat/lafdec: Check if all data was read
Fixes: OOM
Fixes: 54572/clusterfuzz-testcase-minimized-ffmpeg_dem_LAF_fuzzer-4974038870523904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-02-01 20:23:37 +01:00
Martin Storsjö
431f6260ac mov: Reduce the verbosity of the warning about fragmented MP4 vs advanced edit lists
Only warn if the advanced_editlist option is enabled (it is enabled
by default though) so we don't print one warning for each track, and
demote the warning to AV_LOG_LEVEL_VERBOSE; this message does get
generated whenever parsing a fragmented MP4 file, regardless of
whether the file actually uses multiple edits or not.

Later when parsing the mov structures, the demuxer does warn if
the file did contain multiple edits which would require the
advanced_editlist option enabled for decoding correctly.

Adjust the warning message for the case when the file seemed like it
actually would have needed handling of advanced edit lists, to
reflect the fact that it doesn't help to try set the option as
it has been automatically disabled.

Signed-off-by: Martin Storsjö <martin@martin.st>
2023-01-31 14:29:08 +02:00
Paul B Mahol
fa42575ffa avformat: add XMD demuxer 2023-01-30 21:02:48 +01:00
Marton Balint
af606c232a avformat/mxfdec: check number of index table entires more strictly
Let's ignore the index table if the number of index entries does not match the
index duration (or the special AVID index entry counts).

Fixes: OOM
Fixes: 50551/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6607795234930688

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-01-29 18:58:30 +01:00
Marton Balint
41dfa629d7 avformat/mxfdec: support Avid files with an extra index entry
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-01-29 18:58:30 +01:00
Marton Balint
6aff3c5e43 avformat/mxfdec: check index entry array size
Signed-off-by: Marton Balint <cus@passwd.hu>
2023-01-29 18:58:30 +01:00
Paul B Mahol
01343683fa avcodec: add CBD2 DPCM decoder 2023-01-27 19:45:36 +01:00
Zhao Zhili
b8fca1f1f5 avformat/teeproto: setup max_packet_size
It's the minimum of all child protocols max_packet_size. Can be used
like this:

ffmpeg -re -i cctv.mp4 -c copy -f mpegts \
  -protocol_whitelist 'tee,file,udp' \
  'tee:out.ts|udp://127.0.0.1:6666?pkt_size=1316'

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-26 23:31:44 +08:00
Paul B Mahol
2c3107c3e9 avformat/bonk: remove unused variable 2023-01-25 18:49:09 +01:00
Paul B Mahol
b8640bfc99 avformat: add WADY demuxer 2023-01-24 16:58:01 +01:00
Gyan Doshi
01f46f18db avformat/segment: calculate segment durations correctly.
segment_time and segment_times are defined as duration specifications, not
timestamps, so calculation of segment duration must account for initial
timestamp. Fixed.

FATE ref for segment-mp4-to-ts changed on account of avoiding premature
segment cut at the end of the first segment.
2023-01-16 15:37:59 +05:30
Paul B Mahol
2524d0b33b avformat/dtshddec: also read trailing padding in samples 2023-01-16 09:59:31 +01:00
rcombs
d3538dd293 lavf/spdifdec: support EAC3
Parsing should probably be enabled for all codecs, at least for headers,
but e.g. the AAC parser produces 1-byte packets of zero padding with it,
so I'm just enabling it for EAC3 for the moment.
2023-01-13 11:22:59 -06:00
Basel Sayeh
6161eacc74 libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file
Removed the unnecessary calls to ff_format_io_close
this patch introduced in dashenc_delete_file.
dashenc_delete_file functions open a
new HTTP connection regardless of the http_persistent value,
So change their behaviour to keep http connections open
if http_persistent is set.

Signed-off-by: Basel Sayeh <basel.sayeh@hotmail.com>
2023-01-13 14:02:33 +08:00
Basel Sayeh
77ad210fba libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file
Removed the unnecessary calls to ff_format_io_close
this patch introduced in hls_delete_file.
hls_delete_file functions open a new HTTP connection
regardless of the http_persistent value,
So change their behaviour to keep http connections open
if http_persistent is set

Signed-off-by: Basel Sayeh <basel.sayeh@hotmail.com>
2023-01-13 14:01:02 +08:00
Vignesh Venkatasubramanian
54c488223b avformat/movenc: Add loop parameter to animated AVIF
The HEIF specification permits specifying the looping behavior of
animated sequences by using the EditList (elst) box. The track
duration will be set to the total duration of all the loops (or
infinite) and the duration of a single loop will be set in the edit
list box.

The default behavior is to loop infinitely.

Compliance verification:
* This was added in libavif recently [1] and the files produced by
  ffmpeg after this change have EditList boxes similar to the ones
  produced by libavif (and avifdec is able to parse the loop count as
  intended).
* ComplianceWarden is ok with the produced files.
* Chrome is able to play back the produced files.

[1] 4d2776a3af

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-13 20:03:36 +08:00
Vignesh Venkatasubramanian
f2b1750871 avformat/movenc: Add movie_timescale option to AVIF
Allow specifying the movie_timescale options to AVIF ouptut.

This also makes sure that when movie_timescale is not specified,
the default value of 1000 is used instead of 0. Animated AVIF
files which don't specify the movie_timescale will have the
correct duration written in the track and movie headers after this
change (instead of writing 0).

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-13 20:03:28 +08:00
Paul B Mahol
fc263f073e avformat/nsvdec: add support for STARDIVA format 2023-01-12 10:44:16 +01:00
Zhao Zhili
e30bf5acee avformat/file: add S_IFBLK/S_ISBLK compatability macro
They are not available on Windows.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-12 20:52:37 +08:00
Zhao Zhili
6e7c006e40 avformat/file: add fd protocol
Unlike the pipe protocol, fd protocol has seek support if it
corresponding to a regular file.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:50:36 +08:00
Zhao Zhili
e9fe1634d4 avformat/file: dup file descriptor for pipe
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:50:36 +08:00
Zhao Zhili
8d91a8faab avformat/file: reindent after the previous commit
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:50:36 +08:00
Zhao Zhili
49b8f043ca avformat/file: add fd option for pipe
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-11 18:50:36 +08:00
Derek Buitenhuis
94aa70d757 avformat: Rename IPFS to IPFS gateway
It is a URL rewriter for IPFS gateways, not an actual implementation of
IPFS, and naming it as such was both incorrect and misleading.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2023-01-09 12:14:47 -05:00
Derek Buitenhuis
dae3679a9b mov: Disable advanced_editlist for fragmented MP4 input
Advanced edit list support is entirely broken for fragmented MP4s,
currently. mov_fix_index is never run in mov_build_index, since
in fragmented MP4s the stco, stsz, stts, and stsc boxes have zero
entries, with the index being filled in as each fragment's trun
box is seen.

The result of this is that the skip samples is never set properly,
since half the code thinks it doesn't need to, as advanced_editlist
is enabled, but as mov_fix_index is never called, it doesnt get set.
This means that any edits for e.g. priming are not properly applied
as skip samples side data.

This also means remuxing to fragmented MP4 from progressive MP4 with
lavf will quietly drop the edit list, currently.

Example:

    $ ffmpeg -loglevel quiet -advanced_editlist 1 -i non_fragmented.mp4 -f md5 -
    MD5=d02d929f8eb4edef624758a298d5f7c6
    $ ffmpeg -loglevel quiet -advanced_editlist 0 -i non_fragmented.mp4 -f md5 -
    MD5=d02d929f8eb4edef624758a298d5f7c6
    $ ffmpeg -loglevel quiet -advanced_editlist 1 -i fragmented.mp4 -f md5 -
    MD5=e38b110f586fa886ff94e0ca98a95d59 <-- wrong, extra samples are output instead of being skipped
    $ ffmpeg -loglevel quiet -advanced_editlist 0 -i fragmented.mp4 -f md5 -
    MD5=d02d929f8eb4edef624758a298d5f7c6

We cannot call mov_fix_index after reading a trun box
since mov_fix_index seems to assume it is only called once, on a
fully complete index, an multiple calls to it don't seem like
they'd work, so the "best" option seems to be disabling advanced
edit list support entirely for the time being, as it is broken
for these types of files.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2023-01-09 15:23:41 +00:00
James Almer
a781279871 avformat/oggenc: don't flush twice when the last packet is side data only
Commit 18f24527eb accidentally made side data only packets be handled like a
flush request. Fix this regression by effectively ignoring them as was the
original intention.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-01-03 21:35:03 -03:00
James Almer
99e3d26f20 avformat/mux: use only valid timestamps when calculating packet distance
Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long int'
Fixes: fate-cover-art-aiff-id3v2-remux, fate-cover-art-mp3-id3v2-remux and fate-mov-cover-image
under ubsan.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-01-03 21:35:03 -03:00
Paul B Mahol
cc2b1a3251 avformat/bonk: add support for ID3 metadata 2023-01-02 19:54:56 +01:00
Gyan Doshi
d39b34123d avformat/segment: add option min_seg_duration
New option can be used to avoid creating very short segments with inputs
whose GOP size is variable or unharmonic with segment_time.

Only effective with segment_time.
2022-12-29 15:43:40 +05:30
Michael Niedermayer
64a04fc165
avformat/mxfdec: Use 64bit in remainder
Fixes: signed integer overflow: 48000 * 223587 cannot be represented in type 'int'
Fixes: 54513/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5817594836025344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-28 00:25:34 +01:00
James Almer
18f24527eb avformat/oggenc: ignore empty packets
Some encoders, like flac, can send side data only packets at the end.
Eventually, said extradata update should ideally be used to update the header
when writting to seekable output, but for now, ignore them.

Should fix the undefined behavior of passing NULL to memcpy().

Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-27 11:03:18 -03:00
Michael Niedermayer
b92260f70a
avformat/lafdec: Check for EOF in header reading
Fixes: OOM testcase
Fixes: 51527/clusterfuzz-testcase-minimized-ffmpeg_dem_LAF_fuzzer-5453663505612800

OOM can still happen after this as an arbitrary sized block is allocated and read
this would require a redesign or some limit on the sample rate.

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-23 00:43:02 +01:00
Gyan Doshi
9adf02247c avformat/movenc: correct write_colr warning placement
The old warning is no longer applicable in the inner block after
c5b20cfe19.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
2022-12-15 15:28:23 +05:30
Marvin Scholz
45ab5307a6 avformat/fifo: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:15 +01:00
Marvin Scholz
d75d8370bd avformat/matroskaenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:15 +01:00
Marvin Scholz
643c2b4722 avformat/http: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:15 +01:00
Marvin Scholz
fb93d3d043 avformat/asfenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:15 +01:00
Marvin Scholz
521d8dcf88 avformat/apetag: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:15 +01:00
Marvin Scholz
4bf8c9c2d8 avformat/nutenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
0464aa484e avformat/id3v2enc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
995616b752 avformat/ffmetaenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
b31c16d625 avformat/wtvenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
2b5391b88f avformat/dump: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
8298f20c59 avformat/lrcenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
6c4f23cc20 avformat/hls: use av_dict_iterate
And constify oldentry too while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
b463ef0339 avformat/flvenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
b7c577cec7 avformat/metadata: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
562d19b503 avformat/movenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
401508b24b avformat/cafenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
734acfde4c avformat/vorbiscomment: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Marvin Scholz
f8584c13f0 avformat/smjpegenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Andreas Rheinhardt
4d9c0b3efa configure: Add (h264|hevc)_sei subsystems
Currently, several components select atsc_a53, despite
not using anything from it themselves. They only select
it because parsing SEI messages adds an indirect dependency.
But using direct dependencies is more natural, so add
dedicated subsystems for them.

It already allows to remove a superfluous dependency of
the HEVC QSV encoder on hevc_sei and atsc_a53.

Adding new subsystems only becomes effective after a reconfiguration.
In order to force this, some needed headers (which are only included
implicitly before this commit) were included explicitly in
libavformat/allformats.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:00:40 +01:00
Sasi Inguva
9d8d7bdffb avformat/mov: Set duration to zero if the duration is UINT_MAX
Fixes some MP4F files which have duration in mdhd set to UINT_MAX instead of zero.

Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-29 08:39:32 -03:00
Michael Niedermayer
a798af91d7
avformat/id3v2: Check taglen in read_uslt()
Fixes: Timeout (read mostly the same data repeatly)
Fixes: 52457/clusterfuzz-testcase-minimized-ffmpeg_dem_ALP_fuzzer-6610706313379840
Fixes: 53098/clusterfuzz-testcase-minimized-ffmpeg_dem_SOL_fuzzer-6481382981632000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-28 21:20:56 +01:00
Paul B Mahol
2ad199ae31 avformat/wavenc: w64 muxer supports only 1 stream 2022-11-25 10:23:19 +01:00
Marton Balint
98f6c59f4f avformat/electronicarts: add option to return alpha channel in the main video stream in VP6A codec
VP6 alpha in EA format is a second VP6 encoded video stream where only the Y
component is used and is interpreted as the alpha channel of the first VP6
stream. The alpha VP6 stream is muxed separately from the main VP6 stream, has
its own stream headers and packet headers. In theory the two streams might not
even have the same resolution (although most likely that is not something that
is seen or supported in the wild), but the format is capable of doing it.

Merged VP6 alpha (also known as the VP6A codec) means that a packet of the
video stream contains the corresponding packet of both VP6 substreams like
this:

{OffsetOfAlpha, DataPacket, AlphaDataPacket}

So data and alpha data of a frame is merged to a single packet, this is how VP6
video with alpha is muxed in FLV and SWF.

The first approach is more like how the demuxer sees data in the EA format,
unfortunately it is different to what the FLV or SWF format expects, so -
having no better place for it in the framework - I decided to do an optional
format conversion in the EA demuxer.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-11-22 22:59:51 +01:00
Marton Balint
bd5ea78556 avformat/electronicarts: set packet_read in one place
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-11-22 22:54:27 +01:00
Marton Balint
29d1d3e2e8 avformat/electronicarts: fix EOF check
Similar to feof(), avio_feof() is only true after an actual overread.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-11-22 22:54:27 +01:00
James Almer
63db6a02a7 avformat/concatdec: check that there's extradata before trying to copy it
The first argument for memcpy must not be NULL.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-17 10:53:20 -03:00
James Almer
cb925c0bc0 avformat/vpcc: parse bitstream data to get profile and bitdepth
Profile can be derived from values codecpar pixel format only with software
formats. For hardware formats, we're forced to parse a frame header to get
the required information.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-17 10:05:49 -03:00
Michael Niedermayer
2532b20b17
avformat/replaygain: avoid undefined / negative abs
Fixes: signed integer overflow: -2147483648 * 100000 cannot be represented in type 'int'
Fixes: 52060/clusterfuzz-testcase-minimized-ffmpeg_dem_MP3_fuzzer-5131616708329472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-04 22:44:16 +01:00
Paul B Mahol
e27bef9a56 avformat/serdec: fix BE/LE format handling 2022-11-03 16:59:18 +01:00
Pierre-Anthony Lemieux
89a49fd5a9
avformat/imfdec: variable initialiaztion cosmetics 2022-11-03 21:16:10 +10:00
Pierre-Anthony Lemieux
906219e3ca
avformat/tests/imf: add CPL timecode test 2022-11-03 21:16:10 +10:00
Pierre-Anthony Lemieux
94922f6cab
avformat/imfdec: use CPL start timecode if available
The IMF CPL contains an optional timecode start address. This patch reads the
latter, if present, into the context's timecode metadata parameter.
This addresses https://trac.ffmpeg.org/ticket/9842.
2022-11-03 21:16:03 +10:00
James Almer
5d5b87f688 avformat/mov_chan: use the cube layout
Signed-off-by: James Almer <jamrial@gmail.com>
2022-10-30 16:46:48 -03:00
Andreas Rheinhardt
cdd50223a6 avformat/argo_cvg: Mark overrides as const
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-28 09:08:00 +02:00
Andreas Rheinhardt
9aa7397db1 avformat/mux: Constify validate_codec_tag()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-27 15:32:37 +02:00
Andreas Rheinhardt
5da8b522c8 avformat/mux: Don't call ff_toupper4() unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-27 15:32:37 +02:00
Anton Khirnov
a2f5913857 lavf: set internal thread names 2022-10-24 02:00:31 +02:00
Carl Eugen Hoyos
fc410ce572 lavf/hevc: Fix type specifiers, missed in 8b5d1553
Fixes several warnings with msvc:
warning: format specifies type 'unsigned char' but the argument has type 'unsigned int'
2022-10-23 20:45:25 +02:00
Andreas Rheinhardt
1132007d3c avformat/mj2kdec: Remove always-true #if CONFIG_MJPEG_2000_DEMUXER
This file is built iff the MJPEG 2000 demuxer is enabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Chema Gonzalez
a1a87b7a24 avformat/yuv4mpegdec: increase header limit
Allows demuxing UHD F1000000000:33333333 fps yuvj420p files

ffmpeg (at HEAD as of now) is creating this:

```
$ ffmpeg -y -i source.265 /tmp/foo.y4m >& /dev/null
...
$ xxd /tmp/raw.y4m |less
00000000: 5955 5634 4d50 4547 3220 5731 3932 3020  YUV4MPEG2 W1920
00000010: 4831 3038 3020 4631 3030 3030 3030 3030  H1080 F100000000
00000020: 303a 3333 3333 3333 3333 2049 7020 4130  0:33333333 Ip A0
00000030: 3a30 2043 3432 306d 7065 6732 2058 5953  :0 C420mpeg2 XYS
00000040: 4353 533d 3432 304d 5045 4732 2058 434f  CSS=420MPEG2 XCO
00000050: 4c4f 5252 414e 4745 3d4c 494d 4954 4544  LORRANGE=LIMITED
00000060: 0a46 5241 4d45 0a82 8282 8282 8282 8282  .FRAME..........
...
```

Which cannot be parsed by the same ffmpeg decoder:
```
$ ffmpeg -i /tmp/foo.y4m /tmp/bar.y4m
...
[yuv4mpegpipe @ 0x2b69a40] Header too large.
/tmp/foo.y4m: Invalid argument
```

This is kicking the ball (per 0b1ff3265e),
but seems to work.
2022-10-21 20:11:14 +02:00
Michael Niedermayer
557aa7772e
avformat/asfdec_o: Check offset before adding index entry
Fixes: signed integer overflow: 9223372036854550860 + 530259564 cannot be represented in type 'long'
Fixes: 49093/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-4697179192688640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-10-20 21:42:20 +02:00
Tristan Matthews
eb9153b4a7 avformat/hls: fix spelling and grammar on wrap warning 2022-10-20 16:27:06 +05:30
Peter Ross
3141dbb7ad avcodec: ViewQuest VQC decoder
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Peter Ross <pross@xvid.org>
2022-10-18 13:20:37 +11:00
Marvin Scholz
226dde687f avformat/avio: Add doxy for missing argument 2022-10-17 09:56:47 +02:00
Marvin Scholz
99f6d0bdde avformat/avformat: Improve doxy style
Mostly re-indenting and adding some missing references.
2022-10-17 09:51:47 +02:00
Marvin Scholz
1f0529ec5f avformat/avformat: Fix mismatching argument names 2022-10-17 09:51:47 +02:00
Guangyu Sun
fc6f7e2a3b lavf/async: Fix ring_write return value
This fixes a regression from commit 36117968ad.

wrapped_url_read() used to be able to return positive number from
ffurl_read(). It relies on the result to check if EOF is reached in
async_buffer_task().

But FIFO callbacks must return 0 on success. This should be handled
in ring_write() instead.

Test case:
  ffmpeg -f lavfi -i testsrc -t 1 test.mp4
  ffmpeg -i async:test.mp4

Signed-off-by: Guangyu Sun <gsun@roblox.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-14 12:19:13 +02:00
Zhao Zhili
94644343a6 avformat/mp3dec: remove a call to avio_tell()
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-10-08 22:56:30 +08:00
Zhao Zhili
0d17f5228f avformat/mp3dec: avoid seek back and forth
avio_seek() is called inside check(). Seeking to 'off' then seeking
to 'off + i' is unefficient, and it can loop 64 * 1024 times in the
worst case. When probe a malformed file over HTTP, it looks like
stucked forvever. ffio_ensure_seekback() doesn't solve the issue
when the stream is seekable but slow.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-10-08 22:56:20 +08:00
Zhao Zhili
2205ccd216 avformat/mpegtsenc: add omit_rai flag
Add PCR at keyframe can be undesirable when -pcr_period is
specified. Add an flag to disable this behavior.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-10-08 22:55:31 +08:00
Gavin Smith
2c2aaa5bd0 avformat/mxfdec: do not log warning of multiple ANC packets if count is 0
Some NLVEs may insert a KLV packet for EIA-608 data even though
the number of encapsulated ANC packets is zero.
2022-10-06 10:23:39 +02:00
Richard Ayres
b074424bf6 Encrypted SMPTE DC MXF - additional UL needed to unpack EKLV packet
Thanks, Pierre-Anthony. I've updated the patch to remove the unnecessary UL and it's now using mxf_match_uid() to detect the EKLV packet.

Signed-off-by: Richard Ayres <richard.ayres@bydeluxe.com>
2022-10-06 10:04:17 +02:00
Michael Niedermayer
5f44489cc5
avformat/vividas: Check packet size
Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-10-04 23:47:54 +02:00
Andreas Rheinhardt
63b3156558 avformat/aviobuf: Don't use NULL as src for memcpy
This might happen in avio_write() if size == 0
when the direct codepath is taken. It is undefined behaviour
according to the spec although it happens to work in practice.
Fixes the webm-webvtt-remux FATE-test under UBSan.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
d09776d486 avformat/avio: Schedule AVIODirContext to become an opaque type
Users can't make anything with its content.
Making it opaque might allow us to avoid one level of indirection.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-03 23:21:57 +02:00
Andreas Rheinhardt
7eed125dbb avcodec/mpeg4audio: Move ff_copy_pce_data() to a header of its own
It is only used by three of the thirty files that (potentially
indirectly) include mpeg4audio.h. Twenty of these files won't
have a put_bits.h inclusion any more after this patch.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-02 20:16:42 +02:00
Paul B Mahol
4b6b75c752 avcodec: add Media 100i decoder 2022-09-30 19:11:36 +02:00
Pierre-Anthony Lemieux
0e402ebf48
format/imfdec: improve error handling when selecting tracks for playback
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
2022-09-28 11:54:52 +10:00
Andreas Rheinhardt
2b41463b87 avformat/internal: Don't include avcodec.h
The general demuxing API uses parsers and decoders. Therefore
FFStream contains pointers to AVCodecContexts and
AVCodecParserContext and lavf/internal.h includes lavc/avcodec.h.

Yet actually only a few files files really use these; and it is best
when this number stays small. Therefore this commit uses opaque
structs in lavf/internal.h for these contexts and stops including
avcodec.h.
This also avoids including lavc/codec_desc.h implicitly. All other
headers are implicitly included as now (mostly through codec.h).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-26 03:02:50 +02:00
Andreas Rheinhardt
832e6563df avformat/matroska*: Use av_chroma_location_(pos_to_enum|enum_to_pos)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-26 03:02:27 +02:00
Andreas Rheinhardt
843fe314ea avformat/nutdec: Don't shrink packet size manually
It is unnecessary because an av_shrink_packet() a few lines below
will set the size; furthermore, it is actually harmful, because
av_shrink_packet() does nothing in case the size already matches,
so that the packet's padding is not correctly zeroed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-25 14:56:03 +02:00
Michael Niedermayer
aa441ac105
avformat/matroskadec: Error out if a timestamp is beyond duration
Maybe timestamp / duration validity should be checked earlier

Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6586894739177472
Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:29:43 +02:00
Michael Niedermayer
4075f0cec1
avformat/spdifdec: Use 64bit to compute bit rate
Fixes: signed integer overflow: 32 * 553590816 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-6564974517944320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:29:32 +02:00
Michael Niedermayer
529f64b2eb
avformat/rpl: Use 64bit for duration computation
Fixes: signed integer overflow: 24709512 * 88 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6737973728641024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:29:08 +02:00
Michael Niedermayer
2c789f753c
avformat/xwma: Use av_rescale() for duration computation
Fixes: signed integer overflow: 34242363648 * 538976288 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6577923913547776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:28:57 +02:00
Michael Niedermayer
aa8eb1bed0
avformat/sdsdec: Use av_rescale() to avoid intermediate overflow in duration calculation
Fixes: signed integer overflow: 72128794995445727 * 240 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SDS_fuzzer-6628185583779840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:28:51 +02:00
Michael Niedermayer
5f529e9147
avformat/sbgdec: Check ts_int in genrate_intervals
There is probably a better place to check for this, but better
here than nowhere

Fixes: signed integer overflow: -9223372036824775808 - 86400000000 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6601162580688896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:28:41 +02:00
Michael Niedermayer
981f5e46af
avformat/sbgdec: clamp end_ts
Fixes: signed integer overflow: 9223372036851135042 + 15666854 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6573717339111424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:28:29 +02:00
Michael Niedermayer
2cb7ee8a36
avformat/rmdec: check tag_size
Fixes: signed integer overflow: -2147483648 - 8 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_RM_fuzzer-6598073725353984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:28:19 +02:00
Michael Niedermayer
2c146406ea
avformat/nutdec: Check fields
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6566001610719232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:28:10 +02:00
Michael Niedermayer
7124f10c1d
avformat/flvdec: Use 64bit for sum_flv_tag_size
Fixes: signed integer overflow: 2138820085 + 16130322 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6704728165187584

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 18:27:43 +02:00
Michael Niedermayer
b1a68127bb
avformat/jacosubdec: Fix overflow in get_shift()
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-6722544461283328
Fixes: signed integer overflow: 48214448 * 60 cannot be represented in type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 17:57:37 +02:00
Michael Niedermayer
0345a88545
avformat/genh: Check nb_channels for IMA ADPCM
The check could be made more strict

Fixes: signed integer overflow: 36 * 538976288 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-6539389873815552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 17:57:37 +02:00
Michael Niedermayer
93db0f0740
avformat/dxa: avoid bpc overflows
Fixes: signed integer overflow: 2147483647 + 32 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_DXA_fuzzer-6639823726706688

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 17:57:37 +02:00
Michael Niedermayer
10453f5192
avformat/dhav: Use 64bit seek_back
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-6604736532447232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 17:57:36 +02:00
Michael Niedermayer
d4bb4e3759
avformat/cafdec: Check that nb_frasmes fits within 64bit
Fixes: signed integer overflow: 1099511693312 * 538976288 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6565048815845376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 17:57:36 +02:00
Michael Niedermayer
736e9e69d5
avformat/asfdec_o: Limit packet offset
avoids overflows with it

Fixes: signed integer overflow: 9223372036846866010 + 4294967047 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-6538296768987136
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-657169555665715

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 17:57:36 +02:00
Michael Niedermayer
5b23cab5c7
avformat/apm: Use 64bit for bit_rate computation
Fixes: signed integer overflow: -1155522528 * 4 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_APM_fuzzer-6580670570299392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 17:57:35 +02:00
Michael Niedermayer
d0349c9929
avformat/ape: Check frames size
Fixes: signed integer overflow: 9223372036854775806 + 3 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_APE_fuzzer-6389264140599296

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-24 17:57:35 +02:00
James Almer
aa79d13f51 avformat/cafenc: derive Opus frame size from the relevant stream parameters
Use the stream duration as last resort, as an off-by-one result of the
"st->duration / (caf->packets - 1)" calculation can break playback on some
devices.
Also, don't write the sample_rate value propagated by encoders like libopus.
The sample rate of the audio fed to it is irrelevant after being encoded.

Fixes ticket #9930.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-24 12:16:15 -03:00
Paul B Mahol
a166b8a19b avcodec: add FTR audio decoder and parser 2022-09-24 14:03:59 +02:00
Paul B Mahol
6c23391064 avformat: add APAC demuxer 2022-09-23 20:27:35 +02:00
Vignesh Venkatasubramanian
a2d95928c3 avformat/movenc: Write auxi box for animated AVIF with alpha
According to the HEIF specification (ISO/IEC 23008-12) Section
7.5.3.1, tracks with handler_type 'auxv' must contain a 'auxi' box
in its SampleEntry to notify the nature of the auxiliary track to the
decoder.

The content is the same as the 'auxC' box. So parameterize and re-use
the existing function.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: James Zern <jzern@google.com>
2022-09-22 14:10:22 -07:00
Michael Niedermayer
db73ae0dc1
avformat/icodec: Check nb_pal
Fixes: signed integer overflow: 538976288 * 4 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-6690068904935424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-22 17:44:05 +02:00
Michael Niedermayer
9303ba272e
avformat/aiffdec: Use 64bit for block_duration use
Fixes: signed integer overflow: 3 * -2147483648 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6668935979728896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-22 17:44:05 +02:00
Michael Niedermayer
1c2b6265c8
avformat/aiffdec: Check block_duration
Fixes: signed integer overflow: 3 * -2147483648 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6668935979728896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-22 17:44:04 +02:00
Michael Niedermayer
c5bd689655
avformat/mxfdec: Avoid some redundant writing to tables in mxf_compute_ptses_fake_index()
offsets suggested by Tomas Härdin
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-22 17:44:04 +02:00
Michael Niedermayer
1182bbb2c3
avformat/mxfdec: only probe max run in
Suggested-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-22 17:44:04 +02:00
Michael Niedermayer
7786097825
avformat/mxfdec: Check run_in is within 65536
Fixes: signed integer overflow: 9223372036854775807 - -2146905566 cannot be represented in type 'long'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6570996594769920

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-22 17:44:03 +02:00
Andreas Rheinhardt
8306074dc6 avformat/dashdec: Reindent after the previous commit
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-22 15:34:54 +02:00
Andreas Rheinhardt
14b3830b33 avformat/dashdec: Fix crash on invalid input/ENOMEM, fix leak
In case a SupplementalProperty node exists in an adaptationset,
it is searched for a "schemeIdUri" property via xmlGetProp().
Whatever xmlGetProp() returns is then compared via av_strcasecmp()
to a string literal. xmlGetProp() can return NULL, namely in case
no "schemeIdUri" exists and (given that this string is allocated)
presumably also on allocation failure. No check for NULL is done,
so this may crash.

Furthermore, the string returned by xmlGetProp() needs to be freed
with xmlFree(), but this is not done either.

This commit fixes both of these issues; they existed since this code
has been added in 10d008f0fd.

This has been found while investigating ticket #9697. The continuous
leaks might very well be the reason behind the observed slowdown.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-22 15:34:23 +02:00
Wang Yaqiang
0744782de3 avformat/mov: get the correct fragment stsd_id when decrypting the sample
When determining whether a packet should be decrypted,
should use the stsd_id of the fragment where the current packet is located.

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Wang Yaqiang <wangyaqiang03@kuaishou.com>
2022-09-21 13:58:40 +08:00
Will Cassella
e601ec3c19 libavformat/riffec: Zero-initialize channels in ff_get_wav_header
Clang's static analyzer complains that leaving the  variable
uninitialized could lead to a code path where the uninitialized value is
written to  at the end of this function.
This patch simply zero-initializes that variable to avoid that.

Signed-off-by: Will Cassella <cassew@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-20 18:58:23 -03:00
Andreas Rheinhardt
d438540d2b avformat/spdifenc: Reorder struct members to make it smaller
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-20 18:32:28 +02:00
Pierre-Anthony Lemieux
48fa27e77a avformat/mxf: set stream frame rates for ST 422 essence containers
The MXF demuxer does not currently set AVStream::avg_frame_rate and ::r_frame_rate
when J2K essence is wrapped according to SMPTE ST 422.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-20 11:25:54 +02:00
Andreas Rheinhardt
c8707c105f avformat/aptxdec: Don't set AV_PKT_FLAG_CORRUPT mistakenly
Just because we try to put multiple units of block_align bytes
(the atomic units for APTX and APTX HD) into one packet
does not mean that packets with fewer units than the
one we wanted are corrupt; only those packets that are not
a multiple of block_align are.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-19 17:05:33 +02:00
Andreas Rheinhardt
9d10d3a4ee avformat/aptxdec: Don't set AVCodecParameters.frame_size
This field was misunderstood: It gives the number of samples
in a packet, not the number of bytes. Its usage was wrong for APTX HD.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-19 17:05:33 +02:00
Paul B Mahol
9c05f178a6 avformat/ape: fix overflow in total_blocks 2022-09-16 18:04:20 +02:00
Paul B Mahol
8f11512273 avformat/ape: set packet duration 2022-09-16 18:04:20 +02:00
Andreas Rheinhardt
2c23cd0181 avformat/bonk: Don't set data_offset to what it would be set to anyway
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-16 17:49:40 +02:00
Paul B Mahol
dd2a01ef5c avformat: add LAF demuxer 2022-09-16 10:02:19 +02:00
Paul B Mahol
ea93943bee avcodec: add MI-SC4 audio decoder 2022-09-16 10:02:19 +02:00
Andreas Rheinhardt
62af385b91 avformat/dump: Avoid unnecessary implicit calculation of strlen
av_strlcpy() returns the length of the src string to enable
the caller to check for truncation. It is currently used in
the following way in dump_metadata(): Every metadata value
is searched for \b, \n, \v, \f, \r and then the data up to
the first of these characters found is copied to a small
temporary buffer via av_strlcpy() (but of course not more
than fits into said buffer) and then printed; all characters up
to the character found earlier are then treated as consumed.

But this is bad performance-wise if the while string is big
and contains many of these characters, because av_strlcpy()
will unnecessarily calculate the length of the whole remaining string.
(dump_metadata() actually ignored the return value of av_strlcpy().)

Fix this by not copying the data to a temporary buffer at all.
Instead just use %.*s to bound the number of characters output.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 15:03:59 +02:00
Paul B Mahol
3ce6fa6b6d avformat: add bonk demuxer 2022-09-12 11:35:43 +02:00
James Almer
60d8c2019f avformat/riffdec: don't unconditionally overwrite WAVEFORMATEXTENSIBLE layout
Do it only if the value conflicts with the previous channels value.

Fixes ticket #9912

Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-11 09:52:02 -03:00
Michael Niedermayer
d32a9f3137
libavformat/hls: Free keys
Fixes: memleak
Fixes: 50703/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-6399058578636800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-09-10 17:32:47 +02:00
James Almer
836b8001c9 avformat/mov: don't read duration from mvhd atom
This duration is equal to the longest duration in all track's tkhd atoms, which
may be comprised of the sum of all edit lists in each track. Empty edit lists
in tracks represent start_time, and the actual media duration is stored in the
mdhd atom.
This change lets the generic demux code derive the longest track duration taken
from mdhd atoms, so the correct duration and start_time combination will be
reported.

Should fix ticket #9775.

Reviewed-by: zhilizhao(赵志立) <quinkblack@foxmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-08 20:06:06 -03:00
Pierre-Anthony Lemieux
6e91d405be avformat/imfdec: check if Asset/Id exists before trying to read it
Fixes Coverity issue #1512406

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-07 17:16:02 +02:00
Andreas Rheinhardt
8913539a5d avformat/matroskaenc: Write CodecDelay for codecs != Opus
The field is not specific to Opus.
The mp2fixed encoder signals initial_padding and is used
by both the matroska-encoding-delay test as well as
the lavf-mkv tests which necessitated several FATE ref changes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 20:36:53 +02:00
Andreas Rheinhardt
bca4fef46a avformat/matroskaenc: Use custom min timestamp
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 20:36:22 +02:00
Andreas Rheinhardt
1a8309e954 avformat/mux: Allow muxers to set custom min timestamp
Matroska requires pts to be >= 0 with a slight exception:
It has a mechanism to deal with codec delay, i.e. with
the data added at the beginning that does not correspond
to actual input data and should be discarded by the player.
Only the audio actually intended to be output needs to have
a timestamp >= 0.
In order to avoid unnecessary timestamp shifting, this patch
allows muxers to inform the shifting code about this so that
it can take it into account.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 20:36:01 +02:00
Andreas Rheinhardt
eb325324aa avformat/matroskaenc: Actually apply timestamp offset for Opus
Matroska generally requires timestamps to be nonnegative, but
there is an exception: Data that corresponds to encoder delay
and is not supposed to be output anyway can have a negative
timestamp. This is achieved by using the CodecDelay header
field: The demuxer has to subtract this value from the raw
(nonnegative) timestamps of the corresponding track.
Therefore the muxer has to add this value first to write
this raw timestamp.

Support for writing CodecDelay has been added in FFmpeg commit
d92b1b1bab and in Libav commit
a1aa37dd0b. The former simply
wrote the header field and did not apply any timestamp offsets,
leading to desynchronisation (if one uses multiple tracks).
The latter applied it at two places, but not at the one where
it actually matters, namely in mkv_write_block(), leading to
the same desynchronisation as with the former commit. It furthermore
used the wrong stream timebase to convert the delay to the
stream's timebase, as the conversion used the timebase from
before avpriv_set_pts_info().

When the latter was merged in 82e4f39883,
it was only done in a deactivated state that still did not
offset the timestamps when muxing due to "assertion failures
and av sync errors". a1aa37dd0b
made it definitely more likely to run into assertion failures
(namely if the relative block timestamp doesn't fit into an int16_t).

Yet all of the above issues have been fixed (in commits
962d631573,
5d3953a5dc and
4ebeab15b0. This commit therefore
enables applying CodecDelay, fixing ticket #7182.

There is just one slight regression from this: If one has input
with encoder delay where the first timestamp is negative, but
the pts of the part of the data that is actually intended to be
output is nonnegative, then the timestamps will currently by default
be shifted to make them nonnegative before they reach the muxer;
the muxer will then ensure that the shifted timestamps are retained.
Before this commit, the muxer did not ensure this; instead the
timestamps that the demuxer will output were shifted and
if the first timestamp of the actually intended output was zero
before shifting, then this unintentional shift just cancels
the shift performed before the packet reached the muxer.
(But notice that this only applies if all the tracks use the same
CodecDelay, or the relative sync between tracks will be impaired.)
This happens in the matroska-opus-remux and matroska-ogg-opus-remux
FATE tests. Future commits will forward the information that
the Matroska muxer has a limited capability to handle negative
timestamps so that the shifting in libavformat can take advantage
of it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 20:35:20 +02:00
Andreas Rheinhardt
be0a2515ab avformat/matroskaenc: Don't override samplerate for CodecDelay
Opus can be decoded to multiple samplerates (namely 48kHz, 24KHz,
16Khz, 12 KHz and 8Khz); libopus as well as our encoder wrapper
support these sample rates. The OpusHead contains a field for
this original samplerate. Yet the pre-skip (and the granule-position
in the Ogg-Opus mapping in general) are always in the 48KHz clock,
irrespective of the original sample rate.

Before commit c3c22bee63, our libopus
encoder was buggy: It did not account for the fact that the pre-skip
field is always according to a 48kHz clock and wrote a too small
value in case one uses the encoder with a sample rate other than 48kHz;
this discrepancy between CodecDelay and OpusHead led to Firefox
rejecting such streams.

In order to account for that, said commit made the muxer always use
48kHz instead of the actual sample rate to convert the initial_padding
(in samples in the stream's sample rate) to ns. This meant that both
fields are now off by the same factor, so Firefox was happy.

Then commit f4bdeddc3c fixed the issue
in libopusenc; so the OpusHead is correct, but the CodecDelay is
still off*. This commit fixes this by effectively reverting
c3c22bee63.

*: Firefox seems to no longer abort when CodecDelay and OpusHead
are off.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 20:33:59 +02:00
Andreas Rheinhardt
7bacef580f avformat/matroskaenc: Only write DiscardPadding if nonzero
It is possible for the trailing padding to be zero, namely
e.g. if the AV_PKT_DATA_SKIP_SAMPLES side data is used
for leading padding. Matroska supports this (use a negative
DiscardPadding), but players do not; at least Firefox refuses
to play such a file. So for now only write DiscardPadding
if it is trailing padding and nonzero.
The fate-matroska-ogg-opus-remux was affected by this.

(I wish CodecDelay would not exist and DiscardPadding would
be used to instead trim the codec delay away (with the Block
timestamp corresponding to the time at which the actually
output audio is output).)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 20:33:09 +02:00
Anton Khirnov
693c1e631c lavf/mov: avoid leaks with multiple dv-audio streams 2022-09-05 08:14:36 +02:00
Anton Khirnov
1ef4620290 lavf/dv: do not update AVCodecParameters.sample_rate while demuxing
Demuxers are not allowed to do this and few callers, if any, will handle
this correctly. Send the AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE side data
instead.
2022-09-05 08:13:57 +02:00
Anton Khirnov
6def44128a lavf/dv: set audio bitrate only at stream creation
Demuxers are not supposed to update AVCodecParameters after the stream
was seen by the caller. This value is not important enough to support
dynamic updates for.
2022-09-05 08:13:09 +02:00
Anton Khirnov
000b8d2acc lavf/dv: set non-changing AVStream fields only once 2022-09-05 08:12:26 +02:00
Anton Khirnov
b2e1d1443c lavf/dv: forward errors from avformat_new_stream() 2022-09-05 08:11:48 +02:00
Anton Khirnov
f0283f278a lavf/dv: return a meaningful error code from avpriv_dv_produce_packet() 2022-09-05 08:11:27 +02:00
Anton Khirnov
090f12b157 lavf/dv: make returning the video packet optional
The mov demuxer only returns DV audio, video packets are discarded.

It first reads the data to be parsed into a packet. Then both this
packet and the pointer to its data are passed together to
avpriv_dv_produce_packet(), which parses the data and partially
overwrites the packet. This is confusing and potentially dangerous, so
just pass NULL and avoid pointless packet modification.
2022-09-05 08:10:55 +02:00
Anton Khirnov
f7b3fc4afe lavc/dv: rename constants to follow our naming conventions
CamelCase for enum tags, ALL_CAPS for enum values.
2022-09-05 08:10:26 +02:00
Anton Khirnov
b6196cb2ef lavf/dv: always provide avpriv_dv_* symbols
They are used from libavdevice.
2022-09-05 08:01:17 +02:00
Anton Khirnov
dcc4704a4e lavf/dv: remove DVMuxContext declaration from dv.h
DVMuxContext is only used inside dvenc.c, there is no reason for it to
be visible outside of that file.
2022-09-05 08:00:57 +02:00
Stephen Hutchinson
6195a0ee19 avformat/avisynth: reindent
Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
2022-09-04 15:03:32 -04:00
Stephen Hutchinson
adead1ccd6 avformat/avisynth: implement avisynth_flags option
Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
2022-09-04 15:03:28 -04:00
Stephen Hutchinson
c49beead19 avformat/avisynth: read _SARNum/_SARDen from frame properties
Initialized to 1:1, but if the script sets these properties, it
will be set to those instead (0:0 disables it, apparently).

Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
2022-09-04 15:03:23 -04:00
Andreas Rheinhardt
72c601e0f7 avutil/internal: Move avpriv-file API to a header of its own
It is not used by the large majority of files that include
lavu/internal.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:44 +02:00
Andreas Rheinhardt
04b7217872 avutil/dict: Move avpriv_dict_set_timestamp() to a header of its own
It is used almost nowhere, so it needn't be auto-included
almost everywhere.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:41:44 +02:00
Andreas Rheinhardt
7de9c0e9d7 avcodec/flac: Don't use bytestream API unnecessarily
It makes no sense here, as flac_parse_block_header()
is not even supposed to advance the caller's pointer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-02 11:55:22 +02:00