Skip to content

Commit

Permalink
Revert "[Decode] JPEG HW transition comments fix " (#5576)
Browse files Browse the repository at this point in the history
This reverts commit 53069f2

Co-authored-by: pinglux <[email protected]>
  • Loading branch information
gfxVPLsdm and pinglux authored Aug 3, 2023
1 parent 3edd496 commit 5f172ab
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 87 deletions.
6 changes: 2 additions & 4 deletions _studio/mfx_lib/decode/mjpeg/include/mfx_mjpeg_dec_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ class VideoDECODEMJPEGBase_HW : public VideoDECODEMJPEGBase
virtual mfxStatus AllocateFrameData(UMC::FrameData *&data);
virtual mfxStatus FillEntryPoint(MFX_ENTRY_POINT *pEntryPoint, mfxFrameSurface1 *surface_work, mfxFrameSurface1 *surface_out);

mfxU32 AdjustFrameAllocRequest(mfxFrameAllocRequest *request, mfxInfoMFX *info, VideoCORE * core, bool isPostProcEnable);
mfxU32 AdjustFrameAllocRequest(mfxFrameAllocRequest *request, mfxInfoMFX *info, eMFXVAType vaType, bool usePostProcessing);

static void AdjustFourCC(mfxFrameInfo *requestFrameInfo, const mfxInfoMFX *info, eMFXVAType vaType, bool isPostProcEnable, bool *needVpp);
static void AdjustFourCC(mfxFrameInfo *requestFrameInfo, const mfxInfoMFX *info, eMFXVAType vaType, bool usePostProc, bool *needVpp);

static mfxStatus CheckVPPCaps(VideoCORE * core, mfxVideoParam * par);
static bool isVideoPostprocEnabled(VideoCORE * core);



protected:
Expand Down
141 changes: 67 additions & 74 deletions _studio/mfx_lib/decode/mjpeg/src/mfx_mjpeg_dec_decode.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2004-2023 Intel Corporation
// Copyright (c) 2004-2022 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
Expand Down Expand Up @@ -192,10 +192,11 @@ mfxStatus VideoDECODEMJPEG::Init(mfxVideoParam *par)
{
VideoDECODEMJPEGBase_HW * dec = new VideoDECODEMJPEGBase_HW;
decoder.reset(dec);
bool usePostProcessing = GetExtendedBuffer(m_vPar.ExtParam, m_vPar.NumExtParam, MFX_EXTBUFF_DEC_VIDEO_PROCESSING);
mfxU32 bNeedVpp = dec->AdjustFrameAllocRequest(&request_internal,
&m_vPar.mfx,
m_core,
VideoDECODEMJPEGBase_HW::isVideoPostprocEnabled(m_core));
m_core->GetVAType(),
usePostProcessing);
useInternal |= bNeedVpp;

if (bNeedVpp)
Expand Down Expand Up @@ -616,9 +617,9 @@ mfxStatus VideoDECODEMJPEG::QueryIOSurfInternal(VideoCORE *core, mfxVideoParam *
}

mfxFrameAllocRequest request_internal = *request;
bool isPostProcEnable = VideoDECODEMJPEGBase_HW::isVideoPostprocEnabled(core);
bool usePostProcessing = GetExtendedBuffer(par->ExtParam, par->NumExtParam, MFX_EXTBUFF_DEC_VIDEO_PROCESSING);
VideoDECODEMJPEGBase_HW::AdjustFourCC(&request_internal.Info, &par->mfx, core->GetVAType(),
isPostProcEnable, &needVpp);
usePostProcessing, &needVpp);


if (needVpp && MFX_HW_D3D11 == core->GetVAType())
Expand Down Expand Up @@ -1036,25 +1037,53 @@ bool MFX_JPEG_Utility::IsNeedPartialAcceleration(VideoCORE * core, mfxVideoParam
par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV444)
return true;

bool isVideoPostprocEnabled = false;
// check sfc capability for some platform may not support sfc
{
VAProfile vaProfile = VAProfileJPEGBaseline;
VAEntrypoint vaEntrypoint = VAEntrypointVLD;

VAConfigAttrib vaAttrib;
memset(&vaAttrib, 0, sizeof(vaAttrib));
vaAttrib.type = VAConfigAttribDecProcessing;
vaAttrib.value = 0;

VADisplay vaDisplay;
mfxStatus mfxSts = core->GetHandle(MFX_HANDLE_VA_DISPLAY, &vaDisplay);
if (MFX_ERR_NONE != mfxSts)
return true;

// Had to duplicate that functionality here, as LinuxVideoAccelerator::Init() has not
// called at this point.
VAStatus vaStatus = vaGetConfigAttributes(vaDisplay, vaProfile, vaEntrypoint, &vaAttrib, 1);
if (VA_STATUS_SUCCESS != vaStatus)
return true;

isVideoPostprocEnabled = vaAttrib.value == VA_DEC_PROCESSING;
}

