libmix: report format change if graphic buffer count is increased
BZ: 183245
report format change if graphic buffer count is increased
Change-Id: Ic75fbe790c911110808fd2b473d46b1151a32457
Signed-off-by: Tianmi Chen <tianmi.chen@intel.com>
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index b5a4a6b..bf2df90 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -833,7 +833,8 @@
if (!rawDataMode) {
needFlush = (mVideoFormatInfo.width > mVideoFormatInfo.surfaceWidth)
|| (mVideoFormatInfo.height > mVideoFormatInfo.surfaceHeight)
- || isWiDiStatusChanged();
+ || isWiDiStatusChanged()
+ || (mVideoFormatInfo.actualBufferNeeded > mConfigBuffer.surfaceNumber);
}
if (needFlush || (rawDataMode && mSizeChanged)) {
diff --git a/videodecoder/VideoDecoderBase.cpp b/videodecoder/VideoDecoderBase.cpp
index 7d1cd13..a5b73f4 100644
--- a/videodecoder/VideoDecoderBase.cpp
+++ b/videodecoder/VideoDecoderBase.cpp
@@ -148,6 +148,7 @@
mVideoFormatInfo.surfaceWidth = buffer->graphicBufferWidth;
mVideoFormatInfo.surfaceHeight = buffer->graphicBufferHeight;
}
+ mVideoFormatInfo.actualBufferNeeded = mConfigBuffer.surfaceNumber;
mLowDelay = buffer->flag & WANT_LOW_DELAY;
mRawOutput = buffer->flag & WANT_RAW_OUTPUT;
if (mRawOutput) {
@@ -220,6 +221,22 @@
}
+void VideoDecoderBase::freeSurfaceBuffers(void) {
+ if (mVAStarted == false) {
+ // nothing to free surface buffers at this stage
+ return;
+ }
+
+ pthread_mutex_lock(&mLock);
+
+ endDecodingFrame(true);
+
+ // if VA is already started, terminate VA as graphic buffers are reallocated by omxcodec
+ terminateVA();
+
+ pthread_mutex_unlock(&mLock);
+}
+
const VideoFormatInfo* VideoDecoderBase::getFormatInfo(void) {
return &mVideoFormatInfo;
}
@@ -961,6 +978,11 @@
}
Decode_Status VideoDecoderBase::terminateVA(void) {
+ if (mVAStarted == false) {
+ // VA hasn't been started yet
+ return DECODE_SUCCESS;
+ }
+
if (mSurfaceBuffers) {
for (int32_t i = 0; i < mNumSurfaces; i++) {
if (mSurfaceBuffers[i].renderBuffer.rawData) {
diff --git a/videodecoder/VideoDecoderBase.h b/videodecoder/VideoDecoderBase.h
index e4a033a..893f23a 100755
--- a/videodecoder/VideoDecoderBase.h
+++ b/videodecoder/VideoDecoderBase.h
@@ -60,6 +60,7 @@
virtual void stop(void);
//virtual Decode_Status decode(VideoDecodeBuffer *buffer);
virtual void flush(void);
+ virtual void freeSurfaceBuffers(void);
virtual const VideoRenderBuffer* getOutput(bool draining = false, VideoErrorBuffer *output_buf = NULL);
virtual Decode_Status signalRenderDone(void * graphichandler);
virtual const VideoFormatInfo* getFormatInfo(void);
diff --git a/videodecoder/VideoDecoderInterface.h b/videodecoder/VideoDecoderInterface.h
index 4c6a039..acedea3 100644
--- a/videodecoder/VideoDecoderInterface.h
+++ b/videodecoder/VideoDecoderInterface.h
@@ -36,6 +36,7 @@
virtual void stop(void) = 0;
virtual void flush() = 0;
virtual Decode_Status decode(VideoDecodeBuffer *buffer) = 0;
+ virtual void freeSurfaceBuffers(void) = 0;
virtual const VideoRenderBuffer* getOutput(bool draining = false, VideoErrorBuffer *output_buf = NULL) = 0;
virtual const VideoFormatInfo* getFormatInfo(void) = 0;
virtual Decode_Status signalRenderDone(void * graphichandler) = 0;