]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agolavc/aarch64: change h264pred_init structure
Mikhail Nitenko [Thu, 15 Apr 2021 09:13:51 +0000 (12:13 +0300)]
lavc/aarch64: change h264pred_init structure

Change structure to allow the addition of other bit depths.

3 years agodoc/muxers.texi: fix build issue for unknown command
Guo, Yejun [Sun, 18 Apr 2021 04:41:53 +0000 (12:41 +0800)]
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)

3 years agoavutil/cpu: Use HW_NCPUONLINE to detect # of online CPUs with OpenBSD
Brad Smith [Sat, 3 Apr 2021 18:49:20 +0000 (14:49 -0400)]
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>
3 years agoavfilter/af_mcompand: check allocation results
Marton Balint [Sat, 10 Apr 2021 10:03:17 +0000 (12:03 +0200)]
avfilter/af_mcompand: check allocation results

Fixes the only remaining part of ticket #8931.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat/hls: check return value of new_init_section()
Marton Balint [Sat, 10 Apr 2021 09:59:00 +0000 (11:59 +0200)]
avformat/hls: check return value of new_init_section()

Fixes part of ticket #8931.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/nvenc: fix lossless tuning logic
Timo Rothenpieler [Sun, 18 Apr 2021 09:17:54 +0000 (11:17 +0200)]
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.

3 years agolavc/libaomdec: fix build with 1.0.0
Anton Khirnov [Sat, 17 Apr 2021 14:12:30 +0000 (16:12 +0200)]
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

3 years agolavu/detection_bbox.h: use AV_NUM_DETECTION_BBOX_CLASSIFY to replace AV_NUM_BBOX_CLASSIFY
Guo, Yejun [Sat, 17 Apr 2021 11:59:34 +0000 (19:59 +0800)]
lavu/detection_bbox.h: use AV_NUM_DETECTION_BBOX_CLASSIFY to replace AV_NUM_BBOX_CLASSIFY

3 years agoavformat/utils: Combine identical statements
Andreas Rheinhardt [Wed, 14 Apr 2021 19:56:50 +0000 (21:56 +0200)]
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>
3 years agoavcodec/jpeglsdec: Don't allocate+free JPEGLSState for every frame
Andreas Rheinhardt [Wed, 14 Apr 2021 19:24:33 +0000 (21:24 +0200)]
avcodec/jpeglsdec: Don't allocate+free JPEGLSState for every frame

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/matroskaenc: Remove unnecessary function calls
Andreas Rheinhardt [Wed, 14 Apr 2021 18:00:12 +0000 (20:00 +0200)]
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>
3 years agoavformat/wavdec: Fix reading files with id3v2 apic before fmt tag
Andreas Rheinhardt [Fri, 16 Apr 2021 18:53:55 +0000 (20:53 +0200)]
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 f5aad350d3695b5b16e7d135154a4c61e4dce9d8.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/segment: Use ff_stream_encode_params_copy()
Andreas Rheinhardt [Thu, 15 Apr 2021 19:46:43 +0000 (21:46 +0200)]
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>
3 years agoavformat/webm_chunk: Use ff_stream_encode_params_copy()
Andreas Rheinhardt [Tue, 13 Apr 2021 16:27:10 +0000 (18:27 +0200)]
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>
3 years agoavformat/id3v2: Don't reverse the order of id3v2 APICs
Andreas Rheinhardt [Mon, 12 Apr 2021 23:24:03 +0000 (01:24 +0200)]
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>
3 years agoavformat/aiffenc: Avoid seek when writing id3v2 tags at the end
Andreas Rheinhardt [Sat, 10 Apr 2021 00:19:05 +0000 (02:19 +0200)]
avformat/aiffenc: Avoid seek when writing id3v2 tags at the end

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/aiffenc: Remove always-false check
Andreas Rheinhardt [Sat, 10 Apr 2021 00:01:41 +0000 (02:01 +0200)]
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>
3 years agofate/id3v2: Add test for id3v2 chapters
Andreas Rheinhardt [Mon, 12 Apr 2021 18:38:24 +0000 (20:38 +0200)]
fate/id3v2: Add test for id3v2 chapters

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agofate/id3v2: Add a test for remuxing id3v2 private tags
Andreas Rheinhardt [Sat, 10 Apr 2021 21:30:51 +0000 (23:30 +0200)]
fate/id3v2: Add a test for remuxing id3v2 private tags

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agofate/cover-art: Add test for writing id3v2 tags and apic with AIFF/MP3
Andreas Rheinhardt [Sat, 10 Apr 2021 19:20:00 +0000 (21:20 +0200)]
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>
3 years agofate/mov: Add test for muxing cover images
Andreas Rheinhardt [Sat, 10 Apr 2021 15:34:45 +0000 (17:34 +0200)]
fate/mov: Add test for muxing cover images

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agofate/filter-video: Remove SAMPLES depedency from refcmp tests
Andreas Rheinhardt [Sat, 10 Apr 2021 15:08:29 +0000 (17:08 +0200)]
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>
3 years agoavcodec/exr: increase vlc depth
Michael Niedermayer [Sun, 11 Apr 2021 19:17:50 +0000 (21:17 +0200)]
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>
3 years agoavcodec/dpx: Check bits_per_color earlier
Michael Niedermayer [Sun, 11 Apr 2021 19:04:12 +0000 (21:04 +0200)]
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>
3 years agolavu/detection_bboxes: add missing space
Lynne [Sat, 17 Apr 2021 11:11:39 +0000 (13:11 +0200)]
lavu/detection_bboxes: add missing space

