Loading media/codec2/sfplugin/CCodec.cpp +24 −11 Original line number Diff line number Diff line Loading @@ -2605,19 +2605,32 @@ void CCodec::signalSetParameters(const sp<AMessage> &msg) { c2_status_t status = GetCodec2BlockPool(C2BlockPool::BASIC_LINEAR, nullptr, &pool); if (status == C2_OK) { int width, height; config->mInputFormat->findInt32("width", &width); config->mInputFormat->findInt32("height", &height); // The length of the qp-map corresponds to the number of 16x16 blocks in one frame int expectedMapSize = ((width + 15) / 16) * ((height + 15) / 16); size_t mapSize = qpOffsetMap->size(); if (mapSize >= expectedMapSize) { std::shared_ptr<C2LinearBlock> block; status = pool->fetchLinearBlock(mapSize, C2MemoryUsage{C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}, &block); status = pool->fetchLinearBlock( expectedMapSize, C2MemoryUsage{C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}, &block); if (status == C2_OK && !block->map().get().error()) { C2WriteView wView = block->map().get(); uint8_t* outData = wView.data(); memcpy(outData, qpOffsetMap->data(), mapSize); memcpy(outData, qpOffsetMap->data(), expectedMapSize); C2InfoBuffer info = C2InfoBuffer::CreateLinearBuffer( kParamIndexQpOffsetMapBuffer, block->share(0, mapSize, C2Fence())); block->share(0, expectedMapSize, C2Fence())); mChannel->setInfoBuffer(std::make_shared<C2InfoBuffer>(info)); } } else { ALOGE("Ignoring param key %s as buffer size %d is less than expected " "buffer size %d", PARAMETER_KEY_QP_OFFSET_MAP, mapSize, expectedMapSize); } } params->removeEntryByName(PARAMETER_KEY_QP_OFFSET_MAP); } Loading media/codec2/sfplugin/CCodecConfig.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -1890,6 +1890,9 @@ ReflectedParamUpdater::Dict CCodecConfig::getReflectedFormat( if (mDomain == (IS_VIDEO | IS_ENCODER)) { AString qpOffsetRects; if (params->findString(PARAMETER_KEY_QP_OFFSET_RECTS, &qpOffsetRects)) { int width, height; mInputFormat->findInt32("width", &width); mInputFormat->findInt32("height", &height); std::vector<C2QpOffsetRectStruct> c2QpOffsetRects; char mutableStrQpOffsetRects[strlen(qpOffsetRects.c_str()) + 1]; strcpy(mutableStrQpOffsetRects, qpOffsetRects.c_str()); Loading @@ -1899,11 +1902,17 @@ ReflectedParamUpdater::Dict CCodecConfig::getReflectedFormat( if (sscanf(box, "%d,%d-%d,%d=%d", &top, &left, &bottom, &right, &offset) == 5) { left = c2_max(0, left); top = c2_max(0, top); right = c2_min(right, width); bottom = c2_min(bottom, height); if (right > left && bottom > top) { C2Rect rect(right - left, bottom - top); rect.at(left, top); c2QpOffsetRects.push_back(C2QpOffsetRectStruct(rect, offset)); } else { ALOGE("Rects configuration %s is not valid.", box); } } else { ALOGE("Rects configuration %s doesn't follow the string pattern.", box); } box = strtok(nullptr, ";"); } Loading Loading
media/codec2/sfplugin/CCodec.cpp +24 −11 Original line number Diff line number Diff line Loading @@ -2605,19 +2605,32 @@ void CCodec::signalSetParameters(const sp<AMessage> &msg) { c2_status_t status = GetCodec2BlockPool(C2BlockPool::BASIC_LINEAR, nullptr, &pool); if (status == C2_OK) { int width, height; config->mInputFormat->findInt32("width", &width); config->mInputFormat->findInt32("height", &height); // The length of the qp-map corresponds to the number of 16x16 blocks in one frame int expectedMapSize = ((width + 15) / 16) * ((height + 15) / 16); size_t mapSize = qpOffsetMap->size(); if (mapSize >= expectedMapSize) { std::shared_ptr<C2LinearBlock> block; status = pool->fetchLinearBlock(mapSize, C2MemoryUsage{C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}, &block); status = pool->fetchLinearBlock( expectedMapSize, C2MemoryUsage{C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}, &block); if (status == C2_OK && !block->map().get().error()) { C2WriteView wView = block->map().get(); uint8_t* outData = wView.data(); memcpy(outData, qpOffsetMap->data(), mapSize); memcpy(outData, qpOffsetMap->data(), expectedMapSize); C2InfoBuffer info = C2InfoBuffer::CreateLinearBuffer( kParamIndexQpOffsetMapBuffer, block->share(0, mapSize, C2Fence())); block->share(0, expectedMapSize, C2Fence())); mChannel->setInfoBuffer(std::make_shared<C2InfoBuffer>(info)); } } else { ALOGE("Ignoring param key %s as buffer size %d is less than expected " "buffer size %d", PARAMETER_KEY_QP_OFFSET_MAP, mapSize, expectedMapSize); } } params->removeEntryByName(PARAMETER_KEY_QP_OFFSET_MAP); } Loading
media/codec2/sfplugin/CCodecConfig.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -1890,6 +1890,9 @@ ReflectedParamUpdater::Dict CCodecConfig::getReflectedFormat( if (mDomain == (IS_VIDEO | IS_ENCODER)) { AString qpOffsetRects; if (params->findString(PARAMETER_KEY_QP_OFFSET_RECTS, &qpOffsetRects)) { int width, height; mInputFormat->findInt32("width", &width); mInputFormat->findInt32("height", &height); std::vector<C2QpOffsetRectStruct> c2QpOffsetRects; char mutableStrQpOffsetRects[strlen(qpOffsetRects.c_str()) + 1]; strcpy(mutableStrQpOffsetRects, qpOffsetRects.c_str()); Loading @@ -1899,11 +1902,17 @@ ReflectedParamUpdater::Dict CCodecConfig::getReflectedFormat( if (sscanf(box, "%d,%d-%d,%d=%d", &top, &left, &bottom, &right, &offset) == 5) { left = c2_max(0, left); top = c2_max(0, top); right = c2_min(right, width); bottom = c2_min(bottom, height); if (right > left && bottom > top) { C2Rect rect(right - left, bottom - top); rect.at(left, top); c2QpOffsetRects.push_back(C2QpOffsetRectStruct(rect, offset)); } else { ALOGE("Rects configuration %s is not valid.", box); } } else { ALOGE("Rects configuration %s doesn't follow the string pattern.", box); } box = strtok(nullptr, ";"); } Loading