aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@google.com>2018-09-26 12:39:21 +0900
committerPin-chih Lin <johnylin@google.com>2018-11-21 21:37:23 +0800
commitd41df2da3228608e55fc27ce02c956d022af880d (patch)
tree6042a3f1cfa30ae8c6def67fcbca80c1805dbbe7
parent7c4cd4b81bae5a20b2fdee1e55138a0b770b1d13 (diff)
downloadv4l2_codec2-d41df2da3228608e55fc27ce02c956d022af880d.tar.gz
C2VDAComponent: Add a parameter for maximum input size
App may set a smaller value for maximum of input buffer size than actually required by mistake. C2VDAComponent overrides it to 1MB if the value specified by app is smaller than 1MB. Bug: 116284248 Test: com.google.android.exoplayer.gts.DashTest#testVp9Fixed360p Change-Id: I0b3b0c945f8b3d66b0f3043d5648c9fda6d2f527 (cherry picked from commit a0adcdfec9dfbf87f5382303594935a9b34f380c)
-rw-r--r--C2VDAComponent.cpp29
-rw-r--r--include/C2VDAComponent.h2
2 files changed, 31 insertions, 0 deletions
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index e0185ea..34eef94 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -169,6 +169,35 @@ C2VDAComponent::IntfImpl::IntfImpl(C2String name, const std::shared_ptr<C2Reflec
.withSetter(LocalSetter::SizeSetter)
.build());
+ // App may set a smaller value for maximum of input buffer size than actually required
+ // by mistake. C2VDAComponent overrides it if the value specified by app is smaller than
+ // the calculated value in MaxSizeCalculator().
+ // This value is the default maximum of linear buffer size (kLinearBufferSize) in
+ // CCodecBufferChannel.cpp.
+ constexpr static size_t kLinearBufferSize = 1048576;
+ struct LocalCalculator {
+ static C2R MaxSizeCalculator(bool mayBlock, C2P<C2StreamMaxBufferSizeInfo::input>& me,
+ const C2P<C2StreamPictureSizeInfo::output>& size) {
+ (void)mayBlock;
+ // TODO: Need larger size?
+ me.set().value = kLinearBufferSize;
+ const uint32_t width = size.v.width;
+ const uint32_t height = size.v.height;
+ // Enlarge the input buffer for 4k video
+ if ((width > 1920 && height > 1080)) {
+ me.set().value = 4 * kLinearBufferSize;
+ }
+ return C2R::Ok();
+ }
+ };
+ addParameter(DefineParam(mMaxInputSize, C2_PARAMKEY_INPUT_MAX_BUFFER_SIZE)
+ .withDefault(new C2StreamMaxBufferSizeInfo::input(0u, kLinearBufferSize))
+ .withFields({
+ C2F(mMaxInputSize, value).any(),
+ })
+ .calculatedAs(LocalCalculator::MaxSizeCalculator, mSize)
+ .build());
+
bool secureMode = name.find(".secure") != std::string::npos;
C2Allocator::id_t inputAllocators[] = {secureMode ? C2VDAAllocatorStore::SECURE_LINEAR
: C2PlatformAllocatorStore::ION};
diff --git a/include/C2VDAComponent.h b/include/C2VDAComponent.h
index 477bc1c..ed8007b 100644
--- a/include/C2VDAComponent.h
+++ b/include/C2VDAComponent.h
@@ -59,6 +59,8 @@ public:
std::shared_ptr<C2PortMediaTypeSetting::output> mOutputMediaType;
// Decoded video size for output.
std::shared_ptr<C2StreamPictureSizeInfo::output> mSize;
+ // Maximum size of one input buffer.
+ std::shared_ptr<C2StreamMaxBufferSizeInfo::input> mMaxInputSize;
// The suggested usage of input buffer allocator ID.
std::shared_ptr<C2PortAllocatorsTuning::input> mInputAllocatorIds;
// The suggested usage of output buffer allocator ID.