Merge changes I73de0e8e,Id1d5968e,I45750c75 am: f6bcf1b2d8
Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1495417
Change-Id: I45e145ac6489eb8027c9560f44c7ccb8c5a737b9
diff --git a/media/codec2/components/aac/C2SoftAacDec.cpp b/media/codec2/components/aac/C2SoftAacDec.cpp
index 677f316..83fea3f 100644
--- a/media/codec2/components/aac/C2SoftAacDec.cpp
+++ b/media/codec2/components/aac/C2SoftAacDec.cpp
@@ -877,11 +877,6 @@
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 1405b97..0036bef 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -1794,7 +1794,6 @@
// 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()
@@ -1829,9 +1828,7 @@
++stream;
}
- if (config->updateConfiguration(updates, config->mOutputDomain)) {
- changed = true;
- }
+ config->updateConfiguration(updates, config->mOutputDomain);
// copy standard infos to graphic buffers if not already present (otherwise, we
// may overwrite the actual intermediate value with a final value)
@@ -1865,7 +1862,7 @@
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;
}
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index 692da58..74f1319 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -158,8 +158,7 @@
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) {
@@ -170,9 +169,6 @@
updateSkipCutBuffer(sampleRate, channelCount);
}
}
- if (notify) {
- mUnreportedFormat = nullptr;
- }
}
void OutputBuffers::submit(const sp<MediaCodecBuffer> &buffer) {
@@ -196,7 +192,6 @@
mReorderStash.clear();
mDepth = 0;
mKey = C2Config::ORDINAL;
- mUnreportedFormat = nullptr;
}
void OutputBuffers::flushStash() {
@@ -272,25 +267,25 @@
*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) {
- if (outputFormat) {
- setFormat(outputFormat);
- } else if (mUnreportedFormat) {
- outputFormat = mUnreportedFormat;
- setFormat(outputFormat);
+ if (entry.notify && mFormat != outputFormat) {
+ updateSkipCutBuffer(outputFormat);
+ sp<ABuffer> imageData;
+ if (mFormat->findBuffer("image-data", &imageData)) {
+ outputFormat->setBuffer("image-data", imageData);
}
- mUnreportedFormat = nullptr;
- } else {
- if (outputFormat) {
- mUnreportedFormat = outputFormat;
- } else if (!mUnreportedFormat) {
- mUnreportedFormat = mFormat;
+ int32_t stride;
+ if (mFormat->findInt32(KEY_STRIDE, &stride)) {
+ outputFormat->setInt32(KEY_STRIDE, stride);
}
+ 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
@@ -301,10 +296,6 @@
}
if (!entry.notify) {
- if (outputFormat) {
- ALOGD("[%s] popFromStashAndRegister: output format changed to %s",
- mName, outputFormat->debugString().c_str());
- }
mPending.pop_front();
return DISCARD;
}
@@ -321,10 +312,6 @@
// 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(),
@@ -1176,7 +1163,6 @@
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 c383a7c..7c4e7b1 100644
--- a/media/codec2/sfplugin/CCodecBuffers.h
+++ b/media/codec2/sfplugin/CCodecBuffers.h
@@ -215,10 +215,8 @@
/**
* 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
@@ -392,9 +390,6 @@
// 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 96f86e8..c324949 100644
--- a/media/codec2/sfplugin/CCodecConfig.cpp
+++ b/media/codec2/sfplugin/CCodecConfig.cpp
@@ -765,21 +765,13 @@
// 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 | D::READ))
- .withMappers([](C2Value v) -> C2Value {
+ .limitTo(D::AUDIO & D::DECODER & (D::CONFIG | D::PARAM))
+ .withMapper([](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