Commit Graph

25208 Commits

Author SHA1 Message Date
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