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>
pull/389/head
James Almer 2 years ago
parent 0275d99427
commit 45fc89bb14
  1. 21
      libavcodec/hevc_ps.c
  2. 2
      libavcodec/hevc_ps.h
  3. 2
      libavcodec/vaapi_hevc.c

@ -1140,17 +1140,24 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->sps_curr_pic_ref_enabled_flag = get_bits1(gb); sps->sps_curr_pic_ref_enabled_flag = get_bits1(gb);
sps->palette_mode_enabled_flag = get_bits1(gb); sps->palette_mode_enabled_flag = get_bits1(gb);
if (sps->palette_mode_enabled_flag) { if (sps->palette_mode_enabled_flag) {
sps->palette_max_size = get_ue_golomb_long(gb); sps->palette_max_size = get_ue_golomb(gb);
sps->delta_palette_max_predictor_size = get_ue_golomb_long(gb); sps->delta_palette_max_predictor_size = get_ue_golomb(gb);
sps->sps_palette_predictor_initializers_present_flag = get_bits1(gb); sps->sps_palette_predictor_initializers_present_flag = get_bits1(gb);
if (sps->sps_palette_predictor_initializers_present_flag) { if (sps->sps_palette_predictor_initializers_present_flag) {
sps->sps_num_palette_predictor_initializers_minus1 = get_ue_golomb_long(gb); sps->sps_num_palette_predictor_initializers = get_ue_golomb(gb) + 1;
if (sps->sps_num_palette_predictor_initializers > HEVC_MAX_PALETTE_PREDICTOR_SIZE) {
av_log(avctx, AV_LOG_ERROR,
"sps_num_palette_predictor_initializers out of range: %u\n",
sps->sps_num_palette_predictor_initializers);
return AVERROR_INVALIDDATA;
}
num_comps = !sps->chroma_format_idc ? 1 : 3; num_comps = !sps->chroma_format_idc ? 1 : 3;
for (int comp = 0; comp < num_comps; comp++) for (int comp = 0; comp < num_comps; comp++) {
for (i = 0; i <= sps->sps_num_palette_predictor_initializers_minus1; i++) int bit_depth = !comp ? sps->bit_depth : sps->bit_depth_chroma;
sps->sps_palette_predictor_initializer[comp][i] = for (i = 0; i < sps->sps_num_palette_predictor_initializers; i++)
get_bits(gb, !comp ? sps->bit_depth : sps->bit_depth_chroma); sps->sps_palette_predictor_initializer[comp][i] = get_bits(gb, bit_depth);
}
} }
} }
sps->motion_vector_resolution_control_idc = get_bits(gb, 2); sps->motion_vector_resolution_control_idc = get_bits(gb, 2);

@ -219,7 +219,7 @@ typedef struct HEVCSPS {
int palette_max_size; int palette_max_size;
int delta_palette_max_predictor_size; int delta_palette_max_predictor_size;
int sps_palette_predictor_initializers_present_flag; int sps_palette_predictor_initializers_present_flag;
int sps_num_palette_predictor_initializers_minus1; int sps_num_palette_predictor_initializers;
int sps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE]; int sps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE];
int motion_vector_resolution_control_idc; int motion_vector_resolution_control_idc;
int intra_boundary_filtering_disabled_flag; int intra_boundary_filtering_disabled_flag;

@ -259,7 +259,7 @@ static int vaapi_hevc_start_frame(AVCodecContext *avctx,
pre_palette_size = pps->pps_palette_predictor_initializers_present_flag ? pre_palette_size = pps->pps_palette_predictor_initializers_present_flag ?
pps->pps_num_palette_predictor_initializers : pps->pps_num_palette_predictor_initializers :
(sps->sps_palette_predictor_initializers_present_flag ? (sps->sps_palette_predictor_initializers_present_flag ?
sps->sps_num_palette_predictor_initializers_minus1 + 1 : sps->sps_num_palette_predictor_initializers :
0); 0);
if (avctx->profile == FF_PROFILE_HEVC_SCC) { if (avctx->profile == FF_PROFILE_HEVC_SCC) {

Loading…
Cancel
Save