Commit Graph

104808 Commits

Author SHA1 Message Date
Andreas Rheinhardt
e38eaf4749 avformat/utils: Make ff_data_to_hex() zero-terminate the string
Most callers want it that way anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 00:42:48 +01:00
Andreas Rheinhardt
b09ea67b40 avcodec/libkvazaar: Increase array size
av_image_copy() expects an array of four pointers according to its
declaration; although it currently only touches pointers that
are actually in use (depending upon the pixel format) this might
change at any time (as has already happened for the linesizes
in d7bc52bf45).

This fixes a -Wstringop-overflow= warning with GCC 11.2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 00:36:32 +01:00
Limin Wang
f1c8c25832 avformat/rtsp: fix the error code from ffurl_read_complete()
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-07 20:48:07 +08:00
Limin Wang
6d42af02f5 avformat/rtsp: add error code handling for ff_rtsp_skip_packet()
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-07 20:33:17 +08:00
Limin Wang
f210766a55 avformat/rtsp: free the alloc memory if failed
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-07 20:33:17 +08:00
Limin Wang
130e4c6f4c avformat/rtsp: remove redundant assignment
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-07 20:33:17 +08:00
Gyan Doshi
a454dfacd5 avformat/concatf: ignore trailing whitespaces
The concatf protocol returns an opaque error on open if
concatf list file contains trailing newlines.

Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
Reviewed-by: James Almer <jamrial@gmail.com>
2021-12-07 17:50:55 +05:30
Anton Khirnov
9f717ca92f ffmpeg: handle errors in print_sdp()
Do not continue as if nothing happened.
2021-12-07 11:23:45 +01:00
Anton Khirnov
9145c6d3b2 ffmpeg: move setting video sync method to new_video_stream()
do_video_out() is the wrong place for it, since the necessary
information is already known when creating the stream and its value
should never change.
2021-12-07 11:23:45 +01:00
Anton Khirnov
6ce9546428 ffmpeg: deprecate passing numbers to -vsync
There is never a reason to do this, using symbolic names is always
preferred.
2021-12-07 11:23:45 +01:00
Anton Khirnov
e3833e8a24 FATE: stop using numeric arguments to -vsync
Symbolic names are always preferable.
2021-12-07 11:23:45 +01:00
Anton Khirnov
011114f3e1 ffmpeg: change vsync value to an enum
Stop explicitly defining VSCFR and DROP values, which were never
documented.
2021-12-07 11:23:45 +01:00
Anton Khirnov
bb6f591c49 ffmpeg: drop useless framerate assignments
If the input stream framerate is known, it will be configured on the
relevant filtergraph input and get propagated to the output stream in
the above line. That makes these assignments redundant.
2021-12-07 11:23:45 +01:00
Anton Khirnov
6ebaccf327 lavf/protocols: avoid discarding const in avio_enum_protocols()
Instead of storing the protocol pointer in the opaque iteration state,
store just the index of the next protocol, similarly to how
ff_urlcontext_child_class_iterate() works.
2021-12-07 11:16:14 +01:00
Anton Khirnov
c0e46ad9a9 lavf/img2enc: avoid a useless copy of the url
img2enc keeps a private (and possibly truncated) copy of the url that is
never modified. Just use AVFormatContext.url instead.
2021-12-07 11:16:14 +01:00
Anton Khirnov
7e29e0278f lavf/ftp: check for truncation in snprintf
Silences e.g. the following warning in gcc 10:
src/libavformat/ftp.c: In function ‘ftp_move’:
src/libavformat/ftp.c:1122:46: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4091 [-Wformat-truncation=]
 1122 |     snprintf(command, sizeof(command), "RNTO %s\r\n", path);
      |                                              ^~       ~~~~
src/libavformat/ftp.c:1122:5: note: ‘snprintf’ output between 8 and 4103 bytes into a destination of size 4096
 1122 |     snprintf(command, sizeof(command), "RNTO %s\r\n", path);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-12-07 11:16:14 +01:00
Anton Khirnov
177a328c7c lavfi/vf_subtitles: stop using deprecated ass_set_aspect_ratio()
It has been deprecated in favor of ass_set_pixel_aspect() since version
0.11.0, roughly ~2014. Even Debian oldoldstable (stretch) has 0.13.
2021-12-07 11:16:14 +01:00
Anton Khirnov
877b6a9e82 lavd/v4l2: detect device name truncation
Silences the following warning with gcc 10:
src/libavdevice/v4l2.c: In function ‘v4l2_get_device_list’:
src/libavdevice/v4l2.c:1042:64: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 251 [-Wformat-truncation=]
 1042 |         ret = snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
      |                                                                ^~
