Skip to content

Commit

Permalink
mm-video-v4l2: support bt601 full range for c2d
Browse files Browse the repository at this point in the history
Add bt601 full range support for c2d colorconvertor.
For RGBA8888 input, don't recommend limited range,
keep client's default configuration for range.

CRs-Fixed: 2264110
Change-Id: Ie8f73fe447b2fba38bfd568693d3ef8d80aa9a7b
  • Loading branch information
Qiwei Liu authored and Gerrit - the friendly Code Review server committed Nov 29, 2018
1 parent a7ba41c commit ba6a82b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions libc2dcolorconvert/C2DColorConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ int32_t C2DColorConverter::getDummySurfaceDef(ColorConvertFormat format,
(*surfaceYUVDef)->phys2 = NULL;
(*surfaceYUVDef)->plane2 = NULL;

if (mFlags & private_handle_t::PRIV_FLAGS_ITU_R_601_FR) {
(*surfaceYUVDef)->format |= C2D_FORMAT_BT601_FULLRANGE;
}

if (format == YCbCr420P ||
format == YCrCb420P) {
ALOGI("%s: half stride for Cb Cr planes \n", __FUNCTION__);
Expand Down
9 changes: 6 additions & 3 deletions mm-video-v4l2/vidc/venc/src/omx_video_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2336,9 +2336,10 @@ OMX_ERRORTYPE omx_video::get_config(OMX_IN OMX_HANDLETYPE hComp,
// If the dataspace says RGB, recommend 601-limited;
// since that is the destination colorspace that C2D or Venus will convert to.
if (pParam->nPixelFormat == HAL_PIXEL_FORMAT_RGBA_8888) {
DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: Recommend 601-limited for RGBA8888");
DEBUG_PRINT_INFO("get_config (dataspace changed): ColorSpace: Recommend 601 for RGBA8888");
pParam->sAspects.mPrimaries = ColorAspects::PrimariesBT601_6_625;
pParam->sAspects.mRange = ColorAspects::RangeLimited;
// keep client-default setting for range
// pParam->sAspects.mRange = ColorAspects::RangeLimited;
pParam->sAspects.mTransfer = ColorAspects::TransferSMPTE170M;
pParam->sAspects.mMatrixCoeffs = ColorAspects::MatrixBT601_6;
} else {
Expand Down Expand Up @@ -5083,6 +5084,8 @@ OMX_ERRORTYPE omx_video::empty_this_buffer_opaque(OMX_IN OMX_HANDLETYPE hComp,

mUsesColorConversion = is_conv_needed(handle);
bool interlaced = is_ubwc_interlaced(handle);
int full_range_flag = m_sConfigColorAspects.sAspects.mRange == ColorAspects::RangeFull ?
private_handle_t::PRIV_FLAGS_ITU_R_601_FR : 0;

if (c2dcc.getConversionNeeded() &&
c2dcc.isPropChanged(m_sInPortDef.format.video.nFrameWidth,
Expand All @@ -5103,7 +5106,7 @@ OMX_ERRORTYPE omx_video::empty_this_buffer_opaque(OMX_IN OMX_HANDLETYPE hComp,
m_sInPortDef.format.video.nFrameWidth,
m_sInPortDef.format.video.nFrameHeight,
c2dSrcFmt, c2dDestFmt,
handle->flags, handle->width)) {
handle->flags | full_range_flag, handle->width)) {
m_pCallbacks.EmptyBufferDone(hComp,m_app_data,buffer);
DEBUG_PRINT_ERROR("SetResolution failed");
return OMX_ErrorBadParameter;
Expand Down

0 comments on commit ba6a82b

Please sign in to comment.