aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Staessens <dstaessens@google.com>2021-03-24 13:21:48 +0900
committerChih-Yu Huang <akahuang@google.com>2021-05-12 11:50:33 +0900
commit128a6ee185b14bc133604ec09f66bff7f1c7a1e7 (patch)
tree5b45e00d2cc55db7d41f4382a1afd0a7ce95ead0
parenteca6155b4da333cebc9f57acc3af8a5259d9ee0e (diff)
downloadv4l2_codec2-128a6ee185b14bc133604ec09f66bff7f1c7a1e7.tar.gz
v4l2_codec2: Use C2Config::PROFILE_VP8_0.
This CL changes the V4L2 encoder component to use the newly introduced C2Config::PROFILE_VP8_0 profile. This profile was initially not present, complicating code dealing with VP8. Note: Submit after ag/13976507 Bug: 155138142 Test: arc.VideoEncodeAccel.vp8_192p_i420_vm Change-Id: I4256a4871221d3f417b5f1a003cc9fcfdb3dcd0e
-rw-r--r--common/EncodeHelpers.cpp2
-rw-r--r--components/V4L2EncodeComponent.cpp11
-rw-r--r--components/V4L2EncodeInterface.cpp52
3 files changed, 26 insertions, 39 deletions
diff --git a/common/EncodeHelpers.cpp b/common/EncodeHelpers.cpp
index 2ab0e71..c23b17d 100644
--- a/common/EncodeHelpers.cpp
+++ b/common/EncodeHelpers.cpp
@@ -42,6 +42,8 @@ media::VideoCodecProfile c2ProfileToVideoCodecProfile(C2Config::profile_t profil
return media::VideoCodecProfile::H264PROFILE_STEREOHIGH;
case C2Config::PROFILE_AVC_MULTIVIEW_HIGH:
return media::VideoCodecProfile::H264PROFILE_MULTIVIEWHIGH;
+ case C2Config::PROFILE_VP8_0:
+ return media::VideoCodecProfile::VP8PROFILE_ANY;
case C2Config::PROFILE_VP9_0:
return media::VideoCodecProfile::VP9PROFILE_PROFILE0;
case C2Config::PROFILE_VP9_1:
diff --git a/components/V4L2EncodeComponent.cpp b/components/V4L2EncodeComponent.cpp
index 76d4531..7a85a06 100644
--- a/components/V4L2EncodeComponent.cpp
+++ b/components/V4L2EncodeComponent.cpp
@@ -619,14 +619,9 @@ bool V4L2EncodeComponent::initializeEncoder() {
mCSDSubmitted = false;
- // Get the requested profile. The codec2 framework doesn't define any profiles for VP8 as VP8
- // only supports a single profile, so we have to deduce the profile from the MIME type.
- media::VideoCodecProfile outputProfile;
- if (strcmp(mInterface->getOutputMediaType(), MEDIA_MIMETYPE_VIDEO_VP8) == 0) {
- outputProfile = media::VideoCodecProfile::VP8PROFILE_ANY;
- } else {
- outputProfile = c2ProfileToVideoCodecProfile(mInterface->getOutputProfile());
- }
+ // Get the requested profile and level.
+ media::VideoCodecProfile outputProfile =
+ c2ProfileToVideoCodecProfile(mInterface->getOutputProfile());
std::optional<uint8_t> h264Level;
if (outputProfile >= media::H264PROFILE_MIN && outputProfile <= media::H264PROFILE_MAX) {
diff --git a/components/V4L2EncodeInterface.cpp b/components/V4L2EncodeInterface.cpp
index f0abd29..4e5ae7a 100644
--- a/components/V4L2EncodeInterface.cpp
+++ b/components/V4L2EncodeInterface.cpp
@@ -67,6 +67,8 @@ C2Config::profile_t videoCodecProfileToC2Profile(media::VideoCodecProfile profil
return C2Config::PROFILE_AVC_STEREO_HIGH;
case media::VideoCodecProfile::H264PROFILE_MULTIVIEWHIGH:
return C2Config::PROFILE_AVC_MULTIVIEW_HIGH;
+ case media::VideoCodecProfile::VP8PROFILE_ANY:
+ return C2Config::PROFILE_VP8_0;
case media::VideoCodecProfile::VP9PROFILE_PROFILE0:
return C2Config::PROFILE_VP9_0;
case media::VideoCodecProfile::VP9PROFILE_PROFILE1:
@@ -96,6 +98,8 @@ bool IsValidProfileForCodec(VideoCodec codec, C2Config::profile_t profile) {
case VideoCodec::H264:
return ((profile >= C2Config::PROFILE_AVC_BASELINE) &&
(profile <= C2Config::PROFILE_AVC_ENHANCED_MULTIVIEW_DEPTH_HIGH));
+ case VideoCodec::VP8:
+ return ((profile >= C2Config::PROFILE_VP8_0) && (profile <= C2Config::PROFILE_VP8_3));
case VideoCodec::VP9:
return ((profile >= C2Config::PROFILE_VP9_0) && (profile <= C2Config::PROFILE_VP9_3));
default:
@@ -295,41 +299,27 @@ void V4L2EncodeInterface::Initialize(const C2String& name) {
V4L2Device::SupportedEncodeProfiles supported_profiles = device->getSupportedEncodeProfiles();
- // Compile the list of supported profiles. In the case of VP8 only a single profile is
- // supported, which is not defined by the C2 framework.
+ // Compile the list of supported profiles.
// Note: unsigned int is used here, since std::vector<C2Config::profile_t> cannot convert to
// std::vector<unsigned int> required by the c2 framework below.
std::vector<unsigned int> profiles;
ui::Size maxSize;
- if (codec == VideoCodec::VP8) {
- auto it = find_if(supported_profiles.begin(), supported_profiles.end(),
- [](const V4L2Device::SupportedEncodeProfile& profile) {
- return profile.profile == media::VideoCodecProfile::VP8PROFILE_MIN;
- });
- if (it == supported_profiles.end()) {
- ALOGE("VP8 profile not supported");
- mInitStatus = C2_BAD_VALUE;
- return;
- }
- maxSize = ui::Size(it->max_resolution.width, it->max_resolution.height);
- } else {
- for (const auto& supportedProfile : supported_profiles) {
- C2Config::profile_t profile = videoCodecProfileToC2Profile(supportedProfile.profile);
- if (!IsValidProfileForCodec(codec.value(), profile)) {
- continue; // Ignore unrecognizable or unsupported profiles.
- }
- ALOGV("Queried c2_profile = 0x%x : max_size = %d x %d", profile,
- supportedProfile.max_resolution.width, supportedProfile.max_resolution.height);
- profiles.push_back(static_cast<unsigned int>(profile));
- maxSize.setWidth(std::max(maxSize.width, supportedProfile.max_resolution.width));
- maxSize.setHeight(std::max(maxSize.height, supportedProfile.max_resolution.height));
+ for (const auto& supportedProfile : supported_profiles) {
+ C2Config::profile_t profile = videoCodecProfileToC2Profile(supportedProfile.profile);
+ if (!IsValidProfileForCodec(codec.value(), profile)) {
+ continue; // Ignore unrecognizable or unsupported profiles.
}
+ ALOGV("Queried c2_profile = 0x%x : max_size = %d x %d", profile,
+ supportedProfile.max_resolution.width, supportedProfile.max_resolution.height);
+ profiles.push_back(static_cast<unsigned int>(profile));
+ maxSize.setWidth(std::max(maxSize.width, supportedProfile.max_resolution.width));
+ maxSize.setHeight(std::max(maxSize.height, supportedProfile.max_resolution.height));
+ }
- if (profiles.empty()) {
- ALOGE("No supported profiles");
- mInitStatus = C2_BAD_VALUE;
- return;
- }
+ if (profiles.empty()) {
+ ALOGE("No supported profiles");
+ mInitStatus = C2_BAD_VALUE;
+ return;
}
// Special note: the order of addParameter matters if your setters are dependent on other
@@ -387,10 +377,10 @@ void V4L2EncodeInterface::Initialize(const C2String& name) {
.build());
} else if (getCodecFromComponentName(name) == VideoCodec::VP8) {
outputMime = MEDIA_MIMETYPE_VIDEO_VP8;
- // VP8 Only has a single profile, so we'll use that when the VP8 codec is requested.
+ // VP8 doesn't have conventional profiles, we'll use profile0 if the VP8 codec is requested.
addParameter(DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL)
.withConstValue(new C2StreamProfileLevelInfo::output(
- 0u, C2Config::PROFILE_UNUSED, C2Config::LEVEL_UNUSED))
+ 0u, C2Config::PROFILE_VP8_0, C2Config::LEVEL_UNUSED))
.build());
} else if (getCodecFromComponentName(name) == VideoCodec::VP9) {
outputMime = MEDIA_MIMETYPE_VIDEO_VP9;