Commit Graph

26013 Commits

Author SHA1 Message Date
Zhao Zhili
cb9c98da16 avformat/file: guard fd_dup by FD_PROTOCOL or PIPE_PROTOCOL
fd_dup is unused when fd and pipe have been disabled. This also
fix build error with wasi since 'dup' isn't available.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-07-16 22:50:21 +08:00
Marth64
f1abb754aa avformat/dvdvideodec: Fix incorrect padding cell trim logic
When -trim option is used (by default), padding cells
at the beginning of the title are supposed to be ignored.
The current implementation does the ignoring after we
have locked on to the PGC navigation event stream,
but does not set the PGC/PG state properly.

This causes false positives and errors on some discs
due to a search for a program stream cell that
never succeeds. User would have to know to disable
the -trim option to work around the issue.

Simplify the logic and move it to the NAV packet
event handling, in turn implementing the behaviour
correctly and fixing the trim function for impacted discs.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-07-13 17:17:36 +02:00
Marth64
f37f86a774 avformat/dvdvideodec: Remove redundant ret initializations
Remove initializing ret = 0, in areas where ret is
only used to hold an error value, immediately returned,
and the function would otherwise return a literal 0.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-07-13 17:17:27 +02:00
Marth64
eb07a593d3 avformat/dvdvideodec: Don't add chapter markers for empty/dummy PTTs
Some discs (usually same ones with padding cells), also have empty
padding PTTs / chapters to accompany them. This results, for example,
in an extra chapter marker that starts and ends at 0 (no duration).

Don't add these empty chapter markers.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-07-13 17:17:22 +02:00
Michael Niedermayer
f13ae63259
avformat/rtpenc_rfc4175: Use 64bit in computation if copy_offset
Found while reviewing: CID1494441 Untrusted value as argument

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-12 16:40:51 +02:00
Michael Niedermayer
38c2e6a2c7
avformat/rtmpproto: Use AV_DICT_MATCH_CASE instead of litteral number
Found by reviewing: CID1530166 Free of array-typed value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-12 16:40:50 +02:00
Michael Niedermayer
cedbef0394
avformat/rtmppkt: Simplify and deobfuscate amf_tag_skip() slightly
Found while reviewing: CID1530313 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-12 16:40:50 +02:00
Michael Niedermayer
665be4fa2f
avformat/rmdec: use 64bit for audio_framesize checks
It is not entirely clear what would prevent such overflow so even if it is
not possible, it is better to use 64bit

Fixes: CID1491898 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-12 16:40:42 +02:00
James Almer
58cb0cab5e avformat/mov: ensure pasp box derived SAR is used if present
It's meant to override any codec specific (but still container level)
information, but its position is not guaranteed, so apply the values after the
entire trak structure has been parsed.
Also, replace the ugly roundabout int -> double -> int method to set SAR from
existing dimensions while at it.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-11 10:22:47 -03:00
James Almer
32588a9394 avformat/movenc: support writing cropping values
Finishes implementing ticket #7437.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-11 10:22:47 -03:00
James Almer
93be6b425e avformat/mov: export cropping values from clap boxes
Addresses part of ticket #7437.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-11 10:22:47 -03:00
Anton Khirnov
9fb8d13d56 lavf: deprecate avformat_transfer_internal_stream_timing_info()
And av_stream_get_codec_timebase().

They were both added for ffmpeg CLI, which no longer calls either of
them. Furthermore the notion of "internal stream timing info" that needs
to be transferred with a special magic API function is fundamentally
flawed and should be removed.
2024-07-09 11:14:47 +02:00
Andreas Rheinhardt
b6c43328ee avformat/matroskaenc: Avoid indirection via st->codecpar
Use the already available AVCodecParameters pointer instead.
Shortens lines.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-07-08 20:11:32 +02:00
Andreas Rheinhardt
0d1bc9666c avformat/matroskaenc: Only write useful cropping values
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-07-08 20:11:27 +02:00
Andreas Rheinhardt
9ffac78eba avformat/matroskaenc: Fix and simplify check for invalid crop values
The check "left >= INT_MAX - right" is supposed to check for
whether left + right does not overflow/wraparound, but given that
left and top are uint32_t INT_MAX - right can already wraparound
for big values of right (and ordinary 32-bit ints):
If right == UINT32_MAX, INT_MAX - right is INT_MAX + 1;
for left in 0..par->width both checks will be passed.

