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

104750 Commits

Author SHA1 Message Date
Andreas Rheinhardt
60a2c74a5e avdevice/lavfi: Make array static const
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 17:00:52 +01:00
Andreas Rheinhardt
88af0962ef avdevice/lavfi: Avoid calling av_buffersink_get_* multiple times
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:59:34 +01:00
Andreas Rheinhardt
83ae589359 avdevice/lavfi: Use dedicated pointer to access st->codecpar
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:58:58 +01:00
Andreas Rheinhardt
84f037edc2 avdevice/lavfi: Don't unnecessarily write '\0' to AVBPrint
An AVBPrint's internal string is always already zero-terminated;
writing another '\0' is unnecessary as long as one treats
the string only as a C-string.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:58:43 +01:00
Andreas Rheinhardt
efc323062c fftools/ffmpeg_filter: Avoid DynBuf API to improve error checks
choose_pix_fmts() used the dynamic buffer API to write strings;
as is common among uses of this API, only opening the dynamic buffer
was checked, but not the end result, leading to crashes in case
of allocation failure.
Furthermore, some static strings were duplicated; the allocations
performed here were not properly checked: Allocation failure would
be treated as "could not determine pixel format".
The first issue is fixed by switching to the AVBPrint API which allows
to easily perform checks at the end. Furthermore, the internal buffer
avoids almost all allocations in case the AVBPrint is used.
The AVBPrint also allows to solve the second issue in an elegant way,
because it allows to return the static strings directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:12:52 +01:00
Andreas Rheinhardt
cf8925a096 fftools/ffmpeg_filter: Avoid DynBuf-API for writing strings
It is not really natural, it requires internal allocations
of its own and its error handling is horrible (i.e. the implicit
(re)allocations here are unchecked).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:11:01 +01:00
Andreas Rheinhardt
3be6fe9a56 swscale/yuv2rgb: Silence a set-but-unused-variable warning
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:10:51 +01:00
Andreas Rheinhardt
01d158d1c8 all: Remove unused-but-set variables
Newer versions of Clang detect this and emit warnings for it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:09:14 +01:00
Andreas Rheinhardt
a4798a5d51 all: Use av_memdup() where appropriate
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:07:02 +01:00
Andreas Rheinhardt
b574fb472e avcodec/h264_redundant_pps_bsf: Inline constant
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:03:49 +01:00
Andreas Rheinhardt
5892a55d55 avcodec/h264_redundant_pps_bsf: Support multiple input PPS
Up until now, the h264_redundant_pps_bsf stored the initial value
of pic_init_qp_minus26 of the most recently encountered PPS;
it also modified the slices based upon to assumption that
the most recent PPS is the PPS the slice belongs to.
Yet this assumption is flawed, as there can be several PPS
with different IDs that are visible at any given time.
If these have different pic_init_qp_minus26 values,
the output can be invalid.

