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

Commit 227fd47a authored by Taehwan Kim's avatar Taehwan Kim Committed by Chong Zhang
Browse files

libstagefright: Do not use max/min luminance if it's 0



this changes is from following commits for ACodec.
=========================================================
Do not set SMPTE2086 if max/min luminance fields are 0,
these may indicate that max/min luminance is not present
in the bitstream. Let GPU composition use default if needed.

Bug: 153847809
Test: Play Netflix HDR content in GPU composition.
Change-Id: Ibce5319f7832095314fe07b0ce13600658ce4627
=========================================================

Change-Id: I41113317e31ee30ed0d093d1fd57662110f798b2
Signed-off-by: default avatarTaehwan Kim <t_h.kim@samsung.com>
parent b1fb801f
Loading
Loading
Loading
Loading
+41 −31
Original line number Diff line number Diff line
@@ -132,6 +132,10 @@ status_t setNativeWindowSizeFormatAndUsage(
}

void setNativeWindowHdrMetadata(ANativeWindow *nativeWindow, HDRStaticInfo *info) {
    // If mastering max and min luminance fields are 0, do not use them.
    // It indicates the value may not be present in the stream.
    if ((float)info->sType1.mMaxDisplayLuminance > 0.0f &&
        (info->sType1.mMinDisplayLuminance * 0.0001f) > 0.0f) {
        struct android_smpte2086_metadata smpte2086_meta = {
                .displayPrimaryRed = {
                        info->sType1.mR.x * 0.00002f,
@@ -155,15 +159,21 @@ void setNativeWindowHdrMetadata(ANativeWindow *nativeWindow, HDRStaticInfo *info

        int err = native_window_set_buffers_smpte2086_metadata(nativeWindow, &smpte2086_meta);
        ALOGW_IF(err != 0, "failed to set smpte2086 metadata on surface (%d)", err);
    }

    // If the content light level fields are 0, do not use them, it
    // indicates the value may not be present in the stream.
    if ((float)info->sType1.mMaxContentLightLevel > 0.0f &&
        (float)info->sType1.mMaxFrameAverageLightLevel > 0.0f) {
        struct android_cta861_3_metadata cta861_meta = {
                .maxContentLightLevel = (float) info->sType1.mMaxContentLightLevel,
                .maxFrameAverageLightLevel = (float) info->sType1.mMaxFrameAverageLightLevel
        };

    err = native_window_set_buffers_cta861_3_metadata(nativeWindow, &cta861_meta);
        int err = native_window_set_buffers_cta861_3_metadata(nativeWindow, &cta861_meta);
        ALOGW_IF(err != 0, "failed to set cta861_3 metadata on surface (%d)", err);
    }
}

status_t pushBlankBuffersToNativeWindow(ANativeWindow *nativeWindow /* nonnull */) {
    status_t err = NO_ERROR;