Merge "libaudiopreprocessing: Define and use cc_defaults"
diff --git a/media/codec2/sfplugin/C2OMXNode.cpp b/media/codec2/sfplugin/C2OMXNode.cpp
index 1a92c08..ab73245 100644
--- a/media/codec2/sfplugin/C2OMXNode.cpp
+++ b/media/codec2/sfplugin/C2OMXNode.cpp
@@ -33,14 +33,12 @@
#include <OMX_IndexExt.h>
#include <android/fdsan.h>
-#include <media/stagefright/foundation/ColorUtils.h>
#include <media/stagefright/omx/OMXUtils.h>
#include <media/stagefright/MediaErrors.h>
#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
#include <utils/Thread.h>
-#include "utils/Codec2Mapper.h"
#include "C2OMXNode.h"
namespace android {
@@ -73,25 +71,6 @@
jobs->cond.broadcast();
}
- void setDataspace(android_dataspace dataspace) {
- Mutexed<Jobs>::Locked jobs(mJobs);
- ColorUtils::convertDataSpaceToV0(dataspace);
- jobs->configUpdate.emplace_back(new C2StreamDataSpaceInfo::input(0u, dataspace));
- int32_t standard = (int32_t(dataspace) & HAL_DATASPACE_STANDARD_MASK)
- >> HAL_DATASPACE_STANDARD_SHIFT;
- int32_t transfer = (int32_t(dataspace) & HAL_DATASPACE_TRANSFER_MASK)
- >> HAL_DATASPACE_TRANSFER_SHIFT;
- int32_t range = (int32_t(dataspace) & HAL_DATASPACE_RANGE_MASK)
- >> HAL_DATASPACE_RANGE_SHIFT;
- std::unique_ptr<C2StreamColorAspectsInfo::input> colorAspects =
- std::make_unique<C2StreamColorAspectsInfo::input>(0u);
- if (C2Mapper::map(standard, &colorAspects->primaries, &colorAspects->matrix)
- && C2Mapper::map(transfer, &colorAspects->transfer)
- && C2Mapper::map(range, &colorAspects->range)) {
- jobs->configUpdate.push_back(std::move(colorAspects));
- }
- }
-
protected:
bool threadLoop() override {
constexpr nsecs_t kIntervalNs = nsecs_t(10) * 1000 * 1000; // 10ms
@@ -123,9 +102,6 @@
uniqueFds.push_back(std::move(queue.workList.front().fd1));
queue.workList.pop_front();
}
- for (const std::unique_ptr<C2Param> ¶m : jobs->configUpdate) {
- items.front()->input.configUpdate.emplace_back(C2Param::Copy(*param));
- }
jobs.unlock();
for (int fenceFd : fenceFds) {
@@ -143,7 +119,6 @@
queued = true;
}
if (queued) {
- jobs->configUpdate.clear();
return true;
}
if (i == 0) {
@@ -186,7 +161,6 @@
std::map<std::weak_ptr<Codec2Client::Component>,
Queue,
std::owner_less<std::weak_ptr<Codec2Client::Component>>> queues;
- std::vector<std::unique_ptr<C2Param>> configUpdate;
Condition cond;
};
Mutexed<Jobs> mJobs;
@@ -198,9 +172,6 @@
mQueueThread(new QueueThread) {
android_fdsan_set_error_level(ANDROID_FDSAN_ERROR_LEVEL_WARN_ALWAYS);
mQueueThread->run("C2OMXNode", PRIORITY_AUDIO);
-
- Mutexed<android_dataspace>::Locked ds(mDataspace);
- *ds = HAL_DATASPACE_UNKNOWN;
}
status_t C2OMXNode::freeNode() {
@@ -488,11 +459,8 @@
android_dataspace dataSpace = (android_dataspace)msg.u.event_data.data1;
uint32_t pixelFormat = msg.u.event_data.data3;
+ // TODO: set dataspace on component to see if it impacts color aspects
ALOGD("dataspace changed to %#x pixel format: %#x", dataSpace, pixelFormat);
- mQueueThread->setDataspace(dataSpace);
-
- Mutexed<android_dataspace>::Locked ds(mDataspace);
- *ds = dataSpace;
return OK;
}
@@ -525,8 +493,4 @@
(void)mBufferSource->onInputBufferEmptied(bufferId, -1);
}
-android_dataspace C2OMXNode::getDataspace() {
- return *mDataspace.lock();
-}
-
} // namespace android
diff --git a/media/codec2/sfplugin/C2OMXNode.h b/media/codec2/sfplugin/C2OMXNode.h
index 5d587bc..1717c96 100644
--- a/media/codec2/sfplugin/C2OMXNode.h
+++ b/media/codec2/sfplugin/C2OMXNode.h
@@ -93,8 +93,6 @@
*/
void onInputBufferDone(c2_cntr64_t index);
- android_dataspace getDataspace();
-
private:
std::weak_ptr<Codec2Client::Component> mComp;
sp<IOMXBufferSource> mBufferSource;
@@ -103,7 +101,6 @@
uint32_t mWidth;
uint32_t mHeight;
uint64_t mUsage;
- Mutexed<android_dataspace> mDataspace;
// WORKAROUND: timestamp adjustment
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 7b914e4..f7564f6 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -211,6 +211,8 @@
(OMX_INDEXTYPE)OMX_IndexParamConsumerUsageBits,
&usage, sizeof(usage));
+ // NOTE: we do not use/pass through color aspects from GraphicBufferSource as we
+ // communicate that directly to the component.
mSource->configure(
mOmxNode, static_cast<hardware::graphics::common::V1_0::Dataspace>(mDataSpace));
return OK;
@@ -409,10 +411,6 @@
mNode->onInputBufferDone(index);
}
- android_dataspace getDataspace() override {
- return mNode->getDataspace();
- }
-
private:
sp<HGraphicBufferSource> mSource;
sp<C2OMXNode> mNode;
@@ -1030,9 +1028,6 @@
}
}
- // get color aspects
- getColorAspectsFromFormat(msg, config->mClientColorAspects);
-
/*
* Handle dataspace
*/
@@ -1042,12 +1037,12 @@
int32_t width, height;
if (msg->findInt32("width", &width)
&& msg->findInt32("height", &height)) {
- setDefaultCodecColorAspectsIfNeeded(config->mClientColorAspects, width, height);
+ ColorAspects aspects;
+ getColorAspectsFromFormat(msg, aspects);
+ setDefaultCodecColorAspectsIfNeeded(aspects, width, height);
// TODO: read dataspace / color aspect from the component
- setColorAspectsIntoFormat(
- config->mClientColorAspects, const_cast<sp<AMessage> &>(msg));
- dataSpace = getDataSpaceForColorAspects(
- config->mClientColorAspects, true /* mayexpand */);
+ setColorAspectsIntoFormat(aspects, const_cast<sp<AMessage> &>(msg));
+ dataSpace = getDataSpaceForColorAspects(aspects, true /* mayexpand */);
}
msg->setInt32("android._dataspace", (int32_t)dataSpace);
ALOGD("setting dataspace to %x", dataSpace);
@@ -1985,44 +1980,6 @@
}
}
-static void HandleDataspace(
- android_dataspace dataspace, ColorAspects *colorAspects, sp<AMessage> *format) {
- ColorUtils::convertDataSpaceToV0(dataspace);
- int32_t range, standard, transfer;
- range = (dataspace & HAL_DATASPACE_RANGE_MASK) >> HAL_DATASPACE_RANGE_SHIFT;
- if (range == 0) {
- range = ColorUtils::wrapColorAspectsIntoColorRange(
- colorAspects->mRange);
- }
- standard = (dataspace & HAL_DATASPACE_STANDARD_MASK) >> HAL_DATASPACE_STANDARD_SHIFT;
- if (standard == 0) {
- standard = ColorUtils::wrapColorAspectsIntoColorStandard(
- colorAspects->mPrimaries,
- colorAspects->mMatrixCoeffs);
- }
- transfer = (dataspace & HAL_DATASPACE_TRANSFER_MASK) >> HAL_DATASPACE_TRANSFER_SHIFT;
- if (transfer == 0) {
- transfer = ColorUtils::wrapColorAspectsIntoColorTransfer(
- colorAspects->mTransfer);
- }
- ColorAspects newColorAspects;
- ColorUtils::convertPlatformColorAspectsToCodecAspects(
- range, standard, transfer, newColorAspects);
- if (ColorUtils::checkIfAspectsChangedAndUnspecifyThem(
- newColorAspects, *colorAspects)) {
- *format = (*format)->dup();
- (*format)->setInt32(KEY_COLOR_RANGE, range);
- (*format)->setInt32(KEY_COLOR_STANDARD, standard);
- (*format)->setInt32(KEY_COLOR_TRANSFER, transfer);
- // Record current color aspects into |colorAspects|.
- // NOTE: newColorAspects could have been modified by
- // checkIfAspectsChangedAndUnspecifyThem() above,
- // so *colorAspects = newColorAspects does not work as intended.
- ColorUtils::convertPlatformColorAspectsToCodecAspects(
- range, standard, transfer, *colorAspects);
- }
-}
-
void CCodec::onMessageReceived(const sp<AMessage> &msg) {
TimePoint now = std::chrono::steady_clock::now();
CCodecWatchdog::getInstance()->watch(this);
@@ -2137,10 +2094,6 @@
sp<AMessage> outputFormat = config->mOutputFormat;
config->updateConfiguration(updates, config->mOutputDomain);
- if (config->mInputSurface) {
- android_dataspace ds = config->mInputSurface->getDataspace();
- HandleDataspace(ds, &config->mClientColorAspects, &config->mOutputFormat);
- }
RevertOutputFormatIfNeeded(outputFormat, config->mOutputFormat);
// copy standard infos to graphic buffers if not already present (otherwise, we
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index 6825dc2..ba44074 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -77,34 +77,39 @@
void CCodecBuffers::handleImageData(const sp<Codec2Buffer> &buffer) {
sp<ABuffer> imageDataCandidate = buffer->getImageData();
if (imageDataCandidate == nullptr) {
+ if (mFormatWithImageData) {
+ // We previously sent the format with image data, so use the same format.
+ buffer->setFormat(mFormatWithImageData);
+ }
return;
}
- sp<ABuffer> imageData;
- if (!mFormat->findBuffer("image-data", &imageData)
- || imageDataCandidate->size() != imageData->size()
- || memcmp(imageDataCandidate->data(), imageData->data(), imageData->size()) != 0) {
+ if (!mLastImageData
+ || imageDataCandidate->size() != mLastImageData->size()
+ || memcmp(imageDataCandidate->data(),
+ mLastImageData->data(),
+ mLastImageData->size()) != 0) {
ALOGD("[%s] updating image-data", mName);
- sp<AMessage> newFormat = dupFormat();
- newFormat->setBuffer("image-data", imageDataCandidate);
+ mFormatWithImageData = dupFormat();
+ mLastImageData = imageDataCandidate;
+ mFormatWithImageData->setBuffer("image-data", imageDataCandidate);
MediaImage2 *img = (MediaImage2*)imageDataCandidate->data();
if (img->mNumPlanes > 0 && img->mType != img->MEDIA_IMAGE_TYPE_UNKNOWN) {
int32_t stride = img->mPlane[0].mRowInc;
- newFormat->setInt32(KEY_STRIDE, stride);
+ mFormatWithImageData->setInt32(KEY_STRIDE, stride);
ALOGD("[%s] updating stride = %d", mName, stride);
if (img->mNumPlanes > 1 && stride > 0) {
int64_t offsetDelta =
(int64_t)img->mPlane[1].mOffset - (int64_t)img->mPlane[0].mOffset;
int32_t vstride = int32_t(offsetDelta / stride);
- newFormat->setInt32(KEY_SLICE_HEIGHT, vstride);
+ mFormatWithImageData->setInt32(KEY_SLICE_HEIGHT, vstride);
ALOGD("[%s] updating vstride = %d", mName, vstride);
buffer->setRange(
img->mPlane[0].mOffset,
buffer->size() - img->mPlane[0].mOffset);
}
}
- setFormat(newFormat);
- buffer->setFormat(newFormat);
}
+ buffer->setFormat(mFormatWithImageData);
}
// InputBuffers
@@ -273,22 +278,12 @@
if (entry.notify && mFormat != outputFormat) {
updateSkipCutBuffer(outputFormat);
- sp<ABuffer> imageData;
- if (mFormat->findBuffer("image-data", &imageData)) {
- outputFormat->setBuffer("image-data", imageData);
- }
- 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);
- }
+ // Trigger image data processing to the new format
+ mLastImageData.clear();
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());
+ ALOGD("[%s] popFromStashAndRegister: at %lldus, output format changed to %s",
+ mName, (long long)entry.timestamp, outputFormat->debugString().c_str());
setFormat(outputFormat);
}
diff --git a/media/codec2/sfplugin/CCodecBuffers.h b/media/codec2/sfplugin/CCodecBuffers.h
index 7c4e7b1..995d3a4 100644
--- a/media/codec2/sfplugin/CCodecBuffers.h
+++ b/media/codec2/sfplugin/CCodecBuffers.h
@@ -86,6 +86,9 @@
// Format to be used for creating MediaCodec-facing buffers.
sp<AMessage> mFormat;
+ sp<ABuffer> mLastImageData;
+ sp<AMessage> mFormatWithImageData;
+
private:
DISALLOW_EVIL_CONSTRUCTORS(CCodecBuffers);
};
diff --git a/media/codec2/sfplugin/CCodecConfig.h b/media/codec2/sfplugin/CCodecConfig.h
index d9116f7..7e060f6 100644
--- a/media/codec2/sfplugin/CCodecConfig.h
+++ b/media/codec2/sfplugin/CCodecConfig.h
@@ -27,7 +27,6 @@
#include <C2Debug.h>
#include <codec2/hidl/client.h>
-#include <media/stagefright/foundation/ColorUtils.h>
#include <utils/RefBase.h>
#include "InputSurfaceWrapper.h"
@@ -125,7 +124,6 @@
std::shared_ptr<InputSurfaceWrapper> mInputSurface;
std::unique_ptr<InputSurfaceWrapper::Config> mISConfig;
- ColorAspects mClientColorAspects;
/// the current configuration. Updated after configure() and based on configUpdate in
/// onWorkDone
diff --git a/media/codec2/sfplugin/InputSurfaceWrapper.h b/media/codec2/sfplugin/InputSurfaceWrapper.h
index bb7ca02..bb35763 100644
--- a/media/codec2/sfplugin/InputSurfaceWrapper.h
+++ b/media/codec2/sfplugin/InputSurfaceWrapper.h
@@ -106,8 +106,6 @@
*/
virtual void onInputBufferDone(c2_cntr64_t /* index */) {}
- virtual android_dataspace getDataspace() { return mDataSpace; }
-
protected:
android_dataspace mDataSpace;
};
diff --git a/media/libeffects/preprocessing/tests/EffectTestHelper.h b/media/libeffects/preprocessing/tests/EffectTestHelper.h
index db06823..117cf7b 100644
--- a/media/libeffects/preprocessing/tests/EffectTestHelper.h
+++ b/media/libeffects/preprocessing/tests/EffectTestHelper.h
@@ -88,7 +88,8 @@
static constexpr size_t kNumChMasks = std::size(kChMasks);
- static constexpr size_t kSampleRates[] = {8000, 16000, 24000, 32000, 48000};
+ static constexpr size_t kSampleRates[] = {8000, 11025, 12000, 16000, 22050,
+ 24000, 32000, 44100, 48000};
static constexpr size_t kNumSampleRates = std::size(kSampleRates);
diff --git a/media/libeffects/preprocessing/tests/build_and_run_all_unit_tests.sh b/media/libeffects/preprocessing/tests/build_and_run_all_unit_tests.sh
index 942f2ec..35da13e 100755
--- a/media/libeffects/preprocessing/tests/build_and_run_all_unit_tests.sh
+++ b/media/libeffects/preprocessing/tests/build_and_run_all_unit_tests.sh
@@ -59,9 +59,13 @@
fs_arr=(
8000
+ 11025
+ 12000
16000
+ 22050
24000
32000
+ 44100
48000
)