@@ -1084,8 +1084,9 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps,
dc_scale = 16;
if (sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) {
+ const HEVCLayerContext *const l = &s->layers[sps->sps_scaling_list_ref_layer_id];
const ScalingList *sl = pps->scaling_list_data_present_flag ?
- &pps->scaling_list : &sps->scaling_list;
+ &pps->scaling_list : &l->sps->scaling_list;
int matrix_id = lc->cu.pred_mode != MODE_INTRA;
matrix_id = 3 * matrix_id + c_idx;
@@ -1373,14 +1373,22 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->scaling_list_enabled = get_bits1(gb);
if (sps->scaling_list_enabled) {
+ int sps_infer_scaling_list_flag = 0;
+
set_default_scaling_list_data(&sps->scaling_list);
- if (multi_layer_ext && get_bits1(gb)) { // sps_infer_scaling_list_flag
- av_log(avctx, AV_LOG_ERROR, "sps_infer_scaling_list_flag=1 not supported\n");
- return AVERROR_PATCHWELCOME;
- }
+ if (multi_layer_ext)
+ sps_infer_scaling_list_flag = get_bits1(gb);
- if (get_bits1(gb)) {
+ sps->sps_scaling_list_ref_layer_id = 0;
+ if (sps_infer_scaling_list_flag) {
+ sps->sps_scaling_list_ref_layer_id = get_bits(gb, 6);
+ if (sps->sps_scaling_list_ref_layer_id >= HEVC_VPS_MAX_LAYERS) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid value %d for sps_scaling_list_ref_layer_id",
+ sps->sps_scaling_list_ref_layer_id);
+ return AVERROR_INVALIDDATA;
+ }
+ } else if (get_bits1(gb)) {
ret = scaling_list_data(gb, avctx, &sps->scaling_list, sps);
if (ret < 0)
return ret;
@@ -277,6 +277,7 @@ typedef struct HEVCSPS {
VUI vui;
PTL ptl;
+ int sps_scaling_list_ref_layer_id;
ScalingList scaling_list;
unsigned int nb_st_rps;
Signed-off-by: James Almer <jamrial@gmail.com> --- Untested, as i can't find a sample that triggers this code. libavcodec/hevc/cabac.c | 3 ++- libavcodec/hevc/ps.c | 18 +++++++++++++----- libavcodec/hevc/ps.h | 1 + 3 files changed, 16 insertions(+), 6 deletions(-)