Revert format change related CLs
Revert "CCodec: simplify format change logic"
This reverts commit a08cd2b279d9a97c5a2e7b29ef5b055ed02a251c.
Revert "aacdec: don't report DRC_COMPRESSION_MODE back"
This reverts commit aaa0309a2b8bcdb56103380d54127ba9aebc9f21.
Revert "CCodecConfig: don't read DRC_COMPRESSION_MODE back"
This reverts commit 30c1d421b10c4760edba45f3e118f7b549ed7104.
Bug: 173176131
Test: revert
Change-Id: Ia16a58cbf7b19a8b3ac908afd2c20d740dfa7c28
diff --git a/media/codec2/components/aac/C2SoftAacDec.cpp b/media/codec2/components/aac/C2SoftAacDec.cpp
index 83fea3f..677f316 100644
--- a/media/codec2/components/aac/C2SoftAacDec.cpp
+++ b/media/codec2/components/aac/C2SoftAacDec.cpp
@@ -877,6 +877,11 @@
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(
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 0036bef..1405b97 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -1794,6 +1794,7 @@
// 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()
@@ -1828,7 +1829,9 @@
++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)
@@ -1862,7 +1865,7 @@
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;
}
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index 74f1319..692da58 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -158,7 +158,8 @@
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) {
@@ -169,6 +170,9 @@
updateSkipCutBuffer(sampleRate, channelCount);
}
}
+ if (notify) {
+ mUnreportedFormat = nullptr;
+ }
}
void OutputBuffers::submit(const sp<MediaCodecBuffer> &buffer) {
@@ -192,6 +196,7 @@
mReorderStash.clear();
mDepth = 0;
mKey = C2Config::ORDINAL;
+ mUnreportedFormat = nullptr;
}
void OutputBuffers::flushStash() {
@@ -267,25 +272,25 @@
*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);
+ }
+
+ 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
@@ -296,6 +301,10 @@
}
if (!entry.notify) {
+ if (outputFormat) {
+ ALOGD("[%s] popFromStashAndRegister: output format changed to %s",
+ mName, outputFormat->debugString().c_str());
+ }
mPending.pop_front();
return DISCARD;
}
@@ -312,6 +321,10 @@
// 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(),
@@ -1163,6 +1176,7 @@
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;
diff --git a/media/codec2/sfplugin/CCodecBuffers.h b/media/codec2/sfplugin/CCodecBuffers.h
index 7c4e7b1..c383a7c 100644
--- a/media/codec2/sfplugin/CCodecBuffers.h
+++ b/media/codec2/sfplugin/CCodecBuffers.h
@@ -215,8 +215,10 @@
/**
* 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
@@ -390,6 +392,9 @@
// 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()
diff --git a/media/codec2/sfplugin/CCodecConfig.cpp b/media/codec2/sfplugin/CCodecConfig.cpp
index c324949..96f86e8 100644
--- a/media/codec2/sfplugin/CCodecConfig.cpp
+++ b/media/codec2/sfplugin/CCodecConfig.cpp
@@ -765,13 +765,21 @@
// 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