src/libavdevice/v4l2.c:1042:15: note: ‘snprintf’ output between 6 and 261 bytes into a destination of size 256
 1042 |         ret = snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previous patches intending to silence it have proposed increasing the
buffer size, but doing that correctly seems to be tricky. Failing on
truncation is simpler and just as effective (as excessively long device
names are unlikely).
2021-12-07 11:16:14 +01:00
Anton Khirnov
b532ca3d2f lavd/v4l2: reduce variable scope
device and cap are local to the loop iteration, there is no need for
them to retain their values. Especially for device it may be dangerous,
since it points to av_malloc'ed data.
2021-12-07 11:16:14 +01:00
Anton Khirnov
e1151fbf22 lavd/v4l2: do not clobber the context FD in v4l2_get_device_list()
The FD opened here is local to the loop iteration, there is no reason to
store it in the context. Since read_header() may have already been
called, this may ovewrite an existing valid FD.
2021-12-07 11:16:14 +01:00
Anton Khirnov
007819a5bc lavd/jack: increase buffer size for snprintf()
Maximum output size with a 32-bit int is 17 bytes, or 26 with a 64-bit
int.

Silences the following gcc 10 warning:
src/libavdevice/jack.c: In function ‘audio_read_header’:
src/libavdevice/jack.c:171:45: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
  171 |         snprintf(str, sizeof(str), "input_%d", i + 1);
      |                                             ^
src/libavdevice/jack.c:171:9: note: ‘snprintf’ output between 8 and 17 bytes into a destination of size 16
  171 |         snprintf(str, sizeof(str), "input_%d", i + 1);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-12-07 11:16:14 +01:00
Andreas Rheinhardt
6fc0fc5441 fftools/ffmpeg_opt: Improve alloc/truncation checks when reading lines
Do this by switching from the dynamic buffer API to the AVBPrint API;
the former has no defined way to check for errors.
This also avoids allocating an AVIOContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-07 10:01:41 +01:00
Andreas Rheinhardt
f3a8d208c0 fftools/ffmpeg_opt: Improve checks for truncation/alloc error
Do this by switching from the dynamic buffer API to the AVBPrint API;
the former has no defined way to check for errors.
This also avoids allocating an AVIOContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-07 10:01:34 +01:00
Lynne
3f3772e444
packet: add description for the AVPacket.time_base field
This description documents the field. Thanks to elenril for
suggesting the phrasing.
2021-12-06 22:16:13 +01:00
Michael Niedermayer
b5ba74053c avformat/mov: Disallow duplicate smdm
Fixes: memleak
Fixes: 39879/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5327819907923968

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-06 14:25:55 +01:00
Michael Niedermayer
51d5e90158 avcodec/gemdec: Move all support checks before image allocation
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-06 14:25:55 +01:00
Michael Niedermayer
e901716daf tools/target_dec_fuzzer: Adjust threshold for HQ_HQA
Fixes: Timeout
Fixes: 41120/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HQ_HQA_fuzzer-6327761690558464

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-06 14:25:55 +01:00
Michael Niedermayer
cd95ac7e33 tools/target_dec_fuzzer: adjust threshold for gem
Fixes: Timeout
Fixes: 42035/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GEM_fuzzer-5033604191748096

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-06 14:25:55 +01:00
Michael Niedermayer
235ac7b492 avcodec/avpacket: Perform fewer reallocations in repeated av_grow_packet()
Fixes: Timeout
Fixes: 41446/clusterfuzz-testcase-minimized-ffmpeg_dem_SAMI_fuzzer-4667644540747776

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-06 14:25:55 +01:00
Michael Niedermayer
59b4e7cbd8 avformat/mov: Check for EOF in mov_read_glbl()
Fixes: Infinite loop
Fixes: 41351/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5433895854669824

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-06 14:25:55 +01:00
Andreas Rheinhardt
b0b90100bf avcodec/libopenh264dec: Increase array sizes, fix stack-buffer overread
av_image_copy() expects an array of four pointers and linesizes
according to its declaration; it currently only pointers that are
actually in use (depending upon the pixel format), but this might
change at any time. It has already happened for the linesizes in
d7bc52bf45 and so increasing their
array fixes a stack-buffer overread.

This fixes a -Wstringop-overflow= and -Wstringop-overread warning
from GCC 11.2.

