summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/omx/GraphicBufferSource.h
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2014-01-10 17:36:57 -0800
committerChong Zhang <chz@google.com>2014-03-11 20:58:57 +0000
commit8bd4d16aa5636e98522c07ae31236420788aa749 (patch)
tree62a6de2d5849abe614ad64ca600ee00b5df6b57c /media/libstagefright/omx/GraphicBufferSource.h
parentbc69c8ba9a8fc881603669205a56d0ca1b572a95 (diff)
downloadframeworks_av-8bd4d16aa5636e98522c07ae31236420788aa749.zip
frameworks_av-8bd4d16aa5636e98522c07ae31236420788aa749.tar.gz
frameworks_av-8bd4d16aa5636e98522c07ae31236420788aa749.tar.bz2
Cap pts gap between adjacent frames to specified value
- In the scenario of cast mirroring, encoding could be suspended for prolonged periods. Limiting the pts gap to workaround the problem where encoder's rate control logic produces huge frames after a long period of suspension. - Repeat last frame a couple more times to get better quality on static scenes. - Fix the timestamp on repeat frames (it was not set) Bug: 11971963 Change-Id: I1d68ab3d269874bf3921aa429a985c5f63e428c7 (cherry picked from commit 94ee4b708acfa941581160b267afb79192b1d816)
Diffstat (limited to 'media/libstagefright/omx/GraphicBufferSource.h')
-rw-r--r--media/libstagefright/omx/GraphicBufferSource.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/media/libstagefright/omx/GraphicBufferSource.h b/media/libstagefright/omx/GraphicBufferSource.h
index 9e5eee6..3b0e454 100644
--- a/media/libstagefright/omx/GraphicBufferSource.h
+++ b/media/libstagefright/omx/GraphicBufferSource.h
@@ -87,6 +87,10 @@ public:
// fill it with a new frame of data; otherwise, just mark it as available.
void codecBufferEmptied(OMX_BUFFERHEADERTYPE* header);
+ // Called when omx_message::FILL_BUFFER_DONE is received. (Currently the
+ // buffer source will fix timestamp in the header if needed.)
+ void codecBufferFilled(OMX_BUFFERHEADERTYPE* header);
+
// This is called after the last input frame has been submitted. We
// need to submit an empty buffer with the EOS flag set. If we don't
// have a codec buffer ready, we just set the mEndOfStream flag.
@@ -105,6 +109,15 @@ public:
// state and once this behaviour is specified it cannot be reset.
status_t setRepeatPreviousFrameDelayUs(int64_t repeatAfterUs);
+ // When set, the timestamp fed to the encoder will be modified such that
+ // the gap between two adjacent frames is capped at maxGapUs. Timestamp
+ // will be restored to the original when the encoded frame is returned to
+ // the client.
+ // This is to solve a problem in certain real-time streaming case, where
+ // encoder's rate control logic produces huge frames after a long period
+ // of suspension on input.
+ status_t setMaxTimestampGapUs(int64_t maxGapUs);
+
protected:
// BufferQueue::ConsumerListener interface, called when a new frame of
// data is available. If we're executing and a codec buffer is
@@ -165,6 +178,7 @@ private:
void setLatestSubmittedBuffer_l(const BufferQueue::BufferItem &item);
bool repeatLatestSubmittedBuffer_l();
+ int64_t getTimestamp(const BufferQueue::BufferItem &item);
// Lock, covers all member variables.
mutable Mutex mMutex;
@@ -206,13 +220,22 @@ private:
enum {
kWhatRepeatLastFrame,
};
-
+ enum {
+ kRepeatLastFrameCount = 10,
+ };
int64_t mRepeatAfterUs;
+ int64_t mMaxTimestampGapUs;
+
+ KeyedVector<int64_t, int64_t> mOriginalTimeUs;
+ int64_t mPrevOriginalTimeUs;
+ int64_t mPrevModifiedTimeUs;
sp<ALooper> mLooper;
sp<AHandlerReflector<GraphicBufferSource> > mReflector;
int32_t mRepeatLastFrameGeneration;
+ int64_t mRepeatLastFrameTimestamp;
+ int32_t mRepeatLastFrameCount;
int mLatestSubmittedBufferId;
uint64_t mLatestSubmittedBufferFrameNum;