Commit Graph

45682 Commits

Author SHA1 Message Date
Andreas Rheinhardt cd03a180cb avcodec/mjpegdec: Use AVCodecInternal.in_pkt for buffer packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 17:46:55 +01:00
Andreas Rheinhardt 7c5ee237be avcodec/libdav1d: Use av_memdup() where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 17:38:22 +01:00
Andreas Rheinhardt 31d0487ba2 avcodec/libdav1d: Use AVCodecInternal.in_pkt instead of stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 17:34:33 +01:00
Andreas Rheinhardt 776e9f9e2a avcodec/libdav1d: Don't leak side-data-only packets
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 17:32:52 +01:00
Andreas Rheinhardt ba91b8b685 avcodec/cuviddec: Use AVCodecInternal.in_pkt instead of stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 17:27:13 +01:00
Andreas Rheinhardt 9b851c4b92 avcodec/crystalhd: Use AVCodecInternal.in_pkt instead of stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 17:26:41 +01:00
Andreas Rheinhardt e353300622 avcodec/binkaudio: Use AVCodecInternal.in_pkt for buffer packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 17:26:09 +01:00
Andreas Rheinhardt ffdda740fe avcodec/internal: Allow receive_frame codecs to use decode_simple pkt
Decoders implementing the receive_frame API currently mostly use
stack packets to temporarily hold the packet they receive from
ff_decode_get_packet(). This role directly parallels the role of
in_pkt, the spare packet used in decode_simple_internal for the
decoders implementing the traditional decoding API. Said packet
is unused by the generic code for the decoders implementing the
receive_frame API, so allow them to use it to fulfill the function
it already fulfills for the traditional API for both APIs.

There is only one caveat in this: The packet is automatically
unreferenced in avcodec_flush_buffers(). But this is actually
positive as it means the decoders don't have to do this themselves
(in case the packet is preserved between receive_frame calls).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 17:12:58 +01:00
James Almer f6ab103bb5 avcodec/libx264: fix sei payload leaks on error
Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-04 22:59:55 -03:00
James Almer 28fac45bde avcodec/libaomdec: use intermediate arrays for plane pointers and strides
Fixes -Wstringop-overflow warnings with libaom >= 2.0.0, where the unused alpha
plane was removed from aom_image.

Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-01 14:58:36 -03:00
Matt Oliver d92fdc7144 libaom: Dont use aom_codec_av1_dx_algo.
This fixes linking errors where variables cannot be correctly linked in from an external shared library such as with msvc (requires dllimport which is not used by libaom). Instead just call the function that returns the same variable.

Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2021-10-30 13:37:45 +11:00
Pekka Väänänen 947d0ce0ea avcodec/vqavideo: Decode 15-bit VQA3 files
Adds support for 15-bit VQA3 videos used in Westwood Studios' games.

