1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-24 13:56:33 +02:00

217 Commits

Author SHA1 Message Date
Andreas Rheinhardt
2c38ca3d37 avcodec/hevc_ps: Fix UB 1 << 31
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-02 05:15:00 +02:00
Anton Khirnov
63a96dbcce lavc/hevc_ps: compactify ShortTermRPS
Do not use larger fields than needed, use size-1 bitfields for flags.

Reduces sizeof(HEVCSPS) by 1280 bytes.
2024-05-31 19:26:06 +02:00
Anton Khirnov
9127819d51 lavc/hevc_ps: reduce the size of ShortTermRPS.used
It is currently an array of 32 uint8_t, each storing a single flag. A
single uint32_t is sufficient.

Reduces sizeof(HEVCSPS) by 1792 bytes.
2024-05-31 19:26:06 +02:00
Anton Khirnov
d893667867 lavc/hevc_ps: do not store delta_poc_s[01] in ShortTermRPS
They are only used in vulkan_hevc and are not actually needed, as they
can be computed from delta_poc.

Reduces sizeof(HEVCSPS) by 16kB.

Also, fix a typo (s0->s1) in the code being touched.
2024-05-31 19:26:06 +02:00
Anton Khirnov
4264e4056c lavc/hevc_ps: fix variable signedness in ff_hevc_decode_short_term_rps()
It is actually supposed to go negative in the loop over num_negative
pics, but underflow does not break anything as the result is then
assigned to a signed int.
2024-05-31 19:26:06 +02:00
Anton Khirnov
6fed1841a1 lavc/hevc_ps/HEVCSPS: change flags into uint8_t
Reduces sizeof(HEVCSPS) by 64 bytes.

Also improve flag names: drop redundant suffixes and prefixes, and
consistently use disabled/enabled.
2024-05-31 19:26:06 +02:00
Anton Khirnov
bd1a06dc43 lavc/hevc_ps: reduce the size of used_by_curr_pic_lt_sps_flag
It is currently an array of 32 uint8_t, each storing a single flag. A
single uint32_t is sufficient.
2024-05-31 19:26:06 +02:00
Michael Niedermayer
d58037c18e
avcodec/hevc_ps: --typo
Fixes: null pointer dereference
Fixes: 67737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4858162608930816

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-03 00:44:37 +02:00
Andreas Rheinhardt
790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
James Almer
547c920193 avcodec/hevc_ps: don't use a fixed sized buffer for parameter set raw data
Allocate it instead, and use it to compare sets instead of the parsed struct.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-29 15:34:21 -03:00
Tong Wu
6bf17136a2 avcodec/hevc_ps: fix the problem of memcmp losing effectiveness
HEVCHdrParams* receives a pointer which points to a dynamically
allocated memory block. It causes the memcmp always returning 1.
Add a function to do the comparision. A condition is also added to
avoid malloc(0).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Tong Wu <tong1.wu@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-29 12:35:54 -03:00
James Almer
535b1a93f5 avcodec/hevc_ps: fix setting HEVCHdrParams fields
These were defined in a way compatible with the Vulkan HEVC acceleration, which
expects bitmasks, yet the fields were being overwritting on each loop with the
latest read value.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-21 11:31:32 -03:00
James Almer
456c8ebe7c avcodec/hevc_ps: allocate only the required HEVCHdrParams within a VPS
Fixes: timeout
Fixes: 64033/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5332101272305664

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-21 09:59:20 -03:00
Michael Niedermayer
5feceed008
avcodec/hevc_ps: Check cpb_cnt_minus1 before storing it
Fixes: index 32 out of bounds for type 'uint32_t [32]'
Fixes: 63003/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4685160840560640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-19 20:46:55 +02:00
Andreas Rheinhardt
2db94a96c8 avcodec/hevc_ps: Use RefStruct API for parameter sets
Avoids allocations and error checks for these allocations;
e.g. syncing buffers across threads can't fail any more
and needn't be checked. It also gets rid of casts and
indirections.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-07 22:34:28 +02:00
llyyr
ded4478b8b hevc_ps: fix fixed_rate check
Fixes: fc429d785e9e24c5520ce716d4bc3b5547e581eb

Since fc429d785e9e24c5520ce716d4bc3b5547e581eb splits the fixed_rate
flag into general and within_cvs, check for both.
2023-09-10 20:05:07 +01:00
llyyr
06241c3154 hevc_ps: fix cpb_cnt_minus1 initialization
Fixes: fc429d785e9e24c5520ce716d4bc3b5547e581eb

cpb_cnt used to be initialized to 1 before
fc429d785e9e24c5520ce716d4bc3b5547e581eb so cpb_cnt_minus1 should be
initialized to 0.

Also add +1 to the decode_sublayer_hrd call to account for the change to
the offset
2023-09-10 20:04:56 +01:00
Andreas Rheinhardt
8238bc0b5e avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* defines
These defines are also used in other contexts than just AVCodecContext
ones, e.g. in libavformat. Furthermore, given that these defines are
public, the AV-prefix is the right one, so deprecate (and not just move)
the FF-macros.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:39:02 +02:00
Andreas Rheinhardt
f6dc85ae16 avcodec/hevc_ps: Improve PPS SCC extension bit depth check
From the spec: "It is a requirement of bitstream conformance that
the value of luma_bit_depth_entry_minus8 shall be equal to
the value of bit_depth_luma_minus8"; similarly for chroma.

