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

Commit aaa1aa1c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12874595 from b62a6ba7 to 25Q2-release

Change-Id: Ie936c1c4e7445288dba4b21ec22f5612d876bacd
parents a27c1949 b62a6ba7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -280,3 +280,13 @@ flag {
    description: "Applies system controlled effects targetting video conferencing"
    bug: "376797335"
}

flag {
    namespace: "camera_platform"
    name: "metadata_resize_fix"
    description: "metadata resize during update needs to consider existing entry"
    bug: "379388099"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+34 −0
Original line number Diff line number Diff line
@@ -736,6 +736,39 @@ static void parseAV1ProfileLevelFromCsd(const sp<ABuffer> &csd, sp<AMessage> &fo
    }
}

static void parseAPVProfileLevelFromCsd(const sp<ABuffer>& csd, sp<AMessage>& format) {
    // Parse CSD structure to extract profile level information
    // https://github.com/openapv/openapv/blob/main/readme/apv_isobmff.md#syntax-1
    const uint8_t* data = csd->data();
    size_t csdSize = csd->size();
    if (csdSize < 21 || data[5] != 0x01) {  // configurationVersion == 1
        return;
    }
    uint8_t profileData = data[9];           // profile_idc
    uint8_t levelData = data[10];            // level_idc
    uint8_t band = data[11];                 // band_idc
    uint8_t bitDepth = (data[20] >> 4) + 8;  // bit_depth_minus8
    const static ALookup<std::pair<uint8_t, uint8_t>, int32_t> profiles{
            {{33, 10}, APVProfile422_10},
            {{44, 12}, APVProfile422_10HDR10Plus},
    };
    int32_t profile;
    if (profiles.map(std::make_pair(profileData, bitDepth), &profile)) {
        // bump to HDR profile
        if (isHdr10or10Plus(format) && profile == APVProfile422_10) {
            if (format->contains("hdr-static-info")) {
                profile = APVProfile422_10HDR10;
            }
        }
        format->setInt32("profile", profile);
    }
    int level_num = (levelData / 30) * 2;
    if (levelData % 30 == 0) {
        level_num -= 1;
    }
    int32_t level = ((0x100 << (level_num - 1)) | (1 << band));
    format->setInt32("level", level);
}

