diff options
author | James Dong <jdong@google.com> | 2010-06-08 11:58:53 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2010-06-08 12:30:58 -0700 |
commit | ddcc4a66d848deef6fb4689e64e30cd9bd2684fe (patch) | |
tree | e34375b6ca52818e02b45af527e68e4b42c92be1 /media/libmediaplayerservice | |
parent | 365a963142093a1cd8efdcea76b5f65096a5b115 (diff) | |
download | frameworks_av-ddcc4a66d848deef6fb4689e64e30cd9bd2684fe.zip frameworks_av-ddcc4a66d848deef6fb4689e64e30cd9bd2684fe.tar.gz frameworks_av-ddcc4a66d848deef6fb4689e64e30cd9bd2684fe.tar.bz2 |
Remove some hard-coded encoding parameters
Change-Id: I7a8ccd5d57891a6a585c8da2ee53acb094955913
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 33 | ||||
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.h | 2 |
2 files changed, 33 insertions, 2 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 572389f..1a684a9 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -287,14 +287,32 @@ status_t StagefrightRecorder::setParamMaxDurationOrFileSize(int64_t limit, status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) { LOGV("setParamInterleaveDuration: %d", durationUs); - if (durationUs <= 20000) { // XXX: 20 ms + if (durationUs <= 500000) { // 500 ms + // If interleave duration is too small, it is very inefficient to do + // interleaving since the metadata overhead will count for a significant + // portion of the saved contents LOGE("Audio/video interleave duration is too small: %d us", durationUs); return BAD_VALUE; + } else if (durationUs >= 10000000) { // 10 seconds + // If interleaving duration is too large, it can cause the recording + // session to use too much memory since we have to save the output + // data before we write them out + LOGE("Audio/video interleave duration is too large: %d us", durationUs); + return BAD_VALUE; } mInterleaveDurationUs = durationUs; return OK; } +// If interval < 0, only the first frame is I frame, and rest are all P frames +// If interval == 0, all frames are encoded as I frames. No P frames +// If interval > 0, it is the time spacing between 2 neighboring I frames +status_t StagefrightRecorder::setParamIFramesInterval(int32_t interval) { + LOGV("setParamIFramesInterval: %d seconds", interval); + mIFramesInterval = interval; + return OK; +} + status_t StagefrightRecorder::setParameter( const String8 &key, const String8 &value) { LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string()); @@ -335,6 +353,11 @@ status_t StagefrightRecorder::setParameter( if (safe_strtoi32(value.string(), &durationUs)) { return setParamInterleaveDuration(durationUs); } + } else if (key == "param-i-frames-interval") { + int32_t interval; + if (safe_strtoi32(value.string(), &interval)) { + return setParamIFramesInterval(interval); + } } else { LOGE("setParameter: failed to find key %s", key.string()); } @@ -619,12 +642,17 @@ status_t StagefrightRecorder::startMPEG4Recording() { sp<MetaData> meta = cameraSource->getFormat(); - int32_t width, height; + int32_t width, height, stride, sliceHeight; CHECK(meta->findInt32(kKeyWidth, &width)); CHECK(meta->findInt32(kKeyHeight, &height)); + CHECK(meta->findInt32(kKeyStride, &stride)); + CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight)); enc_meta->setInt32(kKeyWidth, width); enc_meta->setInt32(kKeyHeight, height); + enc_meta->setInt32(kKeyIFramesInterval, mIFramesInterval); + enc_meta->setInt32(kKeyStride, stride); + enc_meta->setInt32(kKeySliceHeight, sliceHeight); OMXClient client; CHECK_EQ(client.connect(), OK); @@ -702,6 +730,7 @@ status_t StagefrightRecorder::reset() { mAudioChannels = 1; mAudioBitRate = 12200; mInterleaveDurationUs = 0; + mIFramesInterval = 1; mOutputFd = -1; mFlags = 0; diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h index b7d554b..b491e9f 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.h +++ b/media/libmediaplayerservice/StagefrightRecorder.h @@ -75,6 +75,7 @@ private: int32_t mAudioChannels; int32_t mSampleRate; int32_t mInterleaveDurationUs; + int32_t mIFramesInterval; int64_t mMaxFileSizeBytes; int64_t mMaxFileDurationUs; @@ -92,6 +93,7 @@ private: status_t setParamAudioNumberOfChannels(int32_t channles); status_t setParamAudioSamplingRate(int32_t sampleRate); status_t setParamInterleaveDuration(int32_t durationUs); + status_t setParamIFramesInterval(int32_t interval); status_t setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration); StagefrightRecorder(const StagefrightRecorder &); |