Change preview player code also.
Adapt to 32 bit aligned decoder buffers
Change-Id: I631f7e60b8e424af496f45d0e5e292bf9e8a9dde
diff --git a/libvideoeditor/lvpp/PreviewPlayer.cpp b/libvideoeditor/lvpp/PreviewPlayer.cpp
index 2f46e4c..4738fdd 100755
--- a/libvideoeditor/lvpp/PreviewPlayer.cpp
+++ b/libvideoeditor/lvpp/PreviewPlayer.cpp
@@ -141,7 +141,9 @@
PreviewPlayer::PreviewPlayer()
: AwesomePlayer(),
mFrameRGBBuffer(NULL),
- mFrameYUVBuffer(NULL) {
+ mFrameYUVBuffer(NULL),
+ mReportedWidth(0),
+ mReportedHeight(0) {
mVideoRenderer = NULL;
mLastVideoBuffer = NULL;
@@ -308,6 +310,9 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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;
diff --git a/libvideoeditor/lvpp/PreviewPlayer.h b/libvideoeditor/lvpp/PreviewPlayer.h
index 214c136..ebbdec8 100755
--- a/libvideoeditor/lvpp/PreviewPlayer.h
+++ b/libvideoeditor/lvpp/PreviewPlayer.h
@@ -74,7 +74,7 @@
const char *uri, const KeyedVector<String8, String8> *headers);
//Added methods
- status_t loadEffectsSettings(M4VSS3GPP_EffectSettings* pEffectSettings,
+ status_t loadEffectsSettings(M4VSS3GPP_EffectSettings* pEffectSettings,
int nEffects);
status_t loadAudioMixSettings(M4xVSS_AudioMixingSettings* pAudioMixSettings);
status_t setAudioMixPCMFileHandle(M4OSA_Context pAudioMixPCMFileHandle);
@@ -185,6 +185,9 @@
uint32_t mOutputVideoWidth;
uint32_t mOutputVideoHeight;
+ int32_t mReportedWidth; //docoder reported width
+ int32_t mReportedHeight; //docoder reported height
+
uint32_t mStoryboardStartTimeMsec;
bool mIsVideoSourceJpg;
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
index d862255..c079898 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
@@ -1174,7 +1174,7 @@
mTarget->getBufferYV12(&(postProcessParams.pOutBuffer), &(postProcessParams.outBufferStride));
- err = applyEffectsAndRenderingMode(&postProcessParams);
+ err = applyEffectsAndRenderingMode(&postProcessParams, mOutputVideoWidth, mOutputVideoHeight);
return err;
}
@@ -1273,7 +1273,7 @@
// In plane
prepareYUV420ImagePlane(planeIn, videoWidth,
- videoHeight, (M4VIFI_UInt8 *)inBuffer);
+ videoHeight, (M4VIFI_UInt8 *)inBuffer, videoWidth, videoHeight);
outputBufferWidth = mOutputVideoWidth;
outputBufferHeight = mOutputVideoHeight;
diff --git a/libvideoeditor/lvpp/VideoEditorTools.cpp b/libvideoeditor/lvpp/VideoEditorTools.cpp
index 99fc6b5..73362ad 100755
--- a/libvideoeditor/lvpp/VideoEditorTools.cpp
+++ b/libvideoeditor/lvpp/VideoEditorTools.cpp
@@ -2161,7 +2161,7 @@
}
*pContext = M4OSA_NULL ;
-
+
return err ;
}
@@ -2222,7 +2222,7 @@
M4OSA_UInt32 nb_planes;
M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_PARAMETER, pContext) ;
-
+
if(M4AIR_kYUV420AP == pC->m_inputFormat)
{
nb_planes = 4;
@@ -2395,7 +2395,7 @@
}
/**< Update state */
pC->m_state = M4AIR_kConfigured;
-
+
return M4NO_ERROR ;
}
@@ -3065,8 +3065,9 @@
}
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;
plane[0].u_height = height;
@@ -3079,21 +3080,20 @@
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,
M4OSA_UInt32 width, M4OSA_UInt32 height, M4OSA_UInt32 stride,
M4VIFI_UInt8 *buffer) {
-
+
//Y plane
plane[0].u_width = width;
plane[0].u_height = height;
@@ -3119,13 +3119,13 @@
plane[2].pac_data = (buffer +
plane[0].u_height * android::PreviewRenderer::ALIGN(plane[0].u_stride, 16));
-
+
}
M4OSA_Void swapImagePlanes(
M4VIFI_ImagePlane *planeIn, M4VIFI_ImagePlane *planeOut,
M4VIFI_UInt8 *buffer1, M4VIFI_UInt8 *buffer2) {
-
+
planeIn[0].u_height = planeOut[0].u_height;
planeIn[0].u_width = planeOut[0].u_width;
planeIn[0].u_stride = planeOut[0].u_stride;
@@ -3167,7 +3167,7 @@
planeOut[0].u_width*planeOut[0].u_height +
planeOut[1].u_width*planeOut[1].u_height);
}
-
+
}
M4OSA_Void computePercentageDone(
@@ -3405,7 +3405,8 @@
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 @@
}
// 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
diff --git a/libvideoeditor/lvpp/VideoEditorTools.h b/libvideoeditor/lvpp/VideoEditorTools.h
index 368047a..5140e8b 100755
--- a/libvideoeditor/lvpp/VideoEditorTools.h
+++ b/libvideoeditor/lvpp/VideoEditorTools.h
@@ -107,7 +107,8 @@
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 @@
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