codec2: fix coding style by clang-format
clang-format files are in Change-Id:
I78c285c6e1796b3f3ec118fd81a7f52d0503600f
Bug: None
Test: run native tests.
Change-Id: I4d46de3cc89813f50dfd0c12387cd50fb895b438
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index 8054ae0..3e74368 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -5,8 +5,8 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "C2VDAComponent"
-#include <algorithm>
#include <inttypes.h>
+#include <algorithm>
#include "C2VDAAdaptor.h"
#define __C2_GENERATE_GLOBAL_VARS__
@@ -20,7 +20,10 @@
#include <utils/Log.h>
#include <utils/misc.h>
-#define UNUSED(expr) do { (void)(expr); } while (0)
+#define UNUSED(expr) \
+ do { \
+ (void)(expr); \
+ } while (0)
namespace android {
@@ -29,8 +32,8 @@
// Get index from C2param object. Use index to identify the type of the parameter.
// Currently there is no wise way to get index from a parameter because index is private.
uint32_t restoreIndex(const C2Param* param) {
- return (param->forStream() ? (0x02000000 | ((param->stream() << 17) & 0x01FE0000)) : 0)
- | param->type();
+ return (param->forStream() ? (0x02000000 | ((param->stream() << 17) & 0x01FE0000)) : 0) |
+ param->type();
}
// Helper function to allocate string type parameters.
@@ -46,18 +49,18 @@
std::unique_ptr<C2SettingResult> reportReadOnlyFailure(C2Param* c2Param) {
T* param = (T*)c2Param;
return std::unique_ptr<C2SettingResult>(
- new C2SettingResult { C2SettingResult::READ_ONLY,
- { C2ParamField(param, &T::mValue), nullptr /* supportedValues */ },
- {} /* conflictedFields */ });
+ new C2SettingResult{C2SettingResult::READ_ONLY,
+ {C2ParamField(param, &T::mValue), nullptr /* supportedValues */},
+ {} /* conflictedFields */});
}
template <class T>
std::unique_ptr<C2SettingResult> reportReadOnlyFlexFailure(C2Param* c2Param) {
T* param = (T*)c2Param;
return std::unique_ptr<C2SettingResult>(
- new C2SettingResult { C2SettingResult::READ_ONLY,
- { C2ParamField(param, &T::m), nullptr /* supportedValues */ },
- {} /* conflictedFields */ });
+ new C2SettingResult{C2SettingResult::READ_ONLY,
+ {C2ParamField(param, &T::m), nullptr /* supportedValues */},
+ {} /* conflictedFields */});
}
// Helper function to find int32_t value from C2Value::Primitive vector.
@@ -76,7 +79,7 @@
}
// if values.type == C2FieldSupportedValues::VALUES
return std::any_of(values.values.begin(), values.values.end(),
- [v=v](const auto& value) { return value.i32 == v; });
+ [v = v](const auto& value) { return value.i32 == v; });
}
// Helper function to find uint32_t value from C2Value::Primitive vector.
@@ -95,7 +98,7 @@
}
// if values.type == C2FieldSupportedValues::VALUES
return std::any_of(values.values.begin(), values.values.end(),
- [v=v](const auto& value) { return value.u32 == v; });
+ [v = v](const auto& value) { return value.u32 == v; });
}
// Mask against 30 bits to avoid (undefined) wraparound on signed integer.
@@ -109,13 +112,13 @@
} // namespace
C2VDAComponentIntf::C2VDAComponentIntf(C2String name, c2_node_id_t id)
- : kName(name),
- kId(id),
- mInitStatus(C2_OK),
- mDomainInfo(C2DomainVideo),
- mOutputColorFormat(0u, kColorFormatYUV420Flexible),
- mOutputPortMime(allocUniqueCstr<C2PortMimeConfig::output>(MEDIA_MIMETYPE_VIDEO_RAW)),
- mOutputBlockPools(C2PortBlockPoolsTuning::output::alloc_unique({})) {
+ : kName(name),
+ kId(id),
+ mInitStatus(C2_OK),
+ mDomainInfo(C2DomainVideo),
+ mOutputColorFormat(0u, kColorFormatYUV420Flexible),
+ mOutputPortMime(allocUniqueCstr<C2PortMimeConfig::output>(MEDIA_MIMETYPE_VIDEO_RAW)),
+ mOutputBlockPools(C2PortBlockPoolsTuning::output::alloc_unique({})) {
// TODO(johnylin): use factory function to determine whether V4L2 stream or slice API is.
uint32_t inputFormatFourcc;
if (name == kH264DecoderName) {
@@ -153,12 +156,12 @@
for (const auto& supportedProfile : mSupportedProfiles) {
mSupportedCodecProfiles.push_back(supportedProfile.profile);
- ALOGI("Get supported profile: profile=%d, min_res=%s, max_res=%s",
- supportedProfile.profile, supportedProfile.min_resolution.ToString().c_str(),
+ ALOGI("Get supported profile: profile=%d, min_res=%s, max_res=%s", supportedProfile.profile,
+ supportedProfile.min_resolution.ToString().c_str(),
supportedProfile.max_resolution.ToString().c_str());
}
- auto insertParam = [¶ms = mParams] (C2Param* param) {
+ auto insertParam = [& params = mParams](C2Param* param) {
params[restoreIndex(param)] = param;
};
@@ -168,9 +171,8 @@
insertParam(mOutputPortMime.get());
insertParam(&mInputCodecProfile);
- mSupportedValues.emplace(
- C2ParamField(&mInputCodecProfile, &C2StreamFormatConfig::mValue),
- C2FieldSupportedValues(false, mSupportedCodecProfiles));
+ mSupportedValues.emplace(C2ParamField(&mInputCodecProfile, &C2StreamFormatConfig::mValue),
+ C2FieldSupportedValues(false, mSupportedCodecProfiles));
// TODO(johnylin): min/max resolution may change by chosen profile, we should dynamically change
// the supported values in the future.
@@ -192,22 +194,20 @@
insertParam(mOutputBlockPools.get());
- mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
- true, "_domain", &mDomainInfo));
- mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
- false, "_output_color_format", &mOutputColorFormat));
- mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
- true, "_input_port_mime", mInputPortMime.get()));
- mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
- true, "_output_port_mime", mOutputPortMime.get()));
- mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
- false, "_input_codec_profile", &mInputCodecProfile));
- mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
- false, "_video_size", &mVideoSize));
- mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
- false, "_max_video_size_hint", &mMaxVideoSizeHint));
- mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(
- false, "_output_block_pools", mOutputBlockPools.get()));
+ mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(true, "_domain", &mDomainInfo));
+ mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(false, "_output_color_format",
+ &mOutputColorFormat));
+ mParamDescs.push_back(
+ std::make_shared<C2ParamDescriptor>(true, "_input_port_mime", mInputPortMime.get()));
+ mParamDescs.push_back(
+ std::make_shared<C2ParamDescriptor>(true, "_output_port_mime", mOutputPortMime.get()));
+ mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(false, "_input_codec_profile",
+ &mInputCodecProfile));
+ mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(false, "_video_size", &mVideoSize));
+ mParamDescs.push_back(
+ std::make_shared<C2ParamDescriptor>(false, "_max_video_size_hint", &mMaxVideoSizeHint));
+ mParamDescs.push_back(std::make_shared<C2ParamDescriptor>(false, "_output_block_pools",
+ mOutputBlockPools.get()));
}
C2String C2VDAComponentIntf::getName() const {
@@ -220,8 +220,7 @@
c2_status_t C2VDAComponentIntf::query_vb(
const std::vector<C2Param* const>& stackParams,
- const std::vector<C2Param::Index>& heapParamIndices,
- c2_blocking_t mayBlock,
+ const std::vector<C2Param::Index>& heapParamIndices, c2_blocking_t mayBlock,
std::vector<std::unique_ptr<C2Param>>* const heapParams) const {
UNUSED(mayBlock);
c2_status_t err = C2_OK;
@@ -256,8 +255,7 @@
}
c2_status_t C2VDAComponentIntf::config_vb(
- const std::vector<C2Param* const> ¶ms,
- c2_blocking_t mayBlock,
+ const std::vector<C2Param* const>& params, c2_blocking_t mayBlock,
std::vector<std::unique_ptr<C2SettingResult>>* const failures) {
UNUSED(mayBlock);
c2_status_t err = C2_OK;
@@ -279,31 +277,34 @@
err = C2_BAD_VALUE;
continue;
} else if (index == restoreIndex(mInputPortMime.get())) { // read-only
- failures->push_back(
- reportReadOnlyFlexFailure<std::remove_pointer<decltype(mInputPortMime.get())>::type>(param));
+ failures->push_back(reportReadOnlyFlexFailure<
+ std::remove_pointer<decltype(mInputPortMime.get())>::type>(param));
err = C2_BAD_VALUE;
continue;
} else if (index == restoreIndex(mOutputPortMime.get())) { // read-only
- failures->push_back(
- reportReadOnlyFlexFailure<std::remove_pointer<decltype(mOutputPortMime.get())>::type>(param));
+ failures->push_back(reportReadOnlyFlexFailure<
+ std::remove_pointer<decltype(mOutputPortMime.get())>::type>(param));
err = C2_BAD_VALUE;
continue;
} else if (index == restoreIndex(&mInputCodecProfile)) {
- std::unique_ptr<C2SettingResult> result = validateUint32Config<decltype(mInputCodecProfile)>(param);
+ std::unique_ptr<C2SettingResult> result =
+ validateUint32Config<decltype(mInputCodecProfile)>(param);
if (result) {
failures->push_back(std::move(result));
err = C2_BAD_VALUE;
continue;
}
} else if (index == restoreIndex(&mVideoSize)) {
- std::unique_ptr<C2SettingResult> result = validateVideoSizeConfig<decltype(mVideoSize)>(param);
+ std::unique_ptr<C2SettingResult> result =
+ validateVideoSizeConfig<decltype(mVideoSize)>(param);
if (result) {
failures->push_back(std::move(result));
err = C2_BAD_VALUE;
continue;
}
} else if (index == restoreIndex(&mMaxVideoSizeHint)) {
- std::unique_ptr<C2SettingResult> result = validateVideoSizeConfig<decltype(mMaxVideoSizeHint)>(param);
+ std::unique_ptr<C2SettingResult> result =
+ validateVideoSizeConfig<decltype(mMaxVideoSizeHint)>(param);
if (result) {
failures->push_back(std::move(result));
err = C2_BAD_VALUE;
@@ -314,7 +315,7 @@
// TODO: add support for output-block-pools (this will be done when we move all
// config to shared ptr)
mOutputBlockPools.reset(
- static_cast<C2PortBlockPoolsTuning::output *>(C2Param::Copy(*param).release()));
+ static_cast<C2PortBlockPoolsTuning::output*>(C2Param::Copy(*param).release()));
continue;
}
myParam->updateFrom(*param);
@@ -364,60 +365,50 @@
return (iter != mParams.end()) ? iter->second : nullptr;
}
-template<class T>
+template <class T>
std::unique_ptr<C2SettingResult> C2VDAComponentIntf::validateVideoSizeConfig(
C2Param* c2Param) const {
T* videoSize = (T*)c2Param;
C2ParamField fieldWidth(videoSize, &T::mWidth);
- const C2FieldSupportedValues &widths = mSupportedValues.at(fieldWidth);
+ const C2FieldSupportedValues& widths = mSupportedValues.at(fieldWidth);
CHECK_EQ(widths.type, C2FieldSupportedValues::RANGE);
if (!findInt32FromPrimitiveValues(videoSize->mWidth, widths)) {
- std::unique_ptr<C2SettingResult> result(
- new C2SettingResult { C2SettingResult::BAD_VALUE,
- { fieldWidth,
- std::make_unique<C2FieldSupportedValues>(
- widths.range.min,
- widths.range.max,
- widths.range.step) },
- {} /* conflicts */ });
+ std::unique_ptr<C2SettingResult> result(new C2SettingResult{
+ C2SettingResult::BAD_VALUE,
+ {fieldWidth, std::make_unique<C2FieldSupportedValues>(
+ widths.range.min, widths.range.max, widths.range.step)},
+ {} /* conflicts */});
return result;
}
C2ParamField fieldHeight(videoSize, &T::mHeight);
- const C2FieldSupportedValues &heights = mSupportedValues.at(fieldHeight);
+ const C2FieldSupportedValues& heights = mSupportedValues.at(fieldHeight);
CHECK_EQ(heights.type, C2FieldSupportedValues::RANGE);
if (!findInt32FromPrimitiveValues(videoSize->mHeight, heights)) {
- std::unique_ptr<C2SettingResult> result(
- new C2SettingResult { C2SettingResult::BAD_VALUE,
- { fieldHeight,
- std::make_unique<C2FieldSupportedValues>(
- heights.range.min,
- heights.range.max,
- heights.range.step) },
- {} /* conflicts */ });
+ std::unique_ptr<C2SettingResult> result(new C2SettingResult{
+ C2SettingResult::BAD_VALUE,
+ {fieldHeight, std::make_unique<C2FieldSupportedValues>(
+ heights.range.min, heights.range.max, heights.range.step)},
+ {} /* conflicts */});
return result;
}
return nullptr;
}
-template<class T>
-std::unique_ptr<C2SettingResult> C2VDAComponentIntf::validateUint32Config(
- C2Param* c2Param) const {
+template <class T>
+std::unique_ptr<C2SettingResult> C2VDAComponentIntf::validateUint32Config(C2Param* c2Param) const {
T* config = (T*)c2Param;
C2ParamField field(config, &T::mValue);
- const C2FieldSupportedValues &configs = mSupportedValues.at(field);
+ const C2FieldSupportedValues& configs = mSupportedValues.at(field);
if (!findUint32FromPrimitiveValues(config->mValue, configs)) {
- std::unique_ptr<C2SettingResult> result(
- new C2SettingResult { C2SettingResult::BAD_VALUE,
- { field, nullptr },
- {} /* conflicts */ });
+ std::unique_ptr<C2SettingResult> result(new C2SettingResult{
+ C2SettingResult::BAD_VALUE, {field, nullptr}, {} /* conflicts */});
if (configs.type == C2FieldSupportedValues::RANGE) {
- result->field.values.reset(new C2FieldSupportedValues(configs.range.min,
- configs.range.max,
- configs.range.step));
+ result->field.values.reset(new C2FieldSupportedValues(
+ configs.range.min, configs.range.max, configs.range.step));
} else if (configs.type == C2FieldSupportedValues::VALUES) {
result->field.values.reset(new C2FieldSupportedValues(false, configs.values));
} else {
@@ -430,15 +421,15 @@
}
////////////////////////////////////////////////////////////////////////////////
-#define EXPECT_STATE_OR_RETURN_ON_ERROR(x) \
- do { \
+#define EXPECT_STATE_OR_RETURN_ON_ERROR(x) \
+ do { \
if (mComponentState == ComponentState::ERROR) return; \
- CHECK_EQ(mComponentState, ComponentState::x); \
+ CHECK_EQ(mComponentState, ComponentState::x); \
} while (0)
-#define EXPECT_RUNNING_OR_RETURN_ON_ERROR() \
- do { \
- if (mComponentState == ComponentState::ERROR) return; \
+#define EXPECT_RUNNING_OR_RETURN_ON_ERROR() \
+ do { \
+ if (mComponentState == ComponentState::ERROR) return; \
CHECK_NE(mComponentState, ComponentState::UNINITIALIZED); \
} while (0)
@@ -447,37 +438,39 @@
C2VDAGraphicBuffer(const std::shared_ptr<C2GraphicBlock>& block,
const base::Closure& releaseCB);
~C2VDAGraphicBuffer() override;
+
private:
base::Closure mReleaseCB;
};
C2VDAGraphicBuffer::C2VDAGraphicBuffer(const std::shared_ptr<C2GraphicBlock>& block,
const base::Closure& releaseCB)
- : C2Buffer({ block->share(C2Rect(block->width(), block->height()), C2Fence()) }),
- mReleaseCB(releaseCB) {}
+ : C2Buffer({block->share(C2Rect(block->width(), block->height()), C2Fence())}),
+ mReleaseCB(releaseCB) {}
C2VDAGraphicBuffer::~C2VDAGraphicBuffer() {
if (!mReleaseCB.is_null()) {
- mReleaseCB.Run();
+ mReleaseCB.Run();
}
}
C2VDAComponent::VideoFormat::VideoFormat(uint32_t pixelFormat, uint32_t minNumBuffers,
media::Size codedSize, media::Rect visibleRect)
- : mPixelFormat(pixelFormat), mMinNumBuffers(minNumBuffers), mCodedSize(codedSize),
- mVisibleRect(visibleRect) {}
+ : mPixelFormat(pixelFormat),
+ mMinNumBuffers(minNumBuffers),
+ mCodedSize(codedSize),
+ mVisibleRect(visibleRect) {}
-C2VDAComponent::C2VDAComponent(C2String name,
- c2_node_id_t id)
- : mIntf(std::make_shared<C2VDAComponentIntf>(name, id)),
- mThread("C2VDAComponentThread"),
- mVDAInitResult(VideoDecodeAcceleratorAdaptor::Result::ILLEGAL_STATE),
- mComponentState(ComponentState::UNINITIALIZED),
- mColorFormat(0u),
- mLastOutputTimestamp(-1),
- mCodecProfile(media::VIDEO_CODEC_PROFILE_UNKNOWN),
- mState(State::UNLOADED),
- mWeakThisFactory(this) {
+C2VDAComponent::C2VDAComponent(C2String name, c2_node_id_t id)
+ : mIntf(std::make_shared<C2VDAComponentIntf>(name, id)),
+ mThread("C2VDAComponentThread"),
+ mVDAInitResult(VideoDecodeAcceleratorAdaptor::Result::ILLEGAL_STATE),
+ mComponentState(ComponentState::UNINITIALIZED),
+ mColorFormat(0u),
+ mLastOutputTimestamp(-1),
+ mCodecProfile(media::VIDEO_CODEC_PROFILE_UNKNOWN),
+ mState(State::UNLOADED),
+ mWeakThisFactory(this) {
// TODO(johnylin): the client may need to know if init is failed.
if (mIntf->status() != C2_OK) {
ALOGE("Component interface init failed (err code = %d)", mIntf->status());
@@ -496,15 +489,15 @@
CHECK_EQ(mState, State::LOADED);
if (mThread.IsRunning()) {
- mTaskRunner->PostTask(
- FROM_HERE, base::Bind(&C2VDAComponent::onDestroy, base::Unretained(this)));
+ mTaskRunner->PostTask(FROM_HERE,
+ base::Bind(&C2VDAComponent::onDestroy, base::Unretained(this)));
mThread.Stop();
}
}
void C2VDAComponent::fetchParametersFromIntf() {
C2StreamFormatConfig::input codecProfile;
- std::vector<C2Param* const> stackParams{ &codecProfile };
+ std::vector<C2Param* const> stackParams{&codecProfile};
CHECK_EQ(mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr), C2_OK);
// The value should be guaranteed to be within media::VideoCodecProfile enum range by component
// interface.
@@ -663,11 +656,9 @@
// Attach output buffer to the work corresponded to bitstreamId.
CHECK_EQ(work->worklets.size(), 1u);
work->worklets.front()->output.buffers.clear();
- work->worklets.front()->output.buffers.emplace_back(
- std::make_shared<C2VDAGraphicBuffer>(info->mGraphicBlock,
- base::Bind(&C2VDAComponent::returnOutputBuffer,
- mWeakThisFactory.GetWeakPtr(),
- pictureBufferId)));
+ work->worklets.front()->output.buffers.emplace_back(std::make_shared<C2VDAGraphicBuffer>(
+ info->mGraphicBlock, base::Bind(&C2VDAComponent::returnOutputBuffer,
+ mWeakThisFactory.GetWeakPtr(), pictureBufferId)));
work->worklets.front()->output.ordinal = work->input.ordinal;
work->worklets_processed = 1u;
@@ -803,8 +794,8 @@
mComponentState = ComponentState::UNINITIALIZED;
}
-c2_status_t C2VDAComponent::setListener_vb(
- const std::shared_ptr<C2Component::Listener> &listener, c2_blocking_t mayBlock) {
+c2_status_t C2VDAComponent::setListener_vb(const std::shared_ptr<C2Component::Listener>& listener,
+ c2_blocking_t mayBlock) {
UNUSED(mayBlock);
// TODO(johnylin): API says this method must be supported in all states, however I'm quite not
// sure what is the use case.
@@ -820,21 +811,22 @@
ALOGV("sendInputBufferToAccelerator");
int dupFd = dup(input.handle()->data[0]);
if (dupFd < 0) {
- ALOGE("Failed to dup(%d) input buffer (bitstreamId=%d), errno=%d",
- input.handle()->data[0], bitstreamId, errno);
+ ALOGE("Failed to dup(%d) input buffer (bitstreamId=%d), errno=%d", input.handle()->data[0],
+ bitstreamId, errno);
reportError(C2_CORRUPTED);
return;
}
- ALOGV("Decode bitstream ID: %d, offset: %u size: %u",
- bitstreamId, input.offset(), input.size());
+ ALOGV("Decode bitstream ID: %d, offset: %u size: %u", bitstreamId, input.offset(),
+ input.size());
mVDAAdaptor->decode(bitstreamId, dupFd, input.offset(), input.size());
}
C2Work* C2VDAComponent::getPendingWorkByBitstreamId(int32_t bitstreamId) {
- auto workIter = std::find_if(
- mPendingWorks.begin(), mPendingWorks.end(),
- [bitstreamId](const std::unique_ptr<C2Work>& w) {
- return frameIndexToBitstreamId(w->input.ordinal.frame_index) == bitstreamId; });
+ auto workIter = std::find_if(mPendingWorks.begin(), mPendingWorks.end(),
+ [bitstreamId](const std::unique_ptr<C2Work>& w) {
+ return frameIndexToBitstreamId(w->input.ordinal.frame_index) ==
+ bitstreamId;
+ });
if (workIter == mPendingWorks.end()) {
ALOGE("Can't find pending work by bitstream ID: %d", bitstreamId);
@@ -846,10 +838,9 @@
C2Work* C2VDAComponent::getPendingWorkLastToFinish() {
// Get the work with largest timestamp.
auto workIter = std::max_element(
- mPendingWorks.begin(),
- mPendingWorks.end(),
- [](const auto& w1, const auto& w2) {
- return w1->input.ordinal.timestamp < w2->input.ordinal.timestamp; });
+ mPendingWorks.begin(), mPendingWorks.end(), [](const auto& w1, const auto& w2) {
+ return w1->input.ordinal.timestamp < w2->input.ordinal.timestamp;
+ });
if (workIter == mPendingWorks.end()) {
ALOGE("Can't get last finished work from mPendingWork");
@@ -859,7 +850,7 @@
}
C2VDAComponent::GraphicBlockInfo* C2VDAComponent::getGraphicBlockById(int32_t blockId) {
- if (blockId < 0 || blockId >= static_cast<int32_t>(mGraphicBlocks.size())){
+ if (blockId < 0 || blockId >= static_cast<int32_t>(mGraphicBlocks.size())) {
ALOGE("getGraphicBlockById failed: id=%d", blockId);
return nullptr;
}
@@ -919,8 +910,8 @@
setOutputFormatCrop(mPendingOutputFormat->mVisibleRect);
mColorFormat = colorFormat;
- c2_status_t err = allocateBuffersFromBlockAllocator(mPendingOutputFormat->mCodedSize,
- bufferFormat);
+ c2_status_t err =
+ allocateBuffersFromBlockAllocator(mPendingOutputFormat->mCodedSize, bufferFormat);
if (err != C2_OK) {
reportError(err);
return;
@@ -942,8 +933,9 @@
mVDAAdaptor->assignPictureBuffers(bufferCount);
// TODO: lock access to interface
- C2BlockPool::local_id_t poolId = mIntf->mOutputBlockPools->flexCount() ?
- mIntf->mOutputBlockPools->m.mValues[0] : C2BlockPool::BASIC_GRAPHIC;
+ C2BlockPool::local_id_t poolId = mIntf->mOutputBlockPools->flexCount()
+ ? mIntf->mOutputBlockPools->m.mValues[0]
+ : C2BlockPool::BASIC_GRAPHIC;
ALOGI("Using C2BlockPool ID = %" PRIu64 " for allocating output buffers", poolId);
c2_status_t err;
if (!mOutputBlockPool || mOutputBlockPool->getLocalId() != poolId) {
@@ -958,7 +950,7 @@
mGraphicBlocks.clear();
for (size_t i = 0; i < bufferCount; ++i) {
std::shared_ptr<C2GraphicBlock> block;
- C2MemoryUsage usage = { C2MemoryUsage::kSoftwareRead, 0 };
+ C2MemoryUsage usage = {C2MemoryUsage::kSoftwareRead, 0};
err = mOutputBlockPool->fetchGraphicBlock(size.width(), size.height(), pixelFormat, usage,
&block);
if (err != C2_OK) {
@@ -983,9 +975,8 @@
CHECK_NE(data, nullptr);
const C2PlaneLayout& layout = view.layout();
- ALOGV("allocate graphic buffer: %p, id: %u, size: %dx%d",
- info.mGraphicBlock->handle(), info.mBlockId,
- info.mGraphicBlock->width(), info.mGraphicBlock->height());
+ ALOGV("allocate graphic buffer: %p, id: %u, size: %dx%d", info.mGraphicBlock->handle(),
+ info.mBlockId, info.mGraphicBlock->width(), info.mGraphicBlock->height());
// get offset from data pointers
uint32_t offsets[C2PlaneLayout::MAX_NUM_PLANES];
@@ -1008,7 +999,7 @@
std::vector<VideoFramePlane> passedPlanes;
for (uint32_t i = 0; i < layout.mNumPlanes; ++i) {
CHECK_GT(layout.mPlanes[i].mRowInc, 0);
- passedPlanes.push_back({ offsets[i], static_cast<uint32_t>(layout.mPlanes[i].mRowInc) });
+ passedPlanes.push_back({offsets[i], static_cast<uint32_t>(layout.mPlanes[i].mRowInc)});
}
info.mHandle = std::move(passedHandle);
info.mPlanes = std::move(passedPlanes);
@@ -1024,8 +1015,7 @@
// is_valid() is true for the first time the buffer is passed to VDA. In that case, VDA needs to
// import the buffer first.
if (info->mHandle.is_valid()) {
- mVDAAdaptor->importBufferForPicture(
- info->mBlockId, info->mHandle.release(), info->mPlanes);
+ mVDAAdaptor->importBufferForPicture(info->mBlockId, info->mHandle.release(), info->mPlanes);
} else {
mVDAAdaptor->reusePictureBuffer(info->mBlockId);
}
@@ -1054,9 +1044,9 @@
return C2_BAD_STATE;
}
while (!items->empty()) {
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onQueueWork,
- base::Unretained(this),
- base::Passed(&items->front())));
+ mTaskRunner->PostTask(FROM_HERE,
+ base::Bind(&C2VDAComponent::onQueueWork, base::Unretained(this),
+ base::Passed(&items->front())));
items->pop_front();
}
return C2_OK;
@@ -1067,8 +1057,8 @@
return C2_OMITTED; // Tunneling is not supported by now
}
-c2_status_t C2VDAComponent::flush_sm(
- flush_mode_t mode, std::list<std::unique_ptr<C2Work>>* const flushedWork) {
+c2_status_t C2VDAComponent::flush_sm(flush_mode_t mode,
+ std::list<std::unique_ptr<C2Work>>* const flushedWork) {
if (mode != FLUSH_COMPONENT) {
return C2_OMITTED; // Tunneling is not supported by now
}
@@ -1099,9 +1089,8 @@
fetchParametersFromIntf();
base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
- mTaskRunner->PostTask(
- FROM_HERE,
- base::Bind(&C2VDAComponent::onStart, base::Unretained(this), mCodecProfile, &done));
+ mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onStart, base::Unretained(this),
+ mCodecProfile, &done));
done.Wait();
if (mVDAInitResult != VideoDecodeAcceleratorAdaptor::Result::SUCCESS) {
ALOGE("Failed to start component due to VDA error: %d", static_cast<int>(mVDAInitResult));
@@ -1126,26 +1115,25 @@
}
c2_status_t C2VDAComponent::reset() {
- stop();
+ return stop();
// TODO(johnylin): reset is different than stop that it could be called in any state.
// TODO(johnylin): when reset is called, set ComponentInterface to default values.
- return C2_OK;
}
c2_status_t C2VDAComponent::release() {
// TODO(johnylin): what should we do for release?
- return C2_OK;
+ return C2_OMITTED;
}
std::shared_ptr<C2ComponentInterface> C2VDAComponent::intf() {
return mIntf;
}
-void C2VDAComponent::providePictureBuffers(
- uint32_t pixelFormat, uint32_t minNumBuffers, const media::Size& codedSize) {
+void C2VDAComponent::providePictureBuffers(uint32_t pixelFormat, uint32_t minNumBuffers,
+ const media::Size& codedSize) {
// Uses coded size for crop rect while it is not available.
- auto format = std::make_unique<VideoFormat>(
- pixelFormat, minNumBuffers, codedSize, media::Rect(codedSize));
+ auto format = std::make_unique<VideoFormat>(pixelFormat, minNumBuffers, codedSize,
+ media::Rect(codedSize));
// Set mRequestedVisibleRect to default.
mRequestedVisibleRect = media::Rect();
@@ -1159,8 +1147,8 @@
// no ops
}
-void C2VDAComponent::pictureReady(
- int32_t pictureBufferId, int32_t bitstreamId, const media::Rect& cropRect) {
+void C2VDAComponent::pictureReady(int32_t pictureBufferId, int32_t bitstreamId,
+ const media::Rect& cropRect) {
UNUSED(pictureBufferId);
UNUSED(bitstreamId);
@@ -1170,9 +1158,9 @@
base::Unretained(this), cropRect));
}
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onOutputBufferDone,
- base::Unretained(this),
- pictureBufferId, bitstreamId));
+ mTaskRunner->PostTask(FROM_HERE,
+ base::Bind(&C2VDAComponent::onOutputBufferDone, base::Unretained(this),
+ pictureBufferId, bitstreamId));
}
void C2VDAComponent::notifyEndOfBitstreamBuffer(int32_t bitstreamId) {
@@ -1193,7 +1181,7 @@
void C2VDAComponent::notifyError(VideoDecodeAcceleratorAdaptor::Result error) {
ALOGE("Got notifyError from VDA error=%d", error);
c2_status_t err;
- switch(error) {
+ switch (error) {
case VideoDecodeAcceleratorAdaptor::Result::ILLEGAL_STATE:
err = C2_BAD_STATE;
break;
@@ -1280,10 +1268,12 @@
////////////////////////////////////////////////////////////////////////////////
// Neglect flexible flag while matching parameter indices.
-#define CASE(paramType) \
- case paramType::coreIndex: \
+#define CASE(paramType) \
+ case paramType::coreIndex: \
return std::unique_ptr<C2StructDescriptor>(new C2StructDescriptor{ \
- paramType::coreIndex, paramType::fieldList, })
+ paramType::coreIndex, \
+ paramType::fieldList, \
+ })
class C2VDAComponentStore::ParamReflector : public C2ParamReflector {
public:
@@ -1302,16 +1292,14 @@
#undef CASE
// TODO(johnylin): implement C2VDAComponentStore
-C2VDAComponentStore::C2VDAComponentStore()
- : mParamReflector(std::make_shared<ParamReflector>()) {
-}
+C2VDAComponentStore::C2VDAComponentStore() : mParamReflector(std::make_shared<ParamReflector>()) {}
C2String C2VDAComponentStore::getName() const {
return "android.componentStore.v4l2";
}
-c2_status_t C2VDAComponentStore::createComponent(
- C2String name, std::shared_ptr<C2Component>* const component) {
+c2_status_t C2VDAComponentStore::createComponent(C2String name,
+ std::shared_ptr<C2Component>* const component) {
UNUSED(name);
UNUSED(component);
return C2_OMITTED;
@@ -1323,13 +1311,12 @@
return C2_OK;
}
-std::vector<std::shared_ptr<const C2Component::Traits>>
-C2VDAComponentStore::listComponents() {
+std::vector<std::shared_ptr<const C2Component::Traits>> C2VDAComponentStore::listComponents() {
return std::vector<std::shared_ptr<const C2Component::Traits>>();
}
-c2_status_t C2VDAComponentStore::copyBuffer(
- std::shared_ptr<C2GraphicBuffer> src, std::shared_ptr<C2GraphicBuffer> dst) {
+c2_status_t C2VDAComponentStore::copyBuffer(std::shared_ptr<C2GraphicBuffer> src,
+ std::shared_ptr<C2GraphicBuffer> dst) {
UNUSED(src);
UNUSED(dst);
return C2_OMITTED;
@@ -1340,13 +1327,13 @@
}
c2_status_t C2VDAComponentStore::querySupportedParams_nb(
- std::vector<std::shared_ptr<C2ParamDescriptor>>* const params) const {
+ std::vector<std::shared_ptr<C2ParamDescriptor>>* const params) const {
UNUSED(params);
return C2_OMITTED;
}
c2_status_t C2VDAComponentStore::querySupportedValues_sm(
- std::vector<C2FieldSupportedValuesQuery>& fields) const {
+ std::vector<C2FieldSupportedValuesQuery>& fields) const {
UNUSED(fields);
return C2_OMITTED;
}
@@ -1362,7 +1349,7 @@
}
c2_status_t C2VDAComponentStore::config_sm(
- const std::vector<C2Param* const> ¶ms,
+ const std::vector<C2Param* const>& params,
std::vector<std::unique_ptr<C2SettingResult>>* const failures) {
UNUSED(params);
UNUSED(failures);