本文整理汇总了C++中android::sp::lockYCbCr方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::lockYCbCr方法的具体用法?C++ sp::lockYCbCr怎么用?C++ sp::lockYCbCr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android::sp
的用法示例。
在下文中一共展示了sp::lockYCbCr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unlock
/**
* Converts the format of vendor-specific YVU420(planar and semi-planar)
* with the help of GraphicBuffer::lockYCbCr. In this way, we can convert
* the YUV color format without awaring actual definition/enumeration
* of vendor formats.
*/
static status_t
ConvertVendorYUVFormatToRGB565(android::sp<GraphicBuffer>& aBuffer,
gfx::DataSourceSurface *aSurface,
gfx::DataSourceSurface::MappedSurface *aMappedSurface)
{
status_t rv = BAD_VALUE;
#if ANDROID_VERSION >= 18
android_ycbcr ycbcr;
// Check if the vendor provides explicit addresses of Y/Cb/Cr buffer from lockYCbCr
rv = aBuffer->lockYCbCr(android::GraphicBuffer::USAGE_SW_READ_OFTEN, &ycbcr);
if (rv != OK) {
NS_WARNING("Couldn't lock graphic buffer using lockYCbCr()");
return rv;
}
GraphicBufferAutoUnlock unlock(aBuffer);
uint32_t width = aSurface->GetSize().width;
uint32_t height = aSurface->GetSize().height;
if (ycbcr.chroma_step == 2) {
// From the system/core/include/system/graphics.h
// @chroma_step is the distance in bytes from one chroma pixel value to
// the next. This is 2 bytes for semiplanar (because chroma values are
// interleaved and each chroma value is one byte) and 1 for planar.
ConvertYVU420SPToRGB565(ycbcr.y, ycbcr.ystride,
ycbcr.cb, ycbcr.cr, ycbcr.cstride,
aMappedSurface->mData,
width, height);
} else {
layers::PlanarYCbCrData ycbcrData;
ycbcrData.mYChannel = static_cast<uint8_t*>(ycbcr.y);
ycbcrData.mYStride = ycbcr.ystride;
ycbcrData.mYSize = aSurface->GetSize();
ycbcrData.mCbChannel = static_cast<uint8_t*>(ycbcr.cb);
ycbcrData.mCrChannel = static_cast<uint8_t*>(ycbcr.cr);
ycbcrData.mCbCrStride = ycbcr.cstride;
ycbcrData.mCbCrSize = aSurface->GetSize() / 2;
ycbcrData.mPicSize = aSurface->GetSize();
gfx::ConvertYCbCrToRGB(ycbcrData,
aSurface->GetFormat(),
aSurface->GetSize(),
aMappedSurface->mData,
aMappedSurface->mStride);
}
#endif
return rv;
}