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/Android.mk b/Android.mk
index 4a05be2..e8e6958 100644
--- a/Android.mk
+++ b/Android.mk
@@ -30,7 +30,8 @@
libv4l2_codec2_vndk \
# -Wno-unused-parameter is needed for libchrome/base codes
-LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-lambda-capture -std=c++14
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -std=c++14
+LOCAL_CFLAGS += -Wno-unused-lambda-capture -Wno-unknown-warning-option
LOCAL_CLANG := true
LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
diff --git a/C2VDAAdaptor.cpp b/C2VDAAdaptor.cpp
index 90b9a1f..de0ac81 100644
--- a/C2VDAAdaptor.cpp
+++ b/C2VDAAdaptor.cpp
@@ -17,8 +17,7 @@
namespace android {
-C2VDAAdaptor::C2VDAAdaptor() : mNumOutputBuffers(0u) {
-}
+C2VDAAdaptor::C2VDAAdaptor() : mNumOutputBuffers(0u) {}
C2VDAAdaptor::~C2VDAAdaptor() {
if (mVDA) {
@@ -27,8 +26,8 @@
}
VideoDecodeAcceleratorAdaptor::Result C2VDAAdaptor::initialize(
- media::VideoCodecProfile profile, bool secureMode,
- VideoDecodeAcceleratorAdaptor::Client* client) {
+ media::VideoCodecProfile profile, bool secureMode,
+ VideoDecodeAcceleratorAdaptor::Client* client) {
// TODO: use secureMode here, or ignore?
if (mVDA) {
ALOGE("Re-initialize() is not allowed");
@@ -57,16 +56,15 @@
void C2VDAAdaptor::decode(int32_t bitstreamId, int ashmemFd, off_t offset, uint32_t bytesUsed) {
CHECK(mVDA);
- mVDA->Decode(media::BitstreamBuffer(
- bitstreamId, base::SharedMemoryHandle(ashmemFd, true), bytesUsed, offset));
+ mVDA->Decode(media::BitstreamBuffer(bitstreamId, base::SharedMemoryHandle(ashmemFd, true),
+ bytesUsed, offset));
}
void C2VDAAdaptor::assignPictureBuffers(uint32_t numOutputBuffers) {
CHECK(mVDA);
std::vector<media::PictureBuffer> buffers;
for (uint32_t id = 0; id < numOutputBuffers; ++id) {
- buffers.push_back(
- media::PictureBuffer(static_cast<int32_t>(id), mPictureSize));
+ buffers.push_back(media::PictureBuffer(static_cast<int32_t>(id), mPictureSize));
}
mVDA->AssignPictureBuffers(buffers);
mNumOutputBuffers = numOutputBuffers;
@@ -117,8 +115,8 @@
(inputFormatFourcc == V4L2_PIX_FMT_VP8_FRAME) ||
(inputFormatFourcc == V4L2_PIX_FMT_VP9_FRAME);
for (const auto& profile : allProfiles) {
- if (inputFormatFourcc == media::V4L2Device::VideoCodecProfileToV4L2PixFmt(
- profile.profile, isSliceBased)) {
+ if (inputFormatFourcc ==
+ media::V4L2Device::VideoCodecProfileToV4L2PixFmt(profile.profile, isSliceBased)) {
supportedProfiles.push_back(profile);
}
}
@@ -130,22 +128,22 @@
const media::Size& dimensions) {
uint32_t pixelFormat;
switch (output_format) {
- case media::PIXEL_FORMAT_I420:
- case media::PIXEL_FORMAT_YV12:
- case media::PIXEL_FORMAT_NV12:
- case media::PIXEL_FORMAT_NV21:
- // HAL_PIXEL_FORMAT_YCbCr_420_888 is the flexible pixel format in Android
- // which handles all 420 formats, with both orderings of chroma (CbCr and
- // CrCb) as well as planar and semi-planar layouts.
- pixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_888;
- break;
- case media::PIXEL_FORMAT_ARGB:
- pixelFormat = HAL_PIXEL_FORMAT_BGRA_8888;
- break;
- default:
- ALOGE("Format not supported: %d", output_format);
- mClient->notifyError(PLATFORM_FAILURE);
- return;
+ case media::PIXEL_FORMAT_I420:
+ case media::PIXEL_FORMAT_YV12:
+ case media::PIXEL_FORMAT_NV12:
+ case media::PIXEL_FORMAT_NV21:
+ // HAL_PIXEL_FORMAT_YCbCr_420_888 is the flexible pixel format in Android
+ // which handles all 420 formats, with both orderings of chroma (CbCr and
+ // CrCb) as well as planar and semi-planar layouts.
+ pixelFormat = HAL_PIXEL_FORMAT_YCbCr_420_888;
+ break;
+ case media::PIXEL_FORMAT_ARGB:
+ pixelFormat = HAL_PIXEL_FORMAT_BGRA_8888;
+ break;
+ default:
+ ALOGE("Format not supported: %d", output_format);
+ mClient->notifyError(PLATFORM_FAILURE);
+ return;
}
mClient->providePictureBuffers(pixelFormat, requested_num_of_buffers, dimensions);
@@ -157,8 +155,7 @@
}
void C2VDAAdaptor::PictureReady(const media::Picture& picture) {
- mClient->pictureReady(picture.picture_buffer_id(),
- picture.bitstream_buffer_id(),
+ mClient->pictureReady(picture.picture_buffer_id(), picture.bitstream_buffer_id(),
picture.visible_rect());
}
@@ -177,17 +174,17 @@
static VideoDecodeAcceleratorAdaptor::Result convertErrorCode(
media::VideoDecodeAccelerator::Error error) {
switch (error) {
- case media::VideoDecodeAccelerator::ILLEGAL_STATE:
- return VideoDecodeAcceleratorAdaptor::ILLEGAL_STATE;
- case media::VideoDecodeAccelerator::INVALID_ARGUMENT:
- return VideoDecodeAcceleratorAdaptor::INVALID_ARGUMENT;
- case media::VideoDecodeAccelerator::UNREADABLE_INPUT:
- return VideoDecodeAcceleratorAdaptor::UNREADABLE_INPUT;
- case media::VideoDecodeAccelerator::PLATFORM_FAILURE:
- return VideoDecodeAcceleratorAdaptor::PLATFORM_FAILURE;
- default:
- ALOGE("Unknown error code: %d", static_cast<int>(error));
- return VideoDecodeAcceleratorAdaptor::PLATFORM_FAILURE;
+ case media::VideoDecodeAccelerator::ILLEGAL_STATE:
+ return VideoDecodeAcceleratorAdaptor::ILLEGAL_STATE;
+ case media::VideoDecodeAccelerator::INVALID_ARGUMENT:
+ return VideoDecodeAcceleratorAdaptor::INVALID_ARGUMENT;
+ case media::VideoDecodeAccelerator::UNREADABLE_INPUT:
+ return VideoDecodeAcceleratorAdaptor::UNREADABLE_INPUT;
+ case media::VideoDecodeAccelerator::PLATFORM_FAILURE:
+ return VideoDecodeAcceleratorAdaptor::PLATFORM_FAILURE;
+ default:
+ ALOGE("Unknown error code: %d", static_cast<int>(error));
+ return VideoDecodeAcceleratorAdaptor::PLATFORM_FAILURE;
}
}
diff --git a/C2VDAAdaptor.h b/C2VDAAdaptor.h
index e54d6c1..065fd0d 100644
--- a/C2VDAAdaptor.h
+++ b/C2VDAAdaptor.h
@@ -20,8 +20,7 @@
~C2VDAAdaptor() override;
// Implementation of the VideoDecodeAcceleratorAdaptor interface.
- Result initialize(media::VideoCodecProfile profile,
- bool secureMode,
+ Result initialize(media::VideoCodecProfile profile, bool secureMode,
VideoDecodeAcceleratorAdaptor::Client* client) override;
void decode(int32_t bitstreamId, int handleFd, off_t offset, uint32_t bytesUsed) override;
void assignPictureBuffers(uint32_t numOutputBuffers) override;
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);
diff --git a/C2VDAComponent.h b/C2VDAComponent.h
index 6265fbe..18c0f63 100644
--- a/C2VDAComponent.h
+++ b/C2VDAComponent.h
@@ -26,10 +26,8 @@
namespace android {
-C2ENUM(
- ColorFormat, uint32_t,
- kColorFormatYUV420Flexible = 0x7F420888,
-)
+C2ENUM(ColorFormat, uint32_t, // enum for output color format
+ kColorFormatYUV420Flexible = 0x7F420888, )
class C2VDAComponentIntf : public C2ComponentInterface {
public:
@@ -40,21 +38,18 @@
virtual C2String getName() const override;
virtual c2_node_id_t getId() const override;
virtual c2_status_t query_vb(
- const std::vector<C2Param* const> &stackParams,
- const std::vector<C2Param::Index> &heapParamIndices,
- c2_blocking_t mayBlock,
+ const std::vector<C2Param* const>& stackParams,
+ const std::vector<C2Param::Index>& heapParamIndices, c2_blocking_t mayBlock,
std::vector<std::unique_ptr<C2Param>>* const heapParams) const override;
virtual c2_status_t config_vb(
- const std::vector<C2Param* const>& params,
- c2_blocking_t mayBlock,
+ const std::vector<C2Param* const>& params, c2_blocking_t mayBlock,
std::vector<std::unique_ptr<C2SettingResult>>* const failures) override;
virtual c2_status_t createTunnel_sm(c2_node_id_t targetComponent) override;
virtual c2_status_t releaseTunnel_sm(c2_node_id_t targetComponent) override;
virtual c2_status_t querySupportedParams_nb(
std::vector<std::shared_ptr<C2ParamDescriptor>>* const params) const override;
- virtual c2_status_t querySupportedValues_vb(
- std::vector<C2FieldSupportedValuesQuery>& fields,
- c2_blocking_t mayBlock) const override;
+ virtual c2_status_t querySupportedValues_vb(std::vector<C2FieldSupportedValuesQuery>& fields,
+ c2_blocking_t mayBlock) const override;
c2_status_t status() const;
@@ -65,9 +60,9 @@
const c2_node_id_t kId;
C2Param* getParamByIndex(uint32_t index) const;
- template<class T>
+ template <class T>
std::unique_ptr<C2SettingResult> validateVideoSizeConfig(C2Param* c2Param) const;
- template<class T>
+ template <class T>
std::unique_ptr<C2SettingResult> validateUint32Config(C2Param* c2Param) const;
c2_status_t mInitStatus;
@@ -103,22 +98,20 @@
std::vector<uint32_t> mSupportedCodecProfiles;
};
-class C2VDAComponent
- : public C2Component,
- public VideoDecodeAcceleratorAdaptor::Client,
- public std::enable_shared_from_this<C2VDAComponent> {
+class C2VDAComponent : public C2Component,
+ public VideoDecodeAcceleratorAdaptor::Client,
+ public std::enable_shared_from_this<C2VDAComponent> {
public:
- C2VDAComponent(
- C2String name, c2_node_id_t id);
+ C2VDAComponent(C2String name, c2_node_id_t id);
virtual ~C2VDAComponent() override;
// Implementation of C2Component interface
- virtual c2_status_t setListener_vb(
- const std::shared_ptr<Listener>& listener, c2_blocking_t mayBlock) override;
+ virtual c2_status_t setListener_vb(const std::shared_ptr<Listener>& listener,
+ c2_blocking_t mayBlock) override;
virtual c2_status_t queue_nb(std::list<std::unique_ptr<C2Work>>* const items) override;
virtual c2_status_t announce_nb(const std::vector<C2WorkOutline>& items) override;
- virtual c2_status_t flush_sm(
- flush_mode_t mode, std::list<std::unique_ptr<C2Work>>* const flushedWork) override;
+ virtual c2_status_t flush_sm(flush_mode_t mode,
+ std::list<std::unique_ptr<C2Work>>* const flushedWork) override;
virtual c2_status_t drain_nb(drain_mode_t mode) override;
virtual c2_status_t start() override;
virtual c2_status_t stop() override;
@@ -127,8 +120,7 @@
virtual std::shared_ptr<C2ComponentInterface> intf() override;
// Implementation of VideDecodeAcceleratorAdaptor::Client interface
- virtual void providePictureBuffers(uint32_t pixelFormat,
- uint32_t minNumBuffers,
+ virtual void providePictureBuffers(uint32_t pixelFormat, uint32_t minNumBuffers,
const media::Size& codedSize) override;
virtual void dismissPictureBuffer(int32_t pictureBufferId) override;
virtual void pictureReady(int32_t pictureBufferId, int32_t bitstreamId,
@@ -137,6 +129,7 @@
virtual void notifyFlushDone() override;
virtual void notifyResetDone() override;
virtual void notifyError(VideoDecodeAcceleratorAdaptor::Result error) override;
+
private:
// The state machine enumeration on parent thread.
enum class State : int32_t {
@@ -177,9 +170,9 @@
// Internal struct to keep the information of a specific graphic block.
struct GraphicBlockInfo {
enum class State {
- OWNED_BY_COMPONENT, // Owned by this component.
- OWNED_BY_ACCELERATOR, // Owned by video decode accelerator.
- OWNED_BY_CLIENT, // Owned by client.
+ OWNED_BY_COMPONENT, // Owned by this component.
+ OWNED_BY_ACCELERATOR, // Owned by video decode accelerator.
+ OWNED_BY_CLIENT, // Owned by client.
};
int32_t mBlockId = -1;
diff --git a/VideoDecodeAcceleratorAdaptor.h b/VideoDecodeAcceleratorAdaptor.h
index 6d1322d..506b95a 100644
--- a/VideoDecodeAcceleratorAdaptor.h
+++ b/VideoDecodeAcceleratorAdaptor.h
@@ -42,8 +42,7 @@
virtual ~Client() {}
// Callback to tell client how many and what size of buffers to provide.
- virtual void providePictureBuffers(uint32_t pixelFormat,
- uint32_t minNumBuffers,
+ virtual void providePictureBuffers(uint32_t pixelFormat, uint32_t minNumBuffers,
const media::Size& codedSize) = 0;
// Callback to dismiss picture buffer that was assigned earlier.
@@ -70,7 +69,8 @@
// Initializes the video decoder with specific profile. This call is synchronous and returns
// SUCCESS iff initialization is successful.
- virtual Result initialize(media::VideoCodecProfile profile, bool secureMode, Client* client) = 0;
+ virtual Result initialize(media::VideoCodecProfile profile, bool secureMode,
+ Client* client) = 0;
// Decodes given buffer handle with bitstream ID.
virtual void decode(int32_t bitstreamId, int handleFd, off_t offset, uint32_t bytesUsed) = 0;
diff --git a/cmds/codec2.cpp b/cmds/codec2.cpp
index e49826f..020d098 100644
--- a/cmds/codec2.cpp
+++ b/cmds/codec2.cpp
@@ -5,13 +5,13 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "codec2"
-#include <inttypes.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <thread>
@@ -29,10 +29,6 @@
#include <binder/ProcessState.h>
#include <media/ICrypto.h>
#include <media/IMediaHTTPService.h>
-#include <media/stagefright/foundation/ABuffer.h>
-#include <media/stagefright/foundation/ALooper.h>
-#include <media/stagefright/foundation/AMessage.h>
-#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
@@ -40,6 +36,10 @@
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/Utils.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ALooper.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/AUtils.h>
#include <gui/GLConsumer.h>
#include <gui/IProducerListener.h>
@@ -63,7 +63,7 @@
class C2VDALinearBuffer : public C2Buffer {
public:
explicit C2VDALinearBuffer(const std::shared_ptr<C2LinearBlock>& block)
- : C2Buffer({ block->share(block->offset(), block->size(), ::android::C2Fence()) }) {}
+ : C2Buffer({block->share(block->offset(), block->size(), ::android::C2Fence())}) {}
};
class Listener;
@@ -79,7 +79,7 @@
std::vector<std::shared_ptr<C2SettingResult>> settingResult);
void onError(std::weak_ptr<C2Component> component, uint32_t errorCode);
- status_t play(const sp<IMediaSource> &source);
+ status_t play(const sp<IMediaSource>& source);
private:
typedef std::unique_lock<std::mutex> ULock;
@@ -112,7 +112,7 @@
class Listener : public C2Component::Listener {
public:
- explicit Listener(SimplePlayer *thiz) : mThis(thiz) {}
+ explicit Listener(SimplePlayer* thiz) : mThis(thiz) {}
virtual ~Listener() = default;
virtual void onWorkDone_nb(std::weak_ptr<C2Component> component,
@@ -126,19 +126,18 @@
mThis->onTripped(component, settingResult);
}
- virtual void onError_nb(std::weak_ptr<C2Component> component,
- uint32_t errorCode) override {
+ virtual void onError_nb(std::weak_ptr<C2Component> component, uint32_t errorCode) override {
mThis->onError(component, errorCode);
}
private:
- SimplePlayer * const mThis;
+ SimplePlayer* const mThis;
};
SimplePlayer::SimplePlayer()
- : mListener(new Listener(this)),
- mProducerListener(new DummyProducerListener),
- mComposerClient(new SurfaceComposerClient) {
+ : mListener(new Listener(this)),
+ mProducerListener(new DummyProducerListener),
+ mComposerClient(new SurfaceComposerClient) {
CHECK_EQ(mComposerClient->initCheck(), OK);
std::shared_ptr<C2AllocatorStore> store = getCodec2VDAAllocatorStore();
@@ -146,8 +145,8 @@
mLinearBlockPool = std::make_shared<C2BasicLinearBlockPool>(mLinearAlloc);
- mControl = mComposerClient->createSurface(String8("A Surface"),
- kWidth, kHeight, HAL_PIXEL_FORMAT_YV12);
+ mControl = mComposerClient->createSurface(String8("A Surface"), kWidth, kHeight,
+ HAL_PIXEL_FORMAT_YV12);
CHECK(mControl != nullptr);
CHECK(mControl->isValid());
@@ -166,27 +165,26 @@
mComposerClient->dispose();
}
-void SimplePlayer::onWorkDone(
- std::weak_ptr<C2Component> component, std::vector<std::unique_ptr<C2Work>> workItems) {
- (void) component;
+void SimplePlayer::onWorkDone(std::weak_ptr<C2Component> component,
+ std::vector<std::unique_ptr<C2Work>> workItems) {
+ (void)component;
ULock l(mProcessedLock);
- for (auto & item : workItems) {
+ for (auto& item : workItems) {
mProcessedWork.emplace_back(std::move(item));
}
mProcessedCondition.notify_all();
}
-void SimplePlayer::onTripped(
- std::weak_ptr<C2Component> component,
- std::vector<std::shared_ptr<C2SettingResult>> settingResult) {
- (void) component;
- (void) settingResult;
+void SimplePlayer::onTripped(std::weak_ptr<C2Component> component,
+ std::vector<std::shared_ptr<C2SettingResult>> settingResult) {
+ (void)component;
+ (void)settingResult;
// TODO
}
void SimplePlayer::onError(std::weak_ptr<C2Component> component, uint32_t errorCode) {
- (void) component;
- (void) errorCode;
+ (void)component;
+ (void)errorCode;
// TODO
}
@@ -210,11 +208,11 @@
return clone;
}
-status_t SimplePlayer::play(const sp<IMediaSource> &source) {
+status_t SimplePlayer::play(const sp<IMediaSource>& source) {
std::deque<sp<ABuffer>> csds;
if (kComponentName == kH264DecoderName) {
sp<AMessage> format;
- (void) convertMetaDataToMessage(source->getFormat(), &format);
+ (void)convertMetaDataToMessage(source->getFormat(), &format);
csds.resize(2);
format->findBuffer("csd-0", &csds[0]);
@@ -230,10 +228,10 @@
}
std::shared_ptr<C2Component> component(std::make_shared<C2VDAComponent>(kComponentName, 0));
- component->setListener_sm(mListener);
+ component->setListener_vb(mListener, C2_DONT_BLOCK);
std::unique_ptr<C2PortBlockPoolsTuning::output> pools =
- C2PortBlockPoolsTuning::output::alloc_unique(
- { static_cast<uint64_t>(C2BlockPool::BASIC_GRAPHIC) });
+ C2PortBlockPoolsTuning::output::alloc_unique(
+ {static_cast<uint64_t>(C2BlockPool::BASIC_GRAPHIC)});
std::vector<std::unique_ptr<C2SettingResult>> result;
(void)component->intf()->config_vb({pools.get()}, C2_DONT_BLOCK, &result);
component->start();
@@ -245,7 +243,7 @@
std::atomic_bool running(true);
std::thread surfaceThread([this, &running]() {
- const sp<IGraphicBufferProducer> &igbp = mSurface->getIGraphicBufferProducer();
+ const sp<IGraphicBufferProducer>& igbp = mSurface->getIGraphicBufferProducer();
std::vector<std::shared_ptr<C2Buffer>> pendingDisplayBuffers;
pendingDisplayBuffers.resize(BufferQueue::NUM_BUFFER_SLOTS);
while (running) {
@@ -271,27 +269,18 @@
// Create GraphicBuffer from cloning native_handle
native_handle_t* cloneHandle = native_handle_clone(graphic_block.handle());
sp<GraphicBuffer> buffer = new GraphicBuffer(
- graphic_block.width(),
- graphic_block.height(),
- HAL_PIXEL_FORMAT_YCbCr_420_888,
- GRALLOC_USAGE_SW_READ_OFTEN,
- graphic_block.width(),
- cloneHandle,
- false);
+ graphic_block.width(), graphic_block.height(),
+ HAL_PIXEL_FORMAT_YCbCr_420_888, GRALLOC_USAGE_SW_READ_OFTEN,
+ graphic_block.width(), cloneHandle, false);
CHECK_EQ(igbp->attachBuffer(&slot, buffer), OK);
ALOGV("attachBuffer slot=%d ts=%lld", slot,
work->worklets.front()->output.ordinal.timestamp * 1000ll);
IGraphicBufferProducer::QueueBufferInput qbi(
- work->worklets.front()->output.ordinal.timestamp * 1000ll,
- false,
- HAL_DATASPACE_UNKNOWN,
- Rect(graphic_block.width(), graphic_block.height()),
- NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW,
- 0,
- Fence::NO_FENCE,
- 0);
+ work->worklets.front()->output.ordinal.timestamp * 1000ll, false,
+ HAL_DATASPACE_UNKNOWN, Rect(graphic_block.width(), graphic_block.height()),
+ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW, 0, Fence::NO_FENCE, 0);
IGraphicBufferProducer::QueueBufferOutput qbo;
CHECK_EQ(igbp->queueBuffer(slot, qbi, &qbo), OK);
@@ -323,7 +312,7 @@
for (;;) {
size_t size = 0u;
- void *data = nullptr;
+ void* data = nullptr;
int64_t timestamp = 0u;
MediaBuffer* buffer = nullptr;
sp<ABuffer> csd;
@@ -369,7 +358,7 @@
// Allocate input buffer.
std::shared_ptr<C2LinearBlock> block;
mLinearBlockPool->fetchLinearBlock(
- size, { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite }, &block);
+ size, {C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite}, &block);
C2WriteView view = block->map().get();
if (view.error() != C2_OK) {
fprintf(stderr, "C2LinearBlock::map() failed : %d\n", view.error());
@@ -393,7 +382,7 @@
}
++numFrames;
}
- component->drain_nb(C2Component::DRAIN_COMPONENT);
+ component->drain_nb(C2Component::DRAIN_COMPONENT_WITH_EOS);
surfaceThread.join();
@@ -408,8 +397,7 @@
static bool getMediaSourceFromFile(const char* filename, sp<IMediaSource>* source) {
source->clear();
- sp<DataSource> dataSource =
- DataSource::CreateFromURI(nullptr /* httpService */, filename);
+ sp<DataSource> dataSource = DataSource::CreateFromURI(nullptr /* httpService */, filename);
if (dataSource == nullptr) {
fprintf(stderr, "Unable to create data source.\n");
@@ -438,7 +426,7 @@
if (meta == nullptr) {
continue;
}
- const char *mime;
+ const char* mime;
meta->findCString(kKeyMIMEType, &mime);
if (!strcasecmp(mime, expectedMime.c_str())) {
*source = extractor->getTrack(i);
@@ -453,24 +441,23 @@
return false;
}
-static void usage(const char *me) {
+static void usage(const char* me) {
fprintf(stderr, "usage: %s [options] [input_filename]...\n", me);
fprintf(stderr, " -h(elp)\n");
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
android::ProcessState::self()->startThreadPool();
int res;
while ((res = getopt(argc, argv, "h")) >= 0) {
switch (res) {
- case 'h':
- default:
- {
- usage(argv[0]);
- exit(1);
- break;
- }
+ case 'h':
+ default: {
+ usage(argv[0]);
+ exit(1);
+ break;
+ }
}
}
diff --git a/tests/C2VDACompIntf_test.cpp b/tests/C2VDACompIntf_test.cpp
index 4fe9613..542c35e 100644
--- a/tests/C2VDACompIntf_test.cpp
+++ b/tests/C2VDACompIntf_test.cpp
@@ -5,15 +5,18 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "C2VDACompIntf_test"
-#include <limits>
#include <stdio.h>
+#include <limits>
#include <C2VDAComponent.h>
#include <gtest/gtest.h>
#include <utils/Log.h>
-#define UNUSED(expr) do { (void)(expr); } while (0)
+#define UNUSED(expr) \
+ do { \
+ (void)(expr); \
+ } while (0)
namespace android {
@@ -71,7 +74,7 @@
template <typename T>
void C2VDACompIntfTest::checkReadOnlyFailureOnConfig(const T* param) {
- std::vector<C2Param* const> params{ (C2Param* const)param };
+ std::vector<C2Param* const> params{(C2Param* const)param};
std::vector<std::unique_ptr<C2SettingResult>> failures;
ASSERT_EQ(C2_BAD_VALUE, mIntf->config_vb(params, C2_DONT_BLOCK, &failures));
ASSERT_EQ(1u, failures.size());
@@ -81,7 +84,7 @@
template <typename T>
void C2VDACompIntfTest::testReadOnlyParamOnStack(const T* expected, const T* invalid) {
T param;
- std::vector<C2Param* const> stackParams{ ¶m };
+ std::vector<C2Param* const> stackParams{¶m};
ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(*expected, param);
@@ -115,7 +118,7 @@
template <typename T>
void C2VDACompIntfTest::testWritableParam(const T* const newParam) {
- std::vector<C2Param* const> params{ (C2Param* const)newParam };
+ std::vector<C2Param* const> params{(C2Param* const)newParam};
std::vector<std::unique_ptr<C2SettingResult>> failures;
ASSERT_EQ(C2_OK, mIntf->config_vb(params, C2_DONT_BLOCK, &failures));
EXPECT_EQ(0u, failures.size());
@@ -123,7 +126,7 @@
// The param must change to newParam
// Check like param on stack
T param;
- std::vector<C2Param* const> stackParams{ ¶m };
+ std::vector<C2Param* const> stackParams{¶m};
ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(*newParam, param);
@@ -138,18 +141,18 @@
void C2VDACompIntfTest::testInvalidWritableParam(const T* const invalidParam) {
// Get the current parameter info
T preParam;
- std::vector<C2Param* const> stackParams { &preParam };
+ std::vector<C2Param* const> stackParams{&preParam};
ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
// Config invalid value. The failure is expected
- std::vector<C2Param* const> params{ (C2Param* const)invalidParam };
+ std::vector<C2Param* const> params{(C2Param* const)invalidParam};
std::vector<std::unique_ptr<C2SettingResult>> failures;
ASSERT_EQ(C2_BAD_VALUE, mIntf->config_vb(params, C2_DONT_BLOCK, &failures));
EXPECT_EQ(1u, failures.size());
//The param must not change after config failed
T param;
- std::vector<C2Param* const> stackParams2 { ¶m };
+ std::vector<C2Param* const> stackParams2{¶m};
ASSERT_EQ(C2_OK, mIntf->query_vb(stackParams2, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(preParam, param);
@@ -169,9 +172,9 @@
}
template <typename T>
-void C2VDACompIntfTest::testWritableVideoSizeParam(
- int32_t widthMin, int32_t widthMax, int32_t widthStep,
- int32_t heightMin, int32_t heightMax, int32_t heightStep) {
+void C2VDACompIntfTest::testWritableVideoSizeParam(int32_t widthMin, int32_t widthMax,
+ int32_t widthStep, int32_t heightMin,
+ int32_t heightMax, int32_t heightStep) {
// Test supported values of video size
T valid;
for (int32_t h = heightMin; h <= heightMax; h += heightStep) {
@@ -182,8 +185,8 @@
SCOPED_TRACE("testWritableParam");
testWritableParam(&valid);
if (HasFailure()) {
- printf("Failed while config width = %d, height = %d\n",
- valid.mWidth, valid.mHeight);
+ printf("Failed while config width = %d, height = %d\n", valid.mWidth,
+ valid.mHeight);
}
if (HasFatalFailure()) return;
}
@@ -229,11 +232,12 @@
}
}
-#define TRACED_FAILURE(func) do { \
- SCOPED_TRACE(#func); \
- func; \
- if (::testing::Test::HasFatalFailure()) return; \
-} while (false)
+#define TRACED_FAILURE(func) \
+ do { \
+ SCOPED_TRACE(#func); \
+ func; \
+ if (::testing::Test::HasFatalFailure()) return; \
+ } while (false)
TEST_F(C2VDACompIntfTest, CreateInstance) {
auto name = mIntf->getName();
@@ -278,19 +282,15 @@
C2VideoSizeStreamInfo::output videoSize;
videoSize.setStream(0); // only support single stream
std::vector<C2FieldSupportedValuesQuery> widthC2FSV = {
- { C2ParamField(&videoSize, &C2VideoSizeStreamInfo::mWidth),
- C2FieldSupportedValuesQuery::CURRENT },
+ {C2ParamField(&videoSize, &C2VideoSizeStreamInfo::mWidth),
+ C2FieldSupportedValuesQuery::CURRENT},
};
- ASSERT_EQ(
- C2_OK,
- mIntf->querySupportedValues_vb(widthC2FSV, C2_DONT_BLOCK));
+ ASSERT_EQ(C2_OK, mIntf->querySupportedValues_vb(widthC2FSV, C2_DONT_BLOCK));
std::vector<C2FieldSupportedValuesQuery> heightC2FSV = {
- { C2ParamField(&videoSize, &C2VideoSizeStreamInfo::mHeight),
- C2FieldSupportedValuesQuery::CURRENT },
+ {C2ParamField(&videoSize, &C2VideoSizeStreamInfo::mHeight),
+ C2FieldSupportedValuesQuery::CURRENT},
};
- ASSERT_EQ(
- C2_OK,
- mIntf->querySupportedValues_vb(heightC2FSV, C2_DONT_BLOCK));
+ ASSERT_EQ(C2_OK, mIntf->querySupportedValues_vb(heightC2FSV, C2_DONT_BLOCK));
ASSERT_EQ(1u, widthC2FSV.size());
ASSERT_EQ(C2_OK, widthC2FSV[0].status);
ASSERT_EQ(C2FieldSupportedValues::RANGE, widthC2FSV[0].values.type);
@@ -315,20 +315,20 @@
TEST_F(C2VDACompIntfTest, TestMaxVideoSizeHint) {
C2MaxVideoSizeHintPortSetting::input maxVideoSizeHint;
std::vector<C2FieldSupportedValuesQuery> widthC2FSV = {
- { C2ParamField(&maxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mWidth),
- C2FieldSupportedValuesQuery::CURRENT },
+ {C2ParamField(&maxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mWidth),
+ C2FieldSupportedValuesQuery::CURRENT},
};
mIntf->querySupportedValues_vb(widthC2FSV, C2_DONT_BLOCK);
std::vector<C2FieldSupportedValuesQuery> heightC2FSV = {
- { C2ParamField(&maxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mHeight),
- C2FieldSupportedValuesQuery::CURRENT },
+ {C2ParamField(&maxVideoSizeHint, &C2MaxVideoSizeHintPortSetting::mHeight),
+ C2FieldSupportedValuesQuery::CURRENT},
};
mIntf->querySupportedValues_vb(heightC2FSV, C2_DONT_BLOCK);
ASSERT_EQ(1u, widthC2FSV.size());
ASSERT_EQ(C2_OK, widthC2FSV[0].status);
ASSERT_EQ(C2FieldSupportedValues::RANGE, widthC2FSV[0].values.type);
- auto &widthFSVRange = widthC2FSV[0].values.range;
+ auto& widthFSVRange = widthC2FSV[0].values.range;
int32_t widthMin = widthFSVRange.min.i32;
int32_t widthMax = widthFSVRange.max.i32;
int32_t widthStep = widthFSVRange.step.i32;
@@ -336,7 +336,7 @@
ASSERT_EQ(1u, heightC2FSV.size());
ASSERT_EQ(C2_OK, heightC2FSV[0].status);
ASSERT_EQ(C2FieldSupportedValues::RANGE, heightC2FSV[0].values.type);
- auto &heightFSVRange = heightC2FSV[0].values.range;
+ auto& heightFSVRange = heightC2FSV[0].values.range;
int32_t heightMin = heightFSVRange.min.i32;
int32_t heightMax = heightFSVRange.max.i32;
int32_t heightStep = heightFSVRange.step.i32;
@@ -349,12 +349,10 @@
C2StreamFormatConfig::input codecProfile;
codecProfile.setStream(0); // only support single stream
std::vector<C2FieldSupportedValuesQuery> profileValues = {
- { C2ParamField(&codecProfile, &C2StreamFormatConfig::mValue),
- C2FieldSupportedValuesQuery::CURRENT },
+ {C2ParamField(&codecProfile, &C2StreamFormatConfig::mValue),
+ C2FieldSupportedValuesQuery::CURRENT},
};
- ASSERT_EQ(
- C2_OK,
- mIntf->querySupportedValues_vb(profileValues, C2_DONT_BLOCK));
+ ASSERT_EQ(C2_OK, mIntf->querySupportedValues_vb(profileValues, C2_DONT_BLOCK));
ASSERT_EQ(1u, profileValues.size());
ASSERT_EQ(C2_OK, profileValues[0].status);
@@ -368,19 +366,31 @@
TEST_F(C2VDACompIntfTest, TestUnsupportedParam) {
C2ComponentTemporalInfo unsupportedParam;
- std::vector<C2Param* const> stackParams{ &unsupportedParam };
+ std::vector<C2Param* const> stackParams{&unsupportedParam};
ASSERT_EQ(C2_BAD_INDEX, mIntf->query_vb(stackParams, {}, C2_DONT_BLOCK, nullptr));
EXPECT_EQ(0u, unsupportedParam.size()); // invalidated
}
void dumpType(const C2FieldDescriptor::Type type) {
switch (type) {
- case C2FieldDescriptor::INT32: printf("int32_t"); break;
- case C2FieldDescriptor::UINT32: printf("uint32_t"); break;
- case C2FieldDescriptor::INT64: printf("int64_t"); break;
- case C2FieldDescriptor::UINT64: printf("uint64_t"); break;
- case C2FieldDescriptor::FLOAT: printf("float"); break;
- default: printf("<flex>"); break;
+ case C2FieldDescriptor::INT32:
+ printf("int32_t");
+ break;
+ case C2FieldDescriptor::UINT32:
+ printf("uint32_t");
+ break;
+ case C2FieldDescriptor::INT64:
+ printf("int64_t");
+ break;
+ case C2FieldDescriptor::UINT64:
+ printf("uint64_t");
+ break;
+ case C2FieldDescriptor::FLOAT:
+ printf("float");
+ break;
+ default:
+ printf("<flex>");
+ break;
}
}
@@ -407,8 +417,7 @@
printf(" type: %x\n", paramDesc->type().type());
std::unique_ptr<C2StructDescriptor> desc{
store->getParamReflector()->describe(paramDesc->type().type())};
- if (desc.get())
- dumpStruct(*desc);
+ if (desc.get()) dumpStruct(*desc);
}
}
diff --git a/tests/C2VDAComponent_test.cpp b/tests/C2VDAComponent_test.cpp
index 9389484..33448ec 100644
--- a/tests/C2VDAComponent_test.cpp
+++ b/tests/C2VDAComponent_test.cpp
@@ -5,14 +5,14 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "C2VDAComponent_test"
-#include <inttypes.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <algorithm>
#include <chrono>
@@ -29,10 +29,6 @@
#include <C2Work.h>
#include <media/IMediaHTTPService.h>
-#include <media/stagefright/foundation/ABuffer.h>
-#include <media/stagefright/foundation/ALooper.h>
-#include <media/stagefright/foundation/AMessage.h>
-#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
@@ -40,6 +36,10 @@
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/Utils.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ALooper.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/AUtils.h>
#include <gtest/gtest.h>
#include <utils/Log.h>
@@ -63,19 +63,10 @@
const std::string kVP8DecoderName = "v4l2.vp8.decode";
// Magic constants for indicating the timing of flush being called.
-enum FlushPoint : int {
- END_OF_STREAM_FLUSH = -3,
- MID_STREAM_FLUSH = -2,
- NO_FLUSH = -1
-};
+enum FlushPoint : int { END_OF_STREAM_FLUSH = -3, MID_STREAM_FLUSH = -2, NO_FLUSH = -1 };
struct TestVideoFile {
- enum class CodecType {
- UNKNOWN,
- H264,
- VP8,
- VP9
- };
+ enum class CodecType { UNKNOWN, H264, VP8, VP9 };
std::string mFilename;
std::string mComponentName;
@@ -83,14 +74,14 @@
int mWidth = -1;
int mHeight = -1;
int mNumFrames = -1;
- int mNumFragments= -1;
+ int mNumFragments = -1;
sp<IMediaSource> mData;
};
class C2VDALinearBuffer : public C2Buffer {
public:
explicit C2VDALinearBuffer(const std::shared_ptr<C2LinearBlock>& block)
- : C2Buffer({ block->share(block->offset(), block->size(), C2Fence()) }) {}
+ : C2Buffer({block->share(block->offset(), block->size(), C2Fence())}) {}
};
class Listener;
@@ -149,7 +140,7 @@
class Listener : public C2Component::Listener {
public:
- explicit Listener(C2VDAComponentTest *thiz) : mThis(thiz) {}
+ explicit Listener(C2VDAComponentTest* thiz) : mThis(thiz) {}
virtual ~Listener() = default;
virtual void onWorkDone_nb(std::weak_ptr<C2Component> component,
@@ -163,8 +154,7 @@
mThis->onTripped(component, settingResult);
}
- virtual void onError_nb(std::weak_ptr<C2Component> component,
- uint32_t errorCode) override {
+ virtual void onError_nb(std::weak_ptr<C2Component> component, uint32_t errorCode) override {
mThis->onError(component, errorCode);
}
@@ -172,34 +162,32 @@
C2VDAComponentTest* const mThis;
};
-C2VDAComponentTest::C2VDAComponentTest()
- : mListener(new Listener(this)) {
+C2VDAComponentTest::C2VDAComponentTest() : mListener(new Listener(this)) {
std::shared_ptr<C2AllocatorStore> store = getCodec2VDAAllocatorStore();
CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAlloc), C2_OK);
mLinearBlockPool = std::make_shared<C2BasicLinearBlockPool>(mLinearAlloc);
}
-void C2VDAComponentTest::onWorkDone(
- std::weak_ptr<C2Component> component, std::vector<std::unique_ptr<C2Work>> workItems) {
- (void) component;
+void C2VDAComponentTest::onWorkDone(std::weak_ptr<C2Component> component,
+ std::vector<std::unique_ptr<C2Work>> workItems) {
+ (void)component;
ULock l(mProcessedLock);
- for (auto & item : workItems) {
+ for (auto& item : workItems) {
mProcessedWork.emplace_back(std::move(item));
}
mProcessedCondition.notify_all();
}
-void C2VDAComponentTest::onTripped(
- std::weak_ptr<C2Component> component,
- std::vector<std::shared_ptr<C2SettingResult>> settingResult) {
- (void) component;
- (void) settingResult;
+void C2VDAComponentTest::onTripped(std::weak_ptr<C2Component> component,
+ std::vector<std::shared_ptr<C2SettingResult>> settingResult) {
+ (void)component;
+ (void)settingResult;
// no-ops
}
void C2VDAComponentTest::onError(std::weak_ptr<C2Component> component, uint32_t errorCode) {
- (void) component;
+ (void)component;
// fail the test
FAIL() << "Get error code from component: " << errorCode;
}
@@ -216,8 +204,7 @@
}
static bool getMediaSourceFromFile(const std::string& filename,
- const TestVideoFile::CodecType codec,
- sp<IMediaSource>* source) {
+ const TestVideoFile::CodecType codec, sp<IMediaSource>* source) {
source->clear();
sp<DataSource> dataSource =
@@ -250,7 +237,7 @@
if (meta == nullptr) {
continue;
}
- const char *mime;
+ const char* mime;
meta->findCString(kKeyMIMEType, &mime);
if (!strcasecmp(mime, expectedMime.c_str())) {
*source = extractor->getTrack(i);
@@ -297,10 +284,9 @@
mTestVideoFile->mNumFrames = std::stoi(tokens[4]);
mTestVideoFile->mNumFragments = std::stoi(tokens[5]);
- ALOGV("mTestVideoFile: %s, %s, %d, %d, %d, %d",
- mTestVideoFile->mFilename.c_str(), mTestVideoFile->mComponentName.c_str(),
- mTestVideoFile->mWidth, mTestVideoFile->mHeight, mTestVideoFile->mNumFrames,
- mTestVideoFile->mNumFragments);
+ ALOGV("mTestVideoFile: %s, %s, %d, %d, %d, %d", mTestVideoFile->mFilename.c_str(),
+ mTestVideoFile->mComponentName.c_str(), mTestVideoFile->mWidth, mTestVideoFile->mHeight,
+ mTestVideoFile->mNumFrames, mTestVideoFile->mNumFragments);
}
// Test parameters:
@@ -310,10 +296,8 @@
// - Number of play through. This value specifies the iteration time for playing entire video. If
// |mFlushAfterWorkIndex| is not negative, the first iteration will perform flush, then repeat
// times as this value for playing entire video.
-class C2VDAComponentParamTest
- : public C2VDAComponentTest,
- public ::testing::WithParamInterface<std::tuple<int, uint32_t>> {
-
+class C2VDAComponentParamTest : public C2VDAComponentTest,
+ public ::testing::WithParamInterface<std::tuple<int, uint32_t>> {
protected:
int mFlushAfterWorkIndex;
uint32_t mNumberOfPlaythrough;
@@ -336,8 +320,7 @@
// Reset counters and determine the expected answers for all iterations.
mOutputFrameCounts.resize(mNumberOfPlaythrough, 0);
mFinishedWorkCounts.resize(mNumberOfPlaythrough, 0);
- std::vector<int> expectedOutputFrameCounts(mNumberOfPlaythrough,
- mTestVideoFile->mNumFrames);
+ std::vector<int> expectedOutputFrameCounts(mNumberOfPlaythrough, mTestVideoFile->mNumFrames);
std::vector<int> expectedFinishedWorkCounts(mNumberOfPlaythrough,
mTestVideoFile->mNumFragments);
if (mFlushAfterWorkIndex >= 0) {
@@ -348,10 +331,10 @@
std::shared_ptr<C2Component> component(
std::make_shared<C2VDAComponent>(mTestVideoFile->mComponentName, 0));
- ASSERT_EQ(component->setListener_sm(mListener), C2_OK);
+ ASSERT_EQ(component->setListener_vb(mListener, C2_DONT_BLOCK), C2_OK);
std::unique_ptr<C2PortBlockPoolsTuning::output> pools =
- C2PortBlockPoolsTuning::output::alloc_unique(
- { static_cast<uint64_t>(C2BlockPool::BASIC_GRAPHIC) });
+ C2PortBlockPoolsTuning::output::alloc_unique(
+ {static_cast<uint64_t>(C2BlockPool::BASIC_GRAPHIC)});
std::vector<std::unique_ptr<C2SettingResult>> result;
ASSERT_EQ(component->intf()->config_vb({pools.get()}, C2_DONT_BLOCK, &result), C2_OK);
ASSERT_EQ(result.size(), 0u);
@@ -375,8 +358,7 @@
}
mFinishedWorkCounts[iteration]++;
ALOGV("Output: frame index: %" PRIu64 " result: %d outputs: %zu",
- work->input.ordinal.frame_index,
- work->result,
+ work->input.ordinal.frame_index, work->result,
work->worklets.front()->output.buffers.size());
if (work->worklets_processed == 1u) {
@@ -425,7 +407,7 @@
if (mTestVideoFile->mCodec == TestVideoFile::CodecType::H264) {
// Get csd buffers for h264.
sp<AMessage> format;
- (void) convertMetaDataToMessage(mTestVideoFile->mData->getFormat(), &format);
+ (void)convertMetaDataToMessage(mTestVideoFile->mData->getFormat(), &format);
csds.resize(2);
format->findBuffer("csd-0", &csds[0]);
format->findBuffer("csd-1", &csds[1]);
@@ -450,7 +432,7 @@
if (mTestVideoFile->mData->read(&buffer) != OK) {
ASSERT_TRUE(buffer == nullptr);
ALOGV("Meet end of stream. Now drain the component.");
- ASSERT_EQ(component->drain_nb(C2Component::DRAIN_COMPONENT), C2_OK);
+ ASSERT_EQ(component->drain_nb(C2Component::DRAIN_COMPONENT_WITH_EOS), C2_OK);
break;
}
sp<MetaData> meta = buffer->meta_data();
@@ -476,9 +458,7 @@
// Allocate input buffer.
std::shared_ptr<C2LinearBlock> block;
mLinearBlockPool->fetchLinearBlock(
- size,
- { C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite },
- &block);
+ size, {C2MemoryUsage::kSoftwareRead, C2MemoryUsage::kSoftwareWrite}, &block);
C2WriteView view = block->map().get();
ASSERT_EQ(view.error(), C2_OK);
memcpy(view.base(), data, size);
@@ -535,63 +515,50 @@
// Finally check the decoding want as expected.
for (uint32_t i = 0; i < mNumberOfPlaythrough; ++i) {
if (mFlushAfterWorkIndex >= 0 && i == 0) {
- EXPECT_LE(mOutputFrameCounts[i], expectedOutputFrameCounts[i]) <<
- "At iteration: " << i;
+ EXPECT_LE(mOutputFrameCounts[i], expectedOutputFrameCounts[i]) << "At iteration: " << i;
} else {
- EXPECT_EQ(mOutputFrameCounts[i], expectedOutputFrameCounts[i]) <<
- "At iteration: " << i;
+ EXPECT_EQ(mOutputFrameCounts[i], expectedOutputFrameCounts[i]) << "At iteration: " << i;
}
- EXPECT_EQ(mFinishedWorkCounts[i], expectedFinishedWorkCounts[i]) <<
- "At iteration: " << i;
+ EXPECT_EQ(mFinishedWorkCounts[i], expectedFinishedWorkCounts[i]) << "At iteration: " << i;
}
}
// Play input video once.
-INSTANTIATE_TEST_CASE_P(
- SinglePlaythroughTest,
- C2VDAComponentParamTest,
- ::testing::Values(std::make_tuple(static_cast<int>(FlushPoint::NO_FLUSH), 1u)));
+INSTANTIATE_TEST_CASE_P(SinglePlaythroughTest, C2VDAComponentParamTest,
+ ::testing::Values(std::make_tuple(static_cast<int>(FlushPoint::NO_FLUSH),
+ 1u)));
// Play 5 times of input video.
-INSTANTIATE_TEST_CASE_P(
- MultiplePlaythroughTest,
- C2VDAComponentParamTest,
- ::testing::Values(std::make_tuple(static_cast<int>(FlushPoint::NO_FLUSH), 5u)));
+INSTANTIATE_TEST_CASE_P(MultiplePlaythroughTest, C2VDAComponentParamTest,
+ ::testing::Values(std::make_tuple(static_cast<int>(FlushPoint::NO_FLUSH),
+ 5u)));
// Test mid-stream flush then play once entirely.
-INSTANTIATE_TEST_CASE_P(
- FlushPlaythroughTest,
- C2VDAComponentParamTest,
- ::testing::Values(std::make_tuple(40, 1u)));
+INSTANTIATE_TEST_CASE_P(FlushPlaythroughTest, C2VDAComponentParamTest,
+ ::testing::Values(std::make_tuple(40, 1u)));
// Test mid-stream flush then stop.
INSTANTIATE_TEST_CASE_P(
- FlushStopTest,
- C2VDAComponentParamTest,
- ::testing::Values(std::make_tuple(static_cast<int>(FlushPoint::MID_STREAM_FLUSH), 0u)));
+ FlushStopTest, C2VDAComponentParamTest,
+ ::testing::Values(std::make_tuple(static_cast<int>(FlushPoint::MID_STREAM_FLUSH), 0u)));
// Test early flush (after a few works) then stop.
-INSTANTIATE_TEST_CASE_P(
- EarlyFlushStopTest,
- C2VDAComponentParamTest,
- ::testing::Values(std::make_tuple(0, 0u),
- std::make_tuple(1, 0u),
- std::make_tuple(2, 0u),
- std::make_tuple(3, 0u)));
+INSTANTIATE_TEST_CASE_P(EarlyFlushStopTest, C2VDAComponentParamTest,
+ ::testing::Values(std::make_tuple(0, 0u), std::make_tuple(1, 0u),
+ std::make_tuple(2, 0u), std::make_tuple(3, 0u)));
// Test end-of-stream flush then stop.
INSTANTIATE_TEST_CASE_P(
- EndOfStreamFlushStopTest,
- C2VDAComponentParamTest,
- ::testing::Values(std::make_tuple(static_cast<int>(FlushPoint::END_OF_STREAM_FLUSH), 0u)));
+ EndOfStreamFlushStopTest, C2VDAComponentParamTest,
+ ::testing::Values(std::make_tuple(static_cast<int>(FlushPoint::END_OF_STREAM_FLUSH), 0u)));
} // namespace android
-static void usage(const char *me) {
+static void usage(const char* me) {
fprintf(stderr, "usage: %s [-h] [-i test_video_data] [gtest options]\n", me);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
extern int opterr;
opterr = 0; // avoid printing error because we want to ignore that and pass to gtest
@@ -599,23 +566,20 @@
bool escape = false;
while (!escape && (res = getopt(argc, argv, "i:h")) >= 0) {
switch (res) {
- case 'i':
- {
- android::gTestVideoData = optarg;
- break;
- }
- case 'h':
- {
- usage(argv[0]);
- exit(1);
- break;
- }
- default:
- {
- escape = true;
- optind--; // go back to last argv
- break;
- }
+ case 'i': {
+ android::gTestVideoData = optarg;
+ break;
+ }
+ case 'h': {
+ usage(argv[0]);
+ exit(1);
+ break;
+ }
+ default: {
+ escape = true;
+ optind--; // go back to last argv
+ break;
+ }
}
}
argc -= optind;
diff --git a/vndk/C2AllocatorCrosGralloc.cpp b/vndk/C2AllocatorCrosGralloc.cpp
index f74d118..93334b5 100644
--- a/vndk/C2AllocatorCrosGralloc.cpp
+++ b/vndk/C2AllocatorCrosGralloc.cpp
@@ -19,7 +19,7 @@
C2AllocatorCrosGralloc::~C2AllocatorCrosGralloc() {}
C2Allocator::id_t C2AllocatorCrosGralloc::getId() const {
- return 1; // TODO implement ID
+ return 1; // TODO implement ID
}
C2String C2AllocatorCrosGralloc::getName() const {
@@ -28,12 +28,12 @@
c2_status_t C2AllocatorCrosGralloc::newGraphicAllocation(
uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
- std::shared_ptr<C2GraphicAllocation> *allocation) {
- (void) width;
- (void) height;
- (void) format;
- (void) usage;
- (void) allocation;
+ std::shared_ptr<C2GraphicAllocation>* allocation) {
+ (void)width;
+ (void)height;
+ (void)format;
+ (void)usage;
+ (void)allocation;
return C2_OMITTED;
}
diff --git a/vndk/C2AllocatorCrosGrallocNyc.cpp b/vndk/C2AllocatorCrosGrallocNyc.cpp
index eb4dee7..b1792ff 100644
--- a/vndk/C2AllocatorCrosGrallocNyc.cpp
+++ b/vndk/C2AllocatorCrosGrallocNyc.cpp
@@ -23,13 +23,13 @@
public:
virtual ~C2AllocationCrosGralloc();
- virtual c2_status_t map(
- C2Rect rect, C2MemoryUsage usage, int *fenceFd,
- C2PlaneLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) override;
- virtual c2_status_t unmap(C2Fence *fenceFd /* nullable */) override;
+ virtual c2_status_t map(C2Rect rect, C2MemoryUsage usage, int* fenceFd,
+ C2PlaneLayout* layout /* nonnull */,
+ uint8_t** addr /* nonnull */) override;
+ virtual c2_status_t unmap(C2Fence* fenceFd /* nullable */) override;
virtual bool isValid() const override;
- virtual const C2Handle *handle() const override;
- virtual bool equals(const std::shared_ptr<const C2GraphicAllocation> &other) const override;
+ virtual const C2Handle* handle() const override;
+ virtual bool equals(const std::shared_ptr<const C2GraphicAllocation>& other) const override;
// internal methods
C2AllocationCrosGralloc(sp<IGraphicBufferAlloc> allocator, uint32_t width, uint32_t height,
@@ -44,11 +44,12 @@
class C2AllocationCrosGralloc::Impl {
public:
Impl(sp<IGraphicBufferAlloc> allocator, uint32_t width, uint32_t height, uint32_t format,
- uint32_t usage) : mInit(C2_OK), mLocked(false) {
+ uint32_t usage)
+ : mInit(C2_OK), mLocked(false) {
if (format != HAL_PIXEL_FORMAT_YCbCr_420_888) {
- ALOGE("only support format HAL_PIXEL_FORMAT_YCbCr_420_888");
- mInit = C2_BAD_VALUE;
- return;
+ ALOGE("only support format HAL_PIXEL_FORMAT_YCbCr_420_888");
+ mInit = C2_BAD_VALUE;
+ return;
}
status_t error = OK;
mGraphicBuffer = allocator->createGraphicBuffer(width, height, format, usage, &error);
@@ -60,10 +61,10 @@
~Impl() {}
- c2_status_t map(C2Rect rect, C2MemoryUsage usage, int *fenceFd,
- C2PlaneLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
+ c2_status_t map(C2Rect rect, C2MemoryUsage usage, int* fenceFd,
+ C2PlaneLayout* layout /* nonnull */, uint8_t** addr /* nonnull */) {
// TODO
- (void) fenceFd;
+ (void)fenceFd;
if (mLocked) {
return C2_DUPLICATE;
}
@@ -98,47 +99,47 @@
LOG_ALWAYS_FATAL_IF(ycbcr.chroma_step != 1 && ycbcr.chroma_step != 2);
layout->mType = C2PlaneLayout::MEDIA_IMAGE_TYPE_YUV;
layout->mPlanes[C2PlaneLayout::Y] = {
- C2PlaneInfo::Y, // mChannel
- 1, // mColInc
- (int32_t)ycbcr.ystride, // mRowInc
- 1, // mHorizSubsampling
- 1, // mVertSubsampling
- 8, // mBitDepth
- 8, // mAllocatedDepth
+ C2PlaneInfo::Y, // mChannel
+ 1, // mColInc
+ (int32_t)ycbcr.ystride, // mRowInc
+ 1, // mHorizSubsampling
+ 1, // mVertSubsampling
+ 8, // mBitDepth
+ 8, // mAllocatedDepth
};
if (ycbcr.chroma_step == 2) {
// Semi-planar format
layout->mNumPlanes = 2;
layout->mPlanes[C2PlaneLayout::U] = {
- C2PlaneInfo::Cb, // mChannel
- (int32_t)ycbcr.chroma_step, // mColInc
- (int32_t)ycbcr.cstride, // mRowInc
- 1, // mHorizSubsampling
- 2, // mVertSubsampling
- 8, // mBitDepth
- 8, // mAllocatedDepth
+ C2PlaneInfo::Cb, // mChannel
+ (int32_t)ycbcr.chroma_step, // mColInc
+ (int32_t)ycbcr.cstride, // mRowInc
+ 1, // mHorizSubsampling
+ 2, // mVertSubsampling
+ 8, // mBitDepth
+ 8, // mAllocatedDepth
};
addr[C2PlaneLayout::V] = nullptr;
} else {
layout->mNumPlanes = 3;
layout->mPlanes[C2PlaneLayout::U] = {
- C2PlaneInfo::Cb, // mChannel
- (int32_t)ycbcr.chroma_step, // mColInc
- (int32_t)ycbcr.cstride, // mRowInc
- 2, // mHorizSubsampling
- 2, // mVertSubsampling
- 8, // mBitDepth
- 8, // mAllocatedDepth
+ C2PlaneInfo::Cb, // mChannel
+ (int32_t)ycbcr.chroma_step, // mColInc
+ (int32_t)ycbcr.cstride, // mRowInc
+ 2, // mHorizSubsampling
+ 2, // mVertSubsampling
+ 8, // mBitDepth
+ 8, // mAllocatedDepth
};
layout->mPlanes[C2PlaneLayout::V] = {
- C2PlaneInfo::Cr, // mChannel
- (int32_t)ycbcr.chroma_step, // mColInc
- (int32_t)ycbcr.cstride, // mRowInc
- 2, // mHorizSubsampling
- 2, // mVertSubsampling
- 8, // mBitDepth
- 8, // mAllocatedDepth
+ C2PlaneInfo::Cr, // mChannel
+ (int32_t)ycbcr.chroma_step, // mColInc
+ (int32_t)ycbcr.cstride, // mRowInc
+ 2, // mHorizSubsampling
+ 2, // mVertSubsampling
+ 8, // mBitDepth
+ 8, // mAllocatedDepth
};
}
LOG_ALWAYS_FATAL_IF(layout->mNumPlanes > C2PlaneLayout::MAX_NUM_PLANES);
@@ -146,20 +147,16 @@
return C2_OK;
}
- c2_status_t unmap(C2Fence *fenceFd /* nullable */) {
- (void) fenceFd; // TODO
+ c2_status_t unmap(C2Fence* fenceFd /* nullable */) {
+ (void)fenceFd; // TODO
mGraphicBuffer->unlock();
mLocked = false;
return C2_OK;
}
- c2_status_t status() const {
- return mInit;
- }
+ c2_status_t status() const { return mInit; }
- const C2Handle* handle() const {
- return mGraphicBuffer->handle;
- }
+ const C2Handle* handle() const { return mGraphicBuffer->handle; }
private:
c2_status_t mInit;
@@ -167,23 +164,22 @@
bool mLocked;
};
-C2AllocationCrosGralloc::C2AllocationCrosGralloc(
- sp<IGraphicBufferAlloc> allocator, uint32_t width, uint32_t height,
- uint32_t format, uint32_t usage)
- : C2GraphicAllocation(width, height),
- mImpl(new Impl(allocator, width, height, format, usage)) {}
+C2AllocationCrosGralloc::C2AllocationCrosGralloc(sp<IGraphicBufferAlloc> allocator, uint32_t width,
+ uint32_t height, uint32_t format, uint32_t usage)
+ : C2GraphicAllocation(width, height),
+ mImpl(new Impl(allocator, width, height, format, usage)) {}
C2AllocationCrosGralloc::~C2AllocationCrosGralloc() {
delete mImpl;
}
-c2_status_t C2AllocationCrosGralloc::map(
- C2Rect rect, C2MemoryUsage usage, int *fenceFd,
- C2PlaneLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
+c2_status_t C2AllocationCrosGralloc::map(C2Rect rect, C2MemoryUsage usage, int* fenceFd,
+ C2PlaneLayout* layout /* nonnull */,
+ uint8_t** addr /* nonnull */) {
return mImpl->map(rect, usage, fenceFd, layout, addr);
}
-c2_status_t C2AllocationCrosGralloc::unmap(C2Fence *fenceFd /* nullable */) {
+c2_status_t C2AllocationCrosGralloc::unmap(C2Fence* fenceFd /* nullable */) {
return mImpl->unmap(fenceFd);
}
@@ -196,8 +192,8 @@
}
bool C2AllocationCrosGralloc::equals(
- const std::shared_ptr<const C2GraphicAllocation> &other) const {
- (void) other;
+ const std::shared_ptr<const C2GraphicAllocation>& other) const {
+ (void)other;
return false; // TODO(johnylin)
}
@@ -223,7 +219,7 @@
C2AllocatorCrosGralloc::~C2AllocatorCrosGralloc() {}
C2Allocator::id_t C2AllocatorCrosGralloc::getId() const {
- return 1; // TODO implement ID
+ return 1; // TODO implement ID
}
C2String C2AllocatorCrosGralloc::getName() const {
@@ -232,7 +228,7 @@
c2_status_t C2AllocatorCrosGralloc::newGraphicAllocation(
uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
- std::shared_ptr<C2GraphicAllocation> *allocation) {
+ std::shared_ptr<C2GraphicAllocation>* allocation) {
*allocation = nullptr;
if (usage.mConsumer != C2MemoryUsage::kSoftwareRead) {
return C2_BAD_VALUE; // always use GRALLOC_USAGE_SW_READ_OFTEN
diff --git a/vndk/C2AllocatorMemDealer.cpp b/vndk/C2AllocatorMemDealer.cpp
index 2461197..ab5b363 100644
--- a/vndk/C2AllocatorMemDealer.cpp
+++ b/vndk/C2AllocatorMemDealer.cpp
@@ -24,13 +24,12 @@
public:
virtual ~C2AllocationMemDealer();
- virtual c2_status_t map(
- size_t offset, size_t size, C2MemoryUsage usage, int *fence,
- void **addr /* nonnull */) override;
- virtual c2_status_t unmap(void *addr, size_t size, int *fenceFd) override;
+ virtual c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, int* fence,
+ void** addr /* nonnull */) override;
+ virtual c2_status_t unmap(void* addr, size_t size, int* fenceFd) override;
virtual bool isValid() const override;
- virtual const C2Handle *handle() const override;
- virtual bool equals(const std::shared_ptr<C2LinearAllocation> &other) const override;
+ virtual const C2Handle* handle() const override;
+ virtual bool equals(const std::shared_ptr<C2LinearAllocation>& other) const override;
// internal methods
C2AllocationMemDealer(uint32_t capacity);
@@ -65,9 +64,9 @@
mHandle->data[0] = heap->getHeapID();
}
- c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, int *fenceFd, void **addr) {
- (void) fenceFd; // TODO: wait for fence
- (void) usage;
+ c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, int* fenceFd, void** addr) {
+ (void)fenceFd; // TODO: wait for fence
+ (void)usage;
*addr = nullptr;
// For simplicity, only support offset = 0 mapping for now.
if (offset != 0) {
@@ -84,7 +83,7 @@
return C2_OK;
}
- c2_status_t unmap(void* addr, size_t size, int *fenceFd) {
+ c2_status_t unmap(void* addr, size_t size, int* fenceFd) {
if (addr != mMemory->pointer() || size != mMapSize) {
return C2_BAD_VALUE;
}
@@ -95,17 +94,11 @@
return C2_OK;
}
- ~Impl() {
- native_handle_delete(mHandle);
- }
+ ~Impl() { native_handle_delete(mHandle); }
- c2_status_t status() const {
- return mInit;
- }
+ c2_status_t status() const { return mInit; }
- const C2Handle* handle() const {
- return mHandle;
- }
+ const C2Handle* handle() const { return mHandle; }
private:
c2_status_t mInit;
@@ -114,12 +107,12 @@
size_t mMapSize;
};
-c2_status_t C2AllocationMemDealer::map(
- size_t offset, size_t size, C2MemoryUsage usage, int *fenceFd, void **addr) {
+c2_status_t C2AllocationMemDealer::map(size_t offset, size_t size, C2MemoryUsage usage,
+ int* fenceFd, void** addr) {
return mImpl->map(offset, size, usage, fenceFd, addr);
}
-c2_status_t C2AllocationMemDealer::unmap(void *addr, size_t size, int *fenceFd) {
+c2_status_t C2AllocationMemDealer::unmap(void* addr, size_t size, int* fenceFd) {
return mImpl->unmap(addr, size, fenceFd);
}
@@ -131,8 +124,8 @@
return mImpl->status();
}
-bool C2AllocationMemDealer::equals(const std::shared_ptr<C2LinearAllocation> &other) const {
- (void) other;
+bool C2AllocationMemDealer::equals(const std::shared_ptr<C2LinearAllocation>& other) const {
+ (void)other;
return false; // TODO(johnylin)
}
@@ -145,7 +138,7 @@
}
C2AllocationMemDealer::C2AllocationMemDealer(uint32_t capacity)
- : C2LinearAllocation(capacity), mImpl(new Impl(capacity)) {}
+ : C2LinearAllocation(capacity), mImpl(new Impl(capacity)) {}
/* ================================ MEMORY DEALER ALLOCATOR ==================================== */
@@ -154,7 +147,7 @@
C2AllocatorMemDealer::~C2AllocatorMemDealer() {}
C2Allocator::id_t C2AllocatorMemDealer::getId() const {
- return 0; // TODO implement ID
+ return 0; // TODO implement ID
}
C2String C2AllocatorMemDealer::getName() const {
@@ -162,8 +155,8 @@
}
c2_status_t C2AllocatorMemDealer::newLinearAllocation(
- uint32_t capacity, C2MemoryUsage usage, std::shared_ptr<C2LinearAllocation> *allocation) {
- (void) usage; // is usage needed?
+ uint32_t capacity, C2MemoryUsage usage, std::shared_ptr<C2LinearAllocation>* allocation) {
+ (void)usage; // is usage needed?
*allocation = nullptr;
auto alloc = std::make_shared<C2AllocationMemDealer>(capacity);
diff --git a/vndk/C2VDAStore.cpp b/vndk/C2VDAStore.cpp
index 57e8477..efbce44 100644
--- a/vndk/C2VDAStore.cpp
+++ b/vndk/C2VDAStore.cpp
@@ -31,12 +31,10 @@
c2_status_t fetchAllocator(id_t id, std::shared_ptr<C2Allocator>* const allocator) override;
std::vector<std::shared_ptr<const C2Allocator::Traits>> listAllocators_nb() const override {
- return std::vector<std::shared_ptr<const C2Allocator::Traits>>(); /// TODO
+ return std::vector<std::shared_ptr<const C2Allocator::Traits>>(); /// TODO
}
- C2String getName() const override{
- return "vda.allocator-store";
- }
+ C2String getName() const override { return "vda.allocator-store"; }
private:
// returns a shared-singleton memory dealer allocator
@@ -53,8 +51,8 @@
std::weak_ptr<C2Allocator> C2VDAAllocatorStore::mMemDealerAllocator;
std::weak_ptr<C2Allocator> C2VDAAllocatorStore::mCrosGrallocAllocator;
-c2_status_t C2VDAAllocatorStore::fetchAllocator(
- id_t id, std::shared_ptr<C2Allocator>* const allocator) {
+c2_status_t C2VDAAllocatorStore::fetchAllocator(id_t id,
+ std::shared_ptr<C2Allocator>* const allocator) {
allocator->reset();
switch (id) {
case C2VDAAllocatorStore::MEM_DEALER:
@@ -102,9 +100,9 @@
return std::make_shared<C2VDAAllocatorStore>();
}
-c2_status_t getCodec2BlockPool(
- C2BlockPool::local_id_t id, std::shared_ptr<const C2Component> component,
- std::shared_ptr<C2BlockPool> *pool) {
+c2_status_t getCodec2BlockPool(C2BlockPool::local_id_t id,
+ std::shared_ptr<const C2Component> component,
+ std::shared_ptr<C2BlockPool>* pool) {
pool->reset();
if (!component) {
return C2_BAD_VALUE;
@@ -132,4 +130,4 @@
return res;
}
-} // namespace android
+} // namespace android
diff --git a/vndk/include/C2AllocatorCrosGralloc.h b/vndk/include/C2AllocatorCrosGralloc.h
index 1fa8538..ac5ce64 100644
--- a/vndk/include/C2AllocatorCrosGralloc.h
+++ b/vndk/include/C2AllocatorCrosGralloc.h
@@ -16,17 +16,17 @@
virtual C2String getName() const override;
virtual std::shared_ptr<const Traits> getTraits() const override {
- return nullptr; // TODO
+ return nullptr; // TODO
}
virtual c2_status_t newGraphicAllocation(
uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
- std::shared_ptr<C2GraphicAllocation> *allocation) override;
+ std::shared_ptr<C2GraphicAllocation>* allocation) override;
C2AllocatorCrosGralloc();
virtual ~C2AllocatorCrosGralloc();
};
-} // namespace android
+} // namespace android
-#endif // C2_ALLOCATOR_CROS_GRALLOC_H_
+#endif // C2_ALLOCATOR_CROS_GRALLOC_H_
diff --git a/vndk/include/C2AllocatorCrosGrallocNyc.h b/vndk/include/C2AllocatorCrosGrallocNyc.h
index 002e504..a2bd58a 100644
--- a/vndk/include/C2AllocatorCrosGrallocNyc.h
+++ b/vndk/include/C2AllocatorCrosGrallocNyc.h
@@ -20,12 +20,12 @@
virtual C2String getName() const override;
virtual std::shared_ptr<const Traits> getTraits() const override {
- return nullptr; // TODO
+ return nullptr; // TODO
}
virtual c2_status_t newGraphicAllocation(
uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
- std::shared_ptr<C2GraphicAllocation> *allocation) override;
+ std::shared_ptr<C2GraphicAllocation>* allocation) override;
C2AllocatorCrosGralloc();
virtual ~C2AllocatorCrosGralloc();
@@ -35,6 +35,6 @@
sp<IGraphicBufferAlloc> mAllocator;
};
-} // namespace android
+} // namespace android
-#endif // C2_ALLOCATOR_CROS_GRALLOC_H_
+#endif // C2_ALLOCATOR_CROS_GRALLOC_H_
diff --git a/vndk/include/C2AllocatorMemDealer.h b/vndk/include/C2AllocatorMemDealer.h
index 851a2ad..26da7dc 100644
--- a/vndk/include/C2AllocatorMemDealer.h
+++ b/vndk/include/C2AllocatorMemDealer.h
@@ -16,17 +16,17 @@
virtual C2String getName() const override;
virtual std::shared_ptr<const Traits> getTraits() const override {
- return nullptr; // TODO
+ return nullptr; // TODO
}
virtual c2_status_t newLinearAllocation(
uint32_t capacity, C2MemoryUsage usage,
- std::shared_ptr<C2LinearAllocation> *allocation) override;
+ std::shared_ptr<C2LinearAllocation>* allocation) override;
C2AllocatorMemDealer();
virtual ~C2AllocatorMemDealer();
};
-} // namespace android
+} // namespace android
-#endif // C2_ALLOCATOR_MEM_DEALER_H_
+#endif // C2_ALLOCATOR_MEM_DEALER_H_
diff --git a/vndk/include/C2VDASupport.h b/vndk/include/C2VDASupport.h
index 29cc425..aee2d4d 100644
--- a/vndk/include/C2VDASupport.h
+++ b/vndk/include/C2VDASupport.h
@@ -34,10 +34,10 @@
* \retval C2_CORRUPTED some unknown, unrecoverable error occured during operation (unexpected,
* this return value is only possible for basic pools)
*/
-c2_status_t getCodec2BlockPool(
- C2BlockPool::local_id_t id, std::shared_ptr<const C2Component> component,
- std::shared_ptr<C2BlockPool> *pool);
+c2_status_t getCodec2BlockPool(C2BlockPool::local_id_t id,
+ std::shared_ptr<const C2Component> component,
+ std::shared_ptr<C2BlockPool>* pool);
-} // namespace android
+} // namespace android
-#endif // C2_VDA_SUPPORT_H_
+#endif // C2_VDA_SUPPORT_H_