From 974c2a4215871dcb13e8d6b6ce90dd7c0ad37569 Mon Sep 17 00:00:00 2001 From: "Cheah, Vincent Beng Keat" Date: Wed, 10 Jun 2026 20:25:04 +0800 Subject: [PATCH 1/2] [Decode] Add AVC 10bit Dec for PTL --- .../decode/h264/src/mfx_h264_dec_decode.cpp | 18 +++++++++ .../shared/include/mfx_platform_caps.h | 8 ++++ _studio/mfx_lib/shared/src/mfx_common_int.cpp | 3 +- _studio/shared/src/libmfx_core_hw.cpp | 6 +++ .../h264_dec/src/umc_h264_mfx_supplier.cpp | 38 +++++++++++++++---- .../shared/umc/io/umc_va/src/umc_va_linux.cpp | 15 ++++++++ 6 files changed, 80 insertions(+), 8 deletions(-) diff --git a/_studio/mfx_lib/decode/h264/src/mfx_h264_dec_decode.cpp b/_studio/mfx_lib/decode/h264/src/mfx_h264_dec_decode.cpp index c13f57841a..fbcbc07820 100644 --- a/_studio/mfx_lib/decode/h264/src/mfx_h264_dec_decode.cpp +++ b/_studio/mfx_lib/decode/h264/src/mfx_h264_dec_decode.cpp @@ -222,6 +222,11 @@ mfxStatus VideoDECODEH264::Init(mfxVideoParam *par) eMFXHWType type = m_core->GetHWType(); + if (par->mfx.FrameInfo.FourCC == MFX_FOURCC_P010 || + par->mfx.FrameInfo.FourCC == MFX_FOURCC_P210 || + par->mfx.FrameInfo.FourCC == MFX_FOURCC_Y210) + par->mfx.FrameInfo.Shift = 1; + mfxStatus mfxSts = CheckVideoParamDecoders(par, type); MFX_CHECK(mfxSts >= MFX_ERR_NONE, MFX_ERR_INVALID_VIDEO_PARAM); @@ -405,6 +410,8 @@ mfxStatus VideoDECODEH264::QueryImplsDescription( #endif , MFX_PROFILE_AVC_MULTIVIEW_HIGH , MFX_PROFILE_AVC_STEREO_HIGH + , MFX_PROFILE_AVC_HIGH10 + , MFX_PROFILE_AVC_HIGH_422 }; const mfxResourceType SupportedMemTypes[] = { @@ -414,6 +421,8 @@ mfxStatus VideoDECODEH264::QueryImplsDescription( const mfxU32 SupportedFourCC[] = { MFX_FOURCC_NV12 + , MFX_FOURCC_P010 + , MFX_FOURCC_Y210 }; caps.CodecID = MFX_CODEC_AVC; @@ -807,6 +816,15 @@ mfxStatus VideoDECODEH264::GetVideoParam(mfxVideoParam *par) } } + switch (par->mfx.FrameInfo.FourCC) + { + case MFX_FOURCC_P010: + case MFX_FOURCC_P210: + case MFX_FOURCC_Y210: + par->mfx.FrameInfo.Shift = 1; + default: + break; + } TRACE_EVENT(MFX_TRACE_API_DECODE_GETVIDEOPARAM_TASK, EVENT_TYPE_END, TR_KEY_MFX_API, make_event_data(MFX_ERR_NONE)); diff --git a/_studio/mfx_lib/shared/include/mfx_platform_caps.h b/_studio/mfx_lib/shared/include/mfx_platform_caps.h index 87470d77c3..26f3512a28 100644 --- a/_studio/mfx_lib/shared/include/mfx_platform_caps.h +++ b/_studio/mfx_lib/shared/include/mfx_platform_caps.h @@ -281,6 +281,14 @@ namespace H264DCaps { { return platform < MFX_HW_XE_HP_SDV; } + inline bool IsDec420TenBitSupported(eMFXHWType platform) + { + return (platform >= MFX_HW_PTL); + } + inline bool IsDec422TenBitSupported(eMFXHWType platform) + { + return (platform >= MFX_HW_PTL); + } } #endif // MFX_ENABLE_H264_VIDEO_DECODE #endif // __MFX_PLATFORM_CAPS_H__ diff --git a/_studio/mfx_lib/shared/src/mfx_common_int.cpp b/_studio/mfx_lib/shared/src/mfx_common_int.cpp index d3a5f5d1e3..50eb341020 100644 --- a/_studio/mfx_lib/shared/src/mfx_common_int.cpp +++ b/_studio/mfx_lib/shared/src/mfx_common_int.cpp @@ -273,7 +273,8 @@ mfxStatus CheckFrameInfoCodecs(mfxFrameInfo *info, mfxU32 codecId) if (info->FourCC != MFX_FOURCC_NV12 && info->FourCC != MFX_FOURCC_P010 && info->FourCC != MFX_FOURCC_NV16 && - info->FourCC != MFX_FOURCC_P210) + info->FourCC != MFX_FOURCC_P210 && + info->FourCC != MFX_FOURCC_Y210) MFX_RETURN(MFX_ERR_INVALID_VIDEO_PARAM); break; case MFX_CODEC_HEVC: diff --git a/_studio/shared/src/libmfx_core_hw.cpp b/_studio/shared/src/libmfx_core_hw.cpp index fb06a2d429..c30db20cdf 100644 --- a/_studio/shared/src/libmfx_core_hw.cpp +++ b/_studio/shared/src/libmfx_core_hw.cpp @@ -60,6 +60,12 @@ mfxU32 ChooseProfile(mfxVideoParam const* param, eMFXHWType hwType) } #endif } + + if (param->mfx.CodecProfile == MFX_PROFILE_AVC_HIGH10 || + param->mfx.CodecProfile == MFX_PROFILE_AVC_HIGH_422) + { + profile |= VA_PROFILE_REXT | VA_PROFILE_10; + } break; case MFX_CODEC_JPEG: diff --git a/_studio/shared/umc/codec/h264_dec/src/umc_h264_mfx_supplier.cpp b/_studio/shared/umc/codec/h264_dec/src/umc_h264_mfx_supplier.cpp index e01175efa2..49e705036a 100644 --- a/_studio/shared/umc/codec/h264_dec/src/umc_h264_mfx_supplier.cpp +++ b/_studio/shared/umc/codec/h264_dec/src/umc_h264_mfx_supplier.cpp @@ -516,10 +516,13 @@ bool MFX_Utility::IsNeedPartialAcceleration(mfxVideoParam * par, eMFXHWType ) if (par->mfx.SliceGroupsPresent) // Is FMO return true; - if (par->mfx.FrameInfo.FourCC != MFX_FOURCC_NV12) // yuv422 in SW only + if (par->mfx.FrameInfo.FourCC != MFX_FOURCC_NV12 + && par->mfx.FrameInfo.FourCC != MFX_FOURCC_P210 + && par->mfx.FrameInfo.FourCC != MFX_FOURCC_P010 + && par->mfx.FrameInfo.FourCC != MFX_FOURCC_Y210) return true; - if (par->mfx.FrameInfo.BitDepthLuma > 8 || par->mfx.FrameInfo.BitDepthChroma > 8) // yuv422 in SW only + if (par->mfx.FrameInfo.BitDepthLuma > 10 || par->mfx.FrameInfo.BitDepthChroma > 10) return true; mfxExtMVCSeqDesc * points = (mfxExtMVCSeqDesc*)GetExtendedBuffer(par->ExtParam, par->NumExtParam, MFX_EXTBUFF_MVC_SEQ_DESC); @@ -569,6 +572,17 @@ UMC::Status MFX_Utility::FillVideoParam(UMC::TaskSupplier * supplier, mfxVideoPa if (pps) par->mfx.SliceGroupsPresent = pps->num_slice_groups > 1; + if (par->mfx.FrameInfo.FourCC == MFX_FOURCC_P010 + || par->mfx.FrameInfo.FourCC == MFX_FOURCC_P210 + || par->mfx.FrameInfo.FourCC == MFX_FOURCC_Y210) + { + par->mfx.FrameInfo.Shift = 1; + } + else + { + par->mfx.FrameInfo.Shift = 0; + } + return UMC::UMC_OK; } @@ -1158,7 +1172,11 @@ inline bool CheckFourcc(mfxU32 fourcc, mfxU16 codecProfile, eMFXHWType type) #endif case MFX_PROFILE_AVC_MULTIVIEW_HIGH: case MFX_PROFILE_AVC_STEREO_HIGH: - return fourcc == MFX_FOURCC_NV12; + return (fourcc == MFX_FOURCC_NV12); + case MFX_PROFILE_AVC_HIGH10: //High10 may have 8bit clip. + return H264DCaps::IsDec420TenBitSupported(type) ? (fourcc == MFX_FOURCC_NV12 || fourcc == MFX_FOURCC_P010) : (fourcc == MFX_FOURCC_NV12); + case MFX_PROFILE_AVC_HIGH_422: //HIGH_422 may have 420 clip + return H264DCaps::IsDec422TenBitSupported(type) ? (fourcc == MFX_FOURCC_NV12 || fourcc == MFX_FOURCC_P010 || fourcc == MFX_FOURCC_Y210) : (fourcc == MFX_FOURCC_NV12); default: return false; } @@ -1196,7 +1214,9 @@ mfxStatus MFX_Utility::Query(VideoCORE *core, mfxVideoParam *in, mfxVideoParam * (MFX_PROFILE_AVC_SCALABLE_HIGH == in->mfx.CodecProfile) || #endif (MFX_PROFILE_AVC_MULTIVIEW_HIGH == in->mfx.CodecProfile) || - (MFX_PROFILE_AVC_STEREO_HIGH == in->mfx.CodecProfile) + (MFX_PROFILE_AVC_STEREO_HIGH == in->mfx.CodecProfile) || + (MFX_PROFILE_AVC_HIGH_422 == in->mfx.CodecProfile) || + (MFX_PROFILE_AVC_HIGH10 == in->mfx.CodecProfile) ) out->mfx.CodecProfile = in->mfx.CodecProfile; else @@ -1340,6 +1360,9 @@ mfxStatus MFX_Utility::Query(VideoCORE *core, mfxVideoParam *in, mfxVideoParam * sts = MFX_ERR_UNSUPPORTED; } + out->mfx.FrameInfo.BitDepthLuma = in->mfx.FrameInfo.BitDepthLuma; + out->mfx.FrameInfo.BitDepthChroma = in->mfx.FrameInfo.BitDepthChroma; + out->mfx.FrameInfo.Shift = in->mfx.FrameInfo.Shift; switch (in->mfx.FrameInfo.PicStruct) { @@ -1772,6 +1795,8 @@ bool MFX_Utility::CheckVideoParam(mfxVideoParam *in, eMFXHWType type) case MFX_PROFILE_AVC_MAIN: case MFX_PROFILE_AVC_EXTENDED: case MFX_PROFILE_AVC_HIGH: + case MFX_PROFILE_AVC_HIGH10: + case MFX_PROFILE_AVC_HIGH_422: case MFX_PROFILE_AVC_STEREO_HIGH: case MFX_PROFILE_AVC_MULTIVIEW_HIGH: #ifdef MFX_ENABLE_SVC_VIDEO_DECODE @@ -1814,9 +1839,8 @@ bool MFX_Utility::CheckVideoParam(mfxVideoParam *in, eMFXHWType type) if (in->mfx.FrameInfo.Height > 16384 || (in->mfx.FrameInfo.Height % 16)) return false; - if (in->mfx.FrameInfo.FourCC != MFX_FOURCC_NV12 && in->mfx.FrameInfo.FourCC != MFX_FOURCC_NV16 && - in->mfx.FrameInfo.FourCC != MFX_FOURCC_P010 && in->mfx.FrameInfo.FourCC != MFX_FOURCC_P210) + in->mfx.FrameInfo.FourCC != MFX_FOURCC_P010 && in->mfx.FrameInfo.FourCC != MFX_FOURCC_P210 && in->mfx.FrameInfo.FourCC != MFX_FOURCC_Y210) return false; // both zero or not zero @@ -1842,7 +1866,7 @@ bool MFX_Utility::CheckVideoParam(mfxVideoParam *in, eMFXHWType type) if (in->mfx.FrameInfo.ChromaFormat == MFX_CHROMAFORMAT_YUV422) { - if (in->mfx.FrameInfo.FourCC != MFX_FOURCC_P210 && in->mfx.FrameInfo.FourCC != MFX_FOURCC_NV16) + if (in->mfx.FrameInfo.FourCC != MFX_FOURCC_P210 && in->mfx.FrameInfo.FourCC != MFX_FOURCC_Y210 && in->mfx.FrameInfo.FourCC != MFX_FOURCC_NV16) return false; } diff --git a/_studio/shared/umc/io/umc_va/src/umc_va_linux.cpp b/_studio/shared/umc/io/umc_va/src/umc_va_linux.cpp index 9ed42d37af..3e5ff3d9b7 100644 --- a/_studio/shared/umc/io/umc_va/src/umc_va_linux.cpp +++ b/_studio/shared/umc/io/umc_va/src/umc_va_linux.cpp @@ -141,6 +141,16 @@ VAProfile g_H264Profiles[] = VAProfileH264High, VAProfileH264Main, VAProfileH264ConstrainedBaseline }; +#if VA_CHECK_VERSION(1, 18, 0) +VAProfile g_H26410BitProfiles[] = +{ + VAProfileH264High10, +#if VA_CHECK_VERSION(1, 23, 0) + VAProfileH264High422, +#endif +}; +#endif + VAProfile g_H265Profiles[] = { VAProfileHEVCMain @@ -211,6 +221,11 @@ VAProfile get_next_va_profile(uint32_t umc_codec, uint32_t profile) case UMC::VA_H264: if (profile < UMC_ARRAY_SIZE(g_H264Profiles)) va_profile = g_H264Profiles[profile]; break; +#if VA_CHECK_VERSION(1, 18, 0) + case UMC::VA_H264 | UMC::VA_PROFILE_REXT | UMC::VA_PROFILE_10: + if (profile < UMC_ARRAY_SIZE(g_H26410BitProfiles)) va_profile = g_H26410BitProfiles[profile]; + break; +#endif case UMC::VA_H265: if (profile < UMC_ARRAY_SIZE(g_H265Profiles)) va_profile = g_H265Profiles[profile]; break; From ae0991055d03d51ddb06c87f5b4c96c4db91ae78 Mon Sep 17 00:00:00 2001 From: "Cheah, Vincent Beng Keat" Date: Wed, 10 Jun 2026 20:25:44 +0800 Subject: [PATCH 2/2] [Decode] Correct luma and chroma offsets --- .../codec/h264_dec/src/umc_h264_dec_bitstream_headers.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/_studio/shared/umc/codec/h264_dec/src/umc_h264_dec_bitstream_headers.cpp b/_studio/shared/umc/codec/h264_dec/src/umc_h264_dec_bitstream_headers.cpp index a5f868716d..b01db35016 100644 --- a/_studio/shared/umc/codec/h264_dec/src/umc_h264_dec_bitstream_headers.cpp +++ b/_studio/shared/umc/codec/h264_dec/src/umc_h264_dec_bitstream_headers.cpp @@ -1919,7 +1919,6 @@ Status H264HeadersBitstream::GetPredWeightTable( { pPredWeight_L0[refindex].luma_weight = (int8_t)GetVLCElement(true); pPredWeight_L0[refindex].luma_offset = (int8_t)GetVLCElement(true); - pPredWeight_L0[refindex].luma_offset <<= (sps->bit_depth_luma - 8); } else { @@ -1939,9 +1938,6 @@ Status H264HeadersBitstream::GetPredWeightTable( pPredWeight_L0[refindex].chroma_offset[0] = (int8_t)GetVLCElement(true); pPredWeight_L0[refindex].chroma_weight[1] = (int8_t)GetVLCElement(true); pPredWeight_L0[refindex].chroma_offset[1] = (int8_t)GetVLCElement(true); - - pPredWeight_L0[refindex].chroma_offset[0] <<= (sps->bit_depth_chroma - 8); - pPredWeight_L0[refindex].chroma_offset[1] <<= (sps->bit_depth_chroma - 8); } else { @@ -1961,7 +1957,6 @@ Status H264HeadersBitstream::GetPredWeightTable( { pPredWeight_L1[refindex].luma_weight = (int8_t)GetVLCElement(true); pPredWeight_L1[refindex].luma_offset = (int8_t)GetVLCElement(true); - pPredWeight_L1[refindex].luma_offset <<= (sps->bit_depth_luma - 8); } else { @@ -1979,9 +1974,6 @@ Status H264HeadersBitstream::GetPredWeightTable( pPredWeight_L1[refindex].chroma_offset[0] = (int8_t)GetVLCElement(true); pPredWeight_L1[refindex].chroma_weight[1] = (int8_t)GetVLCElement(true); pPredWeight_L1[refindex].chroma_offset[1] = (int8_t)GetVLCElement(true); - - pPredWeight_L1[refindex].chroma_offset[0] <<= (sps->bit_depth_chroma - 8); - pPredWeight_L1[refindex].chroma_offset[1] <<= (sps->bit_depth_chroma - 8); } else {