Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Encode] Enable HEVC ARGB/ARGB10 encoding input supporting for Linux
1. Support ARGB/ARGB10 encoding input
2. Enable encoding swizzle for ARGB input

Change-Id: I9ccbece33288890a8ee33f6534bf9a220531a8f9
  • Loading branch information
Xiaogangli-intel authored and intel-mediadev committed Sep 18, 2019
1 parent e77cc47 commit 6b74dac
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
4 changes: 4 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_hevc.cpp
Expand Up @@ -585,6 +585,10 @@ VAStatus DdiEncodeHevc::ParsePicParams(
hevcPicParams->slice_pic_parameter_set_id = picParams->slice_pic_parameter_set_id;
hevcPicParams->nal_unit_type = picParams->nal_unit_type;
hevcPicParams->no_output_of_prior_pics_flag = picParams->pic_fields.bits.no_output_of_prior_pics_flag;
hevcPicParams->bDisplayFormatSwizzle = NeedDisapayFormatSwizzle(rtTbl->pCurrentRT, rtTbl->pCurrentReconTarget);

// Correct Input color space of Sequence parameter here
hevcSeqParams->InputColorSpace = hevcPicParams->bDisplayFormatSwizzle ? ECOLORSPACE_P601 : ECOLORSPACE_P709;

if (hevcPicParams->tiles_enabled_flag)
{
Expand Down
31 changes: 31 additions & 0 deletions media_driver/linux/common/codec/ddi/media_ddi_encode_hevc.h
Expand Up @@ -262,5 +262,36 @@ class DdiEncodeHevc : public DdiEncodeBase
bool picReference,
bool sliceReference);

//!
//! \brief Check whether swizzle needed
//!
//! \param [in] rawSurface
//! Pointer of Raw Surface
//! \param [in] reconSurface
//! Pointer of Recon Surface
//!
//! \return bool, true if need, otherwise false
//!
inline bool NeedDisapayFormatSwizzle(
DDI_MEDIA_SURFACE *rawSurface,
DDI_MEDIA_SURFACE *reconSurface)
{
bool ret = false;

if (Media_Format_A8R8G8B8 == rawSurface->format ||
Media_Format_B10G10R10A2 == rawSurface->format)
{
ret = true;
}

if (ret &&
(Media_Format_A8R8G8B8 == reconSurface->format ||
Media_Format_B10G10R10A2 == reconSurface->format))
{
ret = false;
}

return ret;
}
};
#endif //__MEDIA_LIBVA_ENCODER_HEVC_H__
10 changes: 9 additions & 1 deletion media_driver/linux/common/ddi/media_libva.cpp
Expand Up @@ -406,8 +406,9 @@ int32_t DdiMedia_MediaFormatToOsFormat(DDI_MEDIA_FORMAT format)
case Media_Format_R8G8B8A8:
return VA_FOURCC_RGBA;
case Media_Format_A8R8G8B8:
case Media_Format_B10G10R10A2:
return VA_FOURCC_ARGB;
case Media_Format_B10G10R10A2:
return VA_FOURCC_A2R10G10B10;
case Media_Format_R5G6B5:
return VA_FOURCC_R5G6B5;
case Media_Format_R8G8B8:
Expand Down Expand Up @@ -495,6 +496,8 @@ DDI_MEDIA_FORMAT DdiMedia_OsFormatToMediaFormat(int32_t fourcc, int32_t rtformat
{
case VA_FOURCC_A2R10G10B10:
return Media_Format_B10G10R10A2;
case VA_FOURCC_A2B10G10R10:
return Media_Format_R10G10B10A2;
case VA_FOURCC_BGRA:
case VA_FOURCC_ARGB:
#ifdef VA_RT_FORMAT_RGB32_10BPP
Expand Down Expand Up @@ -4365,6 +4368,11 @@ VAStatus DdiMedia_DeriveImage (
vaimg->offsets[1] = UPlaneYOffset * mediaSurface->iPitch;
vaimg->offsets[2] = vaimg->offsets[1] + 2;
break;
case Media_Format_R10G10B10A2:
case Media_Format_B10G10R10A2:
vaimg->offsets[1] = vaimg->data_size;
vaimg->offsets[2] = vaimg->offsets[1] + 1;
break;
default:
vaimg->offsets[1] = UPlaneYOffset * mediaSurface->iPitch;
vaimg->offsets[2] = vaimg->offsets[1] + 1;
Expand Down

0 comments on commit 6b74dac

Please sign in to comment.