summaryrefslogtreecommitdiffstats
path: root/libvideoeditor
diff options
context:
space:
mode:
Diffstat (limited to 'libvideoeditor')
-rwxr-xr-xlibvideoeditor/lvpp/Android.mk1
-rwxr-xr-xlibvideoeditor/lvpp/NativeWindowRenderer.cpp12
-rwxr-xr-xlibvideoeditor/lvpp/PreviewRenderer.cpp9
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorAudioPlayer.cpp4
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorSRC.cpp3
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorSRC.h2
-rwxr-xr-xlibvideoeditor/vss/src/VideoEditorResampler.cpp2
-rwxr-xr-xlibvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp12
-rwxr-xr-xlibvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp6
9 files changed, 28 insertions, 23 deletions
diff --git a/libvideoeditor/lvpp/Android.mk b/libvideoeditor/lvpp/Android.mk
index c018d74..0ed7e6c 100755
--- a/libvideoeditor/lvpp/Android.mk
+++ b/libvideoeditor/lvpp/Android.mk
@@ -59,6 +59,7 @@ LOCAL_SHARED_LIBRARIES := \
libstagefright \
libstagefright_foundation \
libstagefright_omx \
+ libsync \
libui \
libutils \
libvideoeditor_osal \
diff --git a/libvideoeditor/lvpp/NativeWindowRenderer.cpp b/libvideoeditor/lvpp/NativeWindowRenderer.cpp
index b2c2675..2e15ff9 100755
--- a/libvideoeditor/lvpp/NativeWindowRenderer.cpp
+++ b/libvideoeditor/lvpp/NativeWindowRenderer.cpp
@@ -22,9 +22,9 @@
#include <cutils/log.h>
#include <gui/SurfaceTexture.h>
#include <gui/SurfaceTextureClient.h>
-#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MetaData.h>
+#include <media/stagefright/foundation/ADebug.h>
#include "VideoEditorTools.h"
#define CHECK_EGL_ERROR CHECK(EGL_SUCCESS == eglGetError())
@@ -382,7 +382,7 @@ void NativeWindowRenderer::queueInternalBuffer(ANativeWindow *anw,
int64_t timeUs;
CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
native_window_set_buffers_timestamp(anw, timeUs * 1000);
- status_t err = anw->queueBuffer(anw, buffer->graphicBuffer().get());
+ status_t err = anw->queueBuffer(anw, buffer->graphicBuffer().get(), -1);
if (err != 0) {
ALOGE("queueBuffer failed with error %s (%d)", strerror(-err), -err);
return;
@@ -399,18 +399,16 @@ void NativeWindowRenderer::queueExternalBuffer(ANativeWindow* anw,
native_window_set_usage(anw, GRALLOC_USAGE_SW_WRITE_OFTEN);
ANativeWindowBuffer* anb;
- anw->dequeueBuffer(anw, &anb);
+ CHECK(NO_ERROR == native_window_dequeue_buffer_and_wait(anw, &anb));
CHECK(anb != NULL);
- sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
- CHECK(NO_ERROR == anw->lockBuffer(anw, buf->getNativeBuffer()));
-
// Copy the buffer
uint8_t* img = NULL;
+ sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
copyI420Buffer(buffer, img, width, height, buf->getStride());
buf->unlock();
- CHECK(NO_ERROR == anw->queueBuffer(anw, buf->getNativeBuffer()));
+ CHECK(NO_ERROR == anw->queueBuffer(anw, buf->getNativeBuffer(), -1));
}
void NativeWindowRenderer::copyI420Buffer(MediaBuffer* src, uint8_t* dst,
diff --git a/libvideoeditor/lvpp/PreviewRenderer.cpp b/libvideoeditor/lvpp/PreviewRenderer.cpp
index 4aa4eb3..b1cfc8e 100755
--- a/libvideoeditor/lvpp/PreviewRenderer.cpp
+++ b/libvideoeditor/lvpp/PreviewRenderer.cpp
@@ -97,13 +97,12 @@ PreviewRenderer::~PreviewRenderer() {
void PreviewRenderer::getBufferYV12(uint8_t **data, size_t *stride) {
int err = OK;
- if ((err = mSurface->ANativeWindow::dequeueBuffer(mSurface.get(), &mBuf)) != 0) {
- ALOGW("Surface::dequeueBuffer returned error %d", err);
+ if ((err = native_window_dequeue_buffer_and_wait(mSurface.get(),
+ &mBuf)) != 0) {
+ ALOGW("native_window_dequeue_buffer_and_wait returned error %d", err);
return;
}
- CHECK_EQ(0, mSurface->ANativeWindow::lockBuffer(mSurface.get(), mBuf));
-
GraphicBufferMapper &mapper = GraphicBufferMapper::get();
Rect bounds(mWidth, mHeight);
@@ -131,7 +130,7 @@ void PreviewRenderer::renderYV12() {
if (mBuf!= NULL) {
CHECK_EQ(0, mapper.unlock(mBuf->handle));
- if ((err = mSurface->ANativeWindow::queueBuffer(mSurface.get(), mBuf)) != 0) {
+ if ((err = mSurface->ANativeWindow::queueBuffer(mSurface.get(), mBuf, -1)) != 0) {
ALOGW("Surface::queueBuffer returned error %d", err);
}
}
diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
index 797686c..c111ba8 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
@@ -534,9 +534,7 @@ status_t VideoEditorAudioPlayer::start(bool sourceAlreadyStarted) {
} else {
mAudioTrack = new AudioTrack(
AUDIO_STREAM_MUSIC, mSampleRate, AUDIO_FORMAT_PCM_16_BIT,
- (numChannels == 2)
- ? AUDIO_CHANNEL_OUT_STEREO
- : AUDIO_CHANNEL_OUT_MONO,
+ audio_channel_out_mask_from_count(numChannels),
0, AUDIO_OUTPUT_FLAG_NONE, &AudioCallback, this, 0);
if ((err = mAudioTrack->initCheck()) != OK) {
diff --git a/libvideoeditor/lvpp/VideoEditorSRC.cpp b/libvideoeditor/lvpp/VideoEditorSRC.cpp
index 4753dd4..36d0812 100755
--- a/libvideoeditor/lvpp/VideoEditorSRC.cpp
+++ b/libvideoeditor/lvpp/VideoEditorSRC.cpp
@@ -321,8 +321,7 @@ void VideoEditorSRC::checkAndSetResampler() {
mResampler = AudioResampler::create(
16 /* bit depth */,
mChannelCnt,
- mOutputSampleRate,
- AudioResampler::DEFAULT);
+ mOutputSampleRate);
CHECK(mResampler);
mResampler->setSampleRate(mSampleRate);
mResampler->setVolume(kUnityGain, kUnityGain);
diff --git a/libvideoeditor/lvpp/VideoEditorSRC.h b/libvideoeditor/lvpp/VideoEditorSRC.h
index 2b7e9b6..1707d4d 100755
--- a/libvideoeditor/lvpp/VideoEditorSRC.h
+++ b/libvideoeditor/lvpp/VideoEditorSRC.h
@@ -17,7 +17,7 @@
#include <stdint.h>
#include <media/stagefright/MediaSource.h>
-#include "AudioBufferProvider.h"
+#include <media/AudioBufferProvider.h>
#include "AudioResampler.h"
namespace android {
diff --git a/libvideoeditor/vss/src/VideoEditorResampler.cpp b/libvideoeditor/vss/src/VideoEditorResampler.cpp
index 38dffb7..1129c3c 100755
--- a/libvideoeditor/vss/src/VideoEditorResampler.cpp
+++ b/libvideoeditor/vss/src/VideoEditorResampler.cpp
@@ -80,7 +80,7 @@ M4OSA_Context LVAudioResamplerCreate(M4OSA_Int32 bitDepth, M4OSA_Int32 inChanne
VideoEditorResampler *context = new VideoEditorResampler();
context->mResampler = AudioResampler::create(
- bitDepth, inChannelCount, sampleRate, AudioResampler::DEFAULT);
+ bitDepth, inChannelCount, sampleRate);
if (context->mResampler == NULL) {
return NULL;
}
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
index b7d4cc0..3c8915a 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
@@ -1483,11 +1483,15 @@ M4OSA_ERR VideoEditor3gpReader_getNextStreamHandler(M4OSA_Context context,
(int32_t*)&(pVideoStreamHandler->m_videoHeight));
(*pStreamHandler) = (M4_StreamHandler*)(pVideoStreamHandler);
- meta->findInt64(kKeyDuration,
- (int64_t*)&(Duration));
- ((*pStreamHandler)->m_duration) =
- (int32_t)((Duration)/1000); // conversion to mS
+ meta->findInt64(kKeyDuration, (int64_t*)&(Duration));
+ ((*pStreamHandler)->m_duration) = (int32_t)((Duration)/1000); // conversion to mS
pC->mMaxDuration = ((*pStreamHandler)->m_duration);
+ if (pC->mMaxDuration == 0) {
+ ALOGE("Video is too short: %lld Us", Duration);
+ delete pVideoStreamHandler;
+ pVideoStreamHandler = NULL;
+ return M4ERR_PARAMETER;
+ }
ALOGV("VideoEditor3gpReader_getNextStreamHandler m_duration %d",
(*pStreamHandler)->m_duration);
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
index 21d3c30..de91731 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
@@ -1149,6 +1149,12 @@ M4OSA_ERR VideoEditorVideoSoftwareDecoder_create(M4OSA_Context *pContext,
pDecShellContext->mLastOutputCts = -1;
pDecShellContext->m_pDecBufferPool = M4OSA_NULL;
+ // Calculate the interval between two video frames.
+ if(pDecShellContext->m_pVideoStreamhandler->m_averageFrameRate > 0){
+ pDecShellContext->mFrameIntervalMs =
+ 1000.0 / pDecShellContext->m_pVideoStreamhandler->m_averageFrameRate;
+ }
+
/**
* StageFright graph building
*/