1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-02 03:06:28 +02:00
Commit Graph

45773 Commits

Author SHA1 Message Date
gxw
3f294ec879 avcodec: [loongarch] Optimize h264dsp with LASX.
./ffmpeg -i ../1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -y /dev/null -an
before:225
after :282

Change-Id: Ibe245827dcdfe8fc1541c6b172483151bfa9e642
Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Reviewed-by: guxiwei <guxiwei-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-15 18:37:40 +01:00
Shiyou Yin
cba7c0267d avcodec: [loongarch] Optimize h264qpel with LASX.
./ffmpeg -i ../1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -y /dev/null -an
before:183
after :225

Change-Id: I7c7d2f34cd82ef728aab5ce8f6bfb46dd81f0da4
Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Reviewed-by: guxiwei <guxiwei-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-15 18:37:40 +01:00
Shiyou Yin
6038a9eb92 avcodec: [loongarch] Optimize h264_chroma_mc with LASX.
./ffmpeg -i ../1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -y /dev/null -an
before:170
after :183

Change-Id: I42ff23cc2dc7c32bd1b7e4274da9d9ec87065f20
Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Reviewed-by: guxiwei <guxiwei-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-15 18:37:40 +01:00
Andreas Rheinhardt
7fe5c7f02d avcodec/mmaldec: Deduplicate AVClasses
Possible now that the child_class_next API is gone.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-12 16:56:04 +01:00
Andreas Rheinhardt
9644ee224f avcodec/mmaldec: Avoid creating unnecessary reference, simplify code
ffmal_add_packet() basically duplicated the logic in
av_packet_make_refcounted() with the added twist that it always
created a reference even if one is already available.
This commit stops doing this.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-12 16:55:33 +01:00
Ho Ming Shun
dd779749f0 avcodec/mmaldec: fix pointer type warning
Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Ho Ming Shun <cyph1984@gmail.com>
2021-12-12 16:55:13 +01:00
Ho Ming Shun
6f0e8b998a avcodec/mmaldec: re-use AVPacket for extra_data
extra_data and normal packets (from ff_decode_get_packet) processing do
not overlap, thus we can re-use the spare AVPacket to send to
ffmmal_add_packet.

Furthermore, this removes allocation of AVPacket on the stack and stops
using deprecated av_init_packet.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Ho Ming Shun <cyph1984@gmail.com>
2021-12-12 16:55:06 +01:00
Ho Ming Shun
b54377b3a7 avcodec/mmaldec: use decoupled dataflow
MMAL is an fundamentally an asynchronous decoder, which was a bad fit
for the legacy dataflow API. Often multiple packets are enqueued before
a flood of frames are returned from MMAL.

The previous lockstep dataflow meant that any delay in returning packets
from the VPU would cause ctx->queue_decoded_frames to grow with no way
of draining the queue.

Testing this with mpv streaming from a live RTSP source visibly reduced
latency introduced by frames waiting in queue_decoded_frames from
roughly 2s to 0.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Ho Ming Shun <cyph1984@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-12 16:54:43 +01:00
Charlie Monroe
34aee50a7f avcodec/movtextenc: Check for existence of font name before using it
Fixes crashes if the font name is NULL (which it is if a \fn tag
is not followed by a font name).

Signed-off-by: Charlie Monroe <charlie@charliemonroe.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-11 17:15:38 +01:00
Andreas Rheinhardt
41b077762c avcodec/movtextdec: Fix wrong error code
Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-11 16:28:53 +01:00
Andreas Rheinhardt
bbc866c9c9 avcodec/movtextdec: Switch to pointer comparisons and bytestream API
Improves readability and avoids a redundant index variable
that was mistakenly called "tracksize".

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-11 16:28:48 +01:00
Andreas Rheinhardt
e1044e55e4 avcodec/movtextdec: Redo TextSampleModifierBox size checks
The current checks just check whether the boxes fit into the remaining
size of the packet instead of whether they actually fit into the box
size. This has been changed; part of this change is to pass the size of
the box (minus the box header) as parameter instead of a pointer to
the AVPacket by which the box parsing function is supposed to
recalculate whether enough data is available.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-11 16:28:43 +01:00
Andreas Rheinhardt
efd7b35d06 avcodec/movtextdec: Use const where appropriate
Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-11 16:28:39 +01:00
Andreas Rheinhardt
b9f5a26a39 avcodec/movtextdec: Improve size check
Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-11 16:28:34 +01:00
Andreas Rheinhardt
cd693c9ec8 avcodec/movtextdec: Switch to smaller type
The base size of a box refers to the size the box has in a file,
not in memory; so size_t is not their natural type. Therefore use
a plain unsigned which is smaller on 64bit systems and still big
enough to represent any conceivable base size.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-11 15:56:10 +01:00
Michael Niedermayer
0ec75723a4 avcodec/apedec: Change avg to uint32_t
Fixes: Integer overflow
Fixes: 40973/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6739312704618496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Suggested-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-09 13:27:23 +01:00
Michael Niedermayer
1e85a698c0 avcodec/targa: Do not return images when there is no image in the tga
Fixes: Timeout
Fixes: 35877/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TARGA_fuzzer-5407292819374080

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-09 13:12:45 +01:00
Limin Wang
b9f4c1231f avcodec/bitpacked_enc: suppport for frame thread encode
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-09 09:10:36 +08:00
Limin Wang
d39f667da1 avcodec/bitpacked_dec: support for frame thread decode
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-09 09:10:35 +08:00
Limin Wang
17b434f1ce avcodec/bitpacked_dec: setting pict_type and key_frame after decode()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-09 09:10:35 +08:00
Limin Wang
b51d772a50 avcodec/bitpacked_dec: remove AV_CODEC_CAP_EXPERIMENTAL capabilities
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-09 09:10:35 +08:00
Andreas Rheinhardt
cc1251ab81 avcodec/movtextdec: Sanitize style entries
There are three types of style entries which are redundant:
a) Entries with length zero. They are already discarded.
b) Entries that are equivalent to the default style:
They can be safely discarded.
c) Entries that are equivalent to the immediately preceding style
if the start of the current style coincides with the end of the
preceding style. In this case the styles can be merged.

This commit implements discarding/merging in cases b) and c).
This fixes ticket #9548. In said ticket each packet contained
exactly one style entry that covered the complete packet with
the exception of the last character (probably created by a tool
that didn't know that the style's end is exclusive). Said style
coincided with the default style, leading to a superfluous reset,
which is now gone.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 21:00:52 +01:00
Andreas Rheinhardt
cce2765ce9 avcodec/movtextdec: Perform RGB->BGR color conversion early
Reduces the amount of conversions.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 21:00:41 +01:00
Andreas Rheinhardt
4b2bc0b8fe avcodec/movtextdec: Deduplicate parsing of StyleRecords
Both TextSampleEntry and TextSample can contain StyleRecords;
yet both the code as well as the structures for them were duplicated.
This commit changes this.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 21:00:33 +01:00
Andreas Rheinhardt
683bbb75db avcodec/movtextdec: Rename several structure elements
Giving elements of a structure called StyleBox names like
"style_start" or "style_end" is redundant, especially given
that the relevant variables are also called style.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 21:00:14 +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
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
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
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
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
Limin Wang
a7df966c82 avcodec/videotoolbox: fix use of unknown builtin '__builtin_available'
Old system is:
OSX version: 10.11.6
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-04 08:32:31 +08: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
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
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
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
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
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