Could at least maintainers with push access follow the code styles
we have?

3 years agolavfi: add filter dnn_detect for object detection
Guo, Yejun [Sun, 7 Feb 2021 06:36:13 +0000 (14:36 +0800)]
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>
3 years agolavfi: show side data of detection bounding boxes
Guo, Yejun [Wed, 27 Jan 2021 04:54:58 +0000 (12:54 +0800)]
lavfi: show side data of detection bounding boxes

3 years agolavu: add side data AV_FRAME_DATA_DETECTION_BBOXES for object detection/classification
Guo, Yejun [Thu, 18 Feb 2021 04:51:48 +0000 (12:51 +0800)]
lavu: add side data AV_FRAME_DATA_DETECTION_BBOXES for object detection/classification

3 years agoavcodec/libaomdec: export frame pict_type
James Almer [Wed, 14 Apr 2021 00:08:09 +0000 (21:08 -0300)]
avcodec/libaomdec: export frame pict_type

Should fix ticket #9180

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/mpegts: set correct extradata size for Opus streams
James Almer [Thu, 15 Apr 2021 03:35:57 +0000 (00:35 -0300)]
avformat/mpegts: set correct extradata size for Opus streams

map_type 0 is always 19 bytes, whereas map_type 1 and 255 are 21 + channel
count bytes.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/mpegts: add missing sample_rate value to Opus extradata
James Almer [Thu, 15 Apr 2021 13:03:05 +0000 (10:03 -0300)]
avformat/mpegts: add missing sample_rate value to Opus extradata

Finishes fixing ticket #9190.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/movenc: fix writing dOps atoms
James Almer [Thu, 15 Apr 2021 04:28:27 +0000 (01:28 -0300)]
avformat/movenc: fix writing dOps atoms

Don't blindly copy all bytes in extradata past ChannelMappingFamily. Instead
check if ChannelMappingFamily is not 0 and then only write the correct amount
of bytes from ChannelMappingTable, as defined in the spec[1].

Fixes part of ticket #9190.

[1] https://opus-codec.org/docs/opus_in_isobmff.html#4.3.2

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/webpenc: don't assume animated webp streams will have more than one packet
James Almer [Sun, 11 Apr 2021 01:53:34 +0000 (22:53 -0300)]
avformat/webpenc: don't assume animated webp streams will have more than one packet

The libwebp_animencoder returns a single packet with the entire animated
stream, as that's what the external library produces. As such, only ensure the
stream was produced by said encoder (or propagated by a demuxer, once support
is added) when attempting to write the requested loop value.

Fixes ticket #9179.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/libwebpenc_animencoder: set the correct packet pts
James Almer [Sun, 11 Apr 2021 02:06:36 +0000 (23:06 -0300)]
avcodec/libwebpenc_animencoder: set the correct packet pts

The only packet produced by this encoder contains the entire animated stream,
so set its pts to the first frame encoded.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/libwebpenc_animencoder: stop propagating bogus empty packets
James Almer [Sun, 11 Apr 2021 01:50:48 +0000 (22:50 -0300)]
avcodec/libwebpenc_animencoder: stop propagating bogus empty packets

Packets must have at least one of data or side_data. If none are available,
then got_packet must not be signaled.

The generic encode code already discarded these empty packets, but it's better
just not propagating them at all.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agodoc/ffprobe.xsd: Clean-up choice indicator definitions
Tobias Rapp [Wed, 31 Mar 2021 09:47:18 +0000 (11:47 +0200)]
doc/ffprobe.xsd: Clean-up choice indicator definitions

Remove the unneeded wrapping sequence element. Also the
minOccurs/maxOccurs occurrence indicators on the inner element
definitions can be removed.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
3 years agofftools/ffprobe: Remove check on show_frames and show_packets in XML writer
Tobias Rapp [Wed, 31 Mar 2021 09:41:49 +0000 (11:41 +0200)]
fftools/ffprobe: Remove check on show_frames and show_packets in XML writer

The "packets_and_frames" element has been added to ffprobe.xsd in
0c9f0da0f7656059e9bd41931d250aafddf35ea3 but apparently removing the
check in ffprobe.c has been forgotten.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
3 years agoavformat/rawenc: remove singlejpeg muxer
Gyan Doshi [Sat, 10 Apr 2021 14:24:41 +0000 (19:54 +0530)]
avformat/rawenc: remove singlejpeg muxer

It was added in 51ac1f616f due to ticket #4218, in order to show a single
image via ffserver. With ffserver long gone, it serves no purpose.

3 years agoavcodec/nellymoserenc: Fix segfault when using unsupported channels/rate
Andreas Rheinhardt [Thu, 15 Apr 2021 13:48:34 +0000 (15:48 +0200)]
avcodec/nellymoserenc: Fix segfault when using unsupported channels/rate

NellyMoserEncodeContext.avctx is only set in init after these checks,
yet it is used by encode_end().
This is a regression since 0a56bfa71f751a2b25da8d060a019c1c75ca9d7b.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agomov: Prioritize aspect ratio values found in pasp atom
Vittorio Giovara [Tue, 6 Apr 2021 16:15:49 +0000 (18:15 +0200)]
mov: Prioritize aspect ratio values found in pasp atom

