Snap for 5158751 from 76d2867bd2c655cd5ef3f51601654ed6e9ef5cb9 to pi-b4s4-release
Change-Id: Id5c0c422a3d5a8a2fe5a303046368f72d8f4aaa6
diff --git a/media/sfplugin/CCodec.cpp b/media/sfplugin/CCodec.cpp
index 4ade391..baf9cb6 100644
--- a/media/sfplugin/CCodec.cpp
+++ b/media/sfplugin/CCodec.cpp
@@ -807,16 +807,12 @@
config->mInputFormat->setInt32("using-sw-read-often", true);
}
- // NOTE: we don't blindly use client specified input size if specified as clients
- // at times specify too small size. Instead, mimic the behavior from OMX, where the
- // client specified size is only used to ask for bigger buffers than component suggested
- // size.
- int32_t clientInputSize = 0;
- bool clientSpecifiedInputSize =
- msg->findInt32(KEY_MAX_INPUT_SIZE, &clientInputSize) && clientInputSize > 0;
+ // use client specified input size if specified
+ bool clientInputSize = msg->findInt32(KEY_MAX_INPUT_SIZE, (int32_t*)&maxInputSize.value);
+
// TEMP: enforce minimum buffer size of 1MB for video decoders
// and 16K / 4K for audio encoders/decoders
- if (maxInputSize.value == 0) {
+ if (!clientInputSize && maxInputSize.value == 0) {
if (config->mDomain & Config::IS_AUDIO) {
maxInputSize.value = encoder ? 16384 : 4096;
} else if (!encoder) {
@@ -836,17 +832,20 @@
// TODO: do this based on component requiring linear allocator for input
if ((config->mDomain & Config::IS_DECODER) || (config->mDomain & Config::IS_AUDIO)) {
- if (clientSpecifiedInputSize) {
- // Warn that we're overriding client's max input size if necessary.
- if ((uint32_t)clientInputSize < maxInputSize.value) {
- ALOGD("client requested max input size %d, which is smaller than "
- "what component recommended (%u); overriding with component "
- "recommendation.", clientInputSize, maxInputSize.value);
+ // For audio decoder, override client's max input size if necessary.
+ if ((config->mDomain & Config::IS_DECODER) && (config->mDomain & Config::IS_AUDIO)) {
+ int32_t compSize;
+ if (config->mInputFormat->findInt32(KEY_MAX_INPUT_SIZE, &compSize)
+ && maxInputSize.value > 0
+ && compSize > 0
+ && maxInputSize.value < (uint32_t)compSize) {
+ ALOGD("client requested max input size %u, which is smaller than "
+ "what component recommended (%d); overriding with component "
+ "recommendation.", maxInputSize.value, compSize);
ALOGW("This behavior is subject to change. It is recommended that "
"app developers double check whether the requested "
"max input size is in reasonable range.");
- } else {
- maxInputSize.value = clientInputSize;
+ maxInputSize.value = compSize;
}
}
// Pass max input size on input format to the buffer channel (if supplied by the
@@ -1016,7 +1015,7 @@
ALOGD("ISConfig: no configuration");
}
- return OK;
+ return surface->start();
}
void CCodec::initiateSetInputSurface(const sp<PersistentSurface> &surface) {
@@ -1103,20 +1102,12 @@
}
sp<AMessage> inputFormat;
sp<AMessage> outputFormat;
- status_t err2 = OK;
{
Mutexed<Config>::Locked config(mConfig);
inputFormat = config->mInputFormat;
outputFormat = config->mOutputFormat;
- if (config->mInputSurface) {
- err2 = config->mInputSurface->start();
- }
}
- if (err2 != OK) {
- mCallback->onError(err2, ACTION_CODE_FATAL);
- return;
- }
- err2 = mChannel->start(inputFormat, outputFormat);
+ status_t err2 = mChannel->start(inputFormat, outputFormat);
if (err2 != OK) {
mCallback->onError(err2, ACTION_CODE_FATAL);
return;
@@ -1190,13 +1181,6 @@
mCallback->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL);
}
- // NOTE: ACodec releases GBS only at stop(), counter-intuitively.
- {
- Mutexed<Config>::Locked config(mConfig);
- if (config->mInputSurface) {
- config->mInputSurface->disconnect();
- }
- }
{
Mutexed<State>::Locked state(mState);
if (state->get() == STOPPING) {
diff --git a/media/sfplugin/CCodecBufferChannel.cpp b/media/sfplugin/CCodecBufferChannel.cpp
index 51213ab..6e8bd90 100644
--- a/media/sfplugin/CCodecBufferChannel.cpp
+++ b/media/sfplugin/CCodecBufferChannel.cpp
@@ -771,13 +771,8 @@
std::unique_ptr<CCodecBufferChannel::InputBuffers> toArrayMode(
size_t size) final {
int32_t capacity = kLinearBufferSize;
- (void)mFormat->findInt32(KEY_MAX_INPUT_SIZE, &capacity);
- if ((size_t)capacity > kMaxLinearBufferSize) {
- ALOGD("client requested %d, capped to %zu", capacity, kMaxLinearBufferSize);
- capacity = kMaxLinearBufferSize;
- }
- // TODO: proper max input size
- // TODO: read usage from intf
+ (void)mFormat->findInt32(C2_NAME_STREAM_MAX_BUFFER_SIZE_SETTING, &capacity);
+
std::unique_ptr<InputBuffersArray> array(
new InputBuffersArray(mComponentName.c_str(), "1D-Input[N]"));
array->setPool(mPool);
@@ -812,7 +807,6 @@
const sp<MemoryDealer> &dealer,
const sp<ICrypto> &crypto,
int32_t heapSeqNum,
- size_t capacity,
const char *componentName, const char *name = "EncryptedInput")
: LinearInputBuffers(componentName, name),
mUsage({0, 0}),
@@ -825,7 +819,7 @@
mUsage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE };
}
for (size_t i = 0; i < kMinInputBufferArraySize; ++i) {
- sp<IMemory> memory = mDealer->allocate(capacity);
+ sp<IMemory> memory = mDealer->allocate(kLinearBufferSize);
if (memory == nullptr) {
ALOGD("[%s] Failed to allocate memory from dealer: only %zu slots allocated", mName, i);
break;
@@ -1451,8 +1445,6 @@
mMetaMode(MODE_NONE),
mAvailablePipelineCapacity(),
mInputMetEos(false) {
- Mutexed<std::unique_ptr<InputBuffers>>::Locked buffers(mInputBuffers);
- buffers->reset(new DummyInputBuffers(""));
}
CCodecBufferChannel::~CCodecBufferChannel() {
@@ -1820,8 +1812,6 @@
hdr.cta8613 = cta861_meta;
qbi.setHdrMetadata(hdr);
}
- // we don't have dirty regions
- qbi.setSurfaceDamage(Region::INVALID_REGION);
android::IGraphicBufferProducer::QueueBufferOutput qbo;
status_t result = mComponent->queueToOutputSurface(block, qbi, &qbo);
if (result != OK) {
@@ -2002,18 +1992,12 @@
}
} else {
if (hasCryptoOrDescrambler()) {
- int32_t capacity = kLinearBufferSize;
- (void)inputFormat->findInt32(KEY_MAX_INPUT_SIZE, &capacity);
- if ((size_t)capacity > kMaxLinearBufferSize) {
- ALOGD("client requested %d, capped to %zu", capacity, kMaxLinearBufferSize);
- capacity = kMaxLinearBufferSize;
- }
if (mDealer == nullptr) {
mDealer = new MemoryDealer(
- align(capacity, MemoryDealer::getAllocationAlignment())
+ align(kLinearBufferSize, MemoryDealer::getAllocationAlignment())
* (kMinInputBufferArraySize + 1),
"EncryptedLinearInputBuffers");
- mDecryptDestination = mDealer->allocate((size_t)capacity);
+ mDecryptDestination = mDealer->allocate(kLinearBufferSize);
}
if (mCrypto != nullptr && mHeapSeqNum < 0) {
mHeapSeqNum = mCrypto->setHeap(mDealer->getMemoryHeap());
@@ -2021,7 +2005,7 @@
mHeapSeqNum = -1;
}
buffers->reset(new EncryptedLinearInputBuffers(
- secure, mDealer, mCrypto, mHeapSeqNum, (size_t)capacity, mName));
+ secure, mDealer, mCrypto, mHeapSeqNum, mName));
} else {
buffers->reset(new LinearInputBuffers(mName));
}
@@ -2250,6 +2234,7 @@
mSync.stop();
mFirstValidFrameIndex = mFrameIndex.load();
if (mInputSurface != nullptr) {
+ mInputSurface->disconnect();
mInputSurface.reset();
}
}
@@ -2470,7 +2455,7 @@
sp<IGraphicBufferProducer> producer;
if (newSurface) {
newSurface->setScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
- newSurface->setMaxDequeuedBufferCount(kMinOutputBufferArraySize + kMinInputBufferArraySize);
+ newSurface->setMaxDequeuedBufferCount(kMinOutputBufferArraySize);
producer = newSurface->getIGraphicBufferProducer();
producer->setGenerationNumber(generation);
} else {
diff --git a/media/sfplugin/Codec2Buffer.cpp b/media/sfplugin/Codec2Buffer.cpp
index 860d3a8..64a48f5 100644
--- a/media/sfplugin/Codec2Buffer.cpp
+++ b/media/sfplugin/Codec2Buffer.cpp
@@ -298,27 +298,6 @@
}
// fall through if we could not wrap
- case COLOR_FormatYUV420SemiPlanar:
- case COLOR_FormatYUV420PackedSemiPlanar:
- mediaImage->mPlane[mediaImage->Y].mOffset = 0;
- mediaImage->mPlane[mediaImage->Y].mColInc = 1;
- mediaImage->mPlane[mediaImage->Y].mRowInc = mStride;
- mediaImage->mPlane[mediaImage->Y].mHorizSubsampling = 1;
- mediaImage->mPlane[mediaImage->Y].mVertSubsampling = 1;
-
- mediaImage->mPlane[mediaImage->U].mOffset = mStride * mVStride;
- mediaImage->mPlane[mediaImage->U].mColInc = 2;
- mediaImage->mPlane[mediaImage->U].mRowInc = mStride;
- mediaImage->mPlane[mediaImage->U].mHorizSubsampling = 2;
- mediaImage->mPlane[mediaImage->U].mVertSubsampling = 2;
-
- mediaImage->mPlane[mediaImage->V].mOffset = mStride * mVStride + 1;
- mediaImage->mPlane[mediaImage->V].mColInc = 2;
- mediaImage->mPlane[mediaImage->V].mRowInc = mStride;
- mediaImage->mPlane[mediaImage->V].mHorizSubsampling = 2;
- mediaImage->mPlane[mediaImage->V].mVertSubsampling = 2;
- break;
-
case COLOR_FormatYUV420Planar:
case COLOR_FormatYUV420PackedPlanar:
mediaImage->mPlane[mediaImage->Y].mOffset = 0;
@@ -340,6 +319,27 @@
mediaImage->mPlane[mediaImage->V].mVertSubsampling = 2;
break;
+ case COLOR_FormatYUV420SemiPlanar:
+ case COLOR_FormatYUV420PackedSemiPlanar:
+ mediaImage->mPlane[mediaImage->Y].mOffset = 0;
+ mediaImage->mPlane[mediaImage->Y].mColInc = 1;
+ mediaImage->mPlane[mediaImage->Y].mRowInc = mStride;
+ mediaImage->mPlane[mediaImage->Y].mHorizSubsampling = 1;
+ mediaImage->mPlane[mediaImage->Y].mVertSubsampling = 1;
+
+ mediaImage->mPlane[mediaImage->U].mOffset = mStride * mVStride;
+ mediaImage->mPlane[mediaImage->U].mColInc = 2;
+ mediaImage->mPlane[mediaImage->U].mRowInc = mStride;
+ mediaImage->mPlane[mediaImage->U].mHorizSubsampling = 2;
+ mediaImage->mPlane[mediaImage->U].mVertSubsampling = 2;
+
+ mediaImage->mPlane[mediaImage->V].mOffset = mStride * mVStride + 1;
+ mediaImage->mPlane[mediaImage->V].mColInc = 2;
+ mediaImage->mPlane[mediaImage->V].mRowInc = mStride;
+ mediaImage->mPlane[mediaImage->V].mHorizSubsampling = 2;
+ mediaImage->mPlane[mediaImage->V].mVertSubsampling = 2;
+ break;
+
default:
ALOGD("Converter: incompactible color format (%d) for YUV layout", mColorFormat);
mInitCheck = BAD_VALUE;