Merge "Camera: Fix link for nested classes" into tm-dev
diff --git a/media/codec2/components/gav1/C2SoftGav1Dec.cpp b/media/codec2/components/gav1/C2SoftGav1Dec.cpp
index beb9336..4dec57f 100644
--- a/media/codec2/components/gav1/C2SoftGav1Dec.cpp
+++ b/media/codec2/components/gav1/C2SoftGav1Dec.cpp
@@ -195,6 +195,11 @@
if (isHalPixelFormatSupported((AHardwareBuffer_Format)HAL_PIXEL_FORMAT_YCBCR_P010)) {
pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010);
}
+ // If color format surface isn't added to supported formats, there is no way to know
+ // when the color-format is configured to surface. This is necessary to be able to
+ // choose 10-bit format while decoding 10-bit clips in surface mode.
+ pixelFormats.push_back(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED);
+
// TODO: support more formats?
addParameter(
DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT)
@@ -323,6 +328,9 @@
return C2R::Ok();
}
+ // unsafe getters
+ std::shared_ptr<C2StreamPixelFormatInfo::output> getPixelFormat_l() const { return mPixelFormat; }
+
private:
std::shared_ptr<C2StreamProfileLevelInfo::input> mProfileLevel;
std::shared_ptr<C2StreamPictureSizeInfo::output> mSize;
@@ -411,6 +419,10 @@
mSignalledError = false;
mSignalledOutputEos = false;
mHalPixelFormat = HAL_PIXEL_FORMAT_YV12;
+ {
+ IntfImpl::Lock lock = mIntf->lock();
+ mPixelFormatInfo = mIntf->getPixelFormat_l();
+ }
mCodecCtx.reset(new libgav1::Decoder());
if (mCodecCtx == nullptr) {
@@ -635,7 +647,7 @@
std::shared_ptr<C2GraphicBlock> block;
uint32_t format = HAL_PIXEL_FORMAT_YV12;
std::shared_ptr<C2StreamColorAspectsInfo::output> codedColorAspects;
- if (buffer->bitdepth == 10) {
+ if (buffer->bitdepth == 10 && mPixelFormatInfo->value != HAL_PIXEL_FORMAT_YCBCR_420_888) {
IntfImpl::Lock lock = mIntf->lock();
codedColorAspects = mIntf->getColorAspects_l();
bool allowRGBA1010102 = false;
diff --git a/media/codec2/components/gav1/C2SoftGav1Dec.h b/media/codec2/components/gav1/C2SoftGav1Dec.h
index 4b13fef..3d4db55 100644
--- a/media/codec2/components/gav1/C2SoftGav1Dec.h
+++ b/media/codec2/components/gav1/C2SoftGav1Dec.h
@@ -51,6 +51,10 @@
std::shared_ptr<IntfImpl> mIntf;
std::unique_ptr<libgav1::Decoder> mCodecCtx;
+ // configurations used by component in process
+ // (TODO: keep this in intf but make them internal only)
+ std::shared_ptr<C2StreamPixelFormatInfo::output> mPixelFormatInfo;
+
uint32_t mHalPixelFormat;
uint32_t mWidth;
uint32_t mHeight;
diff --git a/media/codec2/components/vpx/C2SoftVpxDec.cpp b/media/codec2/components/vpx/C2SoftVpxDec.cpp
index b50fe7d..8087396 100644
--- a/media/codec2/components/vpx/C2SoftVpxDec.cpp
+++ b/media/codec2/components/vpx/C2SoftVpxDec.cpp
@@ -223,6 +223,10 @@
if (isHalPixelFormatSupported((AHardwareBuffer_Format)HAL_PIXEL_FORMAT_YCBCR_P010)) {
pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010);
}
+ // If color format surface isn't added to supported formats, there is no way to know
+ // when the color-format is configured to surface. This is necessary to be able to
+ // choose 10-bit format while decoding 10-bit clips in surface mode
+ pixelFormats.push_back(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED);
#endif
addParameter(
DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT)
@@ -307,6 +311,11 @@
return C2R::Ok();
}
+ // unsafe getters
+ std::shared_ptr<C2StreamPixelFormatInfo::output> getPixelFormat_l() const {
+ return mPixelFormat;
+ }
+
private:
std::shared_ptr<C2StreamProfileLevelInfo::input> mProfileLevel;
std::shared_ptr<C2StreamPictureSizeInfo::output> mSize;
@@ -434,6 +443,11 @@
mMode = MODE_VP8;
#endif
mHalPixelFormat = HAL_PIXEL_FORMAT_YV12;
+ {
+ IntfImpl::Lock lock = mIntf->lock();
+ mPixelFormatInfo = mIntf->getPixelFormat_l();
+ }
+
mWidth = 320;
mHeight = 240;
mFrameParallelMode = false;
@@ -689,7 +703,8 @@
std::shared_ptr<C2GraphicBlock> block;
uint32_t format = HAL_PIXEL_FORMAT_YV12;
std::shared_ptr<C2StreamColorAspectsTuning::output> defaultColorAspects;
- if (img->fmt == VPX_IMG_FMT_I42016) {
+ if (img->fmt == VPX_IMG_FMT_I42016 &&
+ mPixelFormatInfo->value != HAL_PIXEL_FORMAT_YCBCR_420_888) {
IntfImpl::Lock lock = mIntf->lock();
defaultColorAspects = mIntf->getDefaultColorAspects_l();
bool allowRGBA1010102 = false;
diff --git a/media/codec2/components/vpx/C2SoftVpxDec.h b/media/codec2/components/vpx/C2SoftVpxDec.h
index 5564766..e9d6dc9 100644
--- a/media/codec2/components/vpx/C2SoftVpxDec.h
+++ b/media/codec2/components/vpx/C2SoftVpxDec.h
@@ -63,6 +63,10 @@
std::shared_ptr<Mutexed<ConversionQueue>> mQueue;
};
+ // configurations used by component in process
+ // (TODO: keep this in intf but make them internal only)
+ std::shared_ptr<C2StreamPixelFormatInfo::output> mPixelFormatInfo;
+
std::shared_ptr<IntfImpl> mIntf;
vpx_codec_ctx_t *mCodecCtx;
bool mFrameParallelMode; // Frame parallel is only supported by VP9 decoder.
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 529ee36..296d7ed 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -1492,8 +1492,12 @@
// with more enc stat kinds
// Future extended encoding statistics for the level 2 should be added here
case VIDEO_ENCODING_STATISTICS_LEVEL_1:
- config->subscribeToConfigUpdate(comp,
- {kParamIndexAverageBlockQuantization, kParamIndexPictureType});
+ config->subscribeToConfigUpdate(
+ comp,
+ {
+ C2AndroidStreamAverageBlockQuantizationInfo::output::PARAM_TYPE,
+ C2StreamPictureTypeInfo::output::PARAM_TYPE,
+ });
break;
case VIDEO_ENCODING_STATISTICS_LEVEL_NONE:
break;
diff --git a/media/codec2/sfplugin/CCodecConfig.cpp b/media/codec2/sfplugin/CCodecConfig.cpp
index ba2b150..5208be6 100644
--- a/media/codec2/sfplugin/CCodecConfig.cpp
+++ b/media/codec2/sfplugin/CCodecConfig.cpp
@@ -16,6 +16,9 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "CCodecConfig"
+
+#include <initializer_list>
+
#include <cutils/properties.h>
#include <log/log.h>
#include <utils/NativeHandle.h>
@@ -1128,7 +1131,7 @@
if (domain.value == C2Component::DOMAIN_VIDEO) {
addLocalParam(new C2AndroidStreamAverageBlockQuantizationInfo::output(0u, 0),
C2_PARAMKEY_AVERAGE_QP);
- addLocalParam(new C2StreamPictureTypeMaskInfo::output(0u, 0),
+ addLocalParam(new C2StreamPictureTypeInfo::output(0u, 0),
C2_PARAMKEY_PICTURE_TYPE);
}
}
@@ -1165,6 +1168,17 @@
}
}
+ // Parameters that are not subscribed initially, but can be subscribed
+ // upon explicit request.
+ static const std::initializer_list<C2Param::Index> kOptionalParams = {
+ C2AndroidStreamAverageBlockQuantizationInfo::output::PARAM_TYPE,
+ C2StreamPictureTypeInfo::output::PARAM_TYPE,
+ };
+ for (const C2Param::Index &index : kOptionalParams) {
+ mSubscribedIndices.erase(index);
+ }
+ subscribeToConfigUpdate(configurable, {}, C2_MAY_BLOCK);
+
return OK;
}
@@ -1196,6 +1210,20 @@
ALOGV("Subscribed to %zu params", mSubscribedIndices.size());
mSubscribedIndicesSize = mSubscribedIndices.size();
}
+#if defined(LOG_NDEBUG) && !LOG_NDEBUG
+ ALOGV("subscribed to %zu params:", mSubscribedIndices.size());
+ std::stringstream ss;
+ for (const C2Param::Index &index : mSubscribedIndices) {
+ ss << index << " ";
+ if (ss.str().length() > 70) {
+ ALOGV("%s", ss.str().c_str());
+ std::stringstream().swap(ss);
+ }
+ }
+ if (!ss.str().empty()) {
+ ALOGV("%s", ss.str().c_str());
+ }
+#endif
return OK;
}
@@ -1220,6 +1248,12 @@
bool changed = false;
for (std::unique_ptr<C2Param> &p : configUpdate) {
if (p && *p) {
+ // Allow unsubscribed vendor parameters to go through --- it may be
+ // later handled by the format shaper.
+ if (!p->isVendor() && mSubscribedIndices.count(p->index()) == 0) {
+ ALOGV("updateConfiguration: skipped unsubscribed param %08x", p->index());
+ continue;
+ }
auto insertion = mCurrentConfig.emplace(p->index(), nullptr);
if (insertion.second || *insertion.first->second != *p) {
if (mSupportedIndices.count(p->index()) || mLocalParams.count(p->index())) {
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index ab1368f..e50880a 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -2622,7 +2622,9 @@
msg->setObject("c2buffer", obj);
msg->setInt64("timeUs", presentationTimeUs);
msg->setInt32("flags", flags);
- msg->setMessage("tunings", tunings);
+ if (tunings && tunings->countEntries() > 0) {
+ msg->setMessage("tunings", tunings);
+ }
msg->setPointer("errorDetailMsg", errorDetailMsg);
sp<AMessage> response;
@@ -2664,7 +2666,9 @@
msg->setInt32("skipBlocks", pattern.mSkipBlocks);
msg->setInt64("timeUs", presentationTimeUs);
msg->setInt32("flags", flags);
- msg->setMessage("tunings", tunings);
+ if (tunings && tunings->countEntries() > 0) {
+ msg->setMessage("tunings", tunings);
+ }
msg->setPointer("errorDetailMsg", errorDetailMsg);
sp<AMessage> response;
@@ -4864,12 +4868,10 @@
sp<WrapperObject<std::shared_ptr<C2Buffer>>> obj{
new WrapperObject<std::shared_ptr<C2Buffer>>{c2Buffer}};
msg->setObject("c2buffer", obj);
- msg->setMessage("tunings", new AMessage);
} else if (memory) {
sp<WrapperObject<sp<hardware::HidlMemory>>> obj{
new WrapperObject<sp<hardware::HidlMemory>>{memory}};
msg->setObject("memory", obj);
- msg->setMessage("tunings", new AMessage);
}
return onQueueInputBuffer(msg);
@@ -5049,9 +5051,10 @@
sp<MediaCodecBuffer> buffer = info->mData;
if (c2Buffer || memory) {
- sp<AMessage> tunings;
- CHECK(msg->findMessage("tunings", &tunings));
- onSetParameters(tunings);
+ sp<AMessage> tunings = NULL;
+ if (msg->findMessage("tunings", &tunings) && tunings != NULL) {
+ onSetParameters(tunings);
+ }
status_t err = OK;
if (c2Buffer) {
diff --git a/media/utils/ServiceUtilities.cpp b/media/utils/ServiceUtilities.cpp
index 1ab5bc1..07f4529 100644
--- a/media/utils/ServiceUtilities.cpp
+++ b/media/utils/ServiceUtilities.cpp
@@ -181,10 +181,14 @@
bool captureAudioOutputAllowed(const AttributionSourceState& attributionSource) {
uid_t uid = VALUE_OR_FATAL(aidl2legacy_int32_t_uid_t(attributionSource.uid));
- pid_t pid = VALUE_OR_FATAL(aidl2legacy_int32_t_pid_t(attributionSource.pid));
if (isAudioServerOrRootUid(uid)) return true;
static const String16 sCaptureAudioOutput("android.permission.CAPTURE_AUDIO_OUTPUT");
- bool ok = PermissionCache::checkPermission(sCaptureAudioOutput, pid, uid);
+ // Use PermissionChecker, which includes some logic for allowing the isolated
+ // HotwordDetectionService to hold certain permissions.
+ permission::PermissionChecker permissionChecker;
+ bool ok = (permissionChecker.checkPermissionForPreflight(
+ sCaptureAudioOutput, attributionSource, String16(),
+ AppOpsManager::OP_NONE) != permission::PermissionChecker::PERMISSION_HARD_DENIED);
if (!ok) ALOGV("Request requires android.permission.CAPTURE_AUDIO_OUTPUT");
return ok;
}