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

Commit d22b19e6 authored by Praveen Chavan's avatar Praveen Chavan Committed by Linux Build Service Account
Browse files

stagefright: Flip encode dimensions for pre-rotated camera buffers

Camera indicates pre-rotation via "video-rotation" parameter.
If the rotation angle is 90 or 270, flip height and width
set on encoder to interpret the image correctly.

CRs-Fixed: 672804
Change-Id: Ie52e77c886410304d8a65bc34990623e881ca408
parent 543b15e9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -581,6 +581,7 @@ status_t CameraSource::initWithCameraAccess(
    mMeta->setInt32(kKeyFrameRate,   mVideoFrameRate);

    ExtendedUtils::HFR::setHFRIfEnabled(params, mMeta);
    ExtendedUtils::applyPreRotation(params, mMeta);

    return OK;
}
+27 −0
Original line number Diff line number Diff line
@@ -1096,6 +1096,30 @@ bool ExtendedUtils::checkIsThumbNailMode(const uint32_t flags, char* componentNa
    return isInThumbnailMode;
}

void ExtendedUtils::applyPreRotation(
        const CameraParameters& params, sp<MetaData> &meta) {

    // Camera pre-rotates video buffers. Width and Height of
    // of the image will be flipped if rotation is 90 or 270.
    // Encoder must be made aware of the flip in this case.
    const char *pRotation = params.get("video-rotation");
    int32_t preRotation = pRotation ? atoi(pRotation) : 0;
    bool flip = preRotation % 180;

    if (flip) {
        int32_t width = 0;
        int32_t height = 0;
        meta->findInt32(kKeyWidth, &width);
        meta->findInt32(kKeyHeight, &height);

        // width assigned to height is intentional
        meta->setInt32(kKeyWidth, height);
        meta->setInt32(kKeyStride, height);
        meta->setInt32(kKeyHeight, width);
        meta->setInt32(kKeySliceHeight, width);
    }
}

}
#else //ENABLE_AV_ENHANCEMENTS

@@ -1255,6 +1279,9 @@ bool ExtendedUtils::HEVCMuxer::getHEVCCodecConfigData(const sp<MetaData> &meta,
    return false;
}

void ExtendedUtils::applyPreRotation(
        const CameraParameters&, sp<MetaData>&) {}

}
#endif //ENABLE_AV_ENHANCEMENTS

+2 −0
Original line number Diff line number Diff line
@@ -196,6 +196,8 @@ struct ExtendedUtils {
    static bool isVideoMuxFormatSupported(const char *mime);

    static void printFileName(int fd);
    static void applyPreRotation(
            const CameraParameters& params, sp<MetaData> &meta);
};

}