Fix this by directly using the pic_init_qp_minus26 value of
the input PPS.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:03:49 +01:00
Andreas Rheinhardt
5e7bdbfff6 avcodec/h264_redundant_pps_bsf: Remove flush callback
extradata_pic_init_qp is unset since
fa75e43875
(and resetting current_pic_init_qp to the value it had in extradata
never made much sense).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:03:49 +01:00
Andreas Rheinhardt
531d289cfd avdevice/lavfi: Properly free an AVDictionary
It is not documented that freeing the last (and only) entry of
an AVDictionary frees the dictionary.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 10:46:01 +01:00
Andreas Rheinhardt
05c924a86d avdevice/lavfi: Cleanup generically on read_header failure
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 10:38:11 +01:00
Andreas Rheinhardt
77a37e0369 swresample/swresample: Remove array size hint from swr_convert()
SWR_CH_MAX is internal only and the arrays are therefore not required
to have that many elements (and they typically don't do it). So remove
this potentially confusing hint.

(Newer versions of GCC emit -Warray-parameter= warnings for this,
because the definition with explicit size differs from the declaration
(which leaves the size unspecified); this is IMO a false-positive,
because definition and declaration didn't conflict, but anyway it is
fixed by this commit.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 10:34:51 +01:00
John-Paul Stewart
6c76b63923 avformat/mvdec: handle audio sample size
Adds support for reading audio sample size from the data instead of
assuming all audio is 16 bits per sample.

Reviewed-by: Peter Ross <pross@xvid.org>
2021-12-03 19:53:56 +11:00
John-Paul Stewart
4a90c039e7 avformat/mvdec: fix reading number of audio channels
The number of audio channels is stored after the magic number
identifying the audio format.  Prior to this patch the code has been
reading it earlier, causing files with only one audio channel to be
handled incorrectly.

Reviewed-by: Peter Ross <pross@xvid.org>
2021-12-03 19:53:56 +11:00
Andreas Rheinhardt
b94db16bf5 fate/ffmpeg: Fix requirements of shortest tests
Fixes FATE failures if e.g. libavdevice is disabled.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-02 17:44:27 +01:00
Andreas Rheinhardt
4a6aece703 fate/ffmpeg: Fix shortest tests
The mpeg4 encoder is slice-threaded and its output depends upon
the number of threads used. Therefore all tests of this encoder
use a hardcoded number of threads (ENC_OPTS in fate-run.sh contains
"-threads 1"; only the vsynth%-mpeg4-thread tests override this
for the mpeg4 encoder, but they also use a hardcoded value to
be consistent across different systems); only the new shortest
and copy-shortest[12] (implicitly due to the sample used) tests
don't and this leads to FATE-failures.
Fix this by explicitly setting the thread count.

Also switch the shortest test to framecrc, because hashing side data
is itchy even though the side data used here (AV_PKT_DATA_QUALITY_STATS)
has a defined endianness.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-02 11:33:32 +01:00
Lynne
bdc920574d
Changelog: update with recent Vulkan filter additions 2021-12-02 11:08:58 +01:00
Wu Jianhua
bdfb0e4da4 avfilter: add a flip_vulkan filter
This filter flips the input video both horizontally and vertically
in one compute pipeline, and it's no need to use two pipelines for
hflip_vulkan,vflip_vulkan anymore.

Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
2021-12-02 11:06:24 +01:00
Paul B Mahol
fc9a686688 avfilter: add audio dynamic smooth filter 2021-12-02 09:39:27 +01:00
Paul B Mahol
11b11577fe avfilter: add audio spectral stats filter 2021-12-02 09:35:36 +01:00
Andreas Rheinhardt
acdfc4bdfb avcodec/movtextenc: Simplify writing a single char
Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-02 07:31:43 +01:00
Andreas Rheinhardt
c4c9d096ae avcodec/movtextenc: Remove redundant byte count
Use the AVBPrint's len instead.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-02 07:31:09 +01:00
Andreas Rheinhardt
0bc3c070fb avcodec/movtextenc: Fix encoding of subtitles with multiple rects
The format of a mov_text (3GPP Timed Text) sample is:

uint16_t text_length;
uint8_t  text[text_length];
TextSampleModifierBox text_modifier;

Yet in case our encoder receives an AVSubtitle with multiple
ASS AVSubtitleRects, it creates something like this:
uint16_t text_length;
uint8_t  text[text_length_1];
TextSampleModifierBox text_modifier_1;
uint8_t  text[text_length_2];
TextSampleModifierBox text_modifier_2;
...

where text_length is the sum of all the text_length_*.
This commit fixes this by writing the TextSampleModifierBoxes only
after all the rects have been written.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-02 07:29:02 +01:00
Andreas Rheinhardt
f8e5e1c523 avcodec/movtextenc: Check for too long subtitles
Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-02 07:28:47 +01:00
Andreas Rheinhardt
0b934f8f17 avcodec/movtextenc: Reset AVBPrint at the beginning, not end of encoding
This avoids abusing a variable called length for the return value
and ensures that the AVBPrint is always reset before using it;
previously this has been forgotten in some error paths.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-02 07:28:35 +01:00
Andreas Rheinhardt
bb89a2f64f avcodec/movtextenc: Fix infinite loop due to variable truncation
Regression since af043b839c.
Fixes ticket #9409.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-02 07:27:46 +01:00
James Almer
6507e96e71 fate/ffmpeg: add some more flags to the shortest tests
Signed-off-by: James Almer <jamrial@gmail.com>
2021-12-01 22:22:19 -03:00
James Almer
686c7c132d fate/ffmpeg: add missing bitexact flags to the shortest tests
Should fix fate failures on some targets.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-12-01 20:30:06 -03:00
James Almer
bb0a28560d fate/ffmpeg: add tests for shortest option
Signed-off-by: James Almer <jamrial@gmail.com>
2021-12-01 18:28:44 -03:00
James Almer
c1818cb947 ffmpeg: fix usage of -shortest in codec copy scenarios
Don't mark all streams as finished, instead make sync_opts keep track of the
stream's duration, and set recording_time to it, same as in transcoding paths.

Fixes tickets #9512 and #9513.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-12-01 18:16:56 -03:00
Michael Niedermayer
96caa01f13 avcodec/vp3: Check version in all cases when VP4 code is not built
Fixes: out of array read
Fixes: 40284/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-4599568176644096

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>
2021-12-01 17:44:56 +01:00
Michael Niedermayer
db27a35012 tools/target_dec_fuzzer: Adjust DXA threshold
Fixes: Timeout
Fixes: 40203/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXA_fuzzer-4587923496894464

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-01 17:44:56 +01:00
Michael Niedermayer
6e34d94797 avcodec/gemdec: Check tag & planes before image allocation
Fixes: Timeout
Fixes: 41083/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GEM_fuzzer-5843826518917120

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>
2021-12-01 17:44:56 +01:00
Hao Chen
024e934480 avcodec: [loongarch] Optimize decode_significance/_8x8_loongarch.
Decoding 1080P H264 from 168fps to 170fps.

Signed-off-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Reviewed-by: 陈昊 <chenhao@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-01 17:44:56 +01:00
Shiyou Yin
afcb36b7e5 avcodec: [loongarch] optimize get_cabac.
Decoding 1080P H264 on 2.5Ghz 3A5000: 165fps==>168fps.
Testing command: ffmpeg -i ***.mp4 -f rawvideo -y /dev/null -an

Reviewed-by: 陈昊 <chenhao@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-01 17:44:56 +01:00
Shiyou Yin
07f8f78a5f configure: Add support for loongarch.
For la464 cpu: ./configure --cpu=la464

With cross-compiler:
./configure --cross-prefix=loongarch64-linux-gnu- \
            --enable-cross-compile --arch=loongarch64 \
            --target-os=linux --cpu=la464

Reviewed-by: 陈昊 <chenhao@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-01 17:44:56 +01:00
Zane van Iperen
12f8293c02
avformat/scd: add demuxer
Adds demuxer for Square Enux SCD files.

Based off [1] and personal investigation.

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

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

Reviewed-by: Peter Ross <pross@xvid.org>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-12-02 01:41:55 +10:00
Andreas Rheinhardt
d1b47f3bfc avcodec/vaapi_encode: Fix segfault upon closing uninitialized encoder
Fixes ticket #9537.
Probably a regression since 2b32068916.

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

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 17:42:18 +01:00
Andreas Rheinhardt
d47a986b79 avcodec/qsvenc: Properly flush the FIFO on close
Freeing the new H.264 specific fields has been forgotten.
(This leak only appears in case the encoder has not been completely
drained.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 17:17:52 +01:00
Andreas Rheinhardt
e9e2157dda avcodec/qsvenc: Fix leak of A53 data
Up until now, it has only been freed when the QSVFrame is reused,
so that the last one contained in it leaked at the end.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 17:17:23 +01:00
Andreas Rheinhardt
1cdbccaa16 avcodec/qsvenc: Fix leak and crash when encoding H.264 due to A53_CC
Since commit 3bbe0c210b, the Payloads
array of every QSVFrame leaks as soon as the frame is reused;
the leak is small and not very noticeable, but if there is an attempt
to use said array the ensuing crash is much more noticeable.
This happens when encoding H.264 with A53 CC side data.

Furthermore, if said array can not be allocated at all, an AVFrame
leaks.

Fix all of this by not allocating the array separately at all; put it
in QSVFrame instead and restore the Payloads array upon reusing the
frame.

Finally, use av_freep() instead of av_free() to free the payload
entries.

Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 17:16:32 +01:00
Andreas Rheinhardt
e22dff43e7 fftools/ffmpeg_opt: Don't set source_index redundantly
It is already set in new_output_stream().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 12:06:02 +01:00
Andreas Rheinhardt
4913f05ccf fftools/ffmpeg_opt: Don't duplicate array unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 11:53:22 +01:00
Ryoji Gyoda
d9f07a506d avformat/fifo: avoid repeated scaling of timestamps on failure and recovery
If fifo_thread_recover() succeeds immediately after
fifo_thread_dispatch_message() fails, the dts of the packet is scaled
twice, causing cur_dts to be abnormally large and "Application provided
invalid, non monotonically increasing dts to muxer in stream" to occur
repeatedly.

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

Signed-off-by: Ryoji Gyoda <gy.cft4@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-29 22:20:20 +01:00
softworkz
939711905a fftools/ffprobe: print size of attachment streams (extradata_size)
Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-29 21:30:11 +01:00
asilvestre
1c2dae153c avformat/flvenc: avoid 24bit timestamp truncation for FLV metadata
FLV AMF tags have a 24bit field for timestamps plus an 8bit for extended
timestamps.

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

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

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

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-29 21:30:09 +01:00