Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 336ffa96 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Integrate dynamic depth processing"

parents c60fccb3 29e9ec18
Loading
Loading
Loading
Loading
+4 −37
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ cc_library_shared {
        "common/CameraDeviceBase.cpp",
        "common/CameraOfflineSessionBase.cpp",
        "common/CameraProviderManager.cpp",
        "common/DepthPhotoProcessor.cpp",
        "common/FrameProcessorBase.cpp",
        "api1/CameraClient.cpp",
        "api1/Camera2Client.cpp",
@@ -91,10 +92,12 @@ cc_library_shared {
        "libmediautils",
        "libcamera_client",
        "libcamera_metadata",
        "libdynamic_depth",
        "libfmq",
        "libgui",
        "libhardware",
        "libhidlbase",
        "libimage_io",
        "libjpeg",
        "libmedia_codeclist",
        "libmedia_omx",
@@ -102,6 +105,7 @@ cc_library_shared {
        "libsensorprivacy",
        "libstagefright",
        "libstagefright_foundation",
        "libxml2",
        "libyuv",
        "android.frameworks.cameraservice.common@2.0",
        "android.frameworks.cameraservice.service@2.0",
@@ -143,40 +147,3 @@ cc_library_shared {

}
cc_library_shared {
    name: "libdepthphoto",

    srcs: [
        "utils/ExifUtils.cpp",
        "common/DepthPhotoProcessor.cpp",
    ],

    shared_libs: [
        "libimage_io",
        "libdynamic_depth",
        "libxml2",
        "liblog",
        "libutilscallstack",
        "libutils",
        "libcutils",
        "libjpeg",
        "libmemunreachable",
        "libexif",
        "libcamera_client",
    ],

    include_dirs: [
        "external/dynamic_depth/includes",
        "external/dynamic_depth/internal",
    ],

    export_include_dirs: ["."],

    cflags: [
        "-Wall",
        "-Wextra",
        "-Werror",
        "-Wno-ignored-qualifiers",
    ],

}
+2 −28
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@

#include "api1/client2/JpegProcessor.h"
#include "common/CameraProviderManager.h"
#include "dlfcn.h"
#include <gui/Surface.h>
#include <utils/Log.h>
#include <utils/Trace.h>
@@ -43,9 +42,7 @@ DepthCompositeStream::DepthCompositeStream(wp<CameraDeviceBase> device,
        mBlobBufferAcquired(false),
        mProducerListener(new ProducerListener()),
        mMaxJpegSize(-1),
        mIsLogicalCamera(false),
        mDepthPhotoLibHandle(nullptr),
        mDepthPhotoProcess(nullptr) {
        mIsLogicalCamera(false) {
    sp<CameraDeviceBase> cameraDevice = device.promote();
    if (cameraDevice.get() != nullptr) {
        CameraMetadata staticInfo = cameraDevice->info();
@@ -83,19 +80,6 @@ DepthCompositeStream::DepthCompositeStream(wp<CameraDeviceBase> device,
        }

        getSupportedDepthSizes(staticInfo, &mSupportedDepthSizes);

        mDepthPhotoLibHandle = dlopen(camera3::kDepthPhotoLibrary, RTLD_NOW | RTLD_LOCAL);
        if (mDepthPhotoLibHandle != nullptr) {
            mDepthPhotoProcess = reinterpret_cast<camera3::process_depth_photo_frame> (
                    dlsym(mDepthPhotoLibHandle, camera3::kDepthPhotoProcessFunction));
            if (mDepthPhotoProcess == nullptr) {
                ALOGE("%s: Failed to link to depth photo process function: %s", __FUNCTION__,
                        dlerror());
            }
        } else {
            ALOGE("%s: Failed to link to depth photo library: %s", __FUNCTION__, dlerror());
        }

    }
}

@@ -108,11 +92,6 @@ DepthCompositeStream::~DepthCompositeStream() {
    mDepthSurface.clear();
    mDepthConsumer = nullptr;
    mDepthSurface = nullptr;
    if (mDepthPhotoLibHandle != nullptr) {
        dlclose(mDepthPhotoLibHandle);
        mDepthPhotoLibHandle = nullptr;
    }
    mDepthPhotoProcess = nullptr;
}

void DepthCompositeStream::compilePendingInputLocked() {
@@ -356,7 +335,7 @@ status_t DepthCompositeStream::processInputFrame(nsecs_t ts, const InputFrame &i
    }

    size_t actualJpegSize = 0;
    res = mDepthPhotoProcess(depthPhoto, finalJpegBufferSize, dstBuffer, &actualJpegSize);
    res = processDepthPhotoFrame(depthPhoto, finalJpegBufferSize, dstBuffer, &actualJpegSize);
    if (res != 0) {
        ALOGE("%s: Depth photo processing failed: %s (%d)", __FUNCTION__, strerror(-res), res);
        outputANW->cancelBuffer(mOutputSurface.get(), anb, /*fence*/ -1);
@@ -583,11 +562,6 @@ status_t DepthCompositeStream::configureStream() {
        return NO_ERROR;
    }

    if ((mDepthPhotoLibHandle == nullptr) || (mDepthPhotoProcess == nullptr)) {
        ALOGE("%s: Depth photo library is not present!", __FUNCTION__);
        return NO_INIT;
    }

    if (mOutputSurface.get() == nullptr) {
        ALOGE("%s: No valid output surface set!", __FUNCTION__);
        return NO_INIT;
+0 −2
Original line number Diff line number Diff line
@@ -126,8 +126,6 @@ private:
    std::vector<std::tuple<size_t, size_t>> mSupportedDepthSizes;
    std::vector<float>   mIntrinsicCalibration, mLensDistortion;
    bool                 mIsLogicalCamera;
    void*                mDepthPhotoLibHandle;
    process_depth_photo_frame mDepthPhotoProcess;

    // Keep all incoming Depth buffer timestamps pending further processing.
    std::vector<int64_t> mInputDepthBuffers;
+0 −30
Original line number Diff line number Diff line
@@ -716,31 +716,6 @@ void CameraProviderManager::ProviderInfo::DeviceInfo3::getSupportedDynamicDepthS
    }
}

bool CameraProviderManager::ProviderInfo::DeviceInfo3::isDepthPhotoLibraryPresent() {
    static bool libraryPresent = false;
    static bool initialized = false;
    if (initialized) {
        return libraryPresent;
    } else {
        initialized = true;
    }

    void* depthLibHandle = dlopen(camera3::kDepthPhotoLibrary, RTLD_NOW | RTLD_LOCAL);
    if (depthLibHandle == nullptr) {
        return false;
    }

    auto processFunc = dlsym(depthLibHandle, camera3::kDepthPhotoProcessFunction);
    if (processFunc != nullptr) {
        libraryPresent = true;
    } else {
        libraryPresent = false;
    }
    dlclose(depthLibHandle);

    return libraryPresent;
}

status_t CameraProviderManager::ProviderInfo::DeviceInfo3::addDynamicDepthTags() {
    uint32_t depthExclTag = ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE;
    uint32_t depthSizesTag = ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS;
@@ -788,11 +763,6 @@ status_t CameraProviderManager::ProviderInfo::DeviceInfo3::addDynamicDepthTags()
        return OK;
    }

    if(!isDepthPhotoLibraryPresent()) {
        // Depth photo processing library is not present, nothing more to do.
        return OK;
    }

    std::vector<int32_t> dynamicDepthEntries;
    for (const auto& it : supportedDynamicDepthSizes) {
        int32_t entry[4] = {HAL_PIXEL_FORMAT_BLOB, static_cast<int32_t> (std::get<0>(it)),
+0 −1
Original line number Diff line number Diff line
@@ -545,7 +545,6 @@ private:
            void getSupportedDynamicDepthDurations(const std::vector<int64_t>& depthDurations,
                    const std::vector<int64_t>& blobDurations,
                    std::vector<int64_t> *dynamicDepthDurations /*out*/);
            static bool isDepthPhotoLibraryPresent();
            static void getSupportedDynamicDepthSizes(
                    const std::vector<std::tuple<size_t, size_t>>& blobSizes,
                    const std::vector<std::tuple<size_t, size_t>>& depthSizes,
Loading