diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-20 14:03:13 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-20 14:03:13 +0000 |
commit | 022fb1071439c13f562c996926a51b3af0c30fe3 (patch) | |
tree | eb4f70c54f548971fb903fa37925ae2e3996c874 | |
parent | d2b1654c9aea685a25610a0967f9ed219450c06e (diff) | |
parent | 5b33db054b4a0423d42e5b90a2898c8da6ff52ab (diff) | |
download | av-t_frc_sta_330443010.tar.gz |
Snap for 8745897 from 5b33db054b4a0423d42e5b90a2898c8da6ff52ab to tm-frc-os-statsd-releaset_frc_sta_330443010android13-frc-os-statsd-release
Change-Id: Id71c0711bccd9c452c67b980bd6986d6cd91ae63
-rw-r--r-- | camera/ndk/include/camera/NdkCameraMetadataTags.h | 13 | ||||
-rw-r--r-- | media/TEST_MAPPING | 45 | ||||
-rw-r--r-- | media/codec2/components/avc/C2SoftAvcEnc.cpp | 3 | ||||
-rw-r--r-- | media/codec2/components/hevc/C2SoftHevcEnc.cpp | 3 | ||||
-rw-r--r-- | media/codec2/components/vpx/C2SoftVpxEnc.cpp | 8 | ||||
-rw-r--r-- | media/codec2/components/vpx/C2SoftVpxEnc.h | 3 | ||||
-rw-r--r-- | media/codec2/sfplugin/CCodec.cpp | 8 | ||||
-rw-r--r-- | media/codec2/sfplugin/CCodecBufferChannel.cpp | 22 | ||||
-rw-r--r-- | media/codec2/sfplugin/CCodecConfig.cpp | 36 | ||||
-rw-r--r-- | media/codec2/sfplugin/Codec2Buffer.cpp | 33 | ||||
-rw-r--r-- | media/codec2/sfplugin/utils/Codec2BufferUtils.cpp | 10 | ||||
-rw-r--r-- | services/camera/libcameraservice/device3/Camera3Device.cpp | 3 |
12 files changed, 132 insertions, 55 deletions
diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h index 913854ce5c..b6f8552ae1 100644 --- a/camera/ndk/include/camera/NdkCameraMetadataTags.h +++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h @@ -3486,10 +3486,11 @@ typedef enum acamera_metadata_tag { * </ul></p> * * <p>This is a subset of ACAMERA_REQUEST_AVAILABLE_REQUEST_KEYS which contains a list - * of keys that can be overridden using <a href="https://developer.android.com/reference/CaptureRequest/Builder.html#setPhysicalCameraKey">Builder#setPhysicalCameraKey</a>. + * of keys that can be overridden using + * <a href="https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Builder.html#setPhysicalCameraKey">Builder#setPhysicalCameraKey</a>. * The respective value of such request key can be obtained by calling - * <a href="https://developer.android.com/reference/CaptureRequest/Builder.html#getPhysicalCameraKey">Builder#getPhysicalCameraKey</a>. Capture requests that contain - * individual physical device requests must be built via + * <a href="https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Builder.html#getPhysicalCameraKey">Builder#getPhysicalCameraKey</a>. + * Capture requests that contain individual physical device requests must be built via * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureRequest(int,">Set)</a>.</p> * * @see ACAMERA_REQUEST_AVAILABLE_REQUEST_KEYS @@ -3713,7 +3714,7 @@ typedef enum acamera_metadata_tag { * IMPLEMENTATION_DEFINED | same as YUV_420_888 | Any |</p> * <p>For applications targeting SDK version 31 or newer, if the mobile device declares to be * media performance class 12 or higher by setting - * <a href="https://developer.android.com/reference/android/os/Build/VERSION_CODES/MEDIA_PERFORMANCE_CLASS.html">MEDIA_PERFORMANCE_CLASS</a> to be 31 or larger, + * <a href="https://developer.android.com/reference/android/os/Build.VERSION.html#MEDIA_PERFORMANCE_CLASS">VERSION#MEDIA_PERFORMANCE_CLASS</a> to be 31 or larger, * the primary camera devices (first rear/front camera in the camera ID list) will not * support JPEG sizes smaller than 1080p. If the application configures a JPEG stream * smaller than 1080p, the camera device will round up the JPEG image size to at least @@ -3732,7 +3733,7 @@ typedef enum acamera_metadata_tag { * IMPLEMENTATION_DEFINED | same as YUV_420_888 | Any |</p> * <p>For applications targeting SDK version 31 or newer, if the mobile device doesn't declare * to be media performance class 12 or better by setting - * <a href="https://developer.android.com/reference/android/os/Build/VERSION_CODES/MEDIA_PERFORMANCE_CLASS.html">MEDIA_PERFORMANCE_CLASS</a> to be 31 or larger, + * <a href="https://developer.android.com/reference/android/os/Build.VERSION.html#MEDIA_PERFORMANCE_CLASS">VERSION#MEDIA_PERFORMANCE_CLASS</a> to be 31 or larger, * or if the camera device isn't a primary rear/front camera, the minimum required output * stream configurations are the same as for applications targeting SDK version older than * 31.</p> @@ -10225,7 +10226,7 @@ typedef enum acamera_metadata_enum_acamera_info_supported_hardware_level { * fire the flash for flash power metering during precapture, and then fire the flash * for the final capture, if a flash is available on the device and the AE mode is set to * enable the flash.</p> - * <p>Devices that initially shipped with Android version <a href="https://developer.android.com/reference/android/os/Build/VERSION_CODES.html#Q">Q</a> or newer will not include any LEGACY-level devices.</p> + * <p>Devices that initially shipped with Android version <a href="https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#Q">Q</a> or newer will not include any LEGACY-level devices.</p> * * @see ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER * @see ACAMERA_REQUEST_AVAILABLE_CAPABILITIES diff --git a/media/TEST_MAPPING b/media/TEST_MAPPING index 41fe08006e..a4c03bab3a 100644 --- a/media/TEST_MAPPING +++ b/media/TEST_MAPPING @@ -1,24 +1,7 @@ // for frameworks/av/media { - "presubmit-large": [ - // runs whenever we change something in this tree - { - "name": "CtsMediaCodecTestCases", - "options": [ - { - "include-filter": "android.media.codec.cts.EncodeDecodeTest" - } - ] - }, - { - "name": "CtsMediaCodecTestCases", - "options": [ - { - "include-filter": "android.media.codec.cts.DecodeEditEncodeTest" - } - ] - } - ], + // TODO (b/229286407) Add EncodeDecodeTest and DecodeEditEncodeTest to + // presubmit-large once issues in cuttlefish are fixed "presubmit": [ { "name": "GtsMediaTestCases", @@ -40,26 +23,8 @@ { "path": "frameworks/av/drm/mediadrm/plugins" } - ], - - "platinum-postsubmit": [ - // runs regularly, independent of changes in this tree. - // signals if changes elsewhere break media functionality - { - "name": "CtsMediaCodecTestCases", - "options": [ - { - "include-filter": "android.media.codec.cts.EncodeDecodeTest" - } - ] - }, - { - "name": "CtsMediaCodecTestCases", - "options": [ - { - "include-filter": "android.media.codec.cts.DecodeEditEncodeTest" - } - ] - } ] + + // TODO (b/229286407) Add EncodeDecodeTest and DecodeEditEncodeTest to + // platinum-postsubmit once issues in cuttlefish are fixed } diff --git a/media/codec2/components/avc/C2SoftAvcEnc.cpp b/media/codec2/components/avc/C2SoftAvcEnc.cpp index 4ffcd59f09..8b46d3f495 100644 --- a/media/codec2/components/avc/C2SoftAvcEnc.cpp +++ b/media/codec2/components/avc/C2SoftAvcEnc.cpp @@ -1514,7 +1514,8 @@ c2_status_t C2SoftAvcEnc::setEncodeArgs( vPlane = uPlane + yPlaneSize / 4; yStride = width; uStride = vStride = yStride / 2; - ConvertRGBToPlanarYUV(yPlane, yStride, height, conversionBuffer.size(), *input); + ConvertRGBToPlanarYUV(yPlane, yStride, height, conversionBuffer.size(), *input, + mColorAspects->matrix, mColorAspects->range); break; } case C2PlanarLayout::TYPE_YUV: { diff --git a/media/codec2/components/hevc/C2SoftHevcEnc.cpp b/media/codec2/components/hevc/C2SoftHevcEnc.cpp index 947e3870d4..60d5875264 100644 --- a/media/codec2/components/hevc/C2SoftHevcEnc.cpp +++ b/media/codec2/components/hevc/C2SoftHevcEnc.cpp @@ -901,7 +901,8 @@ c2_status_t C2SoftHevcEnc::setEncodeArgs(ihevce_inp_buf_t* ps_encode_ip, yStride = width; uStride = vStride = yStride / 2; ConvertRGBToPlanarYUV(yPlane, yStride, height, - conversionBuffer.size(), *input); + conversionBuffer.size(), *input, + mColorAspects->matrix, mColorAspects->range); break; } case C2PlanarLayout::TYPE_YUV: { diff --git a/media/codec2/components/vpx/C2SoftVpxEnc.cpp b/media/codec2/components/vpx/C2SoftVpxEnc.cpp index 617769b326..f99ee248df 100644 --- a/media/codec2/components/vpx/C2SoftVpxEnc.cpp +++ b/media/codec2/components/vpx/C2SoftVpxEnc.cpp @@ -733,8 +733,14 @@ void C2SoftVpxEnc::process( switch (layout.type) { case C2PlanarLayout::TYPE_RGB: case C2PlanarLayout::TYPE_RGBA: { + std::shared_ptr<C2StreamColorAspectsInfo::output> colorAspects; + { + IntfImpl::Lock lock = mIntf->lock(); + colorAspects = mIntf->getCodedColorAspects_l(); + } ConvertRGBToPlanarYUV(mConversionBuffer.data(), stride, vstride, - mConversionBuffer.size(), *rView.get()); + mConversionBuffer.size(), *rView.get(), + colorAspects->matrix, colorAspects->range); vpx_img_wrap(&raw_frame, VPX_IMG_FMT_I420, width, height, mStrideAlign, mConversionBuffer.data()); break; diff --git a/media/codec2/components/vpx/C2SoftVpxEnc.h b/media/codec2/components/vpx/C2SoftVpxEnc.h index e296c8fc34..714fadb504 100644 --- a/media/codec2/components/vpx/C2SoftVpxEnc.h +++ b/media/codec2/components/vpx/C2SoftVpxEnc.h @@ -265,6 +265,9 @@ class C2SoftVpxEnc::IntfImpl : public SimpleInterface<void>::BaseParams { std::shared_ptr<C2StreamTemporalLayeringTuning::output> getTemporalLayers_l() const { return mLayering; } + std::shared_ptr<C2StreamColorAspectsInfo::output> getCodedColorAspects_l() const { + return mCodedColorAspects; + } uint32_t getSyncFramePeriod() const; static C2R ColorAspectsSetter(bool mayBlock, C2P<C2StreamColorAspectsInfo::input> &me); static C2R CodedColorAspectsSetter(bool mayBlock, C2P<C2StreamColorAspectsInfo::output> &me, diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp index 529ee36941..296d7ed771 100644 --- a/media/codec2/sfplugin/CCodec.cpp +++ b/media/codec2/sfplugin/CCodec.cpp @@ -1492,8 +1492,12 @@ void CCodec::configure(const sp<AMessage> &msg) { // 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/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp index f27cc21116..5ecb1307f0 100644 --- a/media/codec2/sfplugin/CCodecBufferChannel.cpp +++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp @@ -1016,6 +1016,10 @@ void CCodecBufferChannel::getInputBufferArray(Vector<sp<MediaCodecBuffer>> *arra array->clear(); Mutexed<Input>::Locked input(mInput); + if (!input->buffers) { + ALOGE("getInputBufferArray: No Input Buffers allocated"); + return; + } if (!input->buffers->isArrayMode()) { input->buffers = input->buffers->toArrayMode(input->numSlots); } @@ -1026,7 +1030,10 @@ void CCodecBufferChannel::getInputBufferArray(Vector<sp<MediaCodecBuffer>> *arra void CCodecBufferChannel::getOutputBufferArray(Vector<sp<MediaCodecBuffer>> *array) { array->clear(); Mutexed<Output>::Locked output(mOutput); - + if (!output->buffers) { + ALOGE("getOutputBufferArray: No Output Buffers allocated"); + return; + } if (!output->buffers->isArrayMode()) { output->buffers = output->buffers->toArrayMode(output->numSlots); } @@ -2034,6 +2041,9 @@ void CCodecBufferChannel::sendOutputBuffers() { sp<MediaCodecBuffer> outBuffer; std::shared_ptr<C2Buffer> c2Buffer; + constexpr int kMaxReallocTry = 5; + int reallocTryNum = 0; + while (true) { Mutexed<Output>::Locked output(mOutput); if (!output->buffers) { @@ -2041,6 +2051,9 @@ void CCodecBufferChannel::sendOutputBuffers() { } action = output->buffers->popFromStashAndRegister( &c2Buffer, &index, &outBuffer); + if (action != OutputBuffers::REALLOCATE) { + reallocTryNum = 0; + } switch (action) { case OutputBuffers::SKIP: return; @@ -2051,6 +2064,13 @@ void CCodecBufferChannel::sendOutputBuffers() { mCallback->onOutputBufferAvailable(index, outBuffer); break; case OutputBuffers::REALLOCATE: + if (++reallocTryNum > kMaxReallocTry) { + output.unlock(); + ALOGE("[%s] sendOutputBuffers: tried %d realloc and failed", + mName, kMaxReallocTry); + mCCodecCallback->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL); + return; + } if (!output->buffers->isArrayMode()) { output->buffers = output->buffers->toArrayMode(output->numSlots); diff --git a/media/codec2/sfplugin/CCodecConfig.cpp b/media/codec2/sfplugin/CCodecConfig.cpp index ba2b1506fa..5208be67d9 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 @@ status_t CCodecConfig::initialize( 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 @@ status_t CCodecConfig::initialize( } } + // 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 @@ status_t CCodecConfig::subscribeToConfigUpdate( 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 CCodecConfig::updateConfiguration( 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/codec2/sfplugin/Codec2Buffer.cpp b/media/codec2/sfplugin/Codec2Buffer.cpp index 6084ee330c..cde4c72f07 100644 --- a/media/codec2/sfplugin/Codec2Buffer.cpp +++ b/media/codec2/sfplugin/Codec2Buffer.cpp @@ -268,6 +268,39 @@ public: mInitCheck = BAD_VALUE; return; } + std::optional<int> clientBitDepth = {}; + switch (mClientColorFormat) { + case COLOR_FormatYUVP010: + clientBitDepth = 10; + break; + case COLOR_FormatYUV411PackedPlanar: + case COLOR_FormatYUV411Planar: + case COLOR_FormatYUV420Flexible: + case COLOR_FormatYUV420PackedPlanar: + case COLOR_FormatYUV420PackedSemiPlanar: + case COLOR_FormatYUV420Planar: + case COLOR_FormatYUV420SemiPlanar: + case COLOR_FormatYUV422Flexible: + case COLOR_FormatYUV422PackedPlanar: + case COLOR_FormatYUV422PackedSemiPlanar: + case COLOR_FormatYUV422Planar: + case COLOR_FormatYUV422SemiPlanar: + case COLOR_FormatYUV444Flexible: + case COLOR_FormatYUV444Interleaved: + clientBitDepth = 8; + break; + default: + // no-op; used with optional + break; + + } + // conversion fails if client bit-depth and the component bit-depth differs + if ((clientBitDepth) && (bitDepth != clientBitDepth.value())) { + ALOGD("Bit depth of client: %d and component: %d differs", + *clientBitDepth, bitDepth); + mInitCheck = BAD_VALUE; + return; + } C2PlaneInfo yPlane = layout.planes[C2PlanarLayout::PLANE_Y]; C2PlaneInfo uPlane = layout.planes[C2PlanarLayout::PLANE_U]; C2PlaneInfo vPlane = layout.planes[C2PlanarLayout::PLANE_V]; diff --git a/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp b/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp index a3a023a3d2..807841e4c6 100644 --- a/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp +++ b/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp @@ -121,7 +121,10 @@ static status_t _ImageCopy(View &view, const MediaImage2 *img, ImagePixel *imgBa } // namespace status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView &view) { - if (view.crop().width != img->mWidth || view.crop().height != img->mHeight) { + if (img == nullptr + || imgBase == nullptr + || view.crop().width != img->mWidth + || view.crop().height != img->mHeight) { return BAD_VALUE; } const uint8_t* src_y = view.data()[0]; @@ -203,7 +206,10 @@ status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView } status_t ImageCopy(C2GraphicView &view, const uint8_t *imgBase, const MediaImage2 *img) { - if (view.crop().width != img->mWidth || view.crop().height != img->mHeight) { + if (img == nullptr + || imgBase == nullptr + || view.crop().width != img->mWidth + || view.crop().height != img->mHeight) { return BAD_VALUE; } const uint8_t* src_y = imgBase + img->mPlane[0].mOffset; diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index dec439ffc6..7c2f34f46e 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -2291,6 +2291,9 @@ status_t Camera3Device::configureStreamsLocked(int operatingMode, mOperatingMode = operatingMode; } + // Reset min expected duration when session is reconfigured. + mMinExpectedDuration = 0; + // In case called from configureStreams, abort queued input buffers not belonging to // any pending requests. if (mInputStream != NULL && notifyRequestThread) { |