Commit Graph

102016 Commits

Author SHA1 Message Date
Lynne aa910a7ecd
lavu/tx: minor code style improvements and additional comments 2021-04-24 17:17:15 +02:00
Andreas Rheinhardt da6e137cb6 avcodec/exr: Return correct error code on allocation failure
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-24 14:03:29 +02:00
Andreas Rheinhardt a1ed984e04 avcodec/avcodec: Actually honour the documentation of subtitle_header
It is only supposed to be freed by libavcodec for decoders, yet
avcodec_open2() always frees it on failure.
Furthermore, avcodec_close() doesn't free it for decoders.
Both of this has been changed.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-24 13:56:43 +02:00
Anton Khirnov 878e45e0fb tests/fate: add a test for APNG_DISPOSE_OP_BACKGROUND 2021-04-24 13:02:54 +02:00
Michael Niedermayer 098314e1e5 avformat/asfdec_o: Use ff_get_extradata()
Fixes: OOM
Fixes: 27240/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-5937469859823616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-24 11:36:47 +02:00
James Almer 33f2144d2f avcodec/av1_metadata: don't store the inserted TD OBU in stack
Fixes: stack-use-after-return
Fixes: clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_METADATA_fuzzer-5931515701755904
Fixes: clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_METADATA_fuzzer-6105676541722624

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-23 17:21:13 -03:00
Michael Niedermayer efdb564504 avformat/id3v2: Check end for overflow in id3v2_parse()
Fixes: signed integer overflow: 9223372036840103978 + 67637280 cannot be represented in type 'long'
Fixes: 33341/clusterfuzz-testcase-minimized-ffmpeg_dem_DSF_fuzzer-6408154041679872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-23 11:35:40 +02:00
Michael Niedermayer f7c3484b26 avformat/mxfdec: Fix file position addition
Fixes: signed integer overflow: 9223372036854775805 + 4 cannot be represented in type 'long'
Fixes: 29927/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5579985228267520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 16:22:22 +02:00
Michael Niedermayer f8ec1da8ac avformat/wtvdec: Improve size overflow checks in parse_chunks()
Fixes: signed integer overflow: 32 + 2147483647 cannot be represented in type 'int
Fixes: 32967/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5132856218222592

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-04-22 16:01:21 +02:00
Michael Niedermayer 7b3881f0da avcodec/faxcompr: Check remaining bits on error in decode_group3_1d_line()
Fixes: Timeout
Fixes: 32886/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4779761466474496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 15:06:55 +02:00
Michael Niedermayer 09be23ccf8 tools/target_dec_fuzzer: Adjust threshold for paf video
Fixes: Timeout (long -> 2sec)
Fixes: 32790/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PAF_VIDEO_fuzzer-5497584169910272

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 15:06:55 +02:00
Michael Niedermayer ee53bb2399 avformat/mov: check for pts overflow in mov_read_sidx()
Fixes: signed integer overflow: 9223372036846336888 + 4278255871 cannot be represented in type 'long'
Fixes: 32782/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6059216516284416

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-22 15:06:55 +02:00
Andreas Rheinhardt 718e03e5f2 avcodec/jpeglsdec: Don't presume the context to contain a JLSState
Before 9b3c46a081 every call to
ff_jpegls_decode_picture() allocated and freed a JLSState. This commit
instead put said structure into the context of the JPEG-LS decoder to
avoid said allocation. But said function can also be called from other
MJPEG-based decoders and their contexts doesn't contain said structure,
leading to segfaults. This commit fixes this: The JLSState is now
allocated on the first call to ff_jpegls_decode_picture() and stored in
the context.

