void MetadataDriver::doColorConversion() { LOGV("doColorConversion"); // Do color conversion using PV's color conversion utility int width = mFrameBufferProp.iFrameWidth; int height = mFrameBufferProp.iFrameHeight; int displayWidth = mFrameBufferProp.iDisplayWidth; int displayHeight = mFrameBufferProp.iDisplayHeight; SkBitmap *bitmap = new SkBitmap(); if (!bitmap) { LOGE("doColorConversion: cannot instantiate a SkBitmap object."); return; } bitmap->setConfig(SkBitmap::kRGB_565_Config, displayWidth, displayHeight); if (!bitmap->allocPixels()) { LOGE("allocPixels failed"); delete bitmap; return; } ColorConvertBase* colorConverter = ColorConvert16::NewL(); if (!colorConverter || !colorConverter->Init(width, height, width, displayWidth, displayHeight, displayWidth, CCROTATE_NONE) || !colorConverter->SetMode(1) || !colorConverter->Convert(mFrameBuffer, (uint8*)bitmap->getPixels())) { LOGE("failed to do color conversion"); delete colorConverter; delete bitmap; return; } delete colorConverter; // Store the SkBitmap pixels in a private shared structure with known // internal memory layout so that the pixels can be sent across the // binder interface delete mVideoFrame; mVideoFrame = new VideoFrame(); if (!mVideoFrame) { LOGE("failed to allocate memory for a VideoFrame object"); delete bitmap; return; } mVideoFrame->mWidth = width; mVideoFrame->mHeight = height; mVideoFrame->mDisplayWidth = displayWidth; mVideoFrame->mDisplayHeight = displayHeight; mVideoFrame->mSize = bitmap->getSize(); LOGV("display width (%d) and height (%d), and size (%d)", displayWidth, displayHeight, mVideoFrame->mSize); mVideoFrame->mData = new uint8[mVideoFrame->mSize]; if (!mVideoFrame->mData) { LOGE("doColorConversion: cannot allocate buffer to hold SkBitmap pixels"); delete bitmap; delete mVideoFrame; mVideoFrame = NULL; return; } memcpy(mVideoFrame->mData, (uint8*) bitmap->getPixels(), mVideoFrame->mSize); delete bitmap; }
void MetadataDriver::doColorConversion() { LOGV("doColorConversion"); // Do color conversion using PV's color conversion utility int width = mFrameBufferProp.iFrameWidth; int height = mFrameBufferProp.iFrameHeight; int displayWidth = mFrameBufferProp.iDisplayWidth; int displayHeight = mFrameBufferProp.iDisplayHeight; SkBitmap *bitmap = new SkBitmap(); //Deinterlace Chroma if the device is an msm7630_surf //and if we are using hardware accelerated video decoder char value[PROPERTY_VALUE_MAX]; property_get("ro.product.device",value,"0"); if(strncmp("msm7630",value,strlen("msm7630")) == 0 && aHwAccelerated == true) deinterlaceChroma(); if (!bitmap) { LOGE("doColorConversion: cannot instantiate a SkBitmap object."); return; } bitmap->setConfig(SkBitmap::kRGB_565_Config, displayWidth, displayHeight); if (!bitmap->allocPixels()) { LOGE("allocPixels failed"); delete bitmap; return; } // When passing parameters in Init call of ColorConverter library // we need to take care of passing even width and height to the CC. // If Width is odd then making it even as below // will reduce the pitch by 1. This may result in a tilted image for // clips with odd width. ColorConvertBase* colorConverter = ColorConvert16::NewL(); if (!colorConverter || !colorConverter->Init(((width)&(~1)), ((height)&(~1)), ((width)&(~1)), displayWidth, ((displayHeight)&(~1)), ((displayWidth)&(~1)), CCROTATE_NONE) || //!colorConverter->Init(width, height, width, displayWidth, displayHeight, displayWidth, CCROTATE_NONE) || !colorConverter->SetMode(1) || !colorConverter->Convert(mFrameBuffer, (uint8*)bitmap->getPixels())) { LOGE("failed to do color conversion"); delete colorConverter; delete bitmap; return; } delete colorConverter; // Store the SkBitmap pixels in a private shared structure with known // internal memory layout so that the pixels can be sent across the // binder interface delete mVideoFrame; mVideoFrame = new VideoFrame(); if (!mVideoFrame) { LOGE("failed to allocate memory for a VideoFrame object"); delete bitmap; return; } mVideoFrame->mWidth = width; mVideoFrame->mHeight = height; mVideoFrame->mDisplayWidth = displayWidth; mVideoFrame->mDisplayHeight = displayHeight; mVideoFrame->mSize = bitmap->getSize(); LOGV("display width (%d) and height (%d), and size (%d)", displayWidth, displayHeight, mVideoFrame->mSize); mVideoFrame->mData = new uint8[mVideoFrame->mSize]; if (!mVideoFrame->mData) { LOGE("doColorConversion: cannot allocate buffer to hold SkBitmap pixels"); delete bitmap; delete mVideoFrame; mVideoFrame = NULL; return; } memcpy(mVideoFrame->mData, (uint8*) bitmap->getPixels(), mVideoFrame->mSize); delete bitmap; }