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

Commit 35cb2de6 authored by Dharmaray Kundargi's avatar Dharmaray Kundargi
Browse files

Change preview player code also.

Adapt to 32 bit aligned decoder buffers

Change-Id: I631f7e60b8e424af496f45d0e5e292bf9e8a9dde
parent bf327086
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -141,7 +141,9 @@ void PreviewLocalRenderer::init(
PreviewPlayer::PreviewPlayer()
    : AwesomePlayer(),
      mFrameRGBBuffer(NULL),
      mFrameYUVBuffer(NULL) {
      mFrameYUVBuffer(NULL),
      mReportedWidth(0),
      mReportedHeight(0) {

    mVideoRenderer = NULL;
    mLastVideoBuffer = NULL;
@@ -308,6 +310,9 @@ status_t PreviewPlayer::setDataSource_l_jpg() {

    mVideoSource = DummyVideoSource::Create(mVideoWidth, mVideoHeight,
                                            mDurationUs, mUri);
    mReportedWidth = mVideoWidth;
    mReportedHeight = mVideoHeight;

    setVideoSource(mVideoSource);
    status_t err1 = mVideoSource->start();
    if (err1 != OK) {
@@ -648,6 +653,9 @@ status_t PreviewPlayer::initVideoDecoder(uint32_t flags) {
        CHECK(mVideoTrack->getFormat()->findInt32(kKeyWidth, &mVideoWidth));
        CHECK(mVideoTrack->getFormat()->findInt32(kKeyHeight, &mVideoHeight));

        mReportedWidth = mVideoWidth;
        mReportedHeight = mVideoHeight;

        status_t err = mVideoSource->start();

        if (err != OK) {
@@ -720,7 +728,10 @@ void PreviewPlayer::onVideoEvent() {
                if (err == INFO_FORMAT_CHANGED) {
                    LOGV("LV PLAYER VideoSource signalled format change");
                    notifyVideoSize_l();
                    sp<MetaData> meta = mVideoSource->getFormat();

                    CHECK(meta->findInt32(kKeyWidth, &mReportedWidth));
                    CHECK(meta->findInt32(kKeyHeight, &mReportedHeight));
                    if (mVideoRenderer != NULL) {
                        mVideoRendererIsPreview = false;
                        initRenderer_l();
@@ -1397,7 +1408,7 @@ M4OSA_ERR PreviewPlayer::doMediaRendering() {

    /* In plane*/
    prepareYUV420ImagePlane(planeIn, mVideoWidth,
      mVideoHeight, (M4VIFI_UInt8 *)inBuffer);
      mVideoHeight, (M4VIFI_UInt8 *)inBuffer, mReportedWidth, mReportedHeight);

    // Set the output YUV420 plane to be compatible with YV12 format
    // W & H even
@@ -1588,7 +1599,7 @@ M4OSA_ERR PreviewPlayer::doVideoPostProcessing() {
    postProcessParams.overlayFrameRGBBuffer = mFrameRGBBuffer;
    postProcessParams.overlayFrameYUVBuffer = mFrameYUVBuffer;
    mVideoRenderer->getBuffer(&(postProcessParams.pOutBuffer), &(postProcessParams.outBufferStride));
    err = applyEffectsAndRenderingMode(&postProcessParams);
    err = applyEffectsAndRenderingMode(&postProcessParams, mReportedWidth, mReportedHeight);

    return err;
}
@@ -1615,6 +1626,10 @@ status_t PreviewPlayer::readFirstVideoFrame() {
                if (err == INFO_FORMAT_CHANGED) {
                    LOGV("LV PLAYER VideoSource signalled format change");
                    notifyVideoSize_l();
                    sp<MetaData> meta = mVideoSource->getFormat();

                    CHECK(meta->findInt32(kKeyWidth, &mReportedWidth));
                    CHECK(meta->findInt32(kKeyHeight, &mReportedHeight));

                    if (mVideoRenderer != NULL) {
                        mVideoRendererIsPreview = false;
+4 −1
Original line number Diff line number Diff line
@@ -185,6 +185,9 @@ private:
    uint32_t mOutputVideoWidth;
    uint32_t mOutputVideoHeight;

    int32_t mReportedWidth;  //docoder reported width
    int32_t mReportedHeight; //docoder reported height

    uint32_t mStoryboardStartTimeMsec;

    bool mIsVideoSourceJpg;
+2 −2
Original line number Diff line number Diff line
@@ -1174,7 +1174,7 @@ M4OSA_ERR VideoEditorPreviewController::applyVideoEffect(

    mTarget->getBufferYV12(&(postProcessParams.pOutBuffer), &(postProcessParams.outBufferStride));

    err = applyEffectsAndRenderingMode(&postProcessParams);
    err = applyEffectsAndRenderingMode(&postProcessParams, mOutputVideoWidth, mOutputVideoHeight);
    return err;
}

@@ -1273,7 +1273,7 @@ M4OSA_ERR VideoEditorPreviewController::doImageRenderingMode(

    // In plane
    prepareYUV420ImagePlane(planeIn, videoWidth,
      videoHeight, (M4VIFI_UInt8 *)inBuffer);
      videoHeight, (M4VIFI_UInt8 *)inBuffer, videoWidth, videoHeight);

    outputBufferWidth = mOutputVideoWidth;
    outputBufferHeight = mOutputVideoHeight;
+18 −17
Original line number Diff line number Diff line
@@ -3065,7 +3065,8 @@ M4OSA_ERR LvGetImageThumbNail(const char *fileName, M4OSA_UInt32 height, M4OSA_U

}
M4OSA_Void prepareYUV420ImagePlane(M4VIFI_ImagePlane *plane,
    M4OSA_UInt32 width, M4OSA_UInt32 height, M4VIFI_UInt8 *buffer) {
    M4OSA_UInt32 width, M4OSA_UInt32 height, M4VIFI_UInt8 *buffer,
    M4OSA_UInt32 reportedWidth, M4OSA_UInt32 reportedHeight) {

    //Y plane
    plane[0].u_width = width;
@@ -3079,15 +3080,14 @@ M4OSA_Void prepareYUV420ImagePlane(M4VIFI_ImagePlane *plane,
    plane[1].u_height = height/2;
    plane[1].u_stride = plane[1].u_width;
    plane[1].u_topleft = 0;
    plane[1].pac_data = buffer+(width*height);
    plane[1].pac_data = buffer+(reportedWidth*reportedHeight);

    // V Plane
    plane[2].u_width = width/2;
    plane[2].u_height = height/2;
    plane[2].u_stride = plane[2].u_width;
    plane[2].u_topleft = 0;
    plane[2].pac_data = buffer+(width*height+(width/2)*(height/2));
    
    plane[2].pac_data = plane[1].pac_data + ((reportedWidth/2)*(reportedHeight/2));
}

M4OSA_Void prepareYV12ImagePlane(M4VIFI_ImagePlane *plane,
@@ -3405,7 +3405,8 @@ M4OSA_ERR applyCurtainEffect(M4VSS3GPP_VideoEffectType videoEffect,
    return err;
}

M4OSA_ERR applyEffectsAndRenderingMode(vePostProcessParams    *params) {
M4OSA_ERR applyEffectsAndRenderingMode(vePostProcessParams *params,
    M4OSA_UInt32 reportedWidth, M4OSA_UInt32 reportedHeight) {

    M4OSA_ERR err = M4NO_ERROR;
    M4VIFI_ImagePlane planeIn[3], planeOut[3];
@@ -3441,12 +3442,12 @@ M4OSA_ERR applyEffectsAndRenderingMode(vePostProcessParams *params) {
    }

    // Initialize the In plane
    prepareYUV420ImagePlane(planeIn, params->videoWidth,
      params->videoHeight, params->vidBuffer);
    prepareYUV420ImagePlane(planeIn, params->videoWidth, params->videoHeight,
       params->vidBuffer, reportedWidth, reportedHeight);

    // Initialize the Out plane
    prepareYUV420ImagePlane(planeOut, params->videoWidth,
      params->videoHeight, (M4VIFI_UInt8 *)tempOutputBuffer);
    prepareYUV420ImagePlane(planeOut, params->videoWidth, params->videoHeight,
       (M4VIFI_UInt8 *)tempOutputBuffer, params->videoWidth, params->videoHeight);

    // The planeIn contains the YUV420 input data to postprocessing node
    // and planeOut will contain the YUV420 data with effect
+5 −2
Original line number Diff line number Diff line
@@ -107,7 +107,8 @@ M4VIFI_UInt8 M4VIFI_ResizeBilinearYUV420toYUV420(void *pUserData,
                                                                M4VIFI_ImagePlane *pPlaneOut);

M4OSA_Void prepareYUV420ImagePlane(M4VIFI_ImagePlane *plane,
    M4OSA_UInt32 width, M4OSA_UInt32 height, M4VIFI_UInt8 *buffer);
    M4OSA_UInt32 width, M4OSA_UInt32 height, M4VIFI_UInt8 *buffer,
    M4OSA_UInt32 reportedWidth, M4OSA_UInt32 reportedHeight);

M4OSA_Void prepareYV12ImagePlane(M4VIFI_ImagePlane *plane,
    M4OSA_UInt32 width, M4OSA_UInt32 height, M4OSA_UInt32 stride, M4VIFI_UInt8 *buffer);
@@ -141,5 +142,7 @@ M4OSA_ERR applyCurtainEffect(M4VSS3GPP_VideoEffectType videoEffect,
    M4VIFI_ImagePlane *planeIn, M4VIFI_ImagePlane *planeOut,
    M4VIFI_UInt8 *buffer1, M4VIFI_UInt8 *buffer2, M4VFL_CurtainParam* curtainParams);

M4OSA_ERR applyEffectsAndRenderingMode(vePostProcessParams*        params);
M4OSA_ERR applyEffectsAndRenderingMode(vePostProcessParams *params,
    M4OSA_UInt32 reportedWidth, M4OSA_UInt32 reportedHeight);

#endif // ANDROID_VE_TOOLS_H
Loading