Loading media/codec2/sfplugin/CCodec.cpp +31 −5 Original line number Diff line number Diff line Loading @@ -487,6 +487,31 @@ public: } }; void RevertOutputFormatIfNeeded( const sp<AMessage> &oldFormat, sp<AMessage> ¤tFormat) { // We used to not report changes to these keys to the client. const static std::set<std::string> sIgnoredKeys({ KEY_BIT_RATE, KEY_MAX_BIT_RATE, "csd-0", "csd-1", "csd-2", }); if (currentFormat == oldFormat) { return; } sp<AMessage> diff = currentFormat->changesFrom(oldFormat); AMessage::Type type; for (size_t i = diff->countEntries(); i > 0; --i) { if (sIgnoredKeys.count(diff->getEntryNameAt(i - 1, &type)) > 0) { diff->removeEntryAt(i - 1); } } if (diff->countEntries() == 0) { currentFormat = oldFormat; } } } // namespace // CCodec::ClientListener Loading Loading @@ -1702,7 +1727,9 @@ void CCodec::signalSetParameters(const sp<AMessage> &msg) { || comp->getName().find("c2.android.") == 0)) { mChannel->setParameters(configUpdate); } else { sp<AMessage> outputFormat = config->mOutputFormat; (void)config->setParameters(comp, configUpdate, C2_MAY_BLOCK); RevertOutputFormatIfNeeded(outputFormat, config->mOutputFormat); } } Loading Loading @@ -1827,7 +1854,6 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { // handle configuration changes in work done Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); const std::unique_ptr<Config> &config = *configLocked; bool changed = false; Config::Watcher<C2StreamInitDataInfo::output> initData = config->watch<C2StreamInitDataInfo::output>(); if (!work->worklets.empty() Loading Loading @@ -1862,9 +1888,9 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { ++stream; } if (config->updateConfiguration(updates, config->mOutputDomain)) { changed = true; } sp<AMessage> outputFormat = config->mOutputFormat; config->updateConfiguration(updates, config->mOutputDomain); RevertOutputFormatIfNeeded(outputFormat, config->mOutputFormat); // copy standard infos to graphic buffers if not already present (otherwise, we // may overwrite the actual intermediate value with a final value) Loading Loading @@ -1898,7 +1924,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } mChannel->onWorkDone( std::move(work), changed ? config->mOutputFormat->dup() : nullptr, std::move(work), config->mOutputFormat, initData.hasChanged() ? initData.update().get() : nullptr); break; } Loading media/codec2/sfplugin/CCodecBuffers.cpp +18 −32 Original line number Diff line number Diff line Loading @@ -161,8 +161,7 @@ void OutputBuffers::updateSkipCutBuffer(int32_t sampleRate, int32_t channelCount setSkipCutBuffer(delay, padding); } void OutputBuffers::updateSkipCutBuffer( const sp<AMessage> &format, bool notify) { void OutputBuffers::updateSkipCutBuffer(const sp<AMessage> &format) { AString mediaType; if (format->findString(KEY_MIME, &mediaType) && mediaType == MIMETYPE_AUDIO_RAW) { Loading @@ -173,9 +172,6 @@ void OutputBuffers::updateSkipCutBuffer( updateSkipCutBuffer(sampleRate, channelCount); } } if (notify) { mUnreportedFormat = nullptr; } } void OutputBuffers::submit(const sp<MediaCodecBuffer> &buffer) { Loading @@ -199,7 +195,6 @@ void OutputBuffers::clearStash() { mReorderStash.clear(); mDepth = 0; mKey = C2Config::ORDINAL; mUnreportedFormat = nullptr; } void OutputBuffers::flushStash() { Loading Loading @@ -275,25 +270,25 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( *c2Buffer = entry.buffer; sp<AMessage> outputFormat = entry.format; // The output format can be processed without a registered slot. if (outputFormat) { updateSkipCutBuffer(outputFormat, entry.notify); if (entry.notify && mFormat != outputFormat) { updateSkipCutBuffer(outputFormat); sp<ABuffer> imageData; if (mFormat->findBuffer("image-data", &imageData)) { outputFormat->setBuffer("image-data", imageData); } if (entry.notify) { if (outputFormat) { setFormat(outputFormat); } else if (mUnreportedFormat) { outputFormat = mUnreportedFormat; setFormat(outputFormat); int32_t stride; if (mFormat->findInt32(KEY_STRIDE, &stride)) { outputFormat->setInt32(KEY_STRIDE, stride); } mUnreportedFormat = nullptr; } else { if (outputFormat) { mUnreportedFormat = outputFormat; } else if (!mUnreportedFormat) { mUnreportedFormat = mFormat; int32_t sliceHeight; if (mFormat->findInt32(KEY_SLICE_HEIGHT, &sliceHeight)) { outputFormat->setInt32(KEY_SLICE_HEIGHT, sliceHeight); } ALOGV("[%s] popFromStashAndRegister: output format reference changed: %p -> %p", mName, mFormat.get(), outputFormat.get()); ALOGD("[%s] popFromStashAndRegister: output format changed to %s", mName, outputFormat->debugString().c_str()); setFormat(outputFormat); } // Flushing mReorderStash because no other buffers should come after output Loading @@ -304,10 +299,6 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( } if (!entry.notify) { if (outputFormat) { ALOGD("[%s] popFromStashAndRegister: output format changed to %s", mName, outputFormat->debugString().c_str()); } mPending.pop_front(); return DISCARD; } Loading @@ -325,10 +316,6 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( (*outBuffer)->meta()->setInt64("timeUs", entry.timestamp); (*outBuffer)->meta()->setInt32("flags", entry.flags); (*outBuffer)->meta()->setInt64("frameIndex", entry.ordinal.frameIndex.peekll()); if (outputFormat) { ALOGD("[%s] popFromStashAndRegister: output format changed to %s", mName, outputFormat->debugString().c_str()); } ALOGV("[%s] popFromStashAndRegister: " "out buffer index = %zu [%p] => %p + %zu (%lld)", mName, *index, outBuffer->get(), Loading Loading @@ -1182,7 +1169,6 @@ void OutputBuffersArray::grow(size_t newSize) { void OutputBuffersArray::transferFrom(OutputBuffers* source) { mFormat = source->mFormat; mSkipCutBuffer = source->mSkipCutBuffer; mUnreportedFormat = source->mUnreportedFormat; mPending = std::move(source->mPending); mReorderStash = std::move(source->mReorderStash); mDepth = source->mDepth; Loading media/codec2/sfplugin/CCodecBuffers.h +1 −6 Original line number Diff line number Diff line Loading @@ -215,10 +215,8 @@ public: /** * Update SkipCutBuffer from format. The @p format must not be null. * @p notify determines whether the format comes with a buffer that should * be reported to the client or not. */ void updateSkipCutBuffer(const sp<AMessage> &format, bool notify = true); void updateSkipCutBuffer(const sp<AMessage> &format); /** * Output Stash Loading Loading @@ -392,9 +390,6 @@ private: // Output stash // Output format that has not been made available to the client. sp<AMessage> mUnreportedFormat; // Struct for an entry in the output stash (mPending and mReorderStash) struct StashEntry { inline StashEntry() Loading Loading
media/codec2/sfplugin/CCodec.cpp +31 −5 Original line number Diff line number Diff line Loading @@ -487,6 +487,31 @@ public: } }; void RevertOutputFormatIfNeeded( const sp<AMessage> &oldFormat, sp<AMessage> ¤tFormat) { // We used to not report changes to these keys to the client. const static std::set<std::string> sIgnoredKeys({ KEY_BIT_RATE, KEY_MAX_BIT_RATE, "csd-0", "csd-1", "csd-2", }); if (currentFormat == oldFormat) { return; } sp<AMessage> diff = currentFormat->changesFrom(oldFormat); AMessage::Type type; for (size_t i = diff->countEntries(); i > 0; --i) { if (sIgnoredKeys.count(diff->getEntryNameAt(i - 1, &type)) > 0) { diff->removeEntryAt(i - 1); } } if (diff->countEntries() == 0) { currentFormat = oldFormat; } } } // namespace // CCodec::ClientListener Loading Loading @@ -1702,7 +1727,9 @@ void CCodec::signalSetParameters(const sp<AMessage> &msg) { || comp->getName().find("c2.android.") == 0)) { mChannel->setParameters(configUpdate); } else { sp<AMessage> outputFormat = config->mOutputFormat; (void)config->setParameters(comp, configUpdate, C2_MAY_BLOCK); RevertOutputFormatIfNeeded(outputFormat, config->mOutputFormat); } } Loading Loading @@ -1827,7 +1854,6 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { // handle configuration changes in work done Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig); const std::unique_ptr<Config> &config = *configLocked; bool changed = false; Config::Watcher<C2StreamInitDataInfo::output> initData = config->watch<C2StreamInitDataInfo::output>(); if (!work->worklets.empty() Loading Loading @@ -1862,9 +1888,9 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { ++stream; } if (config->updateConfiguration(updates, config->mOutputDomain)) { changed = true; } sp<AMessage> outputFormat = config->mOutputFormat; config->updateConfiguration(updates, config->mOutputDomain); RevertOutputFormatIfNeeded(outputFormat, config->mOutputFormat); // copy standard infos to graphic buffers if not already present (otherwise, we // may overwrite the actual intermediate value with a final value) Loading Loading @@ -1898,7 +1924,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } mChannel->onWorkDone( std::move(work), changed ? config->mOutputFormat->dup() : nullptr, std::move(work), config->mOutputFormat, initData.hasChanged() ? initData.update().get() : nullptr); break; } Loading
media/codec2/sfplugin/CCodecBuffers.cpp +18 −32 Original line number Diff line number Diff line Loading @@ -161,8 +161,7 @@ void OutputBuffers::updateSkipCutBuffer(int32_t sampleRate, int32_t channelCount setSkipCutBuffer(delay, padding); } void OutputBuffers::updateSkipCutBuffer( const sp<AMessage> &format, bool notify) { void OutputBuffers::updateSkipCutBuffer(const sp<AMessage> &format) { AString mediaType; if (format->findString(KEY_MIME, &mediaType) && mediaType == MIMETYPE_AUDIO_RAW) { Loading @@ -173,9 +172,6 @@ void OutputBuffers::updateSkipCutBuffer( updateSkipCutBuffer(sampleRate, channelCount); } } if (notify) { mUnreportedFormat = nullptr; } } void OutputBuffers::submit(const sp<MediaCodecBuffer> &buffer) { Loading @@ -199,7 +195,6 @@ void OutputBuffers::clearStash() { mReorderStash.clear(); mDepth = 0; mKey = C2Config::ORDINAL; mUnreportedFormat = nullptr; } void OutputBuffers::flushStash() { Loading Loading @@ -275,25 +270,25 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( *c2Buffer = entry.buffer; sp<AMessage> outputFormat = entry.format; // The output format can be processed without a registered slot. if (outputFormat) { updateSkipCutBuffer(outputFormat, entry.notify); if (entry.notify && mFormat != outputFormat) { updateSkipCutBuffer(outputFormat); sp<ABuffer> imageData; if (mFormat->findBuffer("image-data", &imageData)) { outputFormat->setBuffer("image-data", imageData); } if (entry.notify) { if (outputFormat) { setFormat(outputFormat); } else if (mUnreportedFormat) { outputFormat = mUnreportedFormat; setFormat(outputFormat); int32_t stride; if (mFormat->findInt32(KEY_STRIDE, &stride)) { outputFormat->setInt32(KEY_STRIDE, stride); } mUnreportedFormat = nullptr; } else { if (outputFormat) { mUnreportedFormat = outputFormat; } else if (!mUnreportedFormat) { mUnreportedFormat = mFormat; int32_t sliceHeight; if (mFormat->findInt32(KEY_SLICE_HEIGHT, &sliceHeight)) { outputFormat->setInt32(KEY_SLICE_HEIGHT, sliceHeight); } ALOGV("[%s] popFromStashAndRegister: output format reference changed: %p -> %p", mName, mFormat.get(), outputFormat.get()); ALOGD("[%s] popFromStashAndRegister: output format changed to %s", mName, outputFormat->debugString().c_str()); setFormat(outputFormat); } // Flushing mReorderStash because no other buffers should come after output Loading @@ -304,10 +299,6 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( } if (!entry.notify) { if (outputFormat) { ALOGD("[%s] popFromStashAndRegister: output format changed to %s", mName, outputFormat->debugString().c_str()); } mPending.pop_front(); return DISCARD; } Loading @@ -325,10 +316,6 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( (*outBuffer)->meta()->setInt64("timeUs", entry.timestamp); (*outBuffer)->meta()->setInt32("flags", entry.flags); (*outBuffer)->meta()->setInt64("frameIndex", entry.ordinal.frameIndex.peekll()); if (outputFormat) { ALOGD("[%s] popFromStashAndRegister: output format changed to %s", mName, outputFormat->debugString().c_str()); } ALOGV("[%s] popFromStashAndRegister: " "out buffer index = %zu [%p] => %p + %zu (%lld)", mName, *index, outBuffer->get(), Loading Loading @@ -1182,7 +1169,6 @@ void OutputBuffersArray::grow(size_t newSize) { void OutputBuffersArray::transferFrom(OutputBuffers* source) { mFormat = source->mFormat; mSkipCutBuffer = source->mSkipCutBuffer; mUnreportedFormat = source->mUnreportedFormat; mPending = std::move(source->mPending); mReorderStash = std::move(source->mReorderStash); mDepth = source->mDepth; Loading
media/codec2/sfplugin/CCodecBuffers.h +1 −6 Original line number Diff line number Diff line Loading @@ -215,10 +215,8 @@ public: /** * Update SkipCutBuffer from format. The @p format must not be null. * @p notify determines whether the format comes with a buffer that should * be reported to the client or not. */ void updateSkipCutBuffer(const sp<AMessage> &format, bool notify = true); void updateSkipCutBuffer(const sp<AMessage> &format); /** * Output Stash Loading Loading @@ -392,9 +390,6 @@ private: // Output stash // Output format that has not been made available to the client. sp<AMessage> mUnreportedFormat; // Struct for an entry in the output stash (mPending and mReorderStash) struct StashEntry { inline StashEntry() Loading