Reviewed-by: Linjie Fu <linjie.justin.fu@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-06 13:52:00 +01:00
Gyan Doshi
ef00d40e32 doc/filters: note duration range in xfade 2021-12-06 16:35:47 +05:30
Andreas Rheinhardt
228b25ad9b avformat/smoothstreamingenc: Move buffers to the end of structs
This reduces codesize because the offsets of commonly used elements
are now smaller and thus need less bytes to encode in ptr+offset
addressing modes (with GCC 11.2 on x64: 0x1b8b -> 0x1a7b).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Andreas Rheinhardt
847d199138 avformat/takdec: Simplify data->hex conversion
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Andreas Rheinhardt
6c57e0b4a8 avutil/frame: Treat frame as uninitialized in get_frame_defaults()
Currently, it also tests whether extended_data points to something
different than the AVFrame's data array and frees extended_data
if it is different. Yet this is only necessary for one of its three
callers, namely av_frame_unref(); meanwhile the other two callers
took measures to avoid this (or rather, to make it to an av_free(NULL)).

This commit moves this chunk to av_frame_unref() (so that
get_frame_defaults() now treats its input as uninitialized)
and removes the now superfluous code in the other two callers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Andreas Rheinhardt
fc01a703de fftools/ffmpeg: Avoid creating unnecessary reference
The only caller of do_video_out() doesn't need the frame afterwards,
ergo one can replace an av_frame_ref() by av_frame_move_ref().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Andreas Rheinhardt
b886512ef2 fftools/ffmpeg: Avoid allocating+freeing frame, check allocations
Fixes a potential crash upon av_frame_alloc() failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Andreas Rheinhardt
2d0bfbd0fa fftools/cmdutils: Use av_dynarray_add_nofree()
Simplifies code and reduces the number of allocations a bit
by overallocating.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Andreas Rheinhardt
2e7ef008e3 fftools/cmdutils: Make allocate_array_elem() return ptr to new element
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Andreas Rheinhardt
9d73967b40 fftools/ffmpeg_(filter|opt): Use dedicated pointer for array elem access
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:37 +01:00
Andreas Rheinhardt
3ca1e31e63 fftools/cmdutils: Atomically add elements to list of pointers, fix crash
Currently, adding a (separately allocated) element to a list of pointers
works by first reallocating the array of pointers and (on success)
incrementing its size and only then allocating the new element.
If the latter allocation fails, the size is inconsistent, i.e.
array[nb_array_elems - 1] is NULL. Our cleanup code crashes in such
scenarios.

Fix this by adding an auxiliary function that atomically allocates
and adds a new element to a list of pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:37 +01:00
Anton Khirnov
3a9861e22c lavu/frame: clarify doxy
AVFrame.data[] elements not used by the format should ALWAYS be null,
hwaccel formats are not an exception.
2021-12-04 14:29:06 +01:00
Anton Khirnov
3b8efec3c5 lavu/frame: drop mentions of non-refcounted frames
All frames we deal with should always be refcounted now.
2021-12-04 14:28:23 +01:00
Anton Khirnov
2755e6f32a doc/APIchanges: fix typo 2021-12-04 14:28:09 +01:00
Anton Khirnov
ab3ef54c8c ffmpeg: only copy bits_per_sample from decoder when it remains valid
I.e. when the only filters that are applied do not modify the frame
data.
2021-12-04 14:08:17 +01:00
Anton Khirnov
4258893961 ffmpeg: make -bits_per_raw_sample a per-output-stream option
Also, document it and make it apply to audio in addition to video.
2021-12-04 14:07:36 +01:00
Anton Khirnov
b9c928a486 avfilter: add AVFILTER_FLAG_METADATA_ONLY
This flag allows distinguishing between filters that actually modify the
data and those that only modify metadata or gather some stream
information.
2021-12-04 14:07:19 +01:00
Anton Khirnov
944c34a94c lavfi/allfilters: move vf_chromaber_vulkan to video section 2021-12-04 14:06:42 +01:00
nyanmisaka
64467cbca2 libavutil/hwcontext_qsv: fix a bug for mapping vaapi frame to qsv
The data stored in data[3] in VAAPI AVFrame is VASurfaceID while
the data stored in pair->first is the pointer of VASurfaceID, so
we need to do cast to make following commandline works:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \
-hwaccel_output_format vaapi -i input.264 \
-vf "hwmap=derive_device=qsv,format=qsv" -c:v h264_qsv output.264

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2021-12-04 14:06:30 +01:00
Marvin Scholz
c6f4e10111 avformat: do not use AVIO_FLAG_* with avio_alloc_context
The documentation states that here 0 should be used for read-only and
1 for a writable buffer. AVIO_FLAG_WRITE however is 2, while it works
due to the way the flag is handled internally, it is still wrong
according to the documentation.

Additionally it makes it seem as if the AVIO_FLAG_* values could be used
here, which is actually not true, as when AVIO_FLAG_READ would be used
here it would create a writable buffer as AVIO_FLAG_READ is defined as 1.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2021-12-04 14:06:30 +01:00