summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-08-01 19:32:46 -0700
committerJames Dong <jdong@google.com>2012-08-02 14:01:25 -0700
commit0dff606f42292b8a31b9eee842877f9875279dab (patch)
tree84529f95eacfe525e3ecbc0d9a6f4b49fb0c737b
parentc9729ca1cb1760da836e293e3ed7a82f769f3e07 (diff)
downloadframeworks_av-0dff606f42292b8a31b9eee842877f9875279dab.zip
frameworks_av-0dff606f42292b8a31b9eee842877f9875279dab.tar.gz
frameworks_av-0dff606f42292b8a31b9eee842877f9875279dab.tar.bz2
Allocate buffers before calling start on its source in OMXCodec::start() for encoder case
o This makes it possible to configure the source to use the same number of input buffers as requested by the video encoder, before the source starts. As a result, hardcoded number of video buffers for camera source, for instance, can be avoided. o related-to-bug: 6920805 Change-Id: I13d2c308dce34967768cd407f02988e92ef10a89
-rw-r--r--include/media/stagefright/MetaData.h1
-rwxr-xr-xmedia/libstagefright/OMXCodec.cpp22
2 files changed, 18 insertions, 5 deletions
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index 3c25a14..e91904c 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -111,6 +111,7 @@ enum {
kKeyTrackTimeStatus = 'tktm', // int64_t
kKeyNotRealTime = 'ntrt', // bool (int32_t)
+ kKeyNumBuffers = 'nbbf', // int32_t
// Ogg files can be tagged to be automatically looping...
kKeyAutoLoop = 'autL', // bool (int32_t)
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 2f5e9a4..dabb0e7 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -3623,11 +3623,6 @@ status_t OMXCodec::start(MetaData *meta) {
}
params->setInt64(kKeyTime, startTimeUs);
}
- status_t err = mSource->start(params.get());
-
- if (err != OK) {
- return err;
- }
mCodecSpecificDataIndex = 0;
mInitialBufferSubmit = true;
@@ -3640,6 +3635,23 @@ status_t OMXCodec::start(MetaData *meta) {
mFilledBuffers.clear();
mPaused = false;
+ status_t err;
+ if (mIsEncoder) {
+ // Calling init() before starting its source so that we can configure,
+ // if supported, the source to use exactly the same number of input
+ // buffers as requested by the encoder.
+ if ((err = init()) != OK) {
+ return err;
+ }
+
+ params->setInt32(kKeyNumBuffers, mPortBuffers[kPortIndexInput].size());
+ return mSource->start(params.get());
+ }
+
+ // Decoder case
+ if ((err = mSource->start(params.get())) != OK) {
+ return err;
+ }
return init();
}