Loading media/codec2/components/aac/C2SoftAacDec.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -877,6 +877,11 @@ void C2SoftAacDec::process( work->worklets.front()->output.configUpdate.push_back( C2Param::Copy(currentBoostFactor)); C2StreamDrcCompressionModeTuning::input currentCompressMode(0u, (C2Config::drc_compression_mode_t) compressMode); work->worklets.front()->output.configUpdate.push_back( C2Param::Copy(currentCompressMode)); C2StreamDrcEncodedTargetLevelTuning::input currentEncodedTargetLevel(0u, (C2FloatValue) (encTargetLevel*-0.25)); work->worklets.front()->output.configUpdate.push_back( Loading media/codec2/sfplugin/CCodec.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -1794,6 +1794,7 @@ 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 @@ -1828,7 +1829,9 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { ++stream; } config->updateConfiguration(updates, config->mOutputDomain); if (config->updateConfiguration(updates, config->mOutputDomain)) { changed = true; } // copy standard infos to graphic buffers if not already present (otherwise, we // may overwrite the actual intermediate value with a final value) Loading Loading @@ -1862,7 +1865,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } mChannel->onWorkDone( std::move(work), config->mOutputFormat, std::move(work), changed ? config->mOutputFormat->dup() : nullptr, initData.hasChanged() ? initData.update().get() : nullptr); break; } Loading media/codec2/sfplugin/CCodecBuffers.cpp +32 −18 Original line number Diff line number Diff line Loading @@ -158,7 +158,8 @@ void OutputBuffers::updateSkipCutBuffer(int32_t sampleRate, int32_t channelCount setSkipCutBuffer(delay, padding); } void OutputBuffers::updateSkipCutBuffer(const sp<AMessage> &format) { void OutputBuffers::updateSkipCutBuffer( const sp<AMessage> &format, bool notify) { AString mediaType; if (format->findString(KEY_MIME, &mediaType) && mediaType == MIMETYPE_AUDIO_RAW) { Loading @@ -169,6 +170,9 @@ void OutputBuffers::updateSkipCutBuffer(const sp<AMessage> &format) { updateSkipCutBuffer(sampleRate, channelCount); } } if (notify) { mUnreportedFormat = nullptr; } } void OutputBuffers::submit(const sp<MediaCodecBuffer> &buffer) { Loading @@ -192,6 +196,7 @@ void OutputBuffers::clearStash() { mReorderStash.clear(); mDepth = 0; mKey = C2Config::ORDINAL; mUnreportedFormat = nullptr; } void OutputBuffers::flushStash() { Loading Loading @@ -267,25 +272,25 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( *c2Buffer = entry.buffer; sp<AMessage> outputFormat = entry.format; if (entry.notify && mFormat != outputFormat) { updateSkipCutBuffer(outputFormat); sp<ABuffer> imageData; if (mFormat->findBuffer("image-data", &imageData)) { outputFormat->setBuffer("image-data", imageData); // The output format can be processed without a registered slot. if (outputFormat) { updateSkipCutBuffer(outputFormat, entry.notify); } int32_t stride; if (mFormat->findInt32(KEY_STRIDE, &stride)) { outputFormat->setInt32(KEY_STRIDE, stride); if (entry.notify) { if (outputFormat) { setFormat(outputFormat); } else if (mUnreportedFormat) { outputFormat = mUnreportedFormat; setFormat(outputFormat); } int32_t sliceHeight; if (mFormat->findInt32(KEY_SLICE_HEIGHT, &sliceHeight)) { outputFormat->setInt32(KEY_SLICE_HEIGHT, sliceHeight); mUnreportedFormat = nullptr; } else { if (outputFormat) { mUnreportedFormat = outputFormat; } else if (!mUnreportedFormat) { mUnreportedFormat = mFormat; } 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 @@ -296,6 +301,10 @@ 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 @@ -312,6 +321,10 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( // Append information from the front stash entry to outBuffer. (*outBuffer)->meta()->setInt64("timeUs", entry.timestamp); (*outBuffer)->meta()->setInt32("flags", entry.flags); 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 @@ -1163,6 +1176,7 @@ 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 +6 −1 Original line number Diff line number Diff line Loading @@ -215,8 +215,10 @@ 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); void updateSkipCutBuffer(const sp<AMessage> &format, bool notify = true); /** * Output Stash Loading Loading @@ -390,6 +392,9 @@ 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 media/codec2/sfplugin/CCodecConfig.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -765,13 +765,21 @@ void CCodecConfig::initializeStandardParams() { // convert to compression type and add default add(ConfigMapper(KEY_AAC_DRC_HEAVY_COMPRESSION, C2_PARAMKEY_DRC_COMPRESSION_MODE, "value") .limitTo(D::AUDIO & D::DECODER & (D::CONFIG | D::PARAM)) .withMapper([](C2Value v) -> C2Value { .limitTo(D::AUDIO & D::DECODER & (D::CONFIG | D::PARAM | D::READ)) .withMappers([](C2Value v) -> C2Value { int32_t value; if (!v.get(&value) || value < 0) { value = property_get_int32(PROP_DRC_OVERRIDE_HEAVY, DRC_DEFAULT_MOBILE_DRC_HEAVY); } return value == 1 ? C2Config::DRC_COMPRESSION_HEAVY : C2Config::DRC_COMPRESSION_LIGHT; },[](C2Value v) -> C2Value { int32_t value; if (v.get(&value)) { return value; } else { return C2Value(); } })); // convert to dBFS and add default Loading Loading
media/codec2/components/aac/C2SoftAacDec.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -877,6 +877,11 @@ void C2SoftAacDec::process( work->worklets.front()->output.configUpdate.push_back( C2Param::Copy(currentBoostFactor)); C2StreamDrcCompressionModeTuning::input currentCompressMode(0u, (C2Config::drc_compression_mode_t) compressMode); work->worklets.front()->output.configUpdate.push_back( C2Param::Copy(currentCompressMode)); C2StreamDrcEncodedTargetLevelTuning::input currentEncodedTargetLevel(0u, (C2FloatValue) (encTargetLevel*-0.25)); work->worklets.front()->output.configUpdate.push_back( Loading
media/codec2/sfplugin/CCodec.cpp +5 −2 Original line number Diff line number Diff line Loading @@ -1794,6 +1794,7 @@ 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 @@ -1828,7 +1829,9 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { ++stream; } config->updateConfiguration(updates, config->mOutputDomain); if (config->updateConfiguration(updates, config->mOutputDomain)) { changed = true; } // copy standard infos to graphic buffers if not already present (otherwise, we // may overwrite the actual intermediate value with a final value) Loading Loading @@ -1862,7 +1865,7 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) { config->mInputSurface->onInputBufferDone(work->input.ordinal.frameIndex); } mChannel->onWorkDone( std::move(work), config->mOutputFormat, std::move(work), changed ? config->mOutputFormat->dup() : nullptr, initData.hasChanged() ? initData.update().get() : nullptr); break; } Loading
media/codec2/sfplugin/CCodecBuffers.cpp +32 −18 Original line number Diff line number Diff line Loading @@ -158,7 +158,8 @@ void OutputBuffers::updateSkipCutBuffer(int32_t sampleRate, int32_t channelCount setSkipCutBuffer(delay, padding); } void OutputBuffers::updateSkipCutBuffer(const sp<AMessage> &format) { void OutputBuffers::updateSkipCutBuffer( const sp<AMessage> &format, bool notify) { AString mediaType; if (format->findString(KEY_MIME, &mediaType) && mediaType == MIMETYPE_AUDIO_RAW) { Loading @@ -169,6 +170,9 @@ void OutputBuffers::updateSkipCutBuffer(const sp<AMessage> &format) { updateSkipCutBuffer(sampleRate, channelCount); } } if (notify) { mUnreportedFormat = nullptr; } } void OutputBuffers::submit(const sp<MediaCodecBuffer> &buffer) { Loading @@ -192,6 +196,7 @@ void OutputBuffers::clearStash() { mReorderStash.clear(); mDepth = 0; mKey = C2Config::ORDINAL; mUnreportedFormat = nullptr; } void OutputBuffers::flushStash() { Loading Loading @@ -267,25 +272,25 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( *c2Buffer = entry.buffer; sp<AMessage> outputFormat = entry.format; if (entry.notify && mFormat != outputFormat) { updateSkipCutBuffer(outputFormat); sp<ABuffer> imageData; if (mFormat->findBuffer("image-data", &imageData)) { outputFormat->setBuffer("image-data", imageData); // The output format can be processed without a registered slot. if (outputFormat) { updateSkipCutBuffer(outputFormat, entry.notify); } int32_t stride; if (mFormat->findInt32(KEY_STRIDE, &stride)) { outputFormat->setInt32(KEY_STRIDE, stride); if (entry.notify) { if (outputFormat) { setFormat(outputFormat); } else if (mUnreportedFormat) { outputFormat = mUnreportedFormat; setFormat(outputFormat); } int32_t sliceHeight; if (mFormat->findInt32(KEY_SLICE_HEIGHT, &sliceHeight)) { outputFormat->setInt32(KEY_SLICE_HEIGHT, sliceHeight); mUnreportedFormat = nullptr; } else { if (outputFormat) { mUnreportedFormat = outputFormat; } else if (!mUnreportedFormat) { mUnreportedFormat = mFormat; } 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 @@ -296,6 +301,10 @@ 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 @@ -312,6 +321,10 @@ OutputBuffers::BufferAction OutputBuffers::popFromStashAndRegister( // Append information from the front stash entry to outBuffer. (*outBuffer)->meta()->setInt64("timeUs", entry.timestamp); (*outBuffer)->meta()->setInt32("flags", entry.flags); 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 @@ -1163,6 +1176,7 @@ 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 +6 −1 Original line number Diff line number Diff line Loading @@ -215,8 +215,10 @@ 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); void updateSkipCutBuffer(const sp<AMessage> &format, bool notify = true); /** * Output Stash Loading Loading @@ -390,6 +392,9 @@ 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
media/codec2/sfplugin/CCodecConfig.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -765,13 +765,21 @@ void CCodecConfig::initializeStandardParams() { // convert to compression type and add default add(ConfigMapper(KEY_AAC_DRC_HEAVY_COMPRESSION, C2_PARAMKEY_DRC_COMPRESSION_MODE, "value") .limitTo(D::AUDIO & D::DECODER & (D::CONFIG | D::PARAM)) .withMapper([](C2Value v) -> C2Value { .limitTo(D::AUDIO & D::DECODER & (D::CONFIG | D::PARAM | D::READ)) .withMappers([](C2Value v) -> C2Value { int32_t value; if (!v.get(&value) || value < 0) { value = property_get_int32(PROP_DRC_OVERRIDE_HEAVY, DRC_DEFAULT_MOBILE_DRC_HEAVY); } return value == 1 ? C2Config::DRC_COMPRESSION_HEAVY : C2Config::DRC_COMPRESSION_LIGHT; },[](C2Value v) -> C2Value { int32_t value; if (v.get(&value)) { return value; } else { return C2Value(); } })); // convert to dBFS and add default Loading