From the ISO/IEC specification for MP4:
  The pixel aspect ratio and clean aperture of the video may be specified
  using the ‘pasp’ and ‘clap’ sample entry boxes, respectively. These are
  both optional; if present, they over-ride the declarations (if any) in
  structures specific to the video codec, which structures should be
  examined if these boxes are absent. For maximum compatibility, these
  boxes should follow, not precede, any boxes defined in or required by
  derived specifications.

Fixes trac/#7277.

3 years agoavcodec/mpeg4videodec: update exported AVOptions in the user-facing context
James Almer [Mon, 12 Apr 2021 14:35:47 +0000 (11:35 -0300)]
avcodec/mpeg4videodec: update exported AVOptions in the user-facing context

This prevents bogus values being reported on frame multithreaded decoding
scenarios.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/h264dec: update exported AVOptions in the user-facing context
James Almer [Sat, 10 Apr 2021 19:10:11 +0000 (16:10 -0300)]
avcodec/h264dec: update exported AVOptions in the user-facing context

Based on a patch by Hendrik Leppkes.

Fixes ticket #9176.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agopthread_frame: introduce a codec callback to update the user-facing context
Hendrik Leppkes [Mon, 6 Jul 2020 00:29:59 +0000 (02:29 +0200)]
pthread_frame: introduce a codec callback to update the user-facing context

3 years agoffprobe: only print exported private decoder options
James Almer [Sat, 10 Apr 2021 20:23:22 +0000 (17:23 -0300)]
ffprobe: only print exported private decoder options

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/h264dec: add missing flags to is_avc and nal_length_size AVOptions
James Almer [Sat, 10 Apr 2021 19:06:34 +0000 (16:06 -0300)]
avcodec/h264dec: add missing flags to is_avc and nal_length_size AVOptions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoaarch64: h264pred: Optimize the inner loop of existing 8 bit functions
Martin Storsjö [Mon, 12 Apr 2021 07:31:22 +0000 (10:31 +0300)]
aarch64: h264pred: Optimize the inner loop of existing 8 bit functions

Move the loop counter decrement further from the branch instruction,
this hides the latency of the decrement.

In loops that first load, then store (the horizontal prediction cases),
do the decrement after the load (where the next instruction would
stall a bit anyway, waiting for the result of the load).

In loops that store twice using the same destination register,
also do the decrement between the two stores (as the second store
would need to wait for the updated destination register from the
first instruction).

In loops that store twice to two different destination registers,
do the decrement before both stores, to do it as soon before the
branch as possible.

This gives minor (1-2 cycle) speedups in most cases (modulo measurement
noise), but the horizontal prediction functions get a rather notable
speedup on the Cortex A53.

Before:                     Cortex A53     A72     A73
pred8x8_dc_8_neon:                60.7    46.2    39.2
pred8x8_dc_128_8_neon:            30.7    18.0    14.0
pred8x8_horizontal_8_neon:        42.2    29.2    18.5
pred8x8_left_dc_8_neon:           52.7    36.2    32.2
pred8x8_mad_cow_dc_0l0_8_neon:    48.2    27.7    25.7
pred8x8_mad_cow_dc_0lt_8_neon:    52.5    33.2    34.7
pred8x8_mad_cow_dc_l0t_8_neon:    52.5    31.7    33.2
pred8x8_mad_cow_dc_l00_8_neon:    43.2    27.0    25.5
pred8x8_plane_8_neon:            112.2    86.2    88.2
pred8x8_top_dc_8_neon:            40.7    23.0    21.2
pred8x8_vertical_8_neon:          27.2    15.5    14.0
pred16x16_dc_8_neon:              91.0    73.2    70.5
pred16x16_dc_128_8_neon:          43.0    34.7    30.7
pred16x16_horizontal_8_neon:      86.0    49.7    44.7
pred16x16_left_dc_8_neon:         87.0    67.2    67.5
pred16x16_plane_8_neon:          236.0   175.7   173.0
pred16x16_top_dc_8_neon:          53.2    39.0    41.7
pred16x16_vertical_8_neon:        41.7    29.7    31.0

After:
pred8x8_dc_8_neon:                59.0    46.7    42.5
pred8x8_dc_128_8_neon:            28.2    18.0    14.0
pred8x8_horizontal_8_neon:        34.2    29.2    18.5
pred8x8_left_dc_8_neon:           51.0    38.2    32.7
pred8x8_mad_cow_dc_0l0_8_neon:    46.7    28.2    26.2
pred8x8_mad_cow_dc_0lt_8_neon:    55.2    33.7    37.5
pred8x8_mad_cow_dc_l0t_8_neon:    51.2    31.7    37.2
pred8x8_mad_cow_dc_l00_8_neon:    41.7    27.5    26.0
pred8x8_plane_8_neon:            111.5    86.5    89.5
pred8x8_top_dc_8_neon:            39.0    23.2    21.0
pred8x8_vertical_8_neon:          27.2    16.0    14.0
pred16x16_dc_8_neon:              85.0    70.2    70.5
pred16x16_dc_128_8_neon:          42.0    30.0    30.7
pred16x16_horizontal_8_neon:      66.5    49.5    42.5
pred16x16_left_dc_8_neon:         81.0    66.5    67.5
pred16x16_plane_8_neon:          235.0   175.7   173.0
pred16x16_top_dc_8_neon:          52.0    39.0    41.7
pred16x16_vertical_8_neon:        40.2    33.2    31.0