Found-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-20 21:19:29 +02:00
Michael Niedermayer f40e9b1355 avcodec/utils: Check ima wav duration for overflow
Fixes: signed integer overflow: 44331634 * 65 cannot be represented in type 'int'
Fixes: 32120/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-5760221223583744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:58:20 +02:00
Michael Niedermayer b6eedee529 tools/target_dec_fuzzer: adjust threshold for arbc
Fixes: Timeout (63sec -> 48ms)
Fixes: 31886/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARBC_fuzzer-5287235705503744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:58:20 +02:00
Michael Niedermayer fe584d6002 tools/target_dec_fuzzer: Adjust threshold for TSCC
Fixes: Timeout
Fixes: 31850/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TSCC_fuzzer-5940231289307136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:58:20 +02:00
Michael Niedermayer f8556b632f avcodec/rv10: Execute whole size check earlier for rv20
Fixes: Timeout
Fixes: 31380/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV20_fuzzer-5230899257016320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:58:20 +02:00
Michael Niedermayer 641c1db22b avformat/cafdec: Check channels
Fixes: signed integer overflow: -1184429040541376544 * 32 cannot be represented in type 'long'
Fixes: 31788/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6236746338664448

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-20 16:31:53 +02:00
Gyan Doshi 54d8386f52 doc/filters: note requirements for xfade inputs 2021-04-20 09:32:50 +05:30
Andreas Rheinhardt 7368e5537d avutil/cpu: Schedule deprecated functions for removal
av_set_cpu_flags_mask() has been deprecated in the commit which merged
it: 6df42f98746be06c883ce683563e07c9a2af983f; av_parse_cpu_flags() has
been deprecated in 4b529edff8.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-19 14:34:19 +02:00
Andreas Rheinhardt f3c197b129 Include attributes.h directly
Some files currently rely on libavutil/cpu.h to include it for them;
yet said file won't use include it any more after the currently
deprecated functions are removed, so include attributes.h directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-19 14:34:10 +02:00
Mikhail Nitenko 84ac1440b2 lavc/aarch64: add pred16x16 10-bit functions
Benchmarks:                      A53     A72
pred16x16_dc_10_c:              136.0   124.0
pred16x16_dc_10_neon:           121.2   106.0
pred16x16_horizontal_10_c:      155.0    73.2
pred16x16_horizontal_10_neon:    82.2    67.7
pred16x16_top_dc_10_c:          106.0    93.7
pred16x16_top_dc_10_neon:        87.7    77.2
pred16x16_vertical_10_c:         83.0    67.7
pred16x16_vertical_10_neon:      54.2    61.7

