Merge "Codec2: adjustments due to C2Allocator changes"
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index d7f2a8e..ec3bc9a 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -117,7 +117,8 @@
kId(id),
mInitStatus(C2_OK),
mDomainInfo(C2DomainVideo),
- mOutputColorFormat(0u, kColorFormatYUV420Flexible),
+ mInputFormat(0u, C2FormatCompressed),
+ mOutputFormat(0u, C2FormatVideo),
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.
@@ -172,12 +173,13 @@
auto insertParam = [& params = mParams](C2Param* param) { params[param->index()] = param; };
insertParam(&mDomainInfo);
- insertParam(&mOutputColorFormat);
+ insertParam(&mInputFormat);
+ insertParam(&mOutputFormat);
insertParam(mInputPortMime.get());
insertParam(mOutputPortMime.get());
insertParam(&mInputCodecProfile);
- mSupportedValues.emplace(C2ParamField(&mInputCodecProfile, &C2StreamFormatConfig::value),
+ mSupportedValues.emplace(C2ParamField(&mInputCodecProfile, &C2VDAStreamProfileConfig::value),
C2FieldSupportedValues(false, mSupportedCodecProfiles));
// TODO(johnylin): min/max resolution may change by chosen profile, we should dynamically change
@@ -201,8 +203,10 @@
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>(false, "_input_format", &mInputFormat));
+ mParamDescs.push_back(
+ std::make_shared<C2ParamDescriptor>(false, "_output_format", &mOutputFormat));
mParamDescs.push_back(
std::make_shared<C2ParamDescriptor>(true, "_input_port_mime", mInputPortMime.get()));
mParamDescs.push_back(
@@ -278,8 +282,12 @@
failures->push_back(reportReadOnlyFailure<decltype(mDomainInfo)>(param));
err = C2_BAD_VALUE;
continue;
- } else if (index == mOutputColorFormat.index()) { // read-only
- failures->push_back(reportReadOnlyFailure<decltype(mOutputColorFormat)>(param));
+ } else if (index == mInputFormat.index()) { // read-only
+ failures->push_back(reportReadOnlyFailure<decltype(mInputFormat)>(param));
+ err = C2_BAD_VALUE;
+ continue;
+ } else if (index == mOutputFormat.index()) { // read-only
+ failures->push_back(reportReadOnlyFailure<decltype(mOutputFormat)>(param));
err = C2_BAD_VALUE;
continue;
} else if (index == mInputPortMime->index()) { // read-only
@@ -502,7 +510,7 @@
}
void C2VDAComponent::fetchParametersFromIntf() {
- C2StreamFormatConfig::input codecProfile;
+ C2VDAStreamProfileConfig::input codecProfile;
std::vector<C2Param*> 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
diff --git a/include/C2VDAComponent.h b/include/C2VDAComponent.h
index 1b05d6b..22a83e3 100644
--- a/include/C2VDAComponent.h
+++ b/include/C2VDAComponent.h
@@ -31,6 +31,14 @@
C2ENUM(ColorFormat, uint32_t, // enum for output color format
kColorFormatYUV420Flexible = 0x7F420888, )
+enum C2VDAParamIndexKind : C2Param::type_index_t {
+ kParamIndexVDAProfile = kParamIndexParamStart + 1,
+};
+
+// Codec profile for VDA VideoCodecProfile (see vda/video_codecs.h) [IN]
+// Note: this does not equal to AVC profile index
+typedef C2StreamParam<C2Info, C2Uint32Value, kParamIndexVDAProfile> C2VDAStreamProfileConfig;
+
class C2VDAComponentIntf : public C2ComponentInterface {
public:
C2VDAComponentIntf(C2String name, c2_node_id_t id);
@@ -73,8 +81,10 @@
// The component domain; should be C2DomainVideo.
C2ComponentDomainInfo mDomainInfo;
- // The color format of video output.
- C2StreamFormatConfig::output mOutputColorFormat;
+ // The input format kind; should be C2FormatCompressed.
+ C2StreamFormatConfig::input mInputFormat;
+ // The output format kind; should be C2FormatVideo.
+ C2StreamFormatConfig::output mOutputFormat;
// The MIME type of input port.
std::unique_ptr<C2PortMimeConfig::input> mInputPortMime;
// The MIME type of output port; should be MEDIA_MIMETYPE_VIDEO_RAW.
@@ -83,7 +93,7 @@
// The following parameters are also writable.
// The input video codec profile.
- C2StreamFormatConfig::input mInputCodecProfile;
+ C2VDAStreamProfileConfig::input mInputCodecProfile;
// Decoded video size for output.
C2VideoSizeStreamInfo::output mVideoSize;
// Max video size for video decoder.
diff --git a/tests/C2VDACompIntf_test.cpp b/tests/C2VDACompIntf_test.cpp
index 485155c..dcfd0ac 100644
--- a/tests/C2VDACompIntf_test.cpp
+++ b/tests/C2VDACompIntf_test.cpp
@@ -254,10 +254,18 @@
TRACED_FAILURE(testReadOnlyParam(&expected, &invalid));
}
-TEST_F(C2VDACompIntfTest, TestOutputColorFormat) {
- C2StreamFormatConfig::output expected(0u, kColorFormatYUV420Flexible);
+TEST_F(C2VDACompIntfTest, TestInputFormat) {
+ C2StreamFormatConfig::input expected(0u, C2FormatCompressed);
expected.setStream(0); // only support single stream
- C2StreamFormatConfig::output invalid(0u, 0xdeadbeef);
+ C2StreamFormatConfig::input invalid(0u, C2FormatVideo);
+ invalid.setStream(0); // only support single stream
+ TRACED_FAILURE(testReadOnlyParam(&expected, &invalid));
+}
+
+TEST_F(C2VDACompIntfTest, TestOutputFormat) {
+ C2StreamFormatConfig::output expected(0u, C2FormatVideo);
+ expected.setStream(0); // only support single stream
+ C2StreamFormatConfig::output invalid(0u, C2FormatCompressed);
invalid.setStream(0); // only support single stream
TRACED_FAILURE(testReadOnlyParam(&expected, &invalid));
}
@@ -346,10 +354,10 @@
}
TEST_F(C2VDACompIntfTest, TestInputCodecProfile) {
- C2StreamFormatConfig::input codecProfile;
+ C2VDAStreamProfileConfig::input codecProfile;
codecProfile.setStream(0); // only support single stream
std::vector<C2FieldSupportedValuesQuery> profileValues = {
- {C2ParamField(&codecProfile, &C2StreamFormatConfig::value),
+ {C2ParamField(&codecProfile, &C2VDAStreamProfileConfig::value),
C2FieldSupportedValuesQuery::CURRENT},
};
ASSERT_EQ(C2_OK, mIntf->querySupportedValues_vb(profileValues, C2_DONT_BLOCK));