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

Commit 625300bf authored by Wei Jia's avatar Wei Jia Committed by Android (Google) Code Review
Browse files

Merge "NuPlayer: use width and height from tkhd for display and thumbnail."

parents 61a4fac2 df6c6af2
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1756,6 +1756,20 @@ void NuPlayer::updateVideoSize(
        displayWidth = (displayWidth * sarWidth) / sarHeight;

        ALOGV("display dimensions %d x %d", displayWidth, displayHeight);
    } else {
        int32_t width, height;
        if (inputFormat->findInt32("display-width", &width)
                && inputFormat->findInt32("display-height", &height)
                && width > 0 && height > 0
                && displayWidth > 0 && displayHeight > 0) {
            if (displayHeight * (int64_t)width / height > (int64_t)displayWidth) {
                displayHeight = (int32_t)(displayWidth * (int64_t)height / width);
            } else {
                displayWidth = (int32_t)(displayHeight * (int64_t)width / height);
            }
            ALOGV("Video display width and height are overridden to %d x %d",
                 displayWidth, displayHeight);
        }
    }

    int32_t rotationDegrees;
+16 −0
Original line number Diff line number Diff line
@@ -418,6 +418,22 @@ static VideoFrame *extractVideoFrame(
            && trackMeta->findInt32(kKeySARHeight, &sarHeight)
            && sarHeight != 0) {
        frame->mDisplayWidth = (frame->mDisplayWidth * sarWidth) / sarHeight;
    } else {
        int32_t width, height;
        if (trackMeta->findInt32(kKeyDisplayWidth, &width)
                && trackMeta->findInt32(kKeyDisplayHeight, &height)
                && frame->mDisplayWidth > 0 && frame->mDisplayHeight > 0
                && width > 0 && height > 0) {
            if (frame->mDisplayHeight * (int64_t)width / height > (int64_t)frame->mDisplayWidth) {
                frame->mDisplayHeight =
                        (int32_t)(height * (int64_t)frame->mDisplayWidth / width);
            } else {
                frame->mDisplayWidth =
                        (int32_t)(frame->mDisplayHeight * (int64_t)width / height);
            }
            ALOGV("thumbNail width and height are overridden to %d x %d",
                    frame->mDisplayWidth, frame->mDisplayHeight);
        }
    }

    int32_t srcFormat;
+14 −0
Original line number Diff line number Diff line
@@ -652,6 +652,13 @@ status_t convertMetaDataToMessage(
        msg->setInt32("width", width);
        msg->setInt32("height", height);

        int32_t displayWidth, displayHeight;
        if (meta->findInt32(kKeyDisplayWidth, &displayWidth)
                && meta->findInt32(kKeyDisplayHeight, &displayHeight)) {
            msg->setInt32("display-width", displayWidth);
            msg->setInt32("display-height", displayHeight);
        }

        int32_t sarWidth, sarHeight;
        if (meta->findInt32(kKeySARWidth, &sarWidth)
                && meta->findInt32(kKeySARHeight, &sarHeight)) {
@@ -1300,6 +1307,13 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
            meta->setInt32(kKeySARHeight, sarHeight);
        }

        int32_t displayWidth, displayHeight;
        if (msg->findInt32("display-width", &displayWidth)
                && msg->findInt32("display-height", &displayHeight)) {
            meta->setInt32(kKeyDisplayWidth, displayWidth);
            meta->setInt32(kKeyDisplayHeight, displayHeight);
        }

        int32_t colorFormat;
        if (msg->findInt32("color-format", &colorFormat)) {
            meta->setInt32(kKeyColorFormat, colorFormat);