1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

37 Commits

Author SHA1 Message Date
Michael Niedermayer
57f252b2d1 avcodec/cbs_h266_syntax_template: Check tile_y
Fixes: out of array access
Fixes: 67021/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4883576579489792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-23 22:33:21 +08:00
Frank Plowman
8b6219a99d lavc/vvc: Read subpic ID when only one subpicture is present
Previously, the following syntax elements were not read in the case
sps_num_subpics_minus is 0:
* sps_subpic_id_len_minus1
* sps_subpic_id_mapping_explicitly_signalled_flag
* sps_subpic_id_mapping_present_flag
* sps_subpic_id[i]
This was causing failures to decode bitstreams, for example the DVB's
"VVC HDR UHDTV1 OpenGOP 3840x2160 50fps HLG10 PiP" V&V bitstream.

Patch fixes this by moving the reads for these syntax elements out a
scope.

Signed-off-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-25 19:55:01 -03:00
Frank Plowman
53ab7ff67e lavc/vvc: Correct sps_num_subpics_minus1 minimum
The spec says "the value of sps_num_subpics_minus1 shall be in the
range of 0 to MaxSlicesPerAu − 1, inclusive."

Signed-off-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-25 18:52:18 -03:00
Andreas Rheinhardt
ab2173c0a5 avcodec/cbs_h2645: Avoid function pointer casts, fix UB
The SEI message read/write functions are called
via function pointers where the SEI message-specific
context is passed as void*. But the actual function
definitions use a pointer to their proper context
in place of void*, making the calls undefined behaviour.
Clang UBSan 17 warns about this.

This commit fixes this by adding wrapper functions
(created via macros) that have the right type that
call the actual functions. This reduced the number of failing
FATE tests with UBSan from 164 to 85 here.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-25 13:42:47 +01:00
Andreas Rheinhardt
484e7716bc avcodec/cbs_h266_syntax_template: Don't omit unused function parameter
The calls to the sei_decoded_picture_hash read and write functions
are performed with four pointer arguments; just because one
of them is unused by the callees does not mean that they
can be omitted: This is undefined behaviour.
(This was not recognized because the SEI_MESSAGE_RW macro
contains casts.)

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-25 02:19:18 +01:00
James Almer
cc774cd962 avcodec/cbs_h266_syntax_template: check aps_adaptation_parameter_set_id
"When aps_params_type is equal to ALF_APS or SCALING_APS, the value of aps_adaptation_parameter_set_id shall be
in the range of 0 to 7, inclusive.
When aps_params_type is equal to LMCS_APS, the value of aps_adaptation_parameter_set_id shall be in the range of 0
to 3, inclusive."

Fixes: out of array accesses
Fixes: 65932/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-4563412340244480

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-02-03 23:49:25 +08:00
Frank Plowman
36a986d9a1 lavc/vvc: Add check to num_multi_layer_olss
Check that vps_each_layer_is_an_ols_flag, which indicates that "at
least one OLS specified by the VPS contains more than one layer," is
set if num_multi_layer_olss is non-zero.

Fixes: 65160/clusterfuzz-testcase-minimized-ffmpeg_BSF_VVC_METADATA_fuzzer-4665241535119360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-01-30 09:24:03 -03:00
James Almer
66f028accb avcodec/cbs_h266: fix logic setting num_layers_in_ols when vps_ols_mode_idc is 2
The old code did not follow the syntax from the spec.

Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-01-29 20:45:31 -03:00
Nuo Mi
ce0c178a40
avcodec/cbs_h266: more restrictive check on pps_tile_idx_delta_val
Fixes: out of array access
Fixes: 62603/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5837632490569728

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-14 23:53:10 +01:00
Nuo Mi
09f783692e avcodec/cbs_h266: H266RawSliceHeader, expose curr_subpic_idx
Signed-off-by: James Almer <jamrial@gmail.com>
2023-11-11 11:53:21 -03:00
Andreas Rheinhardt
3e9b8d14e5 avcodec/cbs: Use RefStruct-API for unit content
This avoids allocations and error checks etc. as well
as duplicate pointer lists in the CodedBitstreamFooContexts.
It also avoids casting const away for use as opaque,
as the RefStruct API supports const opaques.

The fact that some of the units are not refcounted
(i.e. they are sometimes part of an encoding context
like VAAPIEncodeH264Context) meant that CodedBitstreamUnit
still contains two pointers, one to the content
and another ownership pointer, replacing the AVBufferRef* pointer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-07 22:35:05 +02:00
Nuo Mi
9ef20920ab
avcodec/cbs_h266_syntax_template: Check num_output_layers_in_ols
from the specification:
For each OLS, there shall be at least one layer that is an output layer. In other words, for any value of i in the range of 0
to TotalNumOlss − 1, inclusive, the value of NumOutputLayersInOls[ i ] shall be greater than or equal to 1

Fixes: index 257 out of bounds for type 'uint8_t [257]'
Fixes: 61160/clusterfuzz-testcase-minimized-ffmpeg_BSF_VVC_METADATA_fuzzer-6709397181825024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-19 21:28:40 +02:00
Nuo Mi
81a48d96e2 cbs_h266: slice_header, fix inference for pred_weight_table
Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-17 10:05:24 -03:00
Nuo Mi
763eb59187 cbs_h266: H266RawSliceHeader, expose NumRefIdxActive[]
Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-17 10:05:24 -03:00
Nuo Mi
088bda0f8e cbs_h266: H266RawPredWeightTable, expose num_weights_l0 and num_weights_l1
Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-17 10:05:24 -03:00
Nuo Mi
ea8571dc99 cbs_h266: H266RawSliceHeader, expose NumEntryPoints
Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-17 10:05:24 -03:00
Nuo Mi
ad8dc5e814 cbs_h266: fix slice_height_in_ctus for single slice tile
Failed clips:
TILE_E_Nokia_2.bit
TILE_D_Nokia_2.bit
LMCS_A_Dolby_3.bit

Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-17 10:05:24 -03:00
Nuo Mi
c837c055a2 cbs_h266: fix inference for xh_deblocking_filter_disabled_flag
if !ph_deblocking_params_present_flag is true, ph_deblocking_filter_disabled_flag infered from pps
if !sh_deblocking_params_present_flag is true, sh_deblocking_filter_disabled_flag infered from ph