Signed-off-by: Pekka Väänänen <pekka.vaananen@iki.fi>
2021-10-28 22:24:54 +02:00
Andreas Rheinhardt e84c83ef98 avcodec/binkaudio: Properly flush the decoder
The packets delivered to this decoder are often decoded to more than
one frame and if the internal buffer packet is not unreferenced,
the decoder will still output frames derived from the old packet (from
before the flush).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-28 10:30:18 +02:00
Andreas Rheinhardt f8790ad002 avcodec/binkaudio: Remove AV_CODEC_CAP_DELAY
This decoder may output multiple AVFrames for every AVPacket
passed to it, but after it has returned AVERROR(EAGAIN),
it is completely drained and there is no reason to flush it
at the end with a NULL packet. Furthermore, there is also no
delay in the common sense of the word.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-28 10:30:18 +02:00
Michael Niedermayer 70024b6b47 avcodec/flac_parser: Consider AV_INPUT_BUFFER_PADDING_SIZE
Fixes: out if array read
Fixes: 40109/clusterfuzz-testcase-minimized-ffmpeg_dem_FLAC_fuzzer-4805686811295744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Mattias Wadman <mattias.wadman@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-10-22 17:34:05 +02:00
Michael Niedermayer f24028c798 avcodec/ttadsp: Fix integer overflows in tta_filter_process_c()
Fixes: signed integer overflow: 822841647 + 1647055738 cannot be represented in type 'int'
Fixes: 39935/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-4592657142251520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-10-21 14:17:12 +02:00
Limin Wang cd38fbf4f7 avcodec/atsc_a53: use AVERROR_INVALIDDATA
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-20 22:47:53 +08:00
Limin Wang 0feb7c8601 avcodec/hevc_sei: remove the duplicate check
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-20 22:47:47 +08:00
James Almer 1e22ad2ada avcodec/libx264: move sei_data_size out of the for loop
Otherwise its value will be reset on each iteration.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-10-20 00:21:44 -03:00
Limin Wang ff7ed0b006 avcodec/extract_extradata_bsf: add support for AVS3
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-19 20:15:48 +08:00
James Almer 66f8055c89 avcodec/libx264: copy unregistered data SEI messages to the input x264 picture
Fixes undefined behavior.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-10-18 21:07:11 -03:00
Mattias Wadman 49597300e8 libavcodec/flac_parser: Validate subframe zero bit and type
Reduces the risk of finding false frames that happens to have valid values and CRC.

Fixes ticket #9185 ffmpeg flac decoder incorrectly finds junk frame
https://trac.ffmpeg.org/ticket/9185
2021-10-18 22:01:11 +02:00
James Almer 762e18da3f avcodec/h264_picture: don't assume Film Grain Params side data will be present
If a decoding error happens before frame side data is allocated, this assert may be
triggered. And since applying film grain is not enforced (we just warn it wasn't
applied and move on), we can just do that in such scenarios.

Fixes: Assertion failure
Fixes: clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5528650032742400

Signed-off-by: James Almer <jamrial@gmail.com>
2021-10-18 10:18:18 -03:00
Brad Hards 7c08cad280 libavcodec/libx264: add user data unregistered SEI encoding
MISB ST 0604 and ST 2101 require user data unregistered SEI messages
(precision timestamps and sensor identifiers) to be included. That
currently isn't supported for libx264. This patch adds support
for user data unregistered SEI messages in accordance with ISO/IEC
14496-10:2020(E) section D.1.7 (syntax) and D.2.7 (semantics).

This code is based on a similar change for libx265 (commit
1f58503013).

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-10-18 13:13:53 +01:00
Martin Storsjö fd3bd5c492 aarch64: h264qpel: Do vertical filtering without transposing
This gives rather big speedups on these functions:

Before:
put_h264_qpel_8_mc01_8_neon:     241.0   131.5   138.7
put_h264_qpel_8_mc02_8_neon:     214.7   121.2   127.5
put_h264_qpel_8_mc03_8_neon:     242.5   131.2   135.7
put_h264_qpel_8_mc11_8_neon:     421.2   218.7   251.0
put_h264_qpel_8_mc12_8_neon:     878.0   509.5   537.5
put_h264_qpel_8_mc13_8_neon:     423.7   217.0   252.0
put_h264_qpel_8_mc21_8_neon:     858.2   479.5   514.0
put_h264_qpel_8_mc22_8_neon:     649.7   385.2   403.0
put_h264_qpel_8_mc23_8_neon:     860.2   476.5   517.7
put_h264_qpel_8_mc31_8_neon:     437.2   219.5   252.5
put_h264_qpel_8_mc32_8_neon:     892.5   510.5   546.0
put_h264_qpel_8_mc33_8_neon:     438.2   218.5   257.0
put_h264_qpel_16_mc01_8_neon:    944.2   509.7   546.7
put_h264_qpel_16_mc02_8_neon:    878.7   469.5   509.7
put_h264_qpel_16_mc03_8_neon:    945.7   510.7   557.0
put_h264_qpel_16_mc11_8_neon:   1663.2   858.5   979.5
put_h264_qpel_16_mc12_8_neon:   3510.2  2027.7  2112.7
put_h264_qpel_16_mc13_8_neon:   1664.7   857.5   980.5
put_h264_qpel_16_mc21_8_neon:   3366.2  1928.5  2030.5
put_h264_qpel_16_mc22_8_neon:   2584.7  1514.7  1590.2
put_h264_qpel_16_mc23_8_neon:   3367.7  1927.7  2035.0
put_h264_qpel_16_mc31_8_neon:   1716.7   849.7   997.0
put_h264_qpel_16_mc32_8_neon:   3564.0  2044.2  3835.2
put_h264_qpel_16_mc33_8_neon:   1717.7   863.0   989.5