static std::vector<std::pair<const char *, uint32_t>> stringMappings {
    {
@@ -1456,6 +1489,7 @@ status_t convertMetaDataToMessage(
        buffer->meta()->setInt32("csd", true);
        buffer->meta()->setInt64("timeUs", 0);
        msg->setBuffer("csd-0", buffer);
        parseAPVProfileLevelFromCsd(buffer, msg);
    } else if (meta->findData(kKeyESDS, &type, &data, &size)) {
        ESDS esds((const char *)data, size);
        if (esds.InitCheck() != (status_t)OK) {
+14 −3
Original line number Diff line number Diff line
@@ -3199,8 +3199,10 @@ audio_io_handle_t AudioPolicyManager::getInputForDevice(const sp<DeviceDescripto
        return input;
    }

    // Reuse an already opened input if a client with the same session ID already exists
    // on that input
    // Reuse an already opened input if:
    //  - a client with the same session ID already exists on that input
    //  - OR the requested device is a remote submix device with the same adrress
    //    as the one connected to that input
    for (size_t i = 0; i < mInputs.size(); i++) {
        sp <AudioInputDescriptor> desc = mInputs.valueAt(i);
        if (desc->mProfile != profile) {
@@ -3212,6 +3214,11 @@ audio_io_handle_t AudioPolicyManager::getInputForDevice(const sp<DeviceDescripto
                return desc->mIoHandle;
            }
        }
        if (audio_is_remote_submix_device(device->type())
                && (device->address() != "0")
                && device->equals(desc->getDevice())) {
            return desc->mIoHandle;
        }
    }

    bool isPreemptor = false;
@@ -7547,7 +7554,8 @@ void AudioPolicyManager::checkOutputForAttributes(const audio_attributes_t &attr
        }

        for (const sp<TrackClientDescriptor>& client : desc->getClientIterable()) {
            if (mEngine->getProductStrategyForAttributes(client->attributes()) != psId) {
            if (mEngine->getProductStrategyForAttributes(client->attributes()) != psId
                    || client->isInvalid()) {
                continue;
            }
            if (!desc->supportsAllDevices(newDevices)) {
@@ -7584,6 +7592,9 @@ void AudioPolicyManager::checkOutputForAttributes(const audio_attributes_t &attr

            bool invalidate = false;
            for (auto client : desc->clientsList(false /*activeOnly*/)) {
                if (client->isInvalid()) {
                    continue;
                }
                if (desc->isDuplicated() || !desc->mProfile->isDirectOutput()) {
                    // a client on a non direct outputs has necessarily a linear PCM format
                    // so we can call selectOutput() safely
+30 −30
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public:
    static bool isInMemoryTempFileSupported();

    // HDR Gainmap subsampling
    static const size_t kGainmapScale = 4;
    static constexpr size_t kGainmapScale = 4;

protected:

@@ -145,9 +145,9 @@ private:
    size_t            mGridRows, mGridCols, mGainmapGridRows, mGainmapGridCols;
    bool              mUseGrid, mGainmapUseGrid; // Whether to use framework YUV frame tiling.

    static const int64_t kNoFrameDropMaxPtsGap = -1000000;
    static const int32_t kNoGridOpRate = 30;
    static const int32_t kGridOpRate = 120;
    static constexpr int64_t kNoFrameDropMaxPtsGap = -1000000;
    static constexpr int32_t kNoGridOpRate = 30;
    static constexpr int32_t kGridOpRate = 120;

    void onHeicOutputFrameAvailable(const CodecOutputBufferInfo& bufferInfo, bool isGainmap);
    void onHeicInputFrameAvailable(int32_t index, bool isGainmap);// Only called for YUV input mode.
@@ -243,17 +243,17 @@ private:
    static size_t calcAppSegmentMaxSize(const CameraMetadata& info);
    void updateCodecQualityLocked(int32_t quality);

    static const nsecs_t kWaitDuration = 10000000; // 10 ms
    static const int32_t kDefaultJpegQuality = 99;
    static const auto kJpegDataSpace = HAL_DATASPACE_V0_JFIF;
    static const android_dataspace kAppSegmentDataSpace =
    static constexpr nsecs_t kWaitDuration = 10000000; // 10 ms
    static constexpr int32_t kDefaultJpegQuality = 99;
    static constexpr auto kJpegDataSpace = HAL_DATASPACE_V0_JFIF;
    static constexpr android_dataspace kAppSegmentDataSpace =
            static_cast<android_dataspace>(HAL_DATASPACE_JPEG_APP_SEGMENTS);
    static const android_dataspace kHeifDataSpace =
    static constexpr android_dataspace kHeifDataSpace =
            static_cast<android_dataspace>(HAL_DATASPACE_HEIF);
    android_dataspace mInternalDataSpace = kHeifDataSpace;
    // Use the limit of pipeline depth in the API sepc as maximum number of acquired
    // app segment buffers.
    static const uint32_t kMaxAcquiredAppSegment = 8;
    static constexpr uint32_t kMaxAcquiredAppSegment = 8;

    int               mAppSegmentStreamId, mAppSegmentSurfaceId;
    sp<CpuConsumer>   mAppSegmentConsumer;
@@ -268,7 +268,7 @@ private:
    bool              mYuvBufferAcquired; // Only applicable to HEVC codec
    std::queue<int64_t> mMainImageFrameNumbers;

    static const int32_t        kMaxOutputSurfaceProducerCount = 1;
    static constexpr int32_t    kMaxOutputSurfaceProducerCount = 1;
    sp<Surface>                 mOutputSurface;
    sp<StreamSurfaceListener>   mStreamSurfaceListener;
    int32_t                     mDequeuedOutputBufferCnt;
@@ -328,39 +328,39 @@ private:
    bool mHDRGainmapEnabled = false;

    // UltraHDR tonemap color and format aspects
    static const uhdr_img_fmt_t kUltraHdrInputFmt = UHDR_IMG_FMT_24bppYCbCrP010;
    static const uhdr_color_gamut kUltraHdrInputGamut = UHDR_CG_BT_2100;
    static const uhdr_color_transfer kUltraHdrInputTransfer = UHDR_CT_HLG;
    static const uhdr_color_range kUltraHdrInputRange = UHDR_CR_FULL_RANGE;
    static constexpr uhdr_img_fmt_t kUltraHdrInputFmt = UHDR_IMG_FMT_24bppYCbCrP010;
    static constexpr uhdr_color_gamut kUltraHdrInputGamut = UHDR_CG_BT_2100;
    static constexpr uhdr_color_transfer kUltraHdrInputTransfer = UHDR_CT_HLG;
    static constexpr uhdr_color_range kUltraHdrInputRange = UHDR_CR_FULL_RANGE;

    static const uhdr_img_fmt_t kUltraHdrOutputFmt = UHDR_IMG_FMT_12bppYCbCr420;
    static const uhdr_color_gamut kUltraHdrOutputGamut = UHDR_CG_DISPLAY_P3;
    static const uhdr_color_transfer kUltraHdrOutputTransfer = UHDR_CT_SRGB;
    static const uhdr_color_range kUltraHdrOutputRange = UHDR_CR_FULL_RANGE;
    static constexpr uhdr_img_fmt_t kUltraHdrOutputFmt = UHDR_IMG_FMT_12bppYCbCr420;
    static constexpr uhdr_color_gamut kUltraHdrOutputGamut = UHDR_CG_DISPLAY_P3;
    static constexpr uhdr_color_transfer kUltraHdrOutputTransfer = UHDR_CT_SRGB;
    static constexpr uhdr_color_range kUltraHdrOutputRange = UHDR_CR_FULL_RANGE;

    static const auto kUltraHDRDataSpace =
    static constexpr auto kUltraHDRDataSpace =
        aidl::android::hardware::graphics::common::Dataspace::HEIF_ULTRAHDR;

    // MediaMuxer/Codec color and format aspects for base image and gainmap metadata
    static const int32_t kCodecColorFormat = COLOR_FormatYUV420Flexible;
    static const ColorAspects::Primaries kCodecColorPrimaries =
    static constexpr int32_t kCodecColorFormat = COLOR_FormatYUV420Flexible;
    static constexpr ColorAspects::Primaries kCodecColorPrimaries =
        ColorAspects::Primaries::PrimariesEG432;
    static const ColorAspects::MatrixCoeffs kCodecColorMatrix =
    static constexpr ColorAspects::MatrixCoeffs kCodecColorMatrix =
        ColorAspects::MatrixCoeffs::MatrixUnspecified;
    static const ColorAspects::Transfer kCodecColorTransfer =
    static constexpr ColorAspects::Transfer kCodecColorTransfer =
        ColorAspects::Transfer::TransferSRGB;
    static const ColorAspects::Range kCodecColorRange =
    static constexpr ColorAspects::Range kCodecColorRange =
        ColorAspects::Range::RangeFull;

    // MediaMuxer/Codec color and format aspects for gainmap as per ISO 23008-12:2024
    static const int32_t kCodecGainmapColorFormat = COLOR_FormatYUV420Flexible;
    static const ColorAspects::Primaries kCodecGainmapColorPrimaries =
    static constexpr int32_t kCodecGainmapColorFormat = COLOR_FormatYUV420Flexible;
    static constexpr ColorAspects::Primaries kCodecGainmapColorPrimaries =
        ColorAspects::Primaries::PrimariesUnspecified;
    static const ColorAspects::MatrixCoeffs kCodecGainmapColorMatrix =
    static constexpr ColorAspects::MatrixCoeffs kCodecGainmapColorMatrix =
        ColorAspects::MatrixCoeffs::MatrixUnspecified;
    static const ColorAspects::Transfer kCodecGainmapColorTransfer =
    static constexpr ColorAspects::Transfer kCodecGainmapColorTransfer =
        ColorAspects::Transfer::TransferUnspecified;
    static const ColorAspects::Range kCodecGainmapColorRange =
    static constexpr ColorAspects::Range kCodecGainmapColorRange =
        ColorAspects::Range::RangeFull;


+30 −3
Original line number Diff line number Diff line
@@ -499,7 +499,20 @@ AidlProviderInfo::AidlDeviceInfo3::AidlDeviceInfo3(
    int resV = validate_camera_metadata_structure(buffer, &expectedSize);
    if (resV == OK || resV == CAMERA_METADATA_VALIDATION_SHIFTED) {
        set_camera_metadata_vendor_id(buffer, mProviderTagid);
        if (flags::metadata_resize_fix()) {
            //b/379388099: Create a CameraCharacteristics object slightly larger
            //to accommodate framework addition/modification. This is to
            //optimize memory because the CameraMetadata::update() doubles the
            //memory footprint, which could be significant if original
            //CameraCharacteristics is already large.
            mCameraCharacteristics = {
                    get_camera_metadata_entry_count(buffer) + CHARACTERISTICS_EXTRA_ENTRIES,
                    get_camera_metadata_data_count(buffer) + CHARACTERISTICS_EXTRA_DATA_SIZE
            };
            mCameraCharacteristics.append(buffer);
        } else {
            mCameraCharacteristics = buffer;
        }
    } else {
        ALOGE("%s: Malformed camera metadata received from HAL", __FUNCTION__);
        return;
@@ -703,7 +716,20 @@ AidlProviderInfo::AidlDeviceInfo3::AidlDeviceInfo3(
            int res = validate_camera_metadata_structure(pBuffer, &expectedSize);
            if (res == OK || res == CAMERA_METADATA_VALIDATION_SHIFTED) {
                set_camera_metadata_vendor_id(pBuffer, mProviderTagid);
                if (flags::metadata_resize_fix()) {
                    //b/379388099: Create a CameraCharacteristics object slightly larger
                    //to accommodate framework addition/modification. This is to
                    //optimize memory because the CameraMetadata::update() doubles the
                    //memory footprint, which could be significant if original
                    //CameraCharacteristics is already large.
                    mPhysicalCameraCharacteristics[id] = {
                          get_camera_metadata_entry_count(pBuffer) + CHARACTERISTICS_EXTRA_ENTRIES,
                          get_camera_metadata_data_count(pBuffer) + CHARACTERISTICS_EXTRA_DATA_SIZE
                    };
                    mPhysicalCameraCharacteristics[id].append(pBuffer);
                } else {
                    mPhysicalCameraCharacteristics[id] = pBuffer;
                }
            } else {
                ALOGE("%s: Malformed camera metadata received from HAL", __FUNCTION__);
                return;
@@ -743,7 +769,8 @@ AidlProviderInfo::AidlDeviceInfo3::AidlDeviceInfo3(

    std::filesystem::path sharedSessionConfigFilePath =
            std::string(SHARED_SESSION_FILE_PATH) + std::string(SHARED_SESSION_FILE_NAME);
    if (flags::camera_multi_client() && std::filesystem::exists(sharedSessionConfigFilePath)) {
    if (flags::camera_multi_client() && std::filesystem::exists(sharedSessionConfigFilePath)
            && mSystemCameraKind == SystemCameraKind::SYSTEM_ONLY_CAMERA) {
        addSharedSessionConfigurationTags(id);
    }

Loading