Skip to content

Commit

Permalink
[Encode] Enable REXT(CL#808610)
Browse files Browse the repository at this point in the history
Implement REXT

Change-Id: I9626f9b926ac563f3973260d879a030d7b2a3270
  • Loading branch information
madhuri_nagaraj authored and Sherry-Lin committed Oct 18, 2018
1 parent a9238ee commit d748abc
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2210,8 +2210,7 @@ void CodechalEncodeHevcBase::SetHcpSrcSurfaceParams(MHW_VDBOX_SURFACE_PARAMS& sr
srcSurfaceParams.ucBitDepthChromaMinus8 = m_hevcSeqParams->bit_depth_chroma_minus8;
srcSurfaceParams.bDisplayFormatSwizzle = m_hevcPicParams->bDisplayFormatSwizzle;
srcSurfaceParams.ChromaType = m_outputChromaFormat;
srcSurfaceParams.bSrc8Pak10Mode = (!m_hevcSeqParams->SourceBitDepth) &&
(m_hevcSeqParams->bit_depth_luma_minus8 == 2);
srcSurfaceParams.bSrc8Pak10Mode = false; //No usage for 8->10 bit encode
srcSurfaceParams.dwActualHeight = ((m_hevcSeqParams->wFrameHeightInMinCbMinus1 + 1) << (m_hevcSeqParams->log2_min_coding_block_size_minus3 + 3));
}

Expand Down
61 changes: 25 additions & 36 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_hevc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ VAStatus DdiEncodeHevc::ContextInitialize(
{
codecHalSettings->codecFunction = CODECHAL_FUNCTION_ENC_VDENC_PAK;
codecHalSettings->disableUltraHME = true;
codecHalSettings->disableSuperHME = true;
}
else
{
Expand All @@ -105,11 +106,31 @@ VAStatus DdiEncodeHevc::ContextInitialize(
codecHalSettings->width = m_encodeCtx->dworiFrameWidth;
codecHalSettings->mode = m_encodeCtx->wModeType;
codecHalSettings->standard = CODECHAL_HEVC;
codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV420;
codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_8_BITS;
if (m_is10Bit)

if(m_encodeCtx->vaProfile==VAProfileHEVCMain)
{
codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV420;
codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_8_BITS;
}
else if(m_encodeCtx->vaProfile==VAProfileHEVCMain10)
{
codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV420;
codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_10_BITS;
}
else if(m_encodeCtx->vaProfile == VAProfileHEVCMain12)
{
codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV420;
codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_12_BITS;
}
else if(m_encodeCtx->vaProfile == VAProfileHEVCMain422_10)
{
codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV422;
codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_10_BITS;
}
else if(m_encodeCtx->vaProfile == VAProfileHEVCMain422_12)
{
codecHalSettings->lumaChromaDepth |= CODECHAL_LUMA_CHROMA_DEPTH_10_BITS;
codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV422;
codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_12_BITS;
}

VAStatus eStatus = VA_STATUS_SUCCESS;
Expand Down Expand Up @@ -264,45 +285,13 @@ VAStatus DdiEncodeHevc::EncodeInCodecHal(uint32_t numSlices)
MOS_SURFACE rawSurface;
MOS_ZeroMemory(&rawSurface, sizeof(rawSurface));
rawSurface.dwOffset = 0;
if (m_encodeCtx->vaProfile == VAProfileHEVCMain10)
{
rawSurface.Format = Format_P010;
}
else if (m_encodeCtx->vaProfile == VAProfileHEVCMain444)
{
rawSurface.Format = Format_AYUV;
}
else if (m_encodeCtx->vaProfile == VAProfileHEVCMain444_10)
{
rawSurface.Format = Format_Y410;
}
else //VAProfileHEVCMain
{
rawSurface.Format = Format_NV12;
}

DdiMedia_MediaSurfaceToMosResource(rtTbl->pCurrentRT, &(rawSurface.OsResource));

// Recon Surface
MOS_SURFACE reconSurface;
MOS_ZeroMemory(&reconSurface, sizeof(reconSurface));
reconSurface.dwOffset = 0;
if (m_encodeCtx->vaProfile == VAProfileHEVCMain10)
{
reconSurface.Format = Format_P010;
}
else if (m_encodeCtx->vaProfile == VAProfileHEVCMain444)
{
reconSurface.Format = Format_AYUV;
}
else if (m_encodeCtx->vaProfile == VAProfileHEVCMain444_10)
{
reconSurface.Format = Format_Y410;
}
else //VAProfileHEVCMain
{
reconSurface.Format = Format_NV12;
}

DdiMedia_MediaSurfaceToMosResource(rtTbl->pCurrentReconTarget, &(reconSurface.OsResource));

Expand Down
3 changes: 1 addition & 2 deletions media_driver/linux/common/codec/ddi/media_libva_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ VAStatus DdiEncode_CreateContext(
// - HEVCMain10 profile
// - VAProfileVP9Profile2
// - VAProfileVP9Profile3
if (profile == VAProfileHEVCMain10 ||
profile == VAProfileVP9Profile2 ||
if (profile == VAProfileVP9Profile2 ||
profile == VAProfileVP9Profile3)
{
encCtx->m_encode->m_is10Bit = true;
Expand Down
11 changes: 10 additions & 1 deletion media_driver/linux/common/ddi/media_libva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,8 +1950,17 @@ DdiMedia_CreateSurfaces2(
case VA_RT_FORMAT_YUV420:
expected_fourcc = VA_FOURCC_NV12;
break;
case VA_RT_FORMAT_YUV420_12:
expected_fourcc = VA_FOURCC_P016;
break;
case VA_RT_FORMAT_YUV422:
expected_fourcc = VA_FOURCC_422H;
expected_fourcc = VA_FOURCC_YUY2;
break;
case VA_RT_FORMAT_YUV422_10:
expected_fourcc = VA_FOURCC_Y210;
break;
case VA_RT_FORMAT_YUV422_12:
expected_fourcc = VA_FOURCC_Y216;
break;
case VA_RT_FORMAT_YUV444:
expected_fourcc = VA_FOURCC_444P;
Expand Down
105 changes: 104 additions & 1 deletion media_driver/linux/common/ddi/media_libva_caps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ const VAImageFormat MediaLibvaCaps::m_supportedImageformats[] =
{VA_FOURCC_UYVY, VA_LSB_FIRST, 16, 0,0,0,0,0},
{VA_FOURCC_YV12, VA_LSB_FIRST, 12, 0,0,0,0,0},
{VA_FOURCC_IYUV, VA_LSB_FIRST, 12, 0,0,0,0,0},
{VA_FOURCC_Y210, VA_LSB_FIRST, 16, 0,0,0,0,0},
{VA_FOURCC_Y216, VA_LSB_FIRST, 16, 0,0,0,0,0},
{VA_FOURCC_422H, VA_LSB_FIRST, 16, 0,0,0,0,0},
{VA_FOURCC_422V, VA_LSB_FIRST, 16, 0,0,0,0,0},
{VA_FOURCC_Y800, VA_LSB_FIRST, 8, 0,0,0,0,0},
Expand All @@ -124,6 +126,7 @@ const VAImageFormat MediaLibvaCaps::m_supportedImageformats[] =
{VA_FOURCC_RGBP, VA_LSB_FIRST, 24, 24, 0xff0000, 0x00ff00, 0x0000ff, 0},
{VA_FOURCC_BGRP, VA_LSB_FIRST, 24, 24, 0x0000ff, 0x00ff00, 0xff0000, 0},
{VA_FOURCC_P208, VA_LSB_FIRST, 8, 0,0,0,0,0},
{VA_FOURCC_P016, VA_LSB_FIRST, 12, 0,0,0,0,0},
{VA_FOURCC('P','0','1','0'), VA_LSB_FIRST, 24, 0,0,0,0,0},
{VA_FOURCC_AYUV, VA_LSB_FIRST, 24, 0,0,0,0,0},
{VA_FOURCC_Y410, VA_LSB_FIRST, 24, 0,0,0,0,0}
Expand Down Expand Up @@ -395,6 +398,18 @@ VAStatus MediaLibvaCaps::CheckEncRTFormat(
{
attrib->value = VA_RT_FORMAT_YUV420_10;
}
else if(profile == VAProfileHEVCMain12)
{
attrib->value = VA_RT_FORMAT_YUV420_12;
}
else if(profile == VAProfileHEVCMain422_10)
{
attrib->value = VA_RT_FORMAT_YUV422_10;
}
else if(profile == VAProfileHEVCMain422_12)
{
attrib->value = VA_RT_FORMAT_YUV422_12;
}
else if(profile == VAProfileHEVCMain444)
{
attrib->value = VA_RT_FORMAT_YUV444;
Expand All @@ -403,7 +418,7 @@ VAStatus MediaLibvaCaps::CheckEncRTFormat(
{
attrib->value = VA_RT_FORMAT_YUV444_10;
}
else
else
{
attrib->value = VA_RT_FORMAT_YUV420;
}
Expand Down Expand Up @@ -1530,6 +1545,57 @@ VAStatus MediaLibvaCaps::LoadHevcEncProfileEntrypoints()
AddProfileEntry(VAProfileHEVCMain10, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}

if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit))
{
status = CreateEncAttributes(VAProfileHEVCMain12, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);

uint32_t configStartIdx = m_encConfigs.size();
AddEncConfig(VA_RC_CQP);
for (int32_t j = 1; j < 7; j++)
{
AddEncConfig(m_encRcMode[j]);
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
}
AddProfileEntry(VAProfileHEVCMain12, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}

if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit422))
{
status = CreateEncAttributes(VAProfileHEVCMain422_10, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);

uint32_t configStartIdx = m_encConfigs.size();
AddEncConfig(VA_RC_CQP);
for (int32_t j = 1; j < 7; j++)
{
AddEncConfig(m_encRcMode[j]);
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
}
AddProfileEntry(VAProfileHEVCMain422_10, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}

if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit422))
{
status = CreateEncAttributes(VAProfileHEVCMain422_12, VAEntrypointEncSlice, &attributeList);
DDI_CHK_RET(status, "Failed to initialize Caps!");
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER);

uint32_t configStartIdx = m_encConfigs.size();
AddEncConfig(VA_RC_CQP);
for (int32_t j = 1; j < 7; j++)
{
AddEncConfig(m_encRcMode[j]);
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL);
}
AddProfileEntry(VAProfileHEVCMain422_12, VAEntrypointEncSlice, attributeList,
configStartIdx, m_encConfigs.size() - configStartIdx);
}

#endif
return status;
Expand Down Expand Up @@ -2428,6 +2494,37 @@ VAStatus MediaLibvaCaps::QuerySurfaceAttributes(
attribs[i].value.value.i = VA_FOURCC('P', '0', '1', '0');
i++;
}
else if(profile == VAProfileHEVCMain12)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_P016;
i++;
}
else if(profile == VAProfileHEVCMain422_10)
{
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_YUY2;
i++;

attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y210;
i++;
}
else if(profile == VAProfileHEVCMain422_12)
{
//hevc rext: Y216 12/16bit 422
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y216;
i++;
}
else if (profile == VAProfileJPEGBaseline)
{
for (uint32_t j = 0; j < m_numJpegEncSurfaceAttr; j++)
Expand Down Expand Up @@ -2663,6 +2760,9 @@ CODECHAL_MODE MediaLibvaCaps::GetEncodeCodecMode(VAProfile profile, VAEntrypoint
return CODECHAL_ENCODE_MODE_VP9;
case VAProfileHEVCMain:
case VAProfileHEVCMain10:
case VAProfileHEVCMain12:
case VAProfileHEVCMain422_10:
case VAProfileHEVCMain422_12:
return CODECHAL_ENCODE_MODE_HEVC;
default:
DDI_ASSERTMESSAGE("Invalid Encode Mode");
Expand Down Expand Up @@ -2768,6 +2868,9 @@ std::string MediaLibvaCaps::GetEncodeCodecKey(VAProfile profile, VAEntrypoint en
return ENCODE_ID_VP9;
case VAProfileHEVCMain:
case VAProfileHEVCMain10:
case VAProfileHEVCMain12:
case VAProfileHEVCMain422_10:
case VAProfileHEVCMain422_12:
if (IsEncFei(entrypoint))
{
return ENCODE_ID_HEVCFEI;
Expand Down
1 change: 1 addition & 0 deletions media_driver/linux/common/os/linux_system_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct LinuxCodecInfo
uint32_t hevc10Decoding : 1;
uint32_t vp9b10Decoding : 1;
uint32_t hevc10Encoding : 1;
uint32_t hevc12Encoding : 1;
uint32_t vp8Encoding : 1;
uint32_t hevcVdenc : 1;
uint32_t vp9Vdenc : 1;
Expand Down
1 change: 1 addition & 0 deletions media_driver/linux/gen10/ddi/media_sku_wa_g10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static struct LinuxCodecInfo cnlCodecInfo =
.hevc10Decoding = 1,
.vp9b10Decoding = 1,
.hevc10Encoding = SET_STATUS_BY_FULL_OPEN_SOURCE(1, 0),
.hevc12Encoding = 0,
.vp8Encoding = 1,
.hevcVdenc = 1,
.vp9Vdenc = 1,
Expand Down
1 change: 1 addition & 0 deletions media_driver/linux/gen11/ddi/media_sku_wa_g11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static struct LinuxCodecInfo iclCodecInfo =
.hevc10Decoding = 1,
.vp9b10Decoding = 1,
.hevc10Encoding = SET_STATUS_BY_FULL_OPEN_SOURCE(1, 0),
.hevc12Encoding = 0,
.vp8Encoding = 1,
.hevcVdenc = 1,
.vp9Vdenc = 1,
Expand Down

0 comments on commit d748abc

Please sign in to comment.