After:
put_h264_qpel_8_mc01_8_neon:     136.0    73.7    76.0
put_h264_qpel_8_mc02_8_neon:     108.7    65.0    64.0
put_h264_qpel_8_mc03_8_neon:     137.5    72.7    73.0
put_h264_qpel_8_mc11_8_neon:     316.2   159.0   188.5
put_h264_qpel_8_mc12_8_neon:     653.0   375.5   384.7
put_h264_qpel_8_mc13_8_neon:     318.7   165.5   189.5
put_h264_qpel_8_mc21_8_neon:     739.2   385.7   432.5
put_h264_qpel_8_mc22_8_neon:     530.7   295.5   309.5
put_h264_qpel_8_mc23_8_neon:     741.2   393.7   421.0
put_h264_qpel_8_mc31_8_neon:     332.2   162.5   190.0
put_h264_qpel_8_mc32_8_neon:     667.5   378.2   390.5
put_h264_qpel_8_mc33_8_neon:     332.7   166.5   195.5
put_h264_qpel_16_mc01_8_neon:    524.2   285.2   294.0
put_h264_qpel_16_mc02_8_neon:    454.7   252.2   250.2
put_h264_qpel_16_mc03_8_neon:    525.7   286.0   283.0
put_h264_qpel_16_mc11_8_neon:   1243.2   630.7   726.7
put_h264_qpel_16_mc12_8_neon:   2610.2  1479.7  1481.2
put_h264_qpel_16_mc13_8_neon:   1250.5   631.7   727.7
put_h264_qpel_16_mc21_8_neon:   2890.2  1571.2  1679.7
put_h264_qpel_16_mc22_8_neon:   2108.7  1177.5  1223.5
put_h264_qpel_16_mc23_8_neon:   2891.7  1578.7  1667.7
put_h264_qpel_16_mc31_8_neon:   1296.7   630.5   752.5
put_h264_qpel_16_mc32_8_neon:   2664.0  1483.2  1503.5
put_h264_qpel_16_mc33_8_neon:   1297.7   632.5   747.2

I.e. overall a 20%-60% reduction in runtime of these
functions.

Signed-off-by: Martin Storsjö <martin@martin.st>
2021-10-18 14:27:58 +03:00
Martin Storsjö 2d5a7f6d00 arm/aarch64: Improve scheduling in the avg form of h264_qpel
Don't use the loaded registers directly, avoiding stalls on in
order cores. Use vrhadd.u8 with q registers where easily possible.

