diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c index f18b88489b..3fc14c1e72 100644 --- a/libavcodec/hevc/ps.c +++ b/libavcodec/hevc/ps.c @@ -470,7 +470,7 @@ static int decode_vps_ext(GetBitContext *gb, AVCodecContext *avctx, HEVCVPS *vps PTL ptl_dummy; uint8_t max_sub_layers[HEVC_MAX_LAYERS]; - int splitting_flag, dimension_id_len, view_id_len, num_add_olss, + int splitting_flag, dimension_id_len, view_id_len, num_add_olss, num_scalability_types, default_output_layer_idc, direct_dep_type_len, direct_dep_type, sub_layers_max_present, sub_layer_flag_info_present_flag, nb_ptl; unsigned non_vui_extension_length; @@ -532,13 +532,17 @@ static int decode_vps_ext(GetBitContext *gb, AVCodecContext *avctx, HEVCVPS *vps return AVERROR_INVALIDDATA; splitting_flag = get_bits1(gb); + num_scalability_types = 0; for (int i = 0; i <= HEVC_SCALABILITY_MASK_MAX; i++) { int scalability_mask_flag = get_bits1(gb); - if (scalability_mask_flag != (i == HEVC_SCALABILITY_MULTIVIEW)) { + if (scalability_mask_flag && (i != HEVC_SCALABILITY_MULTIVIEW)) { av_log(avctx, AV_LOG_ERROR, "Scalability type %d not supported\n", i); return AVERROR_PATCHWELCOME; } + num_scalability_types += scalability_mask_flag; } + if (num_scalability_types != 1) + return AVERROR_INVALIDDATA; if (!splitting_flag) dimension_id_len = get_bits(gb, 3) + 1;