From 0039e3af63ab7bc73cdf45e8952085396f078dc9 Mon Sep 17 00:00:00 2001 From: "Yang, Yawen" Date: Thu, 19 Sep 2024 06:43:38 +0000 Subject: [PATCH] [Decode] Only decode basic layer when input is multi-layer --- .../umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp | 8 +++++--- .../umc/codec/h265_dec/src/umc_h265_task_supplier.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/_studio/shared/umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp b/_studio/shared/umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp index e8101044d2..917cb96985 100755 --- a/_studio/shared/umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp +++ b/_studio/shared/umc/codec/h265_dec/src/umc_h265_bitstream_headers.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2020 Intel Corporation +// Copyright (c) 2012-2024 Intel Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -331,7 +331,7 @@ UMC::Status H265HeadersBitstream::GetVideoParamSet(H265VideoParamSet *pcVPS) } pcVPS->vps_max_layer_id = GetBits(6); - if (pcVPS->vps_max_layer_id >= MAX_NUH_LAYER_ID) + if (pcVPS->vps_max_layer_id > MAX_NUH_LAYER_ID) throw h265_exception(UMC::UMC_ERR_INVALID_STREAM); pcVPS->vps_num_layer_sets = GetVLCElementU() + 1; @@ -2102,8 +2102,10 @@ UMC::Status H265HeadersBitstream::GetNALUnitType(NalUnitType &nal_unit_type, uin nal_unit_type = (NalUnitType)GetBits(6); uint32_t nuh_layer_id = GetBits(6); - if (nuh_layer_id) + if (nuh_layer_id > MAX_NUH_LAYER_ID) throw h265_exception(UMC::UMC_ERR_INVALID_STREAM); + if (nuh_layer_id) + return UMC::UMC_ERR_UNSUPPORTED;//only support layer 0 which is the basic layer uint32_t const nuh_temporal_id_plus1 = GetBits(3); if (!nuh_temporal_id_plus1) diff --git a/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp b/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp index a23eb43f79..d699095876 100755 --- a/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp +++ b/_studio/shared/umc/codec/h265_dec/src/umc_h265_task_supplier.cpp @@ -1432,9 +1432,10 @@ UMC::Status TaskSupplier_H265::DecodeHeaders(UMC::MediaDataEx *nalUnit) NalUnitType nal_unit_type; uint32_t temporal_id = 0; - bitStream.GetNALUnitType(nal_unit_type, temporal_id); - - switch(nal_unit_type) + umcRes = bitStream.GetNALUnitType(nal_unit_type, temporal_id); + if (umcRes != UMC::UMC_OK) + return umcRes; + switch (nal_unit_type) { case NAL_UT_VPS: umcRes = xDecodeVPS(&bitStream);