Despite this, a number of these functions still are slower than
what e.g. GCC 7 generates - this shows the relative speedup of the
neon codepaths over the compiler generated ones:

                           Cortex A53    A72    A73
pred8x8_dc_8_neon:               0.86   0.65   1.04
pred8x8_dc_128_8_neon:           0.59   0.44   0.62
pred8x8_horizontal_8_neon:       1.51   0.58   1.30
pred8x8_left_dc_8_neon:          0.72   0.56   0.89
pred8x8_mad_cow_dc_0l0_8_neon:   0.93   0.93   1.37
pred8x8_mad_cow_dc_0lt_8_neon:   1.37   1.41   1.68
pred8x8_mad_cow_dc_l0t_8_neon:   1.21   1.17   1.32
pred8x8_mad_cow_dc_l00_8_neon:   1.24   1.19   1.60
pred8x8_plane_8_neon:            3.36   3.58   3.76
pred8x8_top_dc_8_neon:           0.97   0.99   1.43
pred8x8_vertical_8_neon:         0.86   0.78   1.18
pred16x16_dc_8_neon:             1.20   1.06   1.49
pred16x16_dc_128_8_neon:         0.83   0.95   0.99
pred16x16_horizontal_8_neon:     1.78   0.96   1.59
pred16x16_left_dc_8_neon:        1.06   0.96   1.32
pred16x16_plane_8_neon:          5.78   6.49   7.19
pred16x16_top_dc_8_neon:         1.48   1.53   1.94
pred16x16_vertical_8_neon:       1.39   1.34   1.98

In particular, on Cortex A72, many of these functions are slower
than the compiler generated code, while they're more beneficial on
e.g. the Cortex A73.

Signed-off-by: Martin Storsjö <martin@martin.st>
3 years agoavformat/dashdec: Also fetch final partial segment
Matt Robinson [Mon, 5 Apr 2021 17:45:04 +0000 (18:45 +0100)]
avformat/dashdec: Also fetch final partial segment

Currently, the DASH demuxer omits the final segment for a non-live
stream (using SegmentTemplate) if it is shorter than the other segments.

Correct calc_max_seg_no to round up when calulating the number of
segments instead of rounding down to resolve this issue.

Signed-off-by: Matt Robinson <git@nerdoftheherd.com>
3 years agofftools/ffmpeg_filter: Fix check for mjpeg encoder
Andreas Rheinhardt [Tue, 13 Apr 2021 17:13:39 +0000 (19:13 +0200)]
fftools/ffmpeg_filter: Fix check for mjpeg encoder

The MJPEG encoder supports some pixel format/color range combinations
only when strictness is set to unofficial or less. Before commit
059fc2d9da5364627613fb3e6424079e14dbdfd3 said encoder's pix_fmts array
only included the pixel formats supported with default strictness.
When strictness was <= unofficial, fftools/ffmpeg_filter.c used
an extended list of pixel formats instead of the encoder's including
the pixel formats only supported when strictness <= unofficial.

Said commit turned the logic around: The encoder's pix_fmts array now
included all pixel formats and fftools/ffmpeg_filter.c instead used
a small list of all pixel formats supported when strictness is >
unofficial and the encoder's pixel formats instead. In particular,
the codec's pix_fmt is not used when strictness is normal.

This works for the mjpeg encoder; yet it did not work for other
(hardware-based) mjpeg encoders, because the check for whether one is
using the MJPEG encoder is wrong: It just checks the codec id.
So if one used strict unofficial with a hardware-accelerated MJPEG
encoder before commit 059fc2d9da53, the unofficial (non-hardware)
pixel formats of the MJPEG encoder would be used; since said commit
the codec's pixel formats are overridden at ordinary strictness
by the ordinary MJPEG pixel formats. This leads to format conversion
errors lateron which were reported in #9186.

The solution to this is to check AVCodec.name instead of its id.

Fixes ticket #9186.

Tested-by: Eoff, Ullysses A <ullysses.a.eoff@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agolibavdevice/gdigrab: fix capture of windows with non-ASCII titles
He Yang [Sat, 20 Mar 2021 15:32:15 +0000 (23:32 +0800)]
libavdevice/gdigrab: fix capture of windows with non-ASCII titles

Properly convert the UTF-8 input string to Windows wchar, and
utilize the wchar version of FindWindow.

Signed-off-by: He Yang <1160386205@qq.com>
3 years agoavcodec/jpeglsenc: Remove redundant pixel format checks
Andreas Rheinhardt [Mon, 12 Apr 2021 17:02:58 +0000 (19:02 +0200)]
avcodec/jpeglsenc: Remove redundant pixel format checks

This encoder has AVCodec.pix_fmts set, so ff_encode_preinit() already
checks for this.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/matroskaenc: Put subtitles without duration into SimpleBlocks
Andreas Rheinhardt [Thu, 8 Apr 2021 23:00:51 +0000 (01:00 +0200)]
avformat/matroskaenc: Put subtitles without duration into SimpleBlocks

