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

Commit a2e7f86e authored by Vignesh Venkat's avatar Vignesh Venkat Committed by Android (Google) Code Review
Browse files

Merge "heif: Clamp display height and display width" into main

parents aad4091d 1b1dcd42
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@
#include <private/media/VideoFrame.h>
#include <private/media/VideoFrame.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
#include <utils/RefBase.h>
#include <algorithm>
#include <vector>
#include <vector>


HeifDecoder* createHeifDecoder() {
HeifDecoder* createHeifDecoder() {
@@ -42,7 +43,10 @@ namespace android {


void initFrameInfo(HeifFrameInfo *info, const VideoFrame *videoFrame) {
void initFrameInfo(HeifFrameInfo *info, const VideoFrame *videoFrame) {
    info->mWidth = videoFrame->mDisplayWidth;
    info->mWidth = videoFrame->mDisplayWidth;
    info->mHeight = videoFrame->mDisplayHeight;
    // Number of scanlines is mDisplayHeight. Clamp it to mHeight to guard
    // against malformed streams claiming that mDisplayHeight is greater than
    // mHeight.
    info->mHeight = std::min(videoFrame->mDisplayHeight, videoFrame->mHeight);
    info->mRotationAngle = videoFrame->mRotationAngle;
    info->mRotationAngle = videoFrame->mRotationAngle;
    info->mBytesPerPixel = videoFrame->mBytesPerPixel;
    info->mBytesPerPixel = videoFrame->mBytesPerPixel;
    info->mDurationUs = videoFrame->mDurationUs;
    info->mDurationUs = videoFrame->mDurationUs;
@@ -746,7 +750,9 @@ bool HeifDecoderImpl::getScanlineInner(uint8_t* dst) {
                   (videoFrame->mRowBytes * (mCurScanline + videoFrame->mDisplayTop)) +
                   (videoFrame->mRowBytes * (mCurScanline + videoFrame->mDisplayTop)) +
                   (videoFrame->mBytesPerPixel * videoFrame->mDisplayLeft);
                   (videoFrame->mBytesPerPixel * videoFrame->mDisplayLeft);
    mCurScanline++;
    mCurScanline++;
    memcpy(dst, src, videoFrame->mBytesPerPixel * videoFrame->mDisplayWidth);
    // Do not try to copy more than |videoFrame->mWidth| pixels.
    uint32_t width = std::min(videoFrame->mDisplayWidth, videoFrame->mWidth);
    memcpy(dst, src, videoFrame->mBytesPerPixel * width);
    return true;
    return true;
}
}


+0 −7
Original line number Original line Diff line number Diff line
@@ -102,13 +102,6 @@ sp<IMemory> allocVideoFrame(const sp<MetaData>& trackMeta,
            displayTop = 0;
            displayTop = 0;
        }
        }
    }
    }
    if (displayWidth > width) {
        displayWidth = width;
    }
    if (displayHeight > height) {
        displayHeight = height;
    }



    if (allocRotated) {
    if (allocRotated) {
        if (rotationAngle == 90 || rotationAngle == 270) {
        if (rotationAngle == 90 || rotationAngle == 270) {