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

Commit 38a8ef7c authored by Ray Essick's avatar Ray Essick
Browse files

Fix several mainline media modules using system libraries

Several places in the media module (around extractors) were using
system-side libstagefright_foundation functions to access data passed
across the module boundaries; restructure libstagefright_foundation
so it works appropriately.

Bug: 193017338
Test: atest android.media.cts.MediaExtractorTest S-on-S, S-on-Q
Test: atest ColorUtilsTest
Test: atest ExtractorUnitTest
Change-Id: I7f8ab13905e31754b1a5ec2de97bc7ec242827ba
parent 0ff42938
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ cc_defaults {

    static_libs: [
        "liblog",
        "libstagefright_foundation_colorutils_ndk",
        "libstagefright_foundation",
        "libmediandk_format",
        "libmedia_ndkformatpriv",
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ cc_library {
    ],

    static_libs: [
        "libstagefright_foundation_colorutils_ndk",   // for mainline-safe ColorUtils
        "libstagefright_foundation",
        "libstagefright_metadatautils",
        "libwebm",
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ cc_test {
        "libstagefright_esds",
        "libstagefright_mpeg2support",
        "libstagefright_mpeg2extractor",
        "libstagefright_foundation_colorutils_ndk",
        "libstagefright_foundation",
        "libstagefright_metadatautils",

+64 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ cc_defaults {
        "AudioPresentationInfo.cpp",
        "ByteUtils.cpp",
        "ColorUtils.cpp",
        "ColorUtils_fill.cpp",
        "FoundationUtils.cpp",
        "MediaBuffer.cpp",
        "MediaBufferBase.cpp",
@@ -148,3 +149,66 @@ cc_library_static {
        "-DNO_IMEMORY",
    ],
}

// this gets linked into extractors in media mainline module
// so must be ndk api 29 so that it runs on >=Q
cc_library_static {
    name: "libstagefright_foundation_colorutils_ndk",
    host_supported: true,
    vendor_available: true,

    target: {
        darwin: {
            enabled: false,
        },
    },

    shared_libs: [
        "liblog",
        "libutils",             // for sp<>
        // actually invokes this, but called from folks who already load it
        // "libmediandk",
    ],

    header_libs: [
        // this is only needed for the vendor variant that removes libbinder, but vendor
        // target below does not allow adding header_libs.
        "libbinder_headers",
        "libstagefright_foundation_headers",
        "media_ndk_headers",
        "media_plugin_headers",
    ],

    local_include_dirs: [
        "include/media/stagefright/foundation",
    ],

    cflags: [
        "-Werror",
        "-Wall",
    ],

    srcs: [
        "ColorUtils_ndk.cpp",
        "ColorUtils_fill.cpp",
    ],

    clang: true,

    sanitize: {
        misc_undefined: [
            "unsigned-integer-overflow",
            "signed-integer-overflow",
        ],
        cfi: true,
    },

    min_sdk_version: "29",
    apex_available: [
        "//apex_available:platform",
        "com.android.media",
        "com.android.media.swcodec",
    ],

}
+1 −49
Original line number Diff line number Diff line
@@ -722,13 +722,6 @@ void ColorUtils::setColorAspectsIntoFormat(
            transfer, asString((ColorTransfer)transfer));
}


// static
void ColorUtils::setHDRStaticInfoIntoAMediaFormat(
        const HDRStaticInfo &info, AMediaFormat *format) {
    setHDRStaticInfoIntoFormat(info, format->mFormat);
}

// static
void ColorUtils::setHDRStaticInfoIntoFormat(
        const HDRStaticInfo &info, sp<AMessage> &format) {
@@ -736,48 +729,7 @@ void ColorUtils::setHDRStaticInfoIntoFormat(

    // Convert the data in infoBuffer to little endian format as defined by CTA-861-3
    uint8_t *data = infoBuffer->data();
    // Static_Metadata_Descriptor_ID
    data[0] = info.mID;

    // display primary 0
    data[1] = LO_UINT16(info.sType1.mR.x);
    data[2] = HI_UINT16(info.sType1.mR.x);
    data[3] = LO_UINT16(info.sType1.mR.y);
    data[4] = HI_UINT16(info.sType1.mR.y);

    // display primary 1
    data[5] = LO_UINT16(info.sType1.mG.x);
    data[6] = HI_UINT16(info.sType1.mG.x);
    data[7] = LO_UINT16(info.sType1.mG.y);
    data[8] = HI_UINT16(info.sType1.mG.y);

    // display primary 2
    data[9] = LO_UINT16(info.sType1.mB.x);
    data[10] = HI_UINT16(info.sType1.mB.x);
    data[11] = LO_UINT16(info.sType1.mB.y);
    data[12] = HI_UINT16(info.sType1.mB.y);

    // white point
    data[13] = LO_UINT16(info.sType1.mW.x);
    data[14] = HI_UINT16(info.sType1.mW.x);
    data[15] = LO_UINT16(info.sType1.mW.y);
    data[16] = HI_UINT16(info.sType1.mW.y);

    // MaxDisplayLuminance
    data[17] = LO_UINT16(info.sType1.mMaxDisplayLuminance);
    data[18] = HI_UINT16(info.sType1.mMaxDisplayLuminance);

    // MinDisplayLuminance
    data[19] = LO_UINT16(info.sType1.mMinDisplayLuminance);
    data[20] = HI_UINT16(info.sType1.mMinDisplayLuminance);

    // MaxContentLightLevel
    data[21] = LO_UINT16(info.sType1.mMaxContentLightLevel);
    data[22] = HI_UINT16(info.sType1.mMaxContentLightLevel);

    // MaxFrameAverageLightLevel
    data[23] = LO_UINT16(info.sType1.mMaxFrameAverageLightLevel);
    data[24] = HI_UINT16(info.sType1.mMaxFrameAverageLightLevel);
    fillHdrStaticInfoBuffer(info, data);

    format->setBuffer("hdr-static-info", infoBuffer);
}
Loading