@@ -1538,17 +1538,24 @@ static int pps_scc_extension(GetBitContext *gb, AVCodecContext *avctx,
}
if (pps->pps_palette_predictor_initializers_present_flag = get_bits1(gb)) {
- if ((pps->pps_num_palette_predictor_initializers = get_ue_golomb_long(gb)) > 0) {
+ pps->pps_num_palette_predictor_initializers = get_ue_golomb(gb);
+ if (pps->pps_num_palette_predictor_initializers > 0) {
+ if (pps->pps_num_palette_predictor_initializers > HEVC_MAX_PALETTE_PREDICTOR_SIZE) {
+ av_log(avctx, AV_LOG_ERROR,
+ "pps_num_palette_predictor_initializers out of range: %u\n",
+ pps->pps_num_palette_predictor_initializers);
+ return AVERROR_INVALIDDATA;
+ }
pps->monochrome_palette_flag = get_bits1(gb);
- pps->luma_bit_depth_entry_minus8 = get_ue_golomb_long(gb);
+ pps->luma_bit_depth_entry = get_ue_golomb_31(gb) + 8;
if (!pps->monochrome_palette_flag)
- pps->chroma_bit_depth_entry_minus8 = get_ue_golomb_long(gb);
+ pps->chroma_bit_depth_entry = get_ue_golomb_31(gb) + 8;
num_comps = pps->monochrome_palette_flag ? 1 : 3;
- for (int comp = 0; comp < num_comps; comp++)
+ for (int comp = 0; comp < num_comps; comp++) {
+ int bit_depth = !comp ? pps->luma_bit_depth_entry : pps->chroma_bit_depth_entry;
for (int i = 0; i < pps->pps_num_palette_predictor_initializers; i++)
- pps->pps_palette_predictor_initializer[comp][i] =
- get_bits(gb, 8 + (!comp ? pps->luma_bit_depth_entry_minus8 :
- pps->chroma_bit_depth_entry_minus8));
+ pps->pps_palette_predictor_initializer[comp][i] = get_bits(gb, bit_depth);
+ }
}
}
@@ -358,9 +358,9 @@ typedef struct HEVCPPS {
uint8_t pps_palette_predictor_initializers_present_flag;
uint8_t pps_num_palette_predictor_initializers;
uint8_t monochrome_palette_flag;
- uint8_t luma_bit_depth_entry_minus8;
- uint8_t chroma_bit_depth_entry_minus8;
- uint8_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE];
+ uint8_t luma_bit_depth_entry;
+ uint8_t chroma_bit_depth_entry;
+ uint16_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE];
// Inferred parameters
unsigned int *column_width; ///< ColumnWidth
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> --- libavcodec/hevc_ps.c | 21 ++++++++++++++------- libavcodec/hevc_ps.h | 6 +++--- 2 files changed, 17 insertions(+), 10 deletions(-)