Some functions work slower than C and are left commented out.
2021-04-19 09:01:14 +02:00
Mikhail Nitenko 6b2e7dc828 lavc/aarch64: change h264pred_init structure
Change structure to allow the addition of other bit depths.
2021-04-19 09:00:58 +02:00
Guo, Yejun ffa39eb975 doc/muxers.texi: fix build issue for unknown command
The build log:
** Unknown command `@code' (left as is) (in src/doc/muxers.texi l. 2020)
*** '{' without macro. Before: -map} option with the ffmpeg CLI tool. (in src/doc/muxers.texi l. 2020)
*** '}' without opening '{' before:  option with the ffmpeg CLI tool. (in src/doc/muxers.texi l. 2020)
2021-04-19 11:25:54 +05:30
Brad Smith c8fb68ec52 avutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD
Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-04-18 22:51:14 +02:00
Marton Balint 46f3ae8f67 avfilter/af_mcompand: check allocation results
Fixes the only remaining part of ticket #8931.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-04-18 17:25:51 +02:00
Marton Balint 28c83584e8 avformat/hls: check return value of new_init_section()
Fixes part of ticket #8931.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-04-18 17:25:51 +02:00
Timo Rothenpieler 988f2e9eb0 avcodec/nvenc: fix lossless tuning logic
Relying on the order of the enum is bad.
It clashes with the new presets having to sit at the end of the list, so
that they can be properly filtered out by the options parser on builds
with older SDKs.

So this refactors nvenc.c to instead rely on the internal NVENC_LOSSLESS
flag. For this, the preset mapping has to happen much earlier, so it's
moved from nvenc_setup_encoder to nvenc_setup_device and thus runs
before the device capability check.
2021-04-18 11:39:45 +02:00
Anton Khirnov d43b26b30d lavc/libaomdec: fix build with 1.0.0
aom_codec_frame_flags_t in libaom 1.0.0 is defined in aom_encoder.h,
whereas for newer versions it was moved to aom_codec.h
2021-04-18 08:36:17 +02:00
Guo, Yejun 0c7aef84a0 lavu/detection_bbox.h: use AV_NUM_DETECTION_BBOX_CLASSIFY to replace AV_NUM_BBOX_CLASSIFY 2021-04-18 10:41:17 +08:00
Andreas Rheinhardt a10c47acc2 avformat/utils: Combine identical statements
This would only make a difference in case the first attempt to
initialize the encoder failed and the second succeeded. The only
reason I can think of for this to happen is that the options (in
particular the codec whitelist) are not used for the second try
and that obviously implies that we should not even try a second time
to open the decoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 04:33:12 +02:00
Andreas Rheinhardt 9b3c46a081 avcodec/jpeglsdec: Don't allocate+free JPEGLSState for every frame
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 04:32:15 +02:00
Andreas Rheinhardt 5627da3555 avformat/matroskaenc: Remove unnecessary function calls
ffio_fill() is used when initially writing unknown length elements;
yet it can happen that the amount of bytes written by it is zero in
which case it is of course unnecessary to ever call it. Whether it is
possible to know this during compiletime depends upon how aggressively
the compiler inlines function calls (i.e. if it inlines calls to
start_ebml_master() where the upper bound for the size of the element
implies that the size will be written on one byte) and this depends upon
optimization settings. It is not the aim of this patch to inline all
calls where it is known that ffio_fill() will be unnecessary, but merely
to make compilers that inline such calls aware of the fact that writing
zero bytes with ffio_fill() is unnecessary. To this end
av_builtin_constant_p() is used to check whether the size is a
compiletime constant.

For GCC 10 this made a difference at -O3 only: The size of .text
decreased from 0x747F (with 29 calls to ffio_fill(), eight of which
use size zero) to 0x7337 (with 21 calls to ffio_fill(), zero of which
use size zero).
For Clang 11 it made a difference at -O2 and -O3: At -O2, the size of
.text decreased from 0x879C to 0x871C (with eight calls to ffio_fill()
eliminated); at -O3 the size of .text decreased from 0xAF2F to 0xAEBF.
Once again, eight calls to ffio_fill() with size zero have been
eliminated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 04:27:19 +02:00
Andreas Rheinhardt e1f41b4fdc avformat/wavdec: Fix reading files with id3v2 apic before fmt tag
Up until now the cover images will get the stream index 0 in this case,
violating the hardcoded assumption that this is the index of the audio
stream. Fix this by creating the audio stream first; this is also in
line with the expectations of ff_pcm_read_seek() and
ff_spdif_read_packet(). It also simplifies the code to parse the fmt and
xma2 tags.

Fixes #8540; regression since f5aad350d3.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:49:43 +02:00
Andreas Rheinhardt a74428921f avformat/segment: Use ff_stream_encode_params_copy()
It is simpler and more complete (e.g. it copies the id).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:29:36 +02:00
Andreas Rheinhardt 3651d6f276 avformat/webm_chunk: Use ff_stream_encode_params_copy()
It is simpler and more complete (e.g. it copies the framerate
information which allows to write the default duration element).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:29:23 +02:00
Andreas Rheinhardt 8068f2fcf3 avformat/id3v2: Don't reverse the order of id3v2 APICs
When parsing ID3v2 tags, special (non-text) metadata is not applied
directly and unconditionally; instead it is stored in a linked list
in which elements are prepended. When traversing the list to add APICs
(or private tags) at the end, the order is reversed. The same also
happens for chapters and therefore the chapter parsing code already
reverses the chapters.

This commit changes this: By keeping pointers to both head and tail
of the linked list one can preserve the order of the entries and
remove the reordering code for chapters. Only the pointer to head
will be exported: No current caller uses a nonempty list, so exporting
both head and tail is unnecessary. This removes the functionality
to combine the lists of special metadata read from different ID3v2 tags,
but that doesn't make really much sense anyway (and would be trivial
to implement if desired) and allows to remove the now unnecessary
initializations performed by the callers.

The FATE-reference for the id3v2-priv test had to be updated
because the order of the tags read into the dict is reversed;
for id3v2-priv-remux only the md5 and not the ffprobe output
of the remuxed file changes because the order of the private tags
has up until now been reversed twice.

The references for the aiff/mp3 cover-art tests needed to be updated,
because the order of the attached pics is reversed upon reading.
It is still not correct, because the muxers write the pics in the order
in which they arrive at the muxer instead of the order given by
pkt->stream_index.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:24:44 +02:00
Andreas Rheinhardt 9f834a1ac1 avformat/aiffenc: Avoid seek when writing id3v2 tags at the end
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:23:50 +02:00
Andreas Rheinhardt a4869bf029 avformat/aiffenc: Remove always-false check
write_header() already checks that there are only video tracks besides
the one audio track.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:21:19 +02:00
Andreas Rheinhardt b0afa10c8c fate/id3v2: Add test for id3v2 chapters
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:20:30 +02:00
Andreas Rheinhardt 8364643f68 fate/id3v2: Add a test for remuxing id3v2 private tags
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:19:42 +02:00
Andreas Rheinhardt 2f4ef9cbdf fate/cover-art: Add test for writing id3v2 tags and apic with AIFF/MP3
Notice that the order of the APIC tracks is currently wrong. This is
a superposition of two bugs: (i) Both muxers write the attached
pictures in the order they arrive in the muxer and not in the
stream_index order, leading to attached pictures that are copied being
written earlier because their timestamp is AV_NOPTS_VALUE, whereas the
timestamp of the encoded pictures is 0. (ii) A bug in the id3v2 parsing
code reverses the order of the parsed pictures.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:18:22 +02:00
Andreas Rheinhardt 3d76d4bf7f fate/mov: Add test for muxing cover images
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 02:04:42 +02:00
Andreas Rheinhardt 0c09d531d6 fate/filter-video: Remove SAMPLES depedency from refcmp tests
They don't need it as they use the lavfi device to create their samples.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-18 01:51:55 +02:00
Michael Niedermayer 3344079d30 avcodec/exr: increase vlc depth
Fixes: shift exponent -4 is negative
Fixes: 32265/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-465133454137753

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-17 16:53:17 +02:00
Michael Niedermayer c093eb3031 avcodec/dpx: Check bits_per_color earlier
Fixes: shift exponent 251 is too large for 32-bit type 'int'
Fixes: 32147/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DPX_fuzzer-5519111675314176

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-17 16:53:17 +02:00
Lynne 6c65e49990
lavu/detection_bboxes: add missing space
Could at least maintainers with push access follow the code styles
we have?
2021-04-17 13:14:47 +02:00
Guo, Yejun aa9ffdaa1e lavfi: add filter dnn_detect for object detection
Below are the example steps to do object detection:

1. download and install l_openvino_toolkit_p_2021.1.110.tgz from
https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/download.html
  or, we can get source code (tag 2021.1), build and install.
2. export LD_LIBRARY_PATH with openvino settings, for example:
.../deployment_tools/inference_engine/lib/intel64/:.../deployment_tools/inference_engine/external/tbb/lib/
3. rebuild ffmpeg from source code with configure option:
--enable-libopenvino
--extra-cflags='-I.../deployment_tools/inference_engine/include/'
--extra-ldflags='-L.../deployment_tools/inference_engine/lib/intel64'
4. download model files and test image
wget https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.bin
wget https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.xml
wget
https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.label
wget https://github.com/guoyejun/ffmpeg_dnn/raw/main/images/cici.jpg
5. run ffmpeg with:
./ffmpeg -i cici.jpg -vf dnn_detect=dnn_backend=openvino:model=face-detection-adas-0001.xml:input=data:output=detection_out:confidence=0.6:labels=face-detection-adas-0001.label,showinfo -f null -

We'll see the detect result as below:
[Parsed_showinfo_1 @ 0x560c21ecbe40]   side data - detection bounding boxes:
[Parsed_showinfo_1 @ 0x560c21ecbe40] source: face-detection-adas-0001.xml
[Parsed_showinfo_1 @ 0x560c21ecbe40] index: 0,  region: (1005, 813) -> (1086, 905), label: face, confidence: 10000/10000.
[Parsed_showinfo_1 @ 0x560c21ecbe40] index: 1,  region: (888, 839) -> (967, 926), label: face, confidence: 6917/10000.

There are two faces detected with confidence 100% and 69.17%.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
2021-04-17 17:27:02 +08:00
Guo, Yejun e942b4bbaa lavfi: show side data of detection bounding boxes 2021-04-17 17:27:02 +08:00
Guo, Yejun f1bf465aa0 lavu: add side data AV_FRAME_DATA_DETECTION_BBOXES for object detection/classification 2021-04-17 17:27:02 +08:00