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

Commit f939ae92 authored by guochuang's avatar guochuang
Browse files

NuPlayer: improve get video info from outputFormat



Bug: 388723642
Test: MediaPlayerTest
Change-Id: Ie61891573e276389c791e0eccce5ab74de471a5b
Signed-off-by: default avatarguochuang <guochuang@xiaomi.corp-partner.google.com>
parent a9c5abeb
Loading
Loading
Loading
Loading
+23 −9
Original line number Original line Diff line number Diff line
@@ -2077,17 +2077,27 @@ void NuPlayer::updateVideoSize(
        return;
        return;
    }
    }


    int32_t displayWidth, displayHeight;
    int32_t displayWidth = 0, displayHeight = 0;
    if (outputFormat != NULL) {
    if (outputFormat != NULL) {
        int32_t width, height, cropLeft, cropTop, cropRight, cropBottom;
        int32_t width, height;
        if (outputFormat->findInt32("width", &width)
        if (!outputFormat->findInt32("width", &width)
                && outputFormat->findInt32("height", &height)
                || !outputFormat->findInt32("height", &height)) {
                && outputFormat->findRect(
            ALOGW("Video output format missing dimension: %s",
                    outputFormat->debugString().c_str());
            notifyListener(MEDIA_SET_VIDEO_SIZE, 0, 0);
            return;
        }

        int32_t cropLeft, cropTop, cropRight, cropBottom;
        if (outputFormat->findRect(
                "crop",
                "crop",
                &cropLeft, &cropTop, &cropRight, &cropBottom)) {
                &cropLeft, &cropTop, &cropRight, &cropBottom)) {

            displayWidth = cropRight - cropLeft + 1;
            displayWidth = cropRight - cropLeft + 1;
            displayHeight = cropBottom - cropTop + 1;
            displayHeight = cropBottom - cropTop + 1;
        } else {
            displayWidth = width;
            displayHeight = height;
        }


        ALOGV("Video output format changed to %d x %d "
        ALOGV("Video output format changed to %d x %d "
                "(crop: %d x %d @ (%d, %d))",
                "(crop: %d x %d @ (%d, %d))",
@@ -2095,7 +2105,6 @@ void NuPlayer::updateVideoSize(
                displayWidth,
                displayWidth,
                displayHeight,
                displayHeight,
                cropLeft, cropTop);
                cropLeft, cropTop);
        }
    } else {
    } else {
        if (!inputFormat->findInt32("width", &displayWidth)
        if (!inputFormat->findInt32("width", &displayWidth)
            || !inputFormat->findInt32("height", &displayHeight)) {
            || !inputFormat->findInt32("height", &displayHeight)) {
@@ -2143,6 +2152,11 @@ void NuPlayer::updateVideoSize(
        displayHeight = tmp;
        displayHeight = tmp;
    }
    }


    if (displayWidth <= 0 || displayHeight <= 0) {
        ALOGE("video size is corrupted or bad, reset it to 0");
        displayWidth = displayHeight = 0;
    }

    notifyListener(
    notifyListener(
            MEDIA_SET_VIDEO_SIZE,
            MEDIA_SET_VIDEO_SIZE,
            displayWidth,
            displayWidth,