Signed-off-by: Martin Storsjö <martin@martin.st>
2021-10-18 14:27:36 +03:00
Michael Niedermayer 85c169f6a6 avcodec/speexdec: Seed should be unsigned otherwise the operations done on it are undefined
Fixes: signed integer overflow: 1664525000 + 1013904223 cannot be represented in type 'int'
Fixes: 39865/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-4979694508834816

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-10-17 22:20:07 +02:00
Limin Wang 77970abb71 avcodec/hevc_filter: Correct indention
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:57:53 +08:00
Limin Wang 5a91850b61 avcodec/hevc_filter: remove unneeded headers
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:57:47 +08:00
Limin Wang 06548e6045 avcodec/hevcdec: remove unused code
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:57:43 +08:00
Fei Wang 84c73102d9 avcodec/av1_vaapi: improve decode quality
- quantizer delta and matrix level specific.
- support loop filter delta.
- support use superres.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:44 -03:00
Fei Wang dc94f2eaaf avcodec/av1_vaapi: enable segmentation features
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:44 -03:00
Fei Wang 7871144cf8 avcodec/av1_vaapi: setting 2 output surface for film grain
VAAPI needs 2 output surface for film grain frame. One used for
reference and the other used for applying film grain and pushing
to downstream.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:44 -03:00
Fei Wang 53403158cc avcodec/vaapi: increase av1 decode pool size
For film grain clip, vaapi_av1 decoder will cache additional 8
surfaces that will be used to store frames which apply film grain.
So increase the pool size by plus 8 to avoid leak of surface.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:44 -03:00
Tong Wu 4e7a7d75e3 avcodec/dxva2_av1: fix global motion params
Defined in spec 5.9.24/5.9.25. Since function void
global_motion_params(AV1DecContext *s) already updates
gm type/params, the wminvalid parameter only need to get
the value from cur_frame.gm_invalid.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
2021-10-16 19:00:44 -03:00
Fei Wang 0d0ea70e7b avcodec/av1_vaapi: add gm params valid check
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:44 -03:00
Fei Wang de7475b111 avcodec/av1dec: support setup shear process
Defined in spec 7.11.3.6/7.11.3.7.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:44 -03:00
Fei Wang 75de7fe262 avcodec/av1: extend some definitions in spec section 3
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:44 -03:00
Fei Wang e7ff5722b1 cbs_av1: fix incorrect data type
Since order_hint_bits_minus_1 range is 0~7, cur_frame_hint can be
most 128. And similar return value for cbs_av1_get_relative_dist.
So if plus them and use int8_t for the result may lose its precision.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2021-10-16 19:00:43 -03:00
Niklas Haas 3cc3f5de2a avcodec/hevcdec: apply H.274 film grain
Similar in spirit and design to 66845cffc3, but slightly simpler due
to the lack of interlaced frames in HEVC. See that commit for more
details.

For the seed value, since no specification for this appears to exist, I
semi-arbitrarily decided to base it off the POC id alone, since there's
no analog of the idr_pic_id in HEVC's I-frames. This design is stable
across remuxes and seeks, but changes for adjacent frames with a period
that's typically long enough not to be noticeable, which makes it
satisfy all of the requirements that a film grain seed should have.

Tested with and without threading, using a patch to insert film grain
metadata artificially (for lack of real files containing film grain).
2021-10-15 11:55:45 -03:00
Limin Wang 871fee82e1 avcodec/videotoolboxenc: use goto end for memory cleanup
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-13 20:12:30 +08:00
Limin Wang f25871d790 avcodec/avs3_parser: Fix usage of init_get_bits() and use init_get_bits8()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-13 20:12:30 +08:00
Limin Wang ba03e4ed33 avcodec/audiotoolboxdec: Fix usage of init_get_bits() and use init_get_bits8()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-13 20:12:30 +08:00
Nachiket Tarate 343c03c61c libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header
These will be used by HLS demuxer in case of sample decryption.

Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2021-10-13 11:23:37 +08:00
Michael Niedermayer 1902a60dda avcodec/gemdec: Use ff_set_dimensions()
Fixes: OOM
Fixes: 39798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GEM_fuzzer-5611636853964800

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-10-11 20:07:35 +02:00
Michael Niedermayer 17e36fac0b avcodec/utils: Ensure 8x8 alignment for ARGO in avcodec_align_dimensions2()
Fixes: out of array access
Fixes: 39736/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-4820016722214912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-10-11 20:07:35 +02:00
Limin Wang 617cf44c8c avcodec/bitpacked: check av_buffer_ref result
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-11 23:27:08 +08:00
Zhao Zhili a742ba60f1 libavcodec/speexdec: fix memleak in error path
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-11 15:24:41 +02:00
Paul B Mahol 5133f4c2c1 avcodec/lagarith: return early on error
Also return proper error values.
2021-10-10 22:05:54 +02:00
Paul B Mahol 148ada5577 avcodec: add native Speex decoder 2021-10-10 17:44:41 +02:00