The value zero for AVPacket.duration means that the duration is unknown,
which in practice means "play this subtitle until overridden by the next
subtitle". Yet for Matroska a BlockGroup with duration zero means
that the subtitle really has a duration zero. "Display until overridden"
is achieved by not setting a duration on the container level at all and
this is achieved by using a SimpleBlock or a BlockGroup without
duration. This commit implements this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/matroskaenc: Remove remnant of inline-timing subtitle packets
Andreas Rheinhardt [Thu, 8 Apr 2021 19:54:17 +0000 (21:54 +0200)]
avformat/matroskaenc: Remove remnant of inline-timing subtitle packets

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/msmpeg4dec: Avoid duplication of VLC init code
Andreas Rheinhardt [Thu, 8 Apr 2021 19:01:05 +0000 (21:01 +0200)]
avcodec/msmpeg4dec: Avoid duplication of VLC init code

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/vc1: Remove unused hrd fields
Andreas Rheinhardt [Thu, 8 Apr 2021 18:11:20 +0000 (20:11 +0200)]
avcodec/vc1: Remove unused hrd fields

Unused since be3492ec7eb2dbb0748c123af911a06c125c90db.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mss2: Remove redundant initialization of vc1 dsp
Andreas Rheinhardt [Thu, 8 Apr 2021 16:53:16 +0000 (18:53 +0200)]
avcodec/mss2: Remove redundant initialization of vc1 dsp

ff_vc1_init_common() already does it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/vc1: Don't pretend ff_vc1_init_common() can fail
Andreas Rheinhardt [Tue, 22 Dec 2020 16:55:19 +0000 (17:55 +0100)]
avcodec/vc1: Don't pretend ff_vc1_init_common() can fail

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/msmpeg4enc: Remove dead code for inexistent VC-1 encoder
Andreas Rheinhardt [Thu, 8 Apr 2021 12:40:04 +0000 (14:40 +0200)]
avcodec/msmpeg4enc: Remove dead code for inexistent VC-1 encoder

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/h263dec, mpeg12dec: Remove redundant writes
Andreas Rheinhardt [Tue, 6 Apr 2021 21:32:57 +0000 (23:32 +0200)]
avcodec/h263dec, mpeg12dec: Remove redundant writes

ff_mpv_decode_init() already sets MpegEncContext.codec_id.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/rv34: Move dsp init code to rv30/rv40
Andreas Rheinhardt [Wed, 7 Apr 2021 16:07:54 +0000 (18:07 +0200)]
avcodec/rv34: Move dsp init code to rv30/rv40

It avoids both runtime and compile-time checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/mvi: Check audio_data_size to be non negative
Michael Niedermayer [Sat, 10 Apr 2021 20:55:00 +0000 (22:55 +0200)]
avformat/mvi: Check audio_data_size to be non negative

Fixes: left shift of negative value -224
Fixes: 32144/clusterfuzz-testcase-minimized-ffmpeg_dem_MVI_fuzzer-4971479323246592
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolavfi/qsvvpp: support async depth
Fei Wang [Wed, 31 Mar 2021 02:07:44 +0000 (10:07 +0800)]
lavfi/qsvvpp: support async depth

Async depth will allow qsv filter cache few frames, and avoid force
switch and end filter task frame by frame. This change will improve
performance for some multi-task case, for example 1:N transcode(
decode + vpp + encode) with all QSV plugins.

Performance data test on my Coffee Lake Desktop(i7-8700K) by using
the following 1:8 transcode test case improvement:
1. Fps improved from 55 to 130.
2. Render/Video usage improved from ~61%/~38% to ~100%/~70%.(Data get
from intel_gpu_top)

test CMD:
ffmpeg -v verbose -init_hw_device qsv=hw:/dev/dri/renderD128 -filter_hw_device                 \
 hw -hwaccel qsv -hwaccel_output_format qsv -c:v h264_qsv -i 1920x1080.264                     \
-vf 'vpp_qsv=w=1280:h=720:async_depth=4' -c:v h264_qsv -r:v 30 -preset 7 -g 33 -refs 2 -bf 3 -q 24 -f null - \
-vf 'vpp_qsv=w=1280:h=720:async_depth=4' -c:v h264_qsv -r:v 30 -preset 7 -g 33 -refs 2 -bf 3 -q 24 -f null - \
-vf 'vpp_qsv=w=1280:h=720:async_depth=4' -c:v h264_qsv -r:v 30 -preset 7 -g 33 -refs 2 -bf 3 -q 24 -f null - \
-vf 'vpp_qsv=w=1280:h=720:async_depth=4' -c:v h264_qsv -r:v 30 -preset 7 -g 33 -refs 2 -bf 3 -q 24 -f null - \
-vf 'vpp_qsv=w=1280:h=720:async_depth=4' -c:v h264_qsv -r:v 30 -preset 7 -g 33 -refs 2 -bf 3 -q 24 -f null - \
-vf 'vpp_qsv=w=1280:h=720:async_depth=4' -c:v h264_qsv -r:v 30 -preset 7 -g 33 -refs 2 -bf 3 -q 24 -f null - \
-vf 'vpp_qsv=w=1280:h=720:async_depth=4' -c:v h264_qsv -r:v 30 -preset 7 -g 33 -refs 2 -bf 3 -q 24 -f null -

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Reviewed-by: Linjie Fu <linjie.justin.fu@gmail.com>
Signed-off-by: Zhong Li <zhongli_dev@126.com>
3 years agoavformat/rawenc: perform stream checks for mp2 muxer
Gyan Doshi [Sun, 11 Apr 2021 05:25:57 +0000 (10:55 +0530)]
avformat/rawenc: perform stream checks for mp2 muxer

