summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-12-11 10:43:41 -0800
committerJames Dong <jdong@google.com>2010-12-11 10:57:03 -0800
commit79e23b41fad961008bfde6e26b3c6f86878ca69d (patch)
tree590d806e7ff9da6341c5185a4d7291d1de428e43
parent8d45a37ff076814db39471f15d309567605b3416 (diff)
downloadframeworks_av-79e23b41fad961008bfde6e26b3c6f86878ca69d.zip
frameworks_av-79e23b41fad961008bfde6e26b3c6f86878ca69d.tar.gz
frameworks_av-79e23b41fad961008bfde6e26b3c6f86878ca69d.tar.bz2
Revert "Allows the authoring engine to skip frame."
o Skipping frames could lead to a lot of issues such as I frames is lost etc. It is not being used anyway. This reverts commit 53d4e0d58e2d5c18f6e026c705af833b9bdd7aba. Conflicts: media/libstagefright/AudioSource.cpp media/libstagefright/CameraSource.cpp Change-Id: I3abba1647de48db25bdc369066eb2a7ae4dedec2
-rw-r--r--include/media/stagefright/MediaSource.h13
-rw-r--r--include/media/stagefright/OMXCodec.h1
-rw-r--r--media/libstagefright/AudioSource.cpp46
-rw-r--r--media/libstagefright/CameraSource.cpp55
-rw-r--r--media/libstagefright/MediaSource.cpp16
-rw-r--r--media/libstagefright/OMXCodec.cpp15
6 files changed, 20 insertions, 126 deletions
diff --git a/include/media/stagefright/MediaSource.h b/include/media/stagefright/MediaSource.h
index dafc621..a31395e 100644
--- a/include/media/stagefright/MediaSource.h
+++ b/include/media/stagefright/MediaSource.h
@@ -78,31 +78,18 @@ struct MediaSource : public RefBase {
void clearSeekTo();
bool getSeekTo(int64_t *time_us, SeekMode *mode) const;
- // Option allows encoder to skip some frames until the specified
- // time stamp.
- // To prevent from being abused, when the skipFrame timestamp is
- // found to be more than 1 second later than the current timestamp,
- // an error will be returned from read().
- void clearSkipFrame();
- bool getSkipFrame(int64_t *timeUs) const;
- void setSkipFrame(int64_t timeUs);
-
void setLateBy(int64_t lateness_us);
int64_t getLateBy() const;
private:
enum Options {
- // Bit map
kSeekTo_Option = 1,
- kSkipFrame_Option = 2,
};
uint32_t mOptions;
int64_t mSeekTimeUs;
SeekMode mSeekMode;
int64_t mLatenessUs;
-
- int64_t mSkipFrameUntilTimeUs;
};
// Causes this source to suspend pulling data from its upstream source
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index d37c22d..bba5b53 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -167,7 +167,6 @@ private:
int64_t mSeekTimeUs;
ReadOptions::SeekMode mSeekMode;
int64_t mTargetTimeUs;
- int64_t mSkipTimeUs;
MediaBuffer *mLeftOverBuffer;
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index 29f16d8..235d752 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -140,38 +140,6 @@ sp<MetaData> AudioSource::getFormat() {
return meta;
}
-/*
- * Returns -1 if frame skipping request is too long.
- * Returns 0 if there is no need to skip frames.
- * Returns 1 if we need to skip frames.
- */
-static int skipFrame(int64_t timestampUs,
- const MediaSource::ReadOptions *options) {
-
- int64_t skipFrameUs;
- if (!options || !options->getSkipFrame(&skipFrameUs)) {
- return 0;
- }
-
- if (skipFrameUs <= timestampUs) {
- return 0;
- }
-
- // Safe guard against the abuse of the kSkipFrame_Option.
- if (skipFrameUs - timestampUs >= 1E6) {
- LOGE("Frame skipping requested is way too long: %lld us",
- skipFrameUs - timestampUs);
-
- return -1;
- }
-
- LOGV("skipFrame: %lld us > timestamp: %lld us",
- skipFrameUs, timestampUs);
-
- return 1;
-
-}
-
void AudioSource::rampVolume(
int32_t startFrame, int32_t rampDurationFrames,
uint8_t *data, size_t bytes) {
@@ -218,7 +186,7 @@ status_t AudioSource::read(
CHECK_EQ(mGroup->acquire_buffer(&buffer), OK);
int err = 0;
- while (mStarted) {
+ if (mStarted) {
uint32_t numFramesRecorded;
mRecord->getPosition(&numFramesRecorded);
@@ -268,12 +236,6 @@ status_t AudioSource::read(
if (mCollectStats) {
mTotalLostFrames += (numLostBytes >> 1);
}
- if ((err = skipFrame(timestampUs, options)) == -1) {
- buffer->release();
- return UNKNOWN_ERROR;
- } else if (err != 0) {
- continue;
- }
memset(buffer->data(), 0, numLostBytes);
buffer->set_range(0, numLostBytes);
if (numFramesRecorded == 0) {
@@ -294,12 +256,6 @@ status_t AudioSource::read(
int64_t recordDurationUs = (1000000LL * n >> 1) / sampleRate;
timestampUs += recordDurationUs;
- if ((err = skipFrame(timestampUs, options)) == -1) {
- buffer->release();
- return UNKNOWN_ERROR;
- } else if (err != 0) {
- continue;
- }
if (mPrevSampleTimeUs - mStartTimeUs < kAutoRampStartUs) {
// Mute the initial video recording signal
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index fac7b78..2f3353b 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -665,45 +665,22 @@ status_t CameraSource::read(
{
Mutex::Autolock autoLock(mLock);
- while (mStarted) {
- while(mFramesReceived.empty()) {
- mFrameAvailableCondition.wait(mLock);
- }
-
- if (!mStarted) {
- return OK;
- }
-
- frame = *mFramesReceived.begin();
- mFramesReceived.erase(mFramesReceived.begin());
-
- frameTime = *mFrameTimes.begin();
- mFrameTimes.erase(mFrameTimes.begin());
- int64_t skipTimeUs;
- if (!options || !options->getSkipFrame(&skipTimeUs)) {
- skipTimeUs = frameTime;
- }
- if (skipTimeUs > frameTime) {
- LOGV("skipTimeUs: %lld us > frameTime: %lld us",
- skipTimeUs, frameTime);
- releaseOneRecordingFrame(frame);
- ++mNumFramesDropped;
- // Safeguard against the abuse of the kSkipFrame_Option.
- if (skipTimeUs - frameTime >= 1E6) {
- LOGE("Frame skipping requested is way too long: %lld us",
- skipTimeUs - frameTime);
- return UNKNOWN_ERROR;
- }
- } else {
- mFramesBeingEncoded.push_back(frame);
- *buffer = new MediaBuffer(frame->pointer(), frame->size());
- (*buffer)->setObserver(this);
- (*buffer)->add_ref();
- (*buffer)->meta_data()->setInt64(kKeyTime, frameTime);
-
- return OK;
- }
+ while (mStarted && mFramesReceived.empty()) {
+ mFrameAvailableCondition.wait(mLock);
}
+ if (!mStarted) {
+ return OK;
+ }
+ frame = *mFramesReceived.begin();
+ mFramesReceived.erase(mFramesReceived.begin());
+
+ frameTime = *mFrameTimes.begin();
+ mFrameTimes.erase(mFrameTimes.begin());
+ mFramesBeingEncoded.push_back(frame);
+ *buffer = new MediaBuffer(frame->pointer(), frame->size());
+ (*buffer)->setObserver(this);
+ (*buffer)->add_ref();
+ (*buffer)->meta_data()->setInt64(kKeyTime, frameTime);
}
return OK;
}
@@ -729,7 +706,7 @@ void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
// May need to skip frame or modify timestamp. Currently implemented
// by the subclass CameraSourceTimeLapse.
- if(skipCurrentFrame(timestampUs)) {
+ if (skipCurrentFrame(timestampUs)) {
releaseOneRecordingFrame(data);
return;
}
diff --git a/media/libstagefright/MediaSource.cpp b/media/libstagefright/MediaSource.cpp
index b4ef338..fd0e79c 100644
--- a/media/libstagefright/MediaSource.cpp
+++ b/media/libstagefright/MediaSource.cpp
@@ -32,7 +32,6 @@ void MediaSource::ReadOptions::reset() {
mOptions = 0;
mSeekTimeUs = 0;
mLatenessUs = 0;
- mSkipFrameUntilTimeUs = 0;
}
void MediaSource::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode) {
@@ -54,21 +53,6 @@ bool MediaSource::ReadOptions::getSeekTo(
return (mOptions & kSeekTo_Option) != 0;
}
-void MediaSource::ReadOptions::clearSkipFrame() {
- mOptions &= ~kSkipFrame_Option;
- mSkipFrameUntilTimeUs = 0;
-}
-
-void MediaSource::ReadOptions::setSkipFrame(int64_t timeUs) {
- mOptions |= kSkipFrame_Option;
- mSkipFrameUntilTimeUs = timeUs;
-}
-
-bool MediaSource::ReadOptions::getSkipFrame(int64_t *timeUs) const {
- *timeUs = mSkipFrameUntilTimeUs;
- return (mOptions & kSkipFrame_Option) != 0;
-}
-
void MediaSource::ReadOptions::setLateBy(int64_t lateness_us) {
mLatenessUs = lateness_us;
}
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 4bf922f..b954be7 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1426,7 +1426,6 @@ OMXCodec::OMXCodec(
mSeekTimeUs(-1),
mSeekMode(ReadOptions::SEEK_CLOSEST_SYNC),
mTargetTimeUs(-1),
- mSkipTimeUs(-1),
mLeftOverBuffer(NULL),
mPaused(false),
mNativeWindow(nativeWindow) {
@@ -2635,15 +2634,13 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) {
for (;;) {
MediaBuffer *srcBuffer;
- MediaSource::ReadOptions options;
- if (mSkipTimeUs >= 0) {
- options.setSkipFrame(mSkipTimeUs);
- }
if (mSeekTimeUs >= 0) {
if (mLeftOverBuffer) {
mLeftOverBuffer->release();
mLeftOverBuffer = NULL;
}
+
+ MediaSource::ReadOptions options;
options.setSeekTo(mSeekTimeUs, mSeekMode);
mSeekTimeUs = -1;
@@ -2668,7 +2665,7 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) {
err = OK;
} else {
- err = mSource->read(&srcBuffer, &options);
+ err = mSource->read(&srcBuffer);
}
if (err != OK) {
@@ -3304,12 +3301,6 @@ status_t OMXCodec::read(
if (options && options->getSeekTo(&seekTimeUs, &seekMode)) {
seeking = true;
}
- int64_t skipTimeUs;
- if (options && options->getSkipFrame(&skipTimeUs)) {
- mSkipTimeUs = skipTimeUs;
- } else {
- mSkipTimeUs = -1;
- }
if (mInitialBufferSubmit) {
mInitialBufferSubmit = false;