Failed clips:
ENT444MAINTIER_C_Sony_3.bit
ENT444HIGHTIER_D_Sony_3.bit

Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-17 10:05:24 -03:00
Nuo Mi
d7f851b8c4 cbs_h266: fix inference for sh_alf_enabled_flag
if pps_alf_info_in_ph_flag is true
sh_alf_enabled_flag infered from ph

Failed clip:
LTRP_A_ERICSSON_3.bit

Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-17 10:05:24 -03:00
Nuo Mi
fe745c2007 cbs_h266: fix inference for sh_lmcs_used_flag and sh_explicit_scaling_list_used_flag
if sh_picture_header_in_slice_header_flag is true
sh_lmcs_used_flag and sh_explicit_scaling_list_used_flag are infered from ph

Failed clips:
LMCS: CLM_A_KDDI_2.bit STILL444_A_KDDI_1.bit
Scaling: SCALING_B_InterDigital_1.bit SCALING_A_InterDigital_1.bit

Signed-off-by: James Almer <jamrial@gmail.com>
2023-08-17 10:05:24 -03:00
James Almer
673862e947 avcodec/cbs_h266_syntax_template: add missing checks to subpic dimension values
Fixes: division by zero
Fixes: 60306/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5538913553612800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-25 18:06:57 -03:00
James Almer
3a30abd8ae avcodec/cbs_h266: use exp_tile_height when checking the allowed range for pps_num_exp_tile_rows_minus1
Fixes warnings about variable set but not used.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-07 11:56:37 -03:00
James Almer
0f008a0ffa avcodec/cbs_h266: fix use of uninitialized value
And fix the allowed range for ph_log2_diff_max_bt_min_qt_intra_slice_luma while at it.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-07 11:56:37 -03:00
James Almer
68e9d2835f avcodec/cbs_h266: add support for Adaptation parameter set NALU type
Reviewed-by: Nuo Mi <nuomi2021@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-06 11:43:13 -03:00
Frank Plowman
4b19690ff4 cbs_h266: add range extension support
example clips:
  * 12b444vvc1_E_Sony_2
  * 12b444Ietsrc_A_Kwai_2
  * 10b444P16_D_Sony_2
  * 12b444Iepp_A_Sharp_2
  * 12b444SPetsrc_B_Kwai_2

Co-authored-by: Nuo Mi <nuomi2021@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-06 09:05:13 -03:00
James Almer
8995e2f77e avcodec/cbs_h266: add support for Decoding capability information NALU type
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-05 18:18:33 -03:00
James Almer
6cb57bb457 avcodec/cbs_h266: add support for Operating point information NALU type
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-05 18:18:33 -03:00
James Almer
319a6b3ae2 avcodec/cbs_h266: store RowHeightVal and ColWidthVal in the context
Stop overwriting values from the bitstream arrays pps_tile_column_width_minus1
and pps_tile_row_height_minus1.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-05 18:18:33 -03:00
James Almer
ee09f20796 avcodec/cbs_h266: don't infer derived values
The macro is meant for coded values only.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-05 18:18:33 -03:00
Frank Plowman
a8178be3b3 cbs_h266: expand the bit depth range to 16 bits
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-05 08:46:50 -03:00
Nuo Mi
3720fa5fec cbs_h266: fix typo for ols_mode_idc == 2
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-02 09:37:16 -03:00
James Almer
a77f5019f5 avcodec/cbs_h266: store SubpicIdVal in the context
And use it to derive CurrSubpicIdx

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-01 19:41:12 -03:00
Andreas Rheinhardt
e7f152a8c2 avcodec/cbs_h266_syntax_template: Avoid shadowing
Reviewed-by: Nuo Mi <nuomi2021@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-07-01 17:38:54 +02:00
Andreas Rheinhardt
c732fdfa05 avcodec/cbs_h266_syntax_template: Don't use uninitialized value
Just a typo. Fixes a warning from Clang.

Reviewed-by: Nuo Mi <nuomi2021@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-07-01 17:37:55 +02:00
James Almer
96d6990517 avcodec/cbs_h266: use VVC_MAX_VPS_COUNT for range checks and array size
Signed-off-by: James Almer <jamrial@gmail.com>
2023-06-30 08:42:07 -03:00
James Almer
995976750a avcodec/cbs_h2645: fix parsing and storing Picture Header references in the context
Signed-off-by: James Almer <jamrial@gmail.com>
2023-06-30 08:26:38 -03:00
Nuo Mi
dfc62fd1c6 avcodec/cbs: add cbs implementation for H266/VVC
Add CodedBitstreamContext to parse VPS,SPS,PPS in VVC nal units.
Implement parsing and writing of SPS,PPS,VPS,PH,AUD,SEI and slices.
Add ff_cbs_type_h266 to cbs types tables and AV_CODEC_ID_H266
to cbs codec ids.

Co-authored-by: Thomas Siedel <thomas.ff@spin-digital.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-06-29 14:12:50 -03:00