3 years agoavformat/img2dec: set r_frame_rate in addition to avg_frame_rate
Jan Ekström [Wed, 7 Apr 2021 18:17:04 +0000 (21:17 +0300)]
avformat/img2dec: set r_frame_rate in addition to avg_frame_rate

Apparently for various image sequences libavformat/utils.c can
calculate rather fancy r_frame_rate values, such as `186/1921`,
and since ffmpeg.c utilizes r_frame_rate for the filter chain
time base, this can quite deteriorate the output frame timing - even
though the user has requested the image sequence to be interpreted
at a specific, constant frame rate.

3 years agoavfilter/overlay_cuda: check av_buffer_ref result
Timo Rothenpieler [Sun, 11 Apr 2021 08:15:47 +0000 (10:15 +0200)]
avfilter/overlay_cuda: check av_buffer_ref result

3 years agoavfilter/vf_v360: unbreak fov_from_dfov() for (d)fisheye when width != height
Paul B Mahol [Sun, 11 Apr 2021 08:09:48 +0000 (10:09 +0200)]
avfilter/vf_v360: unbreak fov_from_dfov() for (d)fisheye when width != height

Based on patch by Daniel Playfair Cal.

3 years agoavfilter/overlay_cuda: hold explicit reference to hw_device_ctx
Timo Rothenpieler [Sat, 10 Apr 2021 12:31:52 +0000 (14:31 +0200)]
avfilter/overlay_cuda: hold explicit reference to hw_device_ctx

3 years agoavcodec/nvenc: add support for gbrp rgb input
Timo Rothenpieler [Tue, 30 Mar 2021 20:08:49 +0000 (22:08 +0200)]
avcodec/nvenc: add support for gbrp rgb input

3 years agodoc/muxers: add entries for raw muxers
Gyan Doshi [Sat, 10 Apr 2021 10:47:53 +0000 (16:17 +0530)]
doc/muxers: add entries for raw muxers

3 years agoavfilter/vf_v360: allow user to control fov for equirectagular format
Paul B Mahol [Sat, 10 Apr 2021 22:56:44 +0000 (00:56 +0200)]
avfilter/vf_v360: allow user to control fov for equirectagular format

It may be useful to use different values from typical 360/180 deg.

3 years agodoc/protocols: update rtsp options
Andriy Gelman [Sat, 10 Apr 2021 20:11:11 +0000 (16:11 -0400)]
doc/protocols: update rtsp options

Define listen_timeout and user_agent. Set timeout and user-agent to deprecated.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
3 years agoavcodec/adpcm: refactor init/flush code
Zane van Iperen [Wed, 31 Mar 2021 07:23:34 +0000 (17:23 +1000)]
avcodec/adpcm: refactor init/flush code

Most of the codecs just need everything zeroed. Those that don't
are either handled inline during decode, or pull state from
extradata.

Move state reset/init functionality into adpcm_flush(), and
invoke it from adpcm_decode_init().

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_swf: remove memory allocation during trellis encoding
Zane van Iperen [Thu, 1 Apr 2021 00:29:19 +0000 (10:29 +1000)]
avcodec/adpcm_swf: remove memory allocation during trellis encoding

The block size is hardcoded, so the buffer size is always known.
Statically allocate the buffer on the stack.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/matroskaenc: Fix leak when writing attachment without filename
Andreas Rheinhardt [Fri, 9 Apr 2021 22:11:06 +0000 (00:11 +0200)]
avformat/matroskaenc: Fix leak when writing attachment without filename

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo: Deprecate bframe opts for encoders not supporting them
Andreas Rheinhardt [Tue, 6 Apr 2021 17:32:07 +0000 (19:32 +0200)]
avcodec/mpegvideo: Deprecate bframe opts for encoders not supporting them

MPEG-1/2/4 are the only mpegvideo based encoders that support bframes;
yet even the encoders not supporting bframes have options that only make
sense for an encoder that supports bframes; setting any of these options
for such an encoder has no impact on the encoded outcome (but setting
b_strategy to two slows down encoding considerably). So deprecate these
options.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo: Deprecate duplicate matrix opt for unsupported codecs
Andreas Rheinhardt [Tue, 6 Apr 2021 16:51:38 +0000 (18:51 +0200)]
avcodec/mpegvideo: Deprecate duplicate matrix opt for unsupported codecs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo: Deprecate a53cc option for encoders != MPEG-2
Andreas Rheinhardt [Tue, 6 Apr 2021 15:53:20 +0000 (17:53 +0200)]
avcodec/mpegvideo: Deprecate a53cc option for encoders != MPEG-2

The MPEG-2 encoder is the only mpegvideo-based encoder that supports
embedding a53 side data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo: Deprecate mpeg_quant option for codecs != MPEG-4
Andreas Rheinhardt [Tue, 6 Apr 2021 15:20:57 +0000 (17:20 +0200)]
avcodec/mpegvideo: Deprecate mpeg_quant option for codecs != MPEG-4

