History

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.

James Almer committed 3 years ago

Commit df3fd3a1 parent 5564ba42 files · +17 −10Browse files

Unified · Split

2 files
  1. libavcodec/hevc_ps.c +14 −7
  2. libavcodec/hevc_ps.h +3 −3
libavcodec/hevc_ps.c+14−7
@@ -1538,17 +1538,24 @@ static int pps_scc_extension(GetBitContext *gb, AVCodecContext *avctx, · 1537 unmodified lines
15381538 }
15391539
15401540 if (pps->pps_palette_predictor_initializers_present_flag = get_bits1(gb)) {
1541− if ((pps->pps_num_palette_predictor_initializers = get_ue_golomb_long(gb)) > 0) {
1541+ pps->pps_num_palette_predictor_initializers = get_ue_golomb(gb);
1542+ if (pps->pps_num_palette_predictor_initializers > 0) {
1543+ if (pps->pps_num_palette_predictor_initializers > HEVC_MAX_PALETTE_PREDICTOR_SIZE) {
1544+ av_log(avctx, AV_LOG_ERROR,
1545+ "pps_num_palette_predictor_initializers out of range: %u\n",
1546+ pps->pps_num_palette_predictor_initializers);
1547+ return AVERROR_INVALIDDATA;
1548+ }
15421549 pps->monochrome_palette_flag = get_bits1(gb);
1543− pps->luma_bit_depth_entry_minus8 = get_ue_golomb_long(gb);
1550+ pps->luma_bit_depth_entry = get_ue_golomb_31(gb) + 8;
15441551 if (!pps->monochrome_palette_flag)
1545− pps->chroma_bit_depth_entry_minus8 = get_ue_golomb_long(gb);
1552+ pps->chroma_bit_depth_entry = get_ue_golomb_31(gb) + 8;
15461553 num_comps = pps->monochrome_palette_flag ? 1 : 3;
1547− for (int comp = 0; comp < num_comps; comp++)
1554+ for (int comp = 0; comp < num_comps; comp++) {
1555+ int bit_depth = !comp ? pps->luma_bit_depth_entry : pps->chroma_bit_depth_entry;
15481556 for (int i = 0; i < pps->pps_num_palette_predictor_initializers; i++)
1549− pps->pps_palette_predictor_initializer[comp][i] =
1550− get_bits(gb, 8 + (!comp ? pps->luma_bit_depth_entry_minus8 :
1551− pps->chroma_bit_depth_entry_minus8));
1557+ pps->pps_palette_predictor_initializer[comp][i] = get_bits(gb, bit_depth);
1558+ }
15521559 }
15531560 }
15541561
libavcodec/hevc_ps.h+3−3
@@ -358,9 +358,9 @@ typedef struct HEVCPPS { · 357 unmodified lines
358358 uint8_t pps_palette_predictor_initializers_present_flag;
359359 uint8_t pps_num_palette_predictor_initializers;
360360 uint8_t monochrome_palette_flag;
361− uint8_t luma_bit_depth_entry_minus8;
362− uint8_t chroma_bit_depth_entry_minus8;
363− uint8_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE];
361+ uint8_t luma_bit_depth_entry;
362+ uint8_t chroma_bit_depth_entry;
363+ uint16_t pps_palette_predictor_initializer[3][HEVC_MAX_PALETTE_PREDICTOR_SIZE];
364364
365365 // Inferred parameters
366366 unsigned int *column_width; ///< ColumnWidth

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t