Also fixes Coverity ticket #1529226 (complaining about the fact
that chroma_bit_depth_entry is checked twice).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-07-10 12:31:06 +02:00
Andreas Rheinhardt
686156f366 avcodec/hevc_ps: Constify VPS, SPS pointers when parsing PPS
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-06-30 17:47:53 +02:00
James Almer
246bec23a9 avcodec/hevc_ps: remove a unused variable
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-28 23:24:51 -03:00
Lynne
21719c29a2
hevc_ps: expose sps_extension_present_flag 2023-05-29 00:41:35 +02:00
Lynne
8b2d46ee3d
hevc_ps: expose conformance_window_flag 2023-05-29 00:41:34 +02:00
Lynne
cc5fab5c48
hevc_ps: expose sublayer_ordering_info_flag 2023-05-29 00:41:34 +02:00
Lynne
32fcb17e42
hevc_ps: expose vui_present flag 2023-05-29 00:41:33 +02:00
Lynne
f58db8e534
hevc_ps: expose rps fields 2023-05-29 00:41:33 +02:00
Lynne
abdd87d44e
hevc_ps: expose log2_diff_max_min_transform_block_size 2023-05-29 00:41:33 +02:00
Lynne
4e1f3ab184
hevc_ps: expose pps_extension_present_flag 2023-05-29 00:41:32 +02:00
Lynne
d0b02c3aff
hevc_ps: expose vps_id 2023-05-29 00:41:31 +02:00
Lynne
3bc866159c
hevc_ps: expose pps_id 2023-05-29 00:41:31 +02:00
Lynne
fc429d785e
hevc_ps: expose SPS and VPS headers 2023-05-29 00:41:31 +02:00
Clement Lecigne
96c30affba avcodec/hevc_ps: add proper bound checks around cm_ref_layer_id in colour_mapping_table.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-17 17:51:36 -03:00
James Almer
e7c690a046 avcodec/hevc_ps: check for out of range bitdepth in SPS
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-30 20:41:55 -03:00
Michael Niedermayer
bf3f91c425
avcodec/hevc_ps: Avoid signed overflow before check on QP
Fixes: signed integer overflow: -2147483648 - 5 cannot be represented in type 'int'
Fixes: 58066/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5312995835379712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-01 00:48:32 +02:00
Michael Niedermayer
cb8180aa66
avcodec/hevc_ps: Check depth to be within 8 to 16
Fixes: assertion failure in bitreader
Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-627318668066816

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-01 00:48:32 +02:00
James Almer
45fc89bb14 avcodec/hevc_ps: use get_ue_golomb() for some SPS Screen Content Coding extension fields
Also remove the _minus1 part of the name to be in line with the rest of the
decoder.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-30 18:29:34 -03:00
James Almer
41dd50ad0d avcodec/hevc_ps: use get_{ue,se}_golomb() for some PPS Range extension fields
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-28 20:15:57 -03:00
James Almer
df3fd3accd avcodec/hevc_ps: use get_ue_golomb() for some PPS Screen Content Coding extension fields
Also remove the _minus8 part of the name to be in line with the rest of the
decoder, and fix the storage type for pps_palette_predictor_initializer,
to support hbd values.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-28 20:15:57 -03:00
James Almer
95a78c08c1 avcodec/hevcdec: further constrain some slice header field values
num_ref_idx_l0_active_minus1, num_ref_idx_l1_active_minus1,
num_ref_idx_l0_default_active_minus1, and num_ref_idx_l1_default_active_minus1
are all in the range 0 to 14, inclusive.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-22 11:15:06 -03:00
James Almer
0760528af2 avcodec/hevc_ps: use get_ue_golomb() for some PPS multilayer extension fields
Also remove the _plus* and _minus* parts of some of these to be in line with
other similar fields in the decoder.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-20 09:53:30 -03:00
James Almer
7fece7676b avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values
The spec says: "The value of num_ref_loc_offsets shall be in the range of 0 to
vps_max_layers_minus1, inclusive".

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-20 09:53:30 -03:00
Michael Niedermayer
80ac1fd148
avcodec/hevc_ps: Check num_ref_loc_offsets
Fixes: Writing arbitrarily over the array end
Fixes: 57812/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4536557859373056

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-04-14 17:56:44 +02:00
Linjie Fu
56e3cd23d4 lavc/hevc_ps: Add SPS/PPS parse support for HEVC extension syntax
1. Add extension syntax according to 7.3.2.2.3/7.3.2.3.3 in T-REC-H.265-201911.
2. Keep using parsed PPS when bitstream overread for compatibility. For
example, the clip PS_A_VIDYO_3.bit in FATE test has incomplete extension
syntax which will be overread and un-decodable if without this change.
3. Format brace in pps_range_extensions().

Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2023-02-27 13:42:06 +08:00
Linjie Fu
f459377543 lavc/avcodec: Add HEVC Screen Content Coding Extensions profile
Described in HEVC spec A.3.7. Bump minor version and add APIchanges
entry for new added profile.

Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2023-02-27 13:42:06 +08:00
Andreas Rheinhardt
8bf18018a3 avcodec/(h264|hevc)_ps: Factor common VUI code out
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:00:41 +01:00
Andreas Rheinhardt
881e8bcc51 avcodec/h264data: Deduplicate H.26[45] aspect ratio table
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:00:41 +01:00
Andreas Rheinhardt
12392ffee5 avcodec/hevc_ps: Fix wrong copyright years
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 20:10:11 +02:00
Andreas Rheinhardt
bdaff63723 avcodec/hevc_ps: Remove unused-but-set variable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-03 11:41:23 +02:00
Andreas Rheinhardt
48a0cd06e3 avcodec/hevc_ps: Don't use show_bits_long() unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-24 18:28:36 +02:00
Michael Niedermayer
ad20a4f92b avcodec/hevc_ps: Change scaling_list_dc_coef to 8 bit
Suggested-by: James
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-12-19 20:07:56 +01:00