Fix this and simplify the check by using 64-bit types,
where the addition is guaranteed not to overflow.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-07-08 20:11:20 +02:00
Andreas Rheinhardt
8765b36a52 avformat/matroskaenc: Fix potential stack-buffer-overflow
Forgotten in f194f291d8

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-07-08 20:11:03 +02:00
James Almer
f194f291d8 avformat/matroskaenc: support writing cropping values
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-08 13:30:24 -03:00
James Almer
79e8e980c2 avformat/matroskadec: export cropping values
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-08 13:30:24 -03:00
James Almer
dc763efe70 avformat/matroskadec: don't infer display dimensions when DisplayUnit is not pixels
The spec doesn't define a default value for other values of DisplayUnit.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-08 13:30:24 -03:00
James Almer
893c6802ac avformat/dump: print Frame Cropping packet side data info
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-08 13:29:49 -03:00
Michael Niedermayer
0619138639
avformat/usmdec: Initialize value
Fixes: CID1551685 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:33 +02:00
Michael Niedermayer
7b2f67ea77
avformat/udp: Fix temporary buffer race
Fixes: CID1551679 Data race condition
Fixes: CID1551687 Data race condition

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:33 +02:00
Michael Niedermayer
f022afea77
avformat/tls_schannel: Initialize ret
Fixes: CID1591881 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:32 +02:00
Michael Niedermayer
426d8c84c3
avformat/subfile: Assert that whence is a known case
This may help CID1452449 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:32 +02:00
Michael Niedermayer
2a0a7d964b
avformat/subfile: Merge if into switch()
Found while reviewing CID1452449 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:32 +02:00
Michael Niedermayer
c8200d3825
avformat/rtsp: Check that lower transport is handled in one of the if()
Fixes: CID1473554 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:31 +02:00
Michael Niedermayer
498ce4e8b8
avformat/rtsp: initialize reply1
It seems reply1 is initialized by ff_rtsp_send_cmd() in most cases but there
are code paths like "continue" which look like they could skip it but even if not
writing this so a complex loop after several layers of calls initialized a local
variable through a pointer is just bad design.
This patch simply initialized the variable.

Fixes: CID1473532 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:31 +02:00
Michael Niedermayer
9bb38ba2b7
avformat/rtsp: use < 0 for error check
Found while reviewing CID1473532 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:31 +02:00
Michael Niedermayer
7a9ddb7051
avformat/rtpenc_vc2hq: Check sizes
Fixes: CID1452585 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-07-07 23:36:30 +02:00
James Almer
33d6e14d6f avformat/hevc: reindent after previous commits
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 13:54:07 -03:00
James Almer
aa8230c7ba avformat/movenc: add support for writting hfov boxes
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
James Almer
6a428876fc avformat/movenc: add support for writting vexu boxes
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
James Almer
d4e2af4144 avformat/movenc: add support for writing lhvC boxes
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
Derek Buitenhuis
c4ebdd8d2d avformat/mov: Mark streams with a layered HEVC box as multilayer
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-07-07 12:38:57 -03:00
James Almer
c657c694e3 avformat/mov: add support for lhvC box parsing
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
James Almer
cbfbacff20 avformat/hevc: add a function to write a lhvC box
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
James Almer
cee43e512d avformat/hevc: store parameter set and layer IDs in HVCCNALUnit
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
James Almer
361b01329f avformat/hevc: use a single array for per-PS NALUs
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
James Almer
ab7893a7b1 avformat/hevc: don't write the same array values per nal addition
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
James Almer
a696b28886 avformat/hevc: don't write NALUs with nuh_layer_id > 0 in hvcC boxes
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-07 12:38:57 -03:00
Derek Buitenhuis
46f7ea4456 avformat: Add a new stream disposition for multilayer video
This lets us detect when a container has flagged a stream as multilayer.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-07-07 12:38:50 -03:00
Anton Khirnov
ef521e7a57 lavf/movenc: mark mov/mp4 as supporting VFR 2024-07-07 11:37:43 +02:00
Marth64
8b8ee799de avformat/dvdvideodec: Remove unused cell count variable
Signed-off-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-07-07 11:33:32 +02:00
James Almer
bef77c6c9c avformat/dump: only print yaw, pitch, and roll if set
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-04 23:35:08 -03:00
Martin Storsjö
e14cdf9990 hlsenc: Calculate the average and actual maximum bitrate of segments
Previously, the bitrate advertised in the master playlist would only
be based on the nominal values in either AVCodecParameters bit_rate,
or via AVCPBProperties max_bitrate. On top of this, a
fudge factor of 10% is added, to account for container overhead.