switch (par->mfx.FrameInfo.FourCC)
{
case MFX_FOURCC_NV12:
if (par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV420 ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV444 ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422H ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422V ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV411 ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_MONOCHROME)
if ((par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr &&
(par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV420 ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV444 ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422H ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422V ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV411 ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_MONOCHROME)) ||
(par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_RGB &&
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV444))
return false;
else
return true;
case MFX_FOURCC_YUY2:
if (par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV420 ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422H ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422V ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_MONOCHROME ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV444)
if(( par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr &&
(par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV420 ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422H ||
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_MONOCHROME)) ||
(par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_RGB &&
par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV444))
return false;
else
return true;
Expand All @@ -1065,7 +1094,12 @@ bool MFX_JPEG_Utility::IsNeedPartialAcceleration(VideoCORE * core, mfxVideoParam
else
return true;
case MFX_FOURCC_RGB4:
if (par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_RGB && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV444)
if (!isVideoPostprocEnabled)
return true;
else if ((par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_RGB && par->mfx.JPEGChromaFormat != MFX_CHROMAFORMAT_YUV444) ||
(par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV422V) ||
(par->mfx.JPEGColorFormat == MFX_JPEG_COLORFORMAT_YCbCr && par->mfx.JPEGChromaFormat == MFX_CHROMAFORMAT_YUV411)
)
return true;
else
return false;
Expand Down Expand Up @@ -1138,10 +1172,10 @@ eMFXPlatform MFX_JPEG_Utility::GetPlatform(VideoCORE * core, mfxVideoParam * par
mfxFrameAllocRequest request;
memset(&request, 0, sizeof(request));
request.Info = par->mfx.FrameInfo;
bool isPostProcEnable = VideoDECODEMJPEGBase_HW::isVideoPostprocEnabled(core);
bool usePostProcessing = GetExtendedBuffer(par->ExtParam, par->NumExtParam, MFX_EXTBUFF_DEC_VIDEO_PROCESSING);

VideoDECODEMJPEGBase_HW::AdjustFourCC(&request.Info, &par->mfx, core->GetVAType(),
isPostProcEnable, &needVpp);
usePostProcessing, &needVpp);

if (needVpp)
{
Expand All @@ -1166,31 +1200,29 @@ bool MFX_JPEG_Utility::IsFormatSupport(mfxVideoParam * in)
switch (chromaFormat)
{
case MFX_CHROMAFORMAT_MONOCHROME:
if (fourCC == 0 || fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_YUV400 || fourCC == MFX_FOURCC_YUY2 || fourCC == MFX_FOURCC_RGB4)
if (fourCC == 0 || fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_YUV400 || fourCC == MFX_FOURCC_RGB4)
support = true;
break;
case MFX_CHROMAFORMAT_YUV420:
if (fourCC == MFX_FOURCC_IMC3 || fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_YUY2 || fourCC == MFX_FOURCC_UYVY || fourCC == MFX_FOURCC_RGB4)
if (fourCC == MFX_FOURCC_IMC3 || fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_YUY2 || fourCC == MFX_FOURCC_UYVY)
support = true;
break;
case MFX_CHROMAFORMAT_YUV411:
if (fourCC == MFX_FOURCC_YUV411 || fourCC == MFX_FOURCC_NV12)
support = true;
break;
case MFX_CHROMAFORMAT_YUV422H:
if ((fourCC == MFX_FOURCC_YUY2 || fourCC == MFX_FOURCC_YUV422H || fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_UYVY || fourCC == MFX_FOURCC_RGB4))
if ((fourCC == MFX_FOURCC_YUY2 || fourCC == MFX_FOURCC_YUV422H || fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_UYVY))
support = true;
break;
case MFX_CHROMAFORMAT_YUV422V:
if ((fourCC == MFX_FOURCC_YUV422V || fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_YUY2 || fourCC == MFX_FOURCC_RGB4))
if ((fourCC == MFX_FOURCC_YUV422V || fourCC == MFX_FOURCC_NV12))
support = true;
break;
case MFX_CHROMAFORMAT_YUV444:
if (fourCC == MFX_FOURCC_RGB4 || fourCC == MFX_FOURCC_NV12 || fourCC == MFX_FOURCC_YUY2)
support = false;
else if (colorFormat == MFX_JPEG_COLORFORMAT_RGB && (fourCC == MFX_FOURCC_RGBP || fourCC == MFX_FOURCC_BGRP))
if (colorFormat == MFX_JPEG_COLORFORMAT_RGB && (fourCC == MFX_FOURCC_RGBP || fourCC == MFX_FOURCC_BGRP || fourCC == MFX_FOURCC_RGB4))
support = true;
else if (colorFormat == MFX_JPEG_COLORFORMAT_YCbCr && fourCC == MFX_FOURCC_YUV444)
else if (colorFormat == MFX_JPEG_COLORFORMAT_YCbCr && (fourCC == MFX_FOURCC_YUV444 || fourCC == MFX_FOURCC_RGB4))
support = true;
break;
default:
Expand Down Expand Up @@ -1639,8 +1671,8 @@ mfxStatus VideoDECODEMJPEGBase_HW::CheckVPPCaps(VideoCORE * core, mfxVideoParam

mfxU32 VideoDECODEMJPEGBase_HW::AdjustFrameAllocRequest(mfxFrameAllocRequest *request,
mfxInfoMFX *info,
VideoCORE *core,
bool isPostProcEnable)
eMFXVAType vaType,
bool usePostProcessing)
{
bool needVpp = false;

Expand All @@ -1656,7 +1688,7 @@ mfxU32 VideoDECODEMJPEGBase_HW::AdjustFrameAllocRequest(mfxFrameAllocRequest *re
}

// set FourCC
AdjustFourCC(&request->Info, info, core->GetVAType(), isPostProcEnable, &needVpp);
AdjustFourCC(&request->Info, info, vaType, usePostProcessing, &needVpp);

#ifdef MFX_ENABLE_MJPEG_ROTATE_VPP
if(info->Rotation == MFX_ROTATION_90 || info->Rotation == MFX_ROTATION_180 || info->Rotation == MFX_ROTATION_270)
Expand Down Expand Up @@ -1735,30 +1767,7 @@ mfxU32 VideoDECODEMJPEGBase_HW::AdjustFrameAllocRequest(mfxFrameAllocRequest *re
return m_needVpp ? 1 : 0;
}

bool VideoDECODEMJPEGBase_HW::isVideoPostprocEnabled(VideoCORE * core)
{
// check sfc capability for some platform may not support sfc
VAProfile vaProfile = VAProfileJPEGBaseline;
VAEntrypoint vaEntrypoint = VAEntrypointVLD;
VAConfigAttrib vaAttrib;
memset(&vaAttrib, 0, sizeof(vaAttrib));
vaAttrib.type = VAConfigAttribDecProcessing;
vaAttrib.value = 0;
VADisplay vaDisplay;
mfxStatus mfxSts = core->GetHandle(MFX_HANDLE_VA_DISPLAY, &vaDisplay);
if (MFX_ERR_NONE != mfxSts)
return false;

// Had to duplicate that functionality here, as LinuxVideoAccelerator::Init() has not
// called at this point.
VAStatus vaStatus = vaGetConfigAttributes(vaDisplay, vaProfile, vaEntrypoint, &vaAttrib, 1);
if (VA_STATUS_SUCCESS != vaStatus)
return false;

return vaAttrib.value == VA_DEC_PROCESSING;
}

void VideoDECODEMJPEGBase_HW::AdjustFourCC(mfxFrameInfo *requestFrameInfo, const mfxInfoMFX *info, eMFXVAType vaType, bool isVideoPostprocEnabled, bool *needVpp)
void VideoDECODEMJPEGBase_HW::AdjustFourCC(mfxFrameInfo *requestFrameInfo, const mfxInfoMFX *info, eMFXVAType vaType, bool usePostProc, bool *needVpp)
{
(void)vaType;

Expand All @@ -1767,23 +1776,16 @@ void VideoDECODEMJPEGBase_HW::AdjustFourCC(mfxFrameInfo *requestFrameInfo, const
switch(info->JPEGChromaFormat)
{
case MFX_CHROMAFORMAT_MONOCHROME:
if (requestFrameInfo->FourCC == MFX_FOURCC_NV12 ||
requestFrameInfo->FourCC == MFX_FOURCC_YUY2 ||
(requestFrameInfo->FourCC == MFX_FOURCC_RGB4 && !isVideoPostprocEnabled))
if (requestFrameInfo->FourCC == MFX_FOURCC_NV12 || requestFrameInfo->FourCC == MFX_FOURCC_YUY2)
{
requestFrameInfo->FourCC = MFX_FOURCC_YUV400;
*needVpp = true;
}
break;
case MFX_CHROMAFORMAT_YUV420:
if (requestFrameInfo->FourCC == MFX_FOURCC_RGB4 && !isVideoPostprocEnabled)
{
requestFrameInfo->FourCC = MFX_FOURCC_NV12;
*needVpp = true;
}
break;
case MFX_CHROMAFORMAT_YUV411:
if (requestFrameInfo->FourCC == MFX_FOURCC_NV12 || requestFrameInfo->FourCC == MFX_FOURCC_RGB4)
if (requestFrameInfo->FourCC == MFX_FOURCC_NV12)
{
requestFrameInfo->FourCC = MFX_FOURCC_YUV411;
*needVpp = true;
Expand All @@ -1792,21 +1794,12 @@ void VideoDECODEMJPEGBase_HW::AdjustFourCC(mfxFrameInfo *requestFrameInfo, const
case MFX_CHROMAFORMAT_YUV422H:
break;
case MFX_CHROMAFORMAT_YUV422V:
// 422V can not do hw decode to YUY2/RGB4 directly, so use VPP to do csc
if (info->Rotation == MFX_ROTATION_0 &&
(requestFrameInfo->FourCC == MFX_FOURCC_YUY2 || requestFrameInfo->FourCC == MFX_FOURCC_RGB4))
{
requestFrameInfo->FourCC = MFX_FOURCC_NV12;
*needVpp = true;
}
break;
case MFX_CHROMAFORMAT_YUV444:
if (info->Rotation == MFX_ROTATION_0 &&
// for YUV444 jpeg, decoded stream is YUV444P from driver,
// to get NV12/YUY2 we must use VPP
(requestFrameInfo->FourCC == MFX_FOURCC_NV12 ||
requestFrameInfo->FourCC == MFX_FOURCC_YUY2 ||
(requestFrameInfo->FourCC == MFX_FOURCC_RGB4 && !isVideoPostprocEnabled)))
// to get NV12 we must use VPP
requestFrameInfo->FourCC == MFX_FOURCC_NV12)
{
requestFrameInfo->FourCC = MFX_FOURCC_YUV444;
*needVpp = true;
Expand Down
2 changes: 1 addition & 1 deletion _studio/mfx_lib/shared/src/mfx_common_decode_int.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2023 Intel Corporation
// Copyright (c) 2017-2020 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
Expand Down
2 changes: 1 addition & 1 deletion _studio/mfx_lib/shared/src/mfx_common_int.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2009-2023 Intel Corporation
// Copyright (c) 2009-2021 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
Expand Down
8 changes: 5 additions & 3 deletions _studio/shared/src/libmfx_allocator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2023 Intel Corporation
// Copyright (c) 2007-2021 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
Expand Down Expand Up @@ -169,8 +169,6 @@ mfxStatus mfxDefaultAllocator::GetSurfaceSizeInBytes(mfxU32 pitch, mfxU32 height
case MFX_FOURCC_Y210:
case MFX_FOURCC_Y216:
case MFX_FOURCC_YUV422H:
case MFX_FOURCC_YUV422V:
case MFX_FOURCC_UYVY:
nBytes = pitch * height + (pitch >> 1) * height + (pitch >> 1) * height;
break;
case MFX_FOURCC_YUV444:
Expand All @@ -195,6 +193,10 @@ mfxStatus mfxDefaultAllocator::GetSurfaceSizeInBytes(mfxU32 pitch, mfxU32 height
case MFX_FOURCC_YUV400:
nBytes = pitch * height;
break;
case MFX_FOURCC_YUV422V:
case MFX_FOURCC_UYVY:
nBytes = pitch * height + pitch * (height >> 1) + pitch * (height >> 1);
break;
case MFX_FOURCC_ABGR16F:
nBytes = (pitch * height + pitch * height + pitch * height + pitch * height) * 2;
break;
Expand Down
4 changes: 2 additions & 2 deletions _studio/shared/src/libmfx_allocator_vaapi.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2023 Intel Corporation
// Copyright (c) 2007-2022 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
Expand Down Expand Up @@ -1083,4 +1083,4 @@ void FlexibleFrameAllocatorHW_VAAPI::SetDevice(mfxHDL device)
m_staging_adapter->SetDevice(device);
}

/* EOF */
/* EOF */
4 changes: 2 additions & 2 deletions _studio/shared/src/mfx_umc_alloc_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2023 Intel Corporation
// Copyright (c) 2008-2020 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
Expand Down Expand Up @@ -2361,4 +2361,4 @@ mfxStatus mfx_UMC_FrameAllocator_D3D::PrepareToOutput(mfxFrameSurface1 *surfac
}

return sts;
}
}

0 comments on commit 5f172ab

Please sign in to comment.