* [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values
@ 2023-04-17 14:16 James Almer
2023-04-17 14:16 ` [FFmpeg-devel] [PATCH 2/3] avcodec/hevc_ps: fix storage type for some PPS multilayer extension fields James Almer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: James Almer @ 2023-04-17 14:16 UTC (permalink / raw)
To: ffmpeg-devel
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>
---
libavcodec/hevc_ps.c | 13 +++++++------
libavcodec/hevc_ps.h | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index be1d668c26..69d5504ce1 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1384,18 +1384,17 @@ static void colour_mapping_table(GetBitContext *gb, HEVCPPS *pps)
}
static int pps_multilayer_extension(GetBitContext *gb, AVCodecContext *avctx,
- HEVCPPS *pps, HEVCSPS *sps)
+ HEVCPPS *pps, HEVCSPS *sps, HEVCVPS *vps)
{
pps->poc_reset_info_present_flag = get_bits1(gb);
pps->pps_infer_scaling_list_flag = get_bits1(gb);
if (pps->pps_infer_scaling_list_flag)
pps->pps_scaling_list_ref_layer_id = get_bits(gb, 6);
- pps->num_ref_loc_offsets = get_ue_golomb_long(gb);
- if (pps->num_ref_loc_offsets > FF_ARRAY_ELEMS(pps->ref_loc_offset_layer_id)) {
- pps->num_ref_loc_offsets = 0;
+ pps->num_ref_loc_offsets = get_ue_golomb(gb);
+ if (pps->num_ref_loc_offsets > vps->vps_max_layers - 1)
return AVERROR_INVALIDDATA;
- }
+
for (int i = 0; i < pps->num_ref_loc_offsets; i++) {
pps->ref_loc_offset_layer_id[i] = get_bits(gb, 6);
pps->scaled_ref_layer_offset_present_flag[i] = get_bits1(gb);
@@ -1693,6 +1692,7 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
HEVCParamSets *ps)
{
HEVCSPS *sps = NULL;
+ HEVCVPS *vps = NULL;
int i, ret = 0;
unsigned int pps_id = 0;
ptrdiff_t nal_size;
@@ -1753,6 +1753,7 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
goto err;
}
sps = (HEVCSPS *)ps->sps_list[pps->sps_id]->data;
+ vps = (HEVCVPS *)ps->vps_list[sps->vps_id]->data;
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
@@ -1921,7 +1922,7 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
}
if (pps->pps_multilayer_extension_flag) {
- if ((ret = pps_multilayer_extension(gb, avctx, pps, sps)) < 0)
+ if ((ret = pps_multilayer_extension(gb, avctx, pps, sps, vps)) < 0)
goto err;
}
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 1f704108e3..184f87a001 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -314,7 +314,7 @@ typedef struct HEVCPPS {
uint8_t poc_reset_info_present_flag;
uint8_t pps_infer_scaling_list_flag;
uint8_t pps_scaling_list_ref_layer_id;
- uint16_t num_ref_loc_offsets;
+ uint8_t num_ref_loc_offsets;
uint8_t ref_loc_offset_layer_id[64];
uint8_t scaled_ref_layer_offset_present_flag[64];
int8_t scaled_ref_layer_left_offset[64];
--
2.40.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH 2/3] avcodec/hevc_ps: fix storage type for some PPS multilayer extension fields
2023-04-17 14:16 [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values James Almer
@ 2023-04-17 14:16 ` James Almer
2023-04-17 14:16 ` [FFmpeg-devel] [PATCH 3/3] avcodec/hevc_ps: use get_ue_golomb() " James Almer
2023-04-20 1:02 ` [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values James Almer
2 siblings, 0 replies; 4+ messages in thread
From: James Almer @ 2023-04-17 14:16 UTC (permalink / raw)
To: ffmpeg-devel
The spec states that the range of values for them is −2^14 to 2^14 − 1, inclusive.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc_ps.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 184f87a001..5a80cf5d80 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -317,15 +317,15 @@ typedef struct HEVCPPS {
uint8_t num_ref_loc_offsets;
uint8_t ref_loc_offset_layer_id[64];
uint8_t scaled_ref_layer_offset_present_flag[64];
- int8_t scaled_ref_layer_left_offset[64];
- int8_t scaled_ref_layer_top_offset[64];
- int8_t scaled_ref_layer_right_offset[64];
- int8_t scaled_ref_layer_bottom_offset[64];
+ int16_t scaled_ref_layer_left_offset[64];
+ int16_t scaled_ref_layer_top_offset[64];
+ int16_t scaled_ref_layer_right_offset[64];
+ int16_t scaled_ref_layer_bottom_offset[64];
uint8_t ref_region_offset_present_flag[64];
- int8_t ref_region_left_offset[64];
- int8_t ref_region_top_offset[64];
- int8_t ref_region_right_offset[64];
- int8_t ref_region_bottom_offset[64];
+ int16_t ref_region_left_offset[64];
+ int16_t ref_region_top_offset[64];
+ int16_t ref_region_right_offset[64];
+ int16_t ref_region_bottom_offset[64];
uint8_t resample_phase_set_present_flag[64];
uint16_t phase_hor_luma[64];
uint16_t phase_ver_luma[64];
--
2.40.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* [FFmpeg-devel] [PATCH 3/3] avcodec/hevc_ps: use get_ue_golomb() for some PPS multilayer extension fields
2023-04-17 14:16 [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values James Almer
2023-04-17 14:16 ` [FFmpeg-devel] [PATCH 2/3] avcodec/hevc_ps: fix storage type for some PPS multilayer extension fields James Almer
@ 2023-04-17 14:16 ` James Almer
2023-04-20 1:02 ` [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values James Almer
2 siblings, 0 replies; 4+ messages in thread
From: James Almer @ 2023-04-17 14:16 UTC (permalink / raw)
To: ffmpeg-devel
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>
---
libavcodec/hevc_ps.c | 27 +++++++++++++--------------
libavcodec/hevc_ps.h | 18 +++++++++---------
2 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 69d5504ce1..7401ea23f5 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1324,7 +1324,7 @@ static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int inp_dept
int idx_y, int idx_cb, int idx_cr, int inp_length)
{
unsigned int split_octant_flag, part_num_y, coded_res_flag, res_coeff_q, res_coeff_r;
- int bit_depth_cm_input_y, bit_depth_cm_output_y, cm_res_bits;
+ int cm_res_bits;
part_num_y = 1 << pps->cm_y_part_num_log2;
@@ -1346,10 +1346,9 @@ static void colour_mapping_octants(GetBitContext *gb, HEVCPPS *pps, int inp_dept
if (coded_res_flag)
for (int c = 0; c < 3; c++) {
res_coeff_q = get_ue_golomb_long(gb);
- bit_depth_cm_input_y = 8 + pps->luma_bit_depth_cm_input_minus8;
- bit_depth_cm_output_y = 8 + pps->luma_bit_depth_cm_output_minus8;
- cm_res_bits = FFMAX(0, 10 + bit_depth_cm_input_y - bit_depth_cm_output_y -
- pps->cm_res_quant_bits - (pps->cm_delta_flc_bits_minus1 + 1));
+ cm_res_bits = FFMAX(0, 10 + pps->luma_bit_depth_cm_input -
+ pps->luma_bit_depth_cm_output -
+ pps->cm_res_quant_bits - pps->cm_delta_flc_bits);
res_coeff_r = cm_res_bits ? get_bits(gb, cm_res_bits) : 0;
if (res_coeff_q || res_coeff_r)
skip_bits1(gb);
@@ -1367,13 +1366,13 @@ static void colour_mapping_table(GetBitContext *gb, HEVCPPS *pps)
pps->cm_octant_depth = get_bits(gb, 2);
pps->cm_y_part_num_log2 = get_bits(gb, 2);
- pps->luma_bit_depth_cm_input_minus8 = get_ue_golomb_long(gb);
- pps->chroma_bit_depth_cm_input_minus8 = get_ue_golomb_long(gb);
- pps->luma_bit_depth_cm_output_minus8 = get_ue_golomb_long(gb);
- pps->chroma_bit_depth_cm_output_minus8 = get_ue_golomb_long(gb);
+ pps->luma_bit_depth_cm_input = get_ue_golomb(gb) + 8;
+ pps->chroma_bit_depth_cm_input = get_ue_golomb(gb) + 8;
+ pps->luma_bit_depth_cm_output = get_ue_golomb(gb) + 8;
+ pps->chroma_bit_depth_cm_output = get_ue_golomb(gb) + 8;
pps->cm_res_quant_bits = get_bits(gb, 2);
- pps->cm_delta_flc_bits_minus1 = get_bits(gb, 2);
+ pps->cm_delta_flc_bits = get_bits(gb, 2) + 1;
if (pps->cm_octant_depth == 1) {
pps->cm_adapt_threshold_u_delta = get_se_golomb_long(gb);
@@ -1415,10 +1414,10 @@ static int pps_multilayer_extension(GetBitContext *gb, AVCodecContext *avctx,
pps->resample_phase_set_present_flag[i] = get_bits1(gb);
if (pps->resample_phase_set_present_flag[i]) {
- pps->phase_hor_luma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_long(gb);
- pps->phase_ver_luma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_long(gb);
- pps->phase_hor_chroma_plus8[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_long(gb);
- pps->phase_ver_chroma_plus8[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_long(gb);
+ pps->phase_hor_luma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_31(gb);
+ pps->phase_ver_luma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb_31(gb);
+ pps->phase_hor_chroma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb(gb) - 8;
+ pps->phase_ver_chroma[pps->ref_loc_offset_layer_id[i]] = get_ue_golomb(gb) - 8;
}
}
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 5a80cf5d80..0c9c278662 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -327,21 +327,21 @@ typedef struct HEVCPPS {
int16_t ref_region_right_offset[64];
int16_t ref_region_bottom_offset[64];
uint8_t resample_phase_set_present_flag[64];
- uint16_t phase_hor_luma[64];
- uint16_t phase_ver_luma[64];
- uint16_t phase_hor_chroma_plus8[64];
- uint16_t phase_ver_chroma_plus8[64];
+ uint8_t phase_hor_luma[64];
+ uint8_t phase_ver_luma[64];
+ int8_t phase_hor_chroma[64];
+ int8_t phase_ver_chroma[64];
uint8_t colour_mapping_enabled_flag;
uint16_t num_cm_ref_layers_minus1;
uint8_t cm_ref_layer_id[63];
uint8_t cm_octant_depth;
uint8_t cm_y_part_num_log2;
- uint16_t luma_bit_depth_cm_input_minus8;
- uint16_t chroma_bit_depth_cm_input_minus8;
- uint16_t luma_bit_depth_cm_output_minus8;
- uint16_t chroma_bit_depth_cm_output_minus8;
+ uint8_t luma_bit_depth_cm_input;
+ uint8_t chroma_bit_depth_cm_input;
+ uint8_t luma_bit_depth_cm_output;
+ uint8_t chroma_bit_depth_cm_output;
uint8_t cm_res_quant_bits;
- uint8_t cm_delta_flc_bits_minus1;
+ uint8_t cm_delta_flc_bits;
int8_t cm_adapt_threshold_u_delta;
int8_t cm_adapt_threshold_v_delta;
--
2.40.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values
2023-04-17 14:16 [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values James Almer
2023-04-17 14:16 ` [FFmpeg-devel] [PATCH 2/3] avcodec/hevc_ps: fix storage type for some PPS multilayer extension fields James Almer
2023-04-17 14:16 ` [FFmpeg-devel] [PATCH 3/3] avcodec/hevc_ps: use get_ue_golomb() " James Almer
@ 2023-04-20 1:02 ` James Almer
2 siblings, 0 replies; 4+ messages in thread
From: James Almer @ 2023-04-20 1:02 UTC (permalink / raw)
To: ffmpeg-devel
On 4/17/2023 11:16 AM, James Almer wrote:
> 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>
> ---
> libavcodec/hevc_ps.c | 13 +++++++------
> libavcodec/hevc_ps.h | 2 +-
> 2 files changed, 8 insertions(+), 7 deletions(-)
Will apply set.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-20 1:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-17 14:16 [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values James Almer
2023-04-17 14:16 ` [FFmpeg-devel] [PATCH 2/3] avcodec/hevc_ps: fix storage type for some PPS multilayer extension fields James Almer
2023-04-17 14:16 ` [FFmpeg-devel] [PATCH 3/3] avcodec/hevc_ps: use get_ue_golomb() " James Almer
2023-04-20 1:02 ` [FFmpeg-devel] [PATCH 1/3] avcodec/hevc_ps: further constrain allowed num_ref_loc_offsets values James Almer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git