Neither of these bitrates may be known, and if the encoder is
running in VBR mode, there is no such value to be known. And
the container overhead may be more or less than the given
constant factor of 10%.

Instead, calculate the maximum bitrate per segment based on
what actually gets output from the muxer, and average bitrate
across all segments.

When muxing of the file finishes, update the master playlist
with these values, exposing both the maximum (which previously
was a guesstimate based on the nominal values) via
EXT-X-STREAM-INF BANDWIDTH, and the average via
EXT-X-STREAM-INF AVERAGE-BANDWIDTH.

This makes it possible to use the hlsenc muxer with VBR
encodes, for VOD style muxing.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-04 23:33:27 +03:00
Martin Storsjö
9246cca7f7 hlsenc: When not using HLS_SINGLE_FILE, set vs->size to range_length
This matches what is done in the corresponding case for
HLS_SINGLE_FILE.

Normally, vs->size is already initialized correctly - but when
writing the initial segment, with mp4 files, vs->size has been set
to the size of the init segment, while range_length contains the
real size of the first segment.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-04 23:33:26 +03:00
Martin Storsjö
a50b8bb7cd hlsenc: Remove bogus check for if (vs->start_pos) for appending segments
Previously, vs->start_pos was never 0 here, unless using the
-hls_segment_size option, which wasn't allowed for SEGMENT_TYPE_FMP4.
Therefore, this if statement was practically always taken anyway.

Remove this bogus if statement, to allow changing vs->start_pos
to reflect the right value when not using the -hls_segment_size
option.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-04 23:33:25 +03:00
Martin Storsjö
52f57568d5 hlsenc: Fix setting vs->start_pos when not using HLS_SINGLE_FILE or hls_segment_size
When not using HLS_SINGLE_FILE or hls_segment_size, we're writing
each segment into a separate file. In that case, the file start pos for
each segment will be zero.

This matches the case in (hls->max_seg_size > 0) above, where we
decide to switch to a new file.

This fixes the calculation of "vs->size = new_start_pos - vs->start_pos"
at the start of hls_write_packet; previously, start_pos would
refer to the byte size of the previous segment file, giving
vs->size entirely bogus values here.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-04 23:33:24 +03:00
Martin Storsjö
01312fdfcf hlsenc: Fix the return value accumulation in append_single_file
Both the read_byte variable (which is accumulated into
append_single_file) and the return value are int64_t;
give the ret variable the right corresponding type too.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-07-04 23:33:23 +03:00
James Almer
cf7e2c5e05 avformat/mov: add more checks for infe atom size
Signed-off-by: James Almer <jamrial@gmail.com>
2024-07-03 19:54:31 -03:00