mpeg_quant may only be set for MPEG-4 and MPEG-2, yet for the latter
it is no option as the code acts as if it were always set.
So deprecate the option for all codecs for which it makes no sense.

Furthermore, given that the code already errors out if the option is set
for a codec that doesn't support it we can restrict the range of
the option for all these codecs without breaking something. This means
that the checks for whether mpeg_quant is set for these codecs can be
removed as soon as AVCodecContext.mpeg_quant is removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo_enc: Combine identical checks
Andreas Rheinhardt [Tue, 6 Apr 2021 14:00:28 +0000 (16:00 +0200)]
avcodec/mpegvideo_enc: Combine identical checks

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpeg12enc: Perform size/level/profile checks earlier
Andreas Rheinhardt [Tue, 6 Apr 2021 19:33:53 +0000 (21:33 +0200)]
avcodec/mpeg12enc: Perform size/level/profile checks earlier

This has the advantage that one does not waste some allocations
if one errors out because of these checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpeg12enc: Move MPEG-1/2 dimension checks to mpeg12enc
Andreas Rheinhardt [Tue, 6 Apr 2021 13:03:19 +0000 (15:03 +0200)]
avcodec/mpeg12enc: Move MPEG-1/2 dimension checks to mpeg12enc

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo_enc: Remove redundant time_base check
Andreas Rheinhardt [Tue, 6 Apr 2021 11:43:46 +0000 (13:43 +0200)]
avcodec/mpegvideo_enc: Remove redundant time_base check

This check is dead as ff_encode_preinit() has an even stricter check.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agofftools/ffmpeg_filter: Don't needlessly copy string
Andreas Rheinhardt [Tue, 6 Apr 2021 05:05:00 +0000 (07:05 +0200)]
fftools/ffmpeg_filter: Don't needlessly copy string

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agofftools/ffmpeg_filter: Don't write string that is never used
Andreas Rheinhardt [Tue, 6 Apr 2021 04:21:22 +0000 (06:21 +0200)]
fftools/ffmpeg_filter: Don't write string that is never used

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agofftools/ffmpeg_filter: Avoid allocations when configuring output filters
Andreas Rheinhardt [Tue, 6 Apr 2021 03:26:31 +0000 (05:26 +0200)]
fftools/ffmpeg_filter: Avoid allocations when configuring output filters

Use an AVBPrint to handle the (typically short) strings involved here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mjpegenc: Include all supported pix_fmts in mpegenc pix_fmts
Andreas Rheinhardt [Tue, 6 Apr 2021 01:01:14 +0000 (03:01 +0200)]
avcodec/mjpegenc: Include all supported pix_fmts in mpegenc pix_fmts

Currently said list contains only the pixel formats that are always
supported irrespective of the range and the value of
strict_std_compliance. This makes the MJPEG encoder an outlier as all
other codecs put all potentially supported pixel formats into said list
and error out if the chosen pixel format is unsupported. This commit
brings it therefore in line with the other encoders.

The behaviour of fftools/ffmpeg_filter.c has been preserved. A more
informed decision would be possible if colour range were available
at this point, but it isn't.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/ljpegenc: Allow full range yuv420p, yuv422p, yuv444p by default
Andreas Rheinhardt [Mon, 5 Apr 2021 22:45:25 +0000 (00:45 +0200)]
avcodec/ljpegenc: Allow full range yuv420p, yuv422p, yuv444p by default

The documentation for AV_PIX_FMT_YUVJ420P reads:
"planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of
AV_PIX_FMT_YUV420P and setting color_range"
Yet the LJPEG encoder only accepts full scale yuv420p when strictness is
set to unofficial or lower; with default strictness it emits a nonsense
error message that says that limit range YUV is unofficial. This has
been changed to allow full range yuv420p, yuv422p and yuv444p irrespective
of the level of strictness.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo_enc: Remove redundant pixel format checks
Andreas Rheinhardt [Mon, 5 Apr 2021 20:35:30 +0000 (22:35 +0200)]
avcodec/mpegvideo_enc: Remove redundant pixel format checks

All encoders using ff_mpv_encode_init() already have pix_fmts set
so that the pixel format is already checked in ff_encode_preinit().
The one exception to this is MJPEG whose check remains.

(Btw: The AVCodec.pix_fmts check for AMV is stricter than the check
in ff_mpv_encode_init().)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mjpegenc: Remove dependency of AMV encoder on mjpegenc_huffman
Andreas Rheinhardt [Tue, 30 Mar 2021 22:21:20 +0000 (00:21 +0200)]
avcodec/mjpegenc: Remove dependency of AMV encoder on mjpegenc_huffman

Using optimal Huffman tables is not supported for AMV and always
disabled by ff_mpv_encode_init(); therefore one can build
the AMV encoder without mjpegenc_huffman if one adds the necessary
compile-time checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo_enc: Make AMV encoder usable without MJPEG encoder
Andreas Rheinhardt [Mon, 5 Apr 2021 19:50:12 +0000 (21:50 +0200)]
avcodec/mpegvideo_enc: Make AMV encoder usable without MJPEG encoder

Up until now the relevant checks all checked for the existence of the
MJPEG encoder only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/proresenc_kostya: Remove harmful check
Andreas Rheinhardt [Wed, 7 Apr 2021 20:43:38 +0000 (22:43 +0200)]
avcodec/proresenc_kostya: Remove harmful check

The ProRes encoder allocates huge worst-case buffers just to be safe;
and for huge resolutions (8k in this case) these can be so big that the
number of bits does no longer fit into a (signed 32-bit) int; this means
that one must no longer use the parts of the PutBits API that deal with
bit counters. Yet proresenc_kostya did it, namely for a check about
whether we are already beyond the end. Yet this check is unnecessary
nowadays, because the PutBits API comes with automatic checks (with
a log message and a av_assert2() in put_bits() and an av_assert0() in
flush_put_bits()), so this is unnecessary. So simply remove the check.

Fixes ticket #9173.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoChangelog: Add new <next> line after 4.4
Michael Niedermayer [Fri, 9 Apr 2021 04:30:31 +0000 (06:30 +0200)]
Changelog: Add new <next> line after 4.4

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoChangelog: replace <next> by 4.4
Michael Niedermayer [Fri, 9 Apr 2021 04:23:34 +0000 (06:23 +0200)]
Changelog: replace <next> by 4.4

Found-by: <jamrial>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolavc/pngdec: always create a copy for APNG_DISPOSE_OP_BACKGROUND
Anton Khirnov [Thu, 8 Apr 2021 08:46:54 +0000 (10:46 +0200)]
lavc/pngdec: always create a copy for APNG_DISPOSE_OP_BACKGROUND

Calling av_frame_make_writable() from decoders is tricky, especially
when frame threading is used. It is much simpler and safer to just make
a private copy of the frame.
This is not expected to have a major performance impact, since
APNG_DISPOSE_OP_BACKGROUND is not used often and
av_frame_make_writable() would typically make a copy anyway.

Found-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/msp2dec: Check available space in RLE decoder
Michael Niedermayer [Tue, 6 Apr 2021 21:14:08 +0000 (23:14 +0200)]
avcodec/msp2dec: Check available space in RLE decoder

Fixes: out of array read
Fixes: 32968/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSP2_fuzzer-5315296027082752
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/webvttenc: Fix use of uninitialized variable
Andreas Rheinhardt [Thu, 8 Apr 2021 12:06:24 +0000 (14:06 +0200)]
avformat/webvttenc: Fix use of uninitialized variable

Happened in 9168a1c0e67b5c31727b12329b6f52d2bb5e0a14.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant
Andreas Rheinhardt [Tue, 6 Apr 2021 13:45:42 +0000 (15:45 +0200)]
avcodec/mpegvideo_enc: Don't segfault on unorthodox mpeg_quant

The (deprecated) field AVCodecContext.mpeg_quant has no range
restriction; MpegEncContext.mpeg_quant is restricted to 0..1.
If the former is set, the latter is overwritten with it without
checking the range. This can trigger an av_assert2() with the MPEG-4
encoder when writing said field.

Fix this by just setting MpegEncContext.mpeg_quant to 1 if
AVCodecContext.mpeg_quant is set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavcodec/encode: Fix check for allowed LJPEG pixel formats
Andreas Rheinhardt [Mon, 5 Apr 2021 22:32:39 +0000 (00:32 +0200)]
avcodec/encode: Fix check for allowed LJPEG pixel formats

The pix_fmts of the LJPEG encoder already contain all supported pixel
formats (including the ones only supported when strictness is unofficial
or less); yet the check in ff_encode_preinit() ignored this list in case
strictness is unofficial or less. But the encoder presumed that it is
always applied and blacklists some of the entries in pix_fmts when
strictness is > unofficial. The result is that if one uses an entry not
on that list and sets strictness to unofficial, said entry passes both
checks and this can lead to segfaults lateron (e.g. when using gray).

Fix this by removing the exception for LJPEG in ff_encode_preinit().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/rmdec: Don't rely on unspecified order of evaluation
Andreas Rheinhardt [Wed, 7 Apr 2021 11:37:09 +0000 (13:37 +0200)]
avformat/rmdec: Don't rely on unspecified order of evaluation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agoavformat/rmdec: Fix memleaks upon read_header failure
Andreas Rheinhardt [Mon, 20 Jul 2020 21:26:15 +0000 (23:26 +0200)]
avformat/rmdec: Fix memleaks upon read_header failure

For both the RealMedia as well as the IVR demuxer (which share the same
context) each AVStream's priv_data contains an AVPacket that might
contain data (even when reading the header) and therefore needs to be
unreferenced. Up until now, this has not always been done:

The RealMedia demuxer didn't do it when allocating a new stream's
priv_data failed although there might be other streams with packets to
unreference. (The reason for this was that until recently rm_read_close()
couldn't handle an AVStream without priv_data, so one had to choose
between a potential crash and a memleak.)

The IVR demuxer meanwhile never ever called read_close so that the data
already contained in packets leaks upon error.

This patch fixes both demuxers by adding the appropriate cleanup code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
3 years agofftools/ffmpeg: copy average framerate for streamcopy, when known
Anton Khirnov [Mon, 5 Apr 2021 08:48:43 +0000 (10:48 +0200)]
fftools/ffmpeg: copy average framerate for streamcopy, when known