diff options
author | James Dong <jdong@google.com> | 2011-01-25 16:31:28 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2011-01-26 12:11:22 -0800 |
commit | 5f3ab06e90365ad6c4865e2cab358a20e12ce0eb (patch) | |
tree | 3b80ccbe855de638f67d98a5e4c4c77c372b3423 /media | |
parent | 373d357a8b13dc2cdc82d9e1d6144fb26e3bb202 (diff) | |
download | frameworks_base-5f3ab06e90365ad6c4865e2cab358a20e12ce0eb.zip frameworks_base-5f3ab06e90365ad6c4865e2cab358a20e12ce0eb.tar.gz frameworks_base-5f3ab06e90365ad6c4865e2cab358a20e12ce0eb.tar.bz2 |
Make sure that key frame is generated for timelapse video recording if there are at least two input video frames from camera source.
This will fix the stop failure issue where we have to wait n * time_interval before a key frame can be received by the file writer, where
o n is the actual number of buffers advertised by the video encoder
o time_interval is the interval settings for timelapse video recording
specifying the time distance between neighboring input video frames
The fix includes two parts:
o OMXCodec will not submit all n buffers at one time, but instead submit one input
frame at one time if it become available.
o Timelapse camera source made available the first two input frames and do not skip
them so that the first compressed output frame data can be received regardless
the specified time_interval
bug - 3367659
Change-Id: Ia68cc2cb0d71aa7dc54540e9ad82fae911ad530b
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 8 | ||||
-rw-r--r-- | media/libstagefright/CameraSource.cpp | 2 | ||||
-rw-r--r-- | media/libstagefright/CameraSourceTimeLapse.cpp | 5 | ||||
-rw-r--r-- | media/libstagefright/OMXCodec.cpp | 18 |
4 files changed, 30 insertions, 3 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 65df68c..f134cba 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -1239,6 +1239,14 @@ status_t StagefrightRecorder::setupVideoEncoder( encoder_flags |= OMXCodec::kHardwareCodecsOnly; encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers; } + + // Do not wait for all the input buffers to become available. + // This give timelapse video recording faster response in + // receiving output from video encoder component. + if (mCaptureTimeLapse) { + encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime; + } + sp<MediaSource> encoder = OMXCodec::Create( client.interface(), enc_meta, true /* createEncoder */, cameraSource, diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index b1c6b18..66e0657 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -147,8 +147,8 @@ CameraSource::CameraSource( mNumFramesReceived(0), mLastFrameTimestampUs(0), mStarted(false), - mFirstFrameTimeUs(0), mNumFramesEncoded(0), + mFirstFrameTimeUs(0), mNumFramesDropped(0), mNumGlitches(0), mGlitchDurationThresholdUs(200000), diff --git a/media/libstagefright/CameraSourceTimeLapse.cpp b/media/libstagefright/CameraSourceTimeLapse.cpp index b58b9d8..e6fe618 100644 --- a/media/libstagefright/CameraSourceTimeLapse.cpp +++ b/media/libstagefright/CameraSourceTimeLapse.cpp @@ -491,7 +491,10 @@ bool CameraSourceTimeLapse::skipFrameAndModifyTimeStamp(int64_t *timestampUs) { } } - if (*timestampUs < + // Workaround to bypass the first 2 input frames for skipping. + // The first 2 output frames from the encoder are: decoder specific info and + // the compressed video frame data for the first input video frame. + if (mNumFramesEncoded >= 1 && *timestampUs < (mLastTimeLapseFrameRealTimestampUs + mTimeBetweenTimeLapseFrameCaptureUs)) { // Skip all frames from last encoded frame until // sufficient time (mTimeBetweenTimeLapseFrameCaptureUs) has passed. diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 7c6e561..2a19b25 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -522,6 +522,12 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) { if (flags & kStoreMetaDataInVideoBuffers) { mIsMetaDataStoredInVideoBuffers = true; } + + mOnlySubmitOneBufferAtOneTime = false; + if (flags & kOnlySubmitOneInputBufferAtOneTime) { + mOnlySubmitOneBufferAtOneTime = true; + } + if (!(flags & kIgnoreCodecSpecificData)) { uint32_t type; const void *data; @@ -2610,7 +2616,17 @@ void OMXCodec::drainInputBuffers() { Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexInput]; for (size_t i = 0; i < buffers->size(); ++i) { - if (!drainInputBuffer(&buffers->editItemAt(i))) { + BufferInfo *info = &buffers->editItemAt(i); + + if (info->mStatus != OWNED_BY_US) { + continue; + } + + if (!drainInputBuffer(info)) { + break; + } + + if (mOnlySubmitOneBufferAtOneTime) { break; } } |