Merge "Transcoder: Added MediaTrackTranscoder and VideoTrackTranscoder"
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..d97975c
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+ license_type: NOTICE
+}
diff --git a/camera/ICameraClient.cpp b/camera/ICameraClient.cpp
index 8620f36..487b8b0 100644
--- a/camera/ICameraClient.cpp
+++ b/camera/ICameraClient.cpp
@@ -143,6 +143,11 @@
if (data.dataAvail() > 0) {
metadata = new camera_frame_metadata_t;
metadata->number_of_faces = data.readInt32();
+ if (metadata->number_of_faces <= 0 ||
+ metadata->number_of_faces > (int32_t)(INT32_MAX / sizeof(camera_face_t))) {
+ ALOGE("%s: Too large face count: %d", __FUNCTION__, metadata->number_of_faces);
+ return BAD_VALUE;
+ }
metadata->faces = (camera_face_t *) data.readInplace(
sizeof(camera_face_t) * metadata->number_of_faces);
}
diff --git a/drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp b/drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp
index ccc73b6..1ce8269 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp
+++ b/drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp
@@ -91,6 +91,19 @@
return Void();
}
+Return<void> DrmFactory::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& /*args*/) {
+ if (fd.getNativeHandle() == nullptr || fd->numFds < 1) {
+ ALOGE("%s: missing fd for writing", __FUNCTION__);
+ return Void();
+ }
+
+ FILE* out = fdopen(dup(fd->data[0]), "w");
+ uint32_t currentSessions = SessionLibrary::get()->numOpenSessions();
+ fprintf(out, "current open sessions: %u\n", currentSessions);
+ fclose(out);
+ return Void();
+}
+
} // namespace clearkey
} // namespace V1_3
} // namespace drm
diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h b/drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h
index 403a8ec..63234cf 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h
+++ b/drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h
@@ -30,6 +30,7 @@
using ::android::hardware::drm::V1_1::SecurityLevel;
using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_handle;
using ::android::hardware::hidl_string;
using ::android::hardware::Return;
@@ -55,6 +56,8 @@
Return<void> getSupportedCryptoSchemes(
getSupportedCryptoSchemes_cb _hidl_cb) override;
+ Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args);
+
private:
CLEARKEY_DISALLOW_COPY_AND_ASSIGN(DrmFactory);
};
diff --git a/media/TEST_MAPPING b/media/TEST_MAPPING
new file mode 100644
index 0000000..206f87f
--- /dev/null
+++ b/media/TEST_MAPPING
@@ -0,0 +1,71 @@
+// for frameworks/av/media
+{
+ "presubmit": [
+ // runs whenever we change something in this tree
+ {
+ "name": "CtsMediaTestCases",
+ "options": [
+ {
+ "include-filter": "android.media.cts.EncodeDecodeTest"
+ }
+ ]
+ },
+ {
+ "name": "CtsMediaTestCases",
+ "options": [
+ {
+ "include-filter": "android.media.cts.DecodeEditEncodeTest"
+ }
+ ]
+ },
+ {
+ "name": "GtsMediaTestCases",
+ "options" : [
+ {
+ "include-annotation": "android.platform.test.annotations.Presubmit"
+ },
+ {
+ "include-filter": "com.google.android.media.gts.WidevineGenericOpsTests"
+ }
+ ]
+ },
+ {
+ "name": "GtsExoPlayerTestCases",
+ "options" : [
+ {
+ "include-annotation": "android.platform.test.annotations.SocPresubmit"
+ },
+ {
+ "include-filter": "com.google.android.exoplayer.gts.DashTest#testWidevine23FpsH264Fixed"
+ }
+ ]
+ }
+ ],
+
+ "imports": [
+ {
+ "path": "frameworks/av/drm/mediadrm/plugins"
+ }
+ ],
+
+ "staged-platinum-postsubmit": [
+ // runs regularly, independent of changes in this tree.
+ // signals if changes elsewhere break media functionality
+ {
+ "name": "CtsMediaTestCases",
+ "options": [
+ {
+ "include-filter": "android.media.cts.EncodeDecodeTest"
+ }
+ ]
+ },
+ {
+ "name": "CtsMediaTestCases",
+ "options": [
+ {
+ "include-filter": "android.media.cts.DecodeEditEncodeTest"
+ }
+ ]
+ }
+ ]
+}
diff --git a/media/codec2/core/Android.bp b/media/codec2/core/Android.bp
index 1f9d7ab..c8c5148 100644
--- a/media/codec2/core/Android.bp
+++ b/media/codec2/core/Android.bp
@@ -19,6 +19,10 @@
"-Werror",
],
+ header_abi_checker: {
+ check_all_apis: true,
+ },
+
header_libs: [
"libcodec2_headers",
"libhardware_headers",
diff --git a/media/codec2/hidl/1.0/vts/functional/component/VtsHalMediaC2V1_0TargetComponentTest.cpp b/media/codec2/hidl/1.0/vts/functional/component/VtsHalMediaC2V1_0TargetComponentTest.cpp
index 119ce14..6122225 100644
--- a/media/codec2/hidl/1.0/vts/functional/component/VtsHalMediaC2V1_0TargetComponentTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/component/VtsHalMediaC2V1_0TargetComponentTest.cpp
@@ -330,7 +330,7 @@
TEST_P(Codec2ComponentInputTests, InputBufferTest) {
description("Tests for different inputs");
- uint32_t flags = std::stol(std::get<2>(GetParam()));
+ uint32_t flags = std::stoul(std::get<2>(GetParam()));
bool isNullBuffer = !std::get<3>(GetParam()).compare("true");
if (isNullBuffer)
ALOGD("Testing for null input buffer with flag : %u", flags);
diff --git a/media/codec2/hidl/client/client.cpp b/media/codec2/hidl/client/client.cpp
index 0acab49..7e4352d 100644
--- a/media/codec2/hidl/client/client.cpp
+++ b/media/codec2/hidl/client/client.cpp
@@ -219,6 +219,7 @@
if (success) {
break;
}
+ invalidate();
using namespace std::chrono_literals;
static constexpr auto kServiceRetryPeriod = 5s;
LOG(INFO) << "Failed to retrieve component traits from service "
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index 6b389d5..e902b5d 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -44,6 +44,7 @@
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/SkipCutBuffer.h>
#include <media/MediaCodecBuffer.h>
+#include <mediadrm/ICrypto.h>
#include <system/window.h>
#include "CCodecBufferChannel.h"
@@ -1084,7 +1085,7 @@
// TODO: handle this without going into array mode
forceArrayMode = true;
} else {
- input->buffers.reset(new GraphicInputBuffers(numInputSlots, mName));
+ input->buffers.reset(new GraphicInputBuffers(mName));
}
} else {
if (hasCryptoOrDescrambler()) {
@@ -1252,7 +1253,7 @@
if (outputSurface || !buffersBoundToCodec) {
output->buffers.reset(new GraphicOutputBuffers(mName));
} else {
- output->buffers.reset(new RawGraphicOutputBuffers(numOutputSlots, mName));
+ output->buffers.reset(new RawGraphicOutputBuffers(mName));
}
} else {
output->buffers.reset(new LinearOutputBuffers(mName));
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index d7cc175..a9120c4 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -23,6 +23,7 @@
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/SkipCutBuffer.h>
+#include <mediadrm/ICrypto.h>
#include "CCodecBuffers.h"
@@ -121,6 +122,11 @@
// OutputBuffers
+OutputBuffers::OutputBuffers(const char *componentName, const char *name)
+ : CCodecBuffers(componentName, name) { }
+
+OutputBuffers::~OutputBuffers() = default;
+
void OutputBuffers::initSkipCutBuffer(
int32_t delay, int32_t padding, int32_t sampleRate, int32_t channelCount) {
CHECK(mSkipCutBuffer == nullptr);
@@ -171,8 +177,11 @@
// LocalBufferPool
-std::shared_ptr<LocalBufferPool> LocalBufferPool::Create(size_t poolCapacity) {
- return std::shared_ptr<LocalBufferPool>(new LocalBufferPool(poolCapacity));
+constexpr size_t kInitialPoolCapacity = kMaxLinearBufferSize;
+constexpr size_t kMaxPoolCapacity = kMaxLinearBufferSize * 32;
+
+std::shared_ptr<LocalBufferPool> LocalBufferPool::Create() {
+ return std::shared_ptr<LocalBufferPool>(new LocalBufferPool(kInitialPoolCapacity));
}
sp<ABuffer> LocalBufferPool::newBuffer(size_t capacity) {
@@ -192,6 +201,11 @@
mUsedSize -= mPool.back().capacity();
mPool.pop_back();
}
+ while (mUsedSize + capacity > mPoolCapacity && mPoolCapacity * 2 <= kMaxPoolCapacity) {
+ ALOGD("Increasing local buffer pool capacity from %zu to %zu",
+ mPoolCapacity, mPoolCapacity * 2);
+ mPoolCapacity *= 2;
+ }
if (mUsedSize + capacity > mPoolCapacity) {
ALOGD("mUsedSize = %zu, capacity = %zu, mPoolCapacity = %zu",
mUsedSize, capacity, mPoolCapacity);
@@ -777,11 +791,10 @@
// GraphicInputBuffers
GraphicInputBuffers::GraphicInputBuffers(
- size_t numInputSlots, const char *componentName, const char *name)
+ const char *componentName, const char *name)
: InputBuffers(componentName, name),
mImpl(mName),
- mLocalBufferPool(LocalBufferPool::Create(
- kMaxLinearBufferSize * numInputSlots)) { }
+ mLocalBufferPool(LocalBufferPool::Create()) { }
bool GraphicInputBuffers::requestNewBuffer(size_t *index, sp<MediaCodecBuffer> *buffer) {
sp<Codec2Buffer> newBuffer = createNewBuffer();
@@ -942,7 +955,7 @@
case C2BufferData::GRAPHIC: {
// This is only called for RawGraphicOutputBuffers.
mAlloc = [format = mFormat,
- lbp = LocalBufferPool::Create(kMaxLinearBufferSize * mImpl.arraySize())] {
+ lbp = LocalBufferPool::Create()] {
return ConstGraphicBlockBuffer::AllocateEmpty(
format,
[lbp](size_t capacity) {
@@ -1079,10 +1092,9 @@
// RawGraphicOutputBuffers
RawGraphicOutputBuffers::RawGraphicOutputBuffers(
- size_t numOutputSlots, const char *componentName, const char *name)
+ const char *componentName, const char *name)
: FlexOutputBuffers(componentName, name),
- mLocalBufferPool(LocalBufferPool::Create(
- kMaxLinearBufferSize * numOutputSlots)) { }
+ mLocalBufferPool(LocalBufferPool::Create()) { }
sp<Codec2Buffer> RawGraphicOutputBuffers::wrap(const std::shared_ptr<C2Buffer> &buffer) {
if (buffer == nullptr) {
diff --git a/media/codec2/sfplugin/CCodecBuffers.h b/media/codec2/sfplugin/CCodecBuffers.h
index 85ca5d5..6244acd 100644
--- a/media/codec2/sfplugin/CCodecBuffers.h
+++ b/media/codec2/sfplugin/CCodecBuffers.h
@@ -28,6 +28,8 @@
namespace android {
+struct ICrypto;
+class MemoryDealer;
class SkipCutBuffer;
constexpr size_t kLinearBufferSize = 1048576;
@@ -156,9 +158,8 @@
class OutputBuffers : public CCodecBuffers {
public:
- OutputBuffers(const char *componentName, const char *name = "Output")
- : CCodecBuffers(componentName, name) { }
- virtual ~OutputBuffers() = default;
+ OutputBuffers(const char *componentName, const char *name = "Output");
+ virtual ~OutputBuffers();
/**
* Register output C2Buffer from the component and obtain corresponding
@@ -243,11 +244,9 @@
/**
* Create a new LocalBufferPool object.
*
- * \param poolCapacity max total size of buffers managed by this pool.
- *
* \return a newly created pool object.
*/
- static std::shared_ptr<LocalBufferPool> Create(size_t poolCapacity);
+ static std::shared_ptr<LocalBufferPool> Create();
/**
* Return an ABuffer object whose size is at least |capacity|.
@@ -679,8 +678,7 @@
class GraphicInputBuffers : public InputBuffers {
public:
- GraphicInputBuffers(
- size_t numInputSlots, const char *componentName, const char *name = "2D-BB-Input");
+ GraphicInputBuffers(const char *componentName, const char *name = "2D-BB-Input");
~GraphicInputBuffers() override = default;
bool requestNewBuffer(size_t *index, sp<MediaCodecBuffer> *buffer) override;
@@ -892,8 +890,7 @@
class RawGraphicOutputBuffers : public FlexOutputBuffers {
public:
- RawGraphicOutputBuffers(
- size_t numOutputSlots, const char *componentName, const char *name = "2D-BB-Output");
+ RawGraphicOutputBuffers(const char *componentName, const char *name = "2D-BB-Output");
~RawGraphicOutputBuffers() override = default;
sp<Codec2Buffer> wrap(const std::shared_ptr<C2Buffer> &buffer) override;
diff --git a/media/codec2/sfplugin/Codec2Buffer.cpp b/media/codec2/sfplugin/Codec2Buffer.cpp
index 5b3a62f..25e7da9 100644
--- a/media/codec2/sfplugin/Codec2Buffer.cpp
+++ b/media/codec2/sfplugin/Codec2Buffer.cpp
@@ -18,6 +18,8 @@
#define LOG_TAG "Codec2Buffer"
#include <utils/Log.h>
+#include <android/hardware/cas/native/1.0/types.h>
+#include <android/hardware/drm/1.0/types.h>
#include <hidlmemory/FrameworkUtils.h>
#include <media/hardware/HardwareAPI.h>
#include <media/stagefright/CodecBase.h>
@@ -25,6 +27,7 @@
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/AUtils.h>
+#include <mediadrm/ICrypto.h>
#include <nativebase/nativebase.h>
#include <ui/Fence.h>
diff --git a/media/codec2/sfplugin/Codec2Buffer.h b/media/codec2/sfplugin/Codec2Buffer.h
index ff79946..dc788cd 100644
--- a/media/codec2/sfplugin/Codec2Buffer.h
+++ b/media/codec2/sfplugin/Codec2Buffer.h
@@ -20,16 +20,29 @@
#include <C2Buffer.h>
-#include <android/hardware/cas/native/1.0/types.h>
-#include <android/hardware/drm/1.0/types.h>
#include <binder/IMemory.h>
#include <media/hardware/VideoAPI.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/MediaCodecBuffer.h>
-#include <mediadrm/ICrypto.h>
namespace android {
+namespace hardware {
+class HidlMemory;
+namespace cas {
+namespace native {
+namespace V1_0 {
+struct SharedBuffer;
+} // namespace V1_0
+} // namespace native
+} // namespace cas
+namespace drm {
+namespace V1_0 {
+struct SharedBuffer;
+} // namespace V1_0
+} // namespace drm
+} // namespace hardware
+
/**
* Copies a graphic view into a media image.
*
diff --git a/media/codec2/sfplugin/tests/Android.bp b/media/codec2/sfplugin/tests/Android.bp
index fe5fa68..8d1a9c3 100644
--- a/media/codec2/sfplugin/tests/Android.bp
+++ b/media/codec2/sfplugin/tests/Android.bp
@@ -2,12 +2,13 @@
name: "ccodec_unit_test",
srcs: [
+ "CCodecBuffers_test.cpp",
"CCodecConfig_test.cpp",
"ReflectedParamUpdater_test.cpp",
],
defaults: [
- "libcodec2-hidl-defaults@1.0",
+ "libcodec2-impl-defaults",
"libcodec2-internal-defaults",
],
@@ -16,14 +17,24 @@
],
shared_libs: [
+ "android.hardware.media.bufferpool@2.0",
+ "android.hardware.media.c2@1.0",
"libcodec2",
"libcodec2_client",
+ "libhidlbase",
+ "libfmq",
+ "libmedia_omx",
"libsfplugin_ccodec",
"libsfplugin_ccodec_utils",
"libstagefright_foundation",
"libutils",
],
+ static_libs: [
+ "libcodec2_hidl@1.0",
+ "libstagefright_bufferpool@2.0",
+ ],
+
cflags: [
"-Werror",
"-Wall",
diff --git a/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp b/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp
new file mode 100644
index 0000000..5bee605
--- /dev/null
+++ b/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CCodecBuffers.h"
+
+#include <gtest/gtest.h>
+
+#include <media/stagefright/MediaCodecConstants.h>
+
+#include <C2PlatformSupport.h>
+
+namespace android {
+
+TEST(RawGraphicOutputBuffersTest, ChangeNumSlots) {
+ constexpr int32_t kWidth = 3840;
+ constexpr int32_t kHeight = 2160;
+
+ std::shared_ptr<RawGraphicOutputBuffers> buffers =
+ std::make_shared<RawGraphicOutputBuffers>("test");
+ sp<AMessage> format{new AMessage};
+ format->setInt32("width", kWidth);
+ format->setInt32("height", kHeight);
+ buffers->setFormat(format);
+
+ std::shared_ptr<C2BlockPool> pool;
+ ASSERT_EQ(OK, GetCodec2BlockPool(C2BlockPool::BASIC_GRAPHIC, nullptr, &pool));
+
+ // Register 4 buffers
+ std::vector<sp<MediaCodecBuffer>> clientBuffers;
+ auto registerBuffer = [&buffers, &clientBuffers, &pool] {
+ std::shared_ptr<C2GraphicBlock> block;
+ ASSERT_EQ(OK, pool->fetchGraphicBlock(
+ kWidth, kHeight, HAL_PIXEL_FORMAT_YCbCr_420_888,
+ C2MemoryUsage{C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}, &block));
+ std::shared_ptr<C2Buffer> c2Buffer = C2Buffer::CreateGraphicBuffer(block->share(
+ block->crop(), C2Fence{}));
+ size_t index;
+ sp<MediaCodecBuffer> clientBuffer;
+ ASSERT_EQ(OK, buffers->registerBuffer(c2Buffer, &index, &clientBuffer));
+ ASSERT_NE(nullptr, clientBuffer);
+ while (clientBuffers.size() <= index) {
+ clientBuffers.emplace_back();
+ }
+ ASSERT_EQ(nullptr, clientBuffers[index]) << "index = " << index;
+ clientBuffers[index] = clientBuffer;
+ };
+ for (int i = 0; i < 4; ++i) {
+ registerBuffer();
+ }
+
+ // Release 2 buffers
+ auto releaseBuffer = [&buffers, &clientBuffers, kWidth, kHeight](int index) {
+ std::shared_ptr<C2Buffer> c2Buffer;
+ ASSERT_TRUE(buffers->releaseBuffer(clientBuffers[index], &c2Buffer))
+ << "index = " << index;
+ clientBuffers[index] = nullptr;
+ // Sanity checks
+ ASSERT_TRUE(c2Buffer->data().linearBlocks().empty());
+ ASSERT_EQ(1u, c2Buffer->data().graphicBlocks().size());
+ C2ConstGraphicBlock block = c2Buffer->data().graphicBlocks().front();
+ ASSERT_EQ(kWidth, block.width());
+ ASSERT_EQ(kHeight, block.height());
+ };
+ for (int i = 0, index = 0; i < 2 && index < clientBuffers.size(); ++index) {
+ if (clientBuffers[index] == nullptr) {
+ continue;
+ }
+ releaseBuffer(index);
+ ++i;
+ }
+
+ // Simulate # of slots 4->16
+ for (int i = 2; i < 16; ++i) {
+ registerBuffer();
+ }
+
+ // Release everything
+ for (int index = 0; index < clientBuffers.size(); ++index) {
+ if (clientBuffers[index] == nullptr) {
+ continue;
+ }
+ releaseBuffer(index);
+ }
+}
+
+} // namespace android
diff --git a/media/codec2/vndk/C2AllocatorGralloc.cpp b/media/codec2/vndk/C2AllocatorGralloc.cpp
index 3ac3d89..e1e1377 100644
--- a/media/codec2/vndk/C2AllocatorGralloc.cpp
+++ b/media/codec2/vndk/C2AllocatorGralloc.cpp
@@ -520,6 +520,22 @@
break;
}
+ case static_cast<uint32_t>(PixelFormat4::BLOB): {
+ void *pointer = nullptr;
+ // TODO: fence
+ status_t err = GraphicBufferMapper::get().lock(
+ const_cast<native_handle_t*>(mBuffer), grallocUsage,
+ { (int32_t)rect.left, (int32_t)rect.top,
+ (int32_t)rect.width, (int32_t)rect.height },
+ &pointer);
+ if (err) {
+ ALOGE("failed transaction: lock(BLOB)");
+ return C2_CORRUPTED;
+ }
+ *addr = (uint8_t *)pointer;
+ break;
+ }
+
case static_cast<uint32_t>(PixelFormat4::YCBCR_420_888):
// fall-through
case static_cast<uint32_t>(PixelFormat4::YV12):
diff --git a/media/extractors/TEST_MAPPING b/media/extractors/TEST_MAPPING
new file mode 100644
index 0000000..5c90a70
--- /dev/null
+++ b/media/extractors/TEST_MAPPING
@@ -0,0 +1,7 @@
+// frameworks/av/media/extractors
+{
+ "presubmit": [
+ // b/148094059: unit tests not allowed to download content
+ //{ "name": "ExtractorUnitTest" }
+ ]
+}
diff --git a/media/extractors/fuzzers/Android.bp b/media/extractors/fuzzers/Android.bp
index 81fa29a..5cae39d 100644
--- a/media/extractors/fuzzers/Android.bp
+++ b/media/extractors/fuzzers/Android.bp
@@ -110,3 +110,58 @@
"libbase",
],
}
+
+cc_fuzz {
+ name: "mp3_extractor_fuzzer",
+
+ srcs: [
+ "mp3_extractor_fuzzer.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/extractors/mp3",
+ ],
+
+ static_libs: [
+ "liblog",
+ "libstagefright_foundation",
+ "libmedia",
+ "libextractorfuzzerbase",
+ "libfifo",
+ "libmp3extractor",
+ "libstagefright_id3",
+ ],
+
+ shared_libs: [
+ "libutils",
+ "libmediandk",
+ "libbinder",
+ ],
+}
+
+cc_fuzz {
+ name: "aac_extractor_fuzzer",
+
+ srcs: [
+ "aac_extractor_fuzzer.cpp",
+ ],
+
+ include_dirs: [
+ "frameworks/av/media/extractors/aac",
+ ],
+
+ static_libs: [
+ "liblog",
+ "libstagefright_foundation",
+ "libmedia",
+ "libextractorfuzzerbase",
+ "libaacextractor",
+ "libstagefright_metadatautils",
+ ],
+
+ shared_libs: [
+ "libutils",
+ "libmediandk",
+ "libbinder",
+ ],
+}
diff --git a/media/extractors/fuzzers/README.md b/media/extractors/fuzzers/README.md
index 5f95075..f09e1c2 100644
--- a/media/extractors/fuzzers/README.md
+++ b/media/extractors/fuzzers/README.md
@@ -1,9 +1,11 @@
# Fuzzer for extractors
## Table of contents
-1. [libextractorfuzzerbase](#ExtractorFuzzerBase)
-2. [libmp4extractor](#mp4ExtractorFuzzer)
-3. [libwavextractor](#wavExtractorFuzzer)
++ [libextractorfuzzerbase](#ExtractorFuzzerBase)
++ [libmp4extractor](#mp4ExtractorFuzzer)
++ [libwavextractor](#wavExtractorFuzzer)
++ [libmp3extractor](#mp3ExtractorFuzzer)
++ [libaacextractor](#aacExtractorFuzzer)
# <a name="ExtractorFuzzerBase"></a> Fuzzer for libextractorfuzzerbase
All the extractors have a common API - creating a data source, extraction
@@ -79,6 +81,64 @@
$ adb shell /data/fuzz/arm64/wav_extractor_fuzzer/wav_extractor_fuzzer CORPUS_DIR
```
+# <a name="mp3ExtractorFuzzer"></a> Fuzzer for libmp3extractor
+
+## Plugin Design Considerations
+The fuzzer plugin for MP3 extractor uses the `ExtractorFuzzerBase` class and
+implements only the `createExtractor` to create the MP3 extractor class.
+
+
+## Build
+
+This describes steps to build mp3_extractor_fuzzer binary.
+
+### Android
+
+#### Steps to build
+Build the fuzzer
+```
+ $ mm -j$(nproc) mp3_extractor_fuzzer
+```
+
+#### Steps to run
+Create a directory CORPUS_DIR and copy some mp3 files to that folder
+Push this directory to device.
+
+To run on device
+```
+ $ adb sync data
+ $ adb shell /data/fuzz/arm64/mp3_extractor_fuzzer/mp3_extractor_fuzzer CORPUS_DIR
+```
+
+# <a name="aacExtractorFuzzer"></a> Fuzzer for libaacextractor
+
+## Plugin Design Considerations
+The fuzzer plugin for AAC extractor uses the `ExtractorFuzzerBase` class and
+implements only the `createExtractor` to create the AAC extractor class.
+
+
+## Build
+
+This describes steps to build aac_extractor_fuzzer binary.
+
+### Android
+
+#### Steps to build
+Build the fuzzer
+```
+ $ mm -j$(nproc) aac_extractor_fuzzer
+```
+
+#### Steps to run
+Create a directory CORPUS_DIR and copy some aac files to that folder
+Push this directory to device.
+
+To run on device
+```
+ $ adb sync data
+ $ adb shell /data/fuzz/arm64/aac_extractor_fuzzer/aac_extractor_fuzzer CORPUS_DIR
+```
+
## References:
* http://llvm.org/docs/LibFuzzer.html
* https://github.com/google/oss-fuzz
diff --git a/media/extractors/fuzzers/aac_extractor_fuzzer.cpp b/media/extractors/fuzzers/aac_extractor_fuzzer.cpp
new file mode 100644
index 0000000..93665f0
--- /dev/null
+++ b/media/extractors/fuzzers/aac_extractor_fuzzer.cpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *****************************************************************************
+ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
+ */
+
+#include "AACExtractor.h"
+
+#include "ExtractorFuzzerBase.h"
+
+using namespace android;
+
+class AacExtractor : public ExtractorFuzzerBase {
+ public:
+ AacExtractor() = default;
+ ~AacExtractor() = default;
+
+ bool createExtractor();
+};
+
+bool AacExtractor::createExtractor() {
+ mExtractor = new AACExtractor(new DataSourceHelper(mDataSource->wrap()), 0);
+ if (!mExtractor) {
+ return false;
+ }
+ mExtractor->name();
+ return true;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ if ((!data) || (size == 0)) {
+ return 0;
+ }
+ AacExtractor* extractor = new AacExtractor();
+ if (!extractor) {
+ return 0;
+ }
+ if (extractor->setDataSource(data, size)) {
+ if (extractor->createExtractor()) {
+ extractor->getExtractorDef();
+ extractor->getMetadata();
+ extractor->extractTracks();
+ extractor->getTracksMetadata();
+ }
+ }
+ delete extractor;
+ return 0;
+}
diff --git a/media/extractors/fuzzers/mp3_extractor_fuzzer.cpp b/media/extractors/fuzzers/mp3_extractor_fuzzer.cpp
new file mode 100644
index 0000000..71c154b
--- /dev/null
+++ b/media/extractors/fuzzers/mp3_extractor_fuzzer.cpp
@@ -0,0 +1,62 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *****************************************************************************
+ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
+ */
+
+#include "ExtractorFuzzerBase.h"
+
+#include "MP3Extractor.h"
+
+using namespace android;
+
+class Mp3Extractor : public ExtractorFuzzerBase {
+ public:
+ Mp3Extractor() = default;
+ ~Mp3Extractor() = default;
+
+ bool createExtractor();
+};
+
+bool Mp3Extractor::createExtractor() {
+ mExtractor = new MP3Extractor(new DataSourceHelper(mDataSource->wrap()), nullptr);
+ if (!mExtractor) {
+ return false;
+ }
+ mExtractor->name();
+ return true;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ if ((!data) || (size == 0)) {
+ return 0;
+ }
+ Mp3Extractor* extractor = new Mp3Extractor();
+ if (!extractor) {
+ return 0;
+ }
+ if (extractor->setDataSource(data, size)) {
+ if (extractor->createExtractor()) {
+ extractor->getExtractorDef();
+ extractor->getMetadata();
+ extractor->extractTracks();
+ extractor->getTracksMetadata();
+ }
+ }
+ delete extractor;
+ return 0;
+}
diff --git a/media/extractors/midi/Android.bp b/media/extractors/midi/Android.bp
index bdb724b..b8255fc 100644
--- a/media/extractors/midi/Android.bp
+++ b/media/extractors/midi/Android.bp
@@ -10,7 +10,7 @@
static_libs: [
"libmedia_midiiowrapper",
- "libsonivox",
+ "libsonivoxwithoutjet",
"libstagefright_foundation",
"libwatchdog",
],
diff --git a/media/extractors/tests/Android.bp b/media/extractors/tests/Android.bp
index fa39b64..0bca6f5 100644
--- a/media/extractors/tests/Android.bp
+++ b/media/extractors/tests/Android.bp
@@ -17,6 +17,7 @@
cc_test {
name: "ExtractorUnitTest",
gtest: true,
+ test_suites: ["device-tests"],
srcs: ["ExtractorUnitTest.cpp"],
@@ -45,7 +46,7 @@
"libstagefright_metadatautils",
"libmedia_midiiowrapper",
- "libsonivox",
+ "libsonivoxwithoutjet",
"libvorbisidec",
"libwebm",
"libFLAC",
diff --git a/media/libaaudio/include/aaudio/AAudio.h b/media/libaaudio/include/aaudio/AAudio.h
index edc09a9..a47f189 100644
--- a/media/libaaudio/include/aaudio/AAudio.h
+++ b/media/libaaudio/include/aaudio/AAudio.h
@@ -406,6 +406,7 @@
* Use this preset for capturing audio meant to be processed in real time
* and played back for live performance (e.g karaoke).
* The capture path will minimize latency and coupling with playback path.
+ * Available since API level 29.
*/
AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE = 10,
};
diff --git a/media/libaaudio/src/core/AudioStream.cpp b/media/libaaudio/src/core/AudioStream.cpp
index 17d389e..0644368 100644
--- a/media/libaaudio/src/core/AudioStream.cpp
+++ b/media/libaaudio/src/core/AudioStream.cpp
@@ -106,21 +106,23 @@
}
void AudioStream::logOpen() {
- LOG_ALWAYS_FATAL_IF(mMetricsId.size() == 0, "mMetricsId is empty!");
- android::mediametrics::LogItem(mMetricsId)
- .set(AMEDIAMETRICS_PROP_PERFORMANCEMODE,
- AudioGlobal_convertPerformanceModeToText(getPerformanceMode()))
- .set(AMEDIAMETRICS_PROP_SHARINGMODE,
- AudioGlobal_convertSharingModeToText(getSharingMode()))
- .record();
+ if (mMetricsId.size() > 0) {
+ android::mediametrics::LogItem(mMetricsId)
+ .set(AMEDIAMETRICS_PROP_PERFORMANCEMODE,
+ AudioGlobal_convertPerformanceModeToText(getPerformanceMode()))
+ .set(AMEDIAMETRICS_PROP_SHARINGMODE,
+ AudioGlobal_convertSharingModeToText(getSharingMode()))
+ .record();
+ }
}
void AudioStream::logBufferState() {
- LOG_ALWAYS_FATAL_IF(mMetricsId.size() == 0, "mMetricsId is empty!");
- android::mediametrics::LogItem(mMetricsId)
- .set(AMEDIAMETRICS_PROP_BUFFERSIZEFRAMES, (int32_t) getBufferSize())
- .set(AMEDIAMETRICS_PROP_UNDERRUN, (int32_t) getXRunCount())
- .record();
+ if (mMetricsId.size() > 0) {
+ android::mediametrics::LogItem(mMetricsId)
+ .set(AMEDIAMETRICS_PROP_BUFFERSIZEFRAMES, (int32_t) getBufferSize())
+ .set(AMEDIAMETRICS_PROP_UNDERRUN, (int32_t) getXRunCount())
+ .record();
+ }
}
aaudio_result_t AudioStream::systemStart() {
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.h b/media/libaaudio/src/legacy/AudioStreamLegacy.h
index da9205f..9c24b2b 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.h
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.h
@@ -128,6 +128,10 @@
return mFramesRead.increment(frames);
}
+ // This is used for exact matching by MediaMetrics. So do not change it.
+ // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_AAUDIO
+ static constexpr char kCallerName[] = "aaudio";
+
MonotonicCounter mFramesWritten;
MonotonicCounter mFramesRead;
MonotonicCounter mTimestampPosition;
@@ -139,6 +143,7 @@
const android::sp<StreamDeviceCallback> mDeviceCallback;
AtomicRequestor mRequestDisconnect;
+
};
} /* namespace aaudio */
diff --git a/media/libaaudio/src/legacy/AudioStreamRecord.cpp b/media/libaaudio/src/legacy/AudioStreamRecord.cpp
index eeb45e1..853c0db 100644
--- a/media/libaaudio/src/legacy/AudioStreamRecord.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamRecord.cpp
@@ -179,6 +179,9 @@
selectedDeviceId
);
+ // Set it here so it can be logged by the destructor if the open failed.
+ mAudioRecord->setCallerName(kCallerName);
+
// Did we get a valid track?
status_t status = mAudioRecord->initCheck();
if (status != OK) {
diff --git a/media/libaaudio/src/legacy/AudioStreamTrack.cpp b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
index 2bdc26b..1120f05 100644
--- a/media/libaaudio/src/legacy/AudioStreamTrack.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
@@ -173,6 +173,9 @@
selectedDeviceId
);
+ // Set it here so it can be logged by the destructor if the open failed.
+ mAudioTrack->setCallerName(kCallerName);
+
// Did we get a valid track?
status_t status = mAudioTrack->initCheck();
if (status != NO_ERROR) {
diff --git a/media/libaudioclient/AudioRecord.cpp b/media/libaudioclient/AudioRecord.cpp
index fc50e07..0bbceef 100644
--- a/media/libaudioclient/AudioRecord.cpp
+++ b/media/libaudioclient/AudioRecord.cpp
@@ -170,6 +170,10 @@
mediametrics::LogItem(mMetricsId)
.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR)
+ .set(AMEDIAMETRICS_PROP_CALLERNAME,
+ mCallerName.empty()
+ ? AMEDIAMETRICS_PROP_CALLERNAME_VALUE_UNKNOWN
+ : mCallerName.c_str())
.set(AMEDIAMETRICS_PROP_STATUS, (int32_t)mStatus)
.record();
@@ -396,6 +400,10 @@
status_t status = NO_ERROR;
mediametrics::Defer defer([&] {
mediametrics::LogItem(mMetricsId)
+ .set(AMEDIAMETRICS_PROP_CALLERNAME,
+ mCallerName.empty()
+ ? AMEDIAMETRICS_PROP_CALLERNAME_VALUE_UNKNOWN
+ : mCallerName.c_str())
.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_START)
.set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs))
.set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive))
diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp
index cd1a847..ca80dc4 100644
--- a/media/libaudioclient/AudioTrack.cpp
+++ b/media/libaudioclient/AudioTrack.cpp
@@ -301,6 +301,10 @@
mediametrics::LogItem(mMetricsId)
.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR)
+ .set(AMEDIAMETRICS_PROP_CALLERNAME,
+ mCallerName.empty()
+ ? AMEDIAMETRICS_PROP_CALLERNAME_VALUE_UNKNOWN
+ : mCallerName.c_str())
.set(AMEDIAMETRICS_PROP_STATE, stateToString(mState))
.set(AMEDIAMETRICS_PROP_STATUS, (int32_t)mStatus)
.record();
@@ -641,6 +645,10 @@
status_t status = NO_ERROR; // logged: make sure to set this before returning.
mediametrics::Defer defer([&] {
mediametrics::LogItem(mMetricsId)
+ .set(AMEDIAMETRICS_PROP_CALLERNAME,
+ mCallerName.empty()
+ ? AMEDIAMETRICS_PROP_CALLERNAME_VALUE_UNKNOWN
+ : mCallerName.c_str())
.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_START)
.set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs))
.set(AMEDIAMETRICS_PROP_STATE, stateToString(mState))
@@ -875,7 +883,7 @@
{
const int64_t beginNs = systemTime();
AutoMutex lock(mLock);
- mediametrics::Defer([&]() {
+ mediametrics::Defer defer([&]() {
mediametrics::LogItem(mMetricsId)
.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE)
.set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs))
@@ -2429,7 +2437,7 @@
{
status_t result = NO_ERROR; // logged: make sure to set this before returning.
const int64_t beginNs = systemTime();
- mediametrics::Defer([&] {
+ mediametrics::Defer defer([&] {
mediametrics::LogItem(mMetricsId)
.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE)
.set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs))
diff --git a/media/libaudioclient/ToneGenerator.cpp b/media/libaudioclient/ToneGenerator.cpp
index 536b00d..050ad65 100644
--- a/media/libaudioclient/ToneGenerator.cpp
+++ b/media/libaudioclient/ToneGenerator.cpp
@@ -1262,7 +1262,9 @@
AUDIO_UID_INVALID,
-1,
&attr);
-
+ // Set caller name so it can be logged in destructor.
+ // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_TONEGENERATOR
+ mpAudioTrack->setCallerName("tonegenerator");
if (status != NO_ERROR) {
ALOGE("AudioTrack(%p) set failed with error %d", mpAudioTrack.get(), status);
mpAudioTrack.clear();
diff --git a/media/libaudioclient/include/media/AudioRecord.h b/media/libaudioclient/include/media/AudioRecord.h
index b3c1cdf..2f66658 100644
--- a/media/libaudioclient/include/media/AudioRecord.h
+++ b/media/libaudioclient/include/media/AudioRecord.h
@@ -277,6 +277,19 @@
*/
status_t getMetrics(mediametrics::Item * &item);
+ /*
+ * Set name of API that is using this object.
+ * For example "aaudio" or "opensles".
+ * This may be logged or reported as part of MediaMetrics.
+ */
+ void setCallerName(const std::string &name) {
+ mCallerName = name;
+ }
+
+ std::string getCallerName() const {
+ return mCallerName;
+ };
+
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
* If event is not AudioSystem::SYNC_EVENT_NONE, the capture start will be delayed until
@@ -776,6 +789,7 @@
};
MediaMetrics mMediaMetrics;
std::string mMetricsId; // GUARDED_BY(mLock), could change in createRecord_l().
+ std::string mCallerName; // for example "aaudio"
};
}; // namespace android
diff --git a/media/libaudioclient/include/media/AudioTrack.h b/media/libaudioclient/include/media/AudioTrack.h
index 30abbb1..17af7d4 100644
--- a/media/libaudioclient/include/media/AudioTrack.h
+++ b/media/libaudioclient/include/media/AudioTrack.h
@@ -410,6 +410,19 @@
*/
status_t getMetrics(mediametrics::Item * &item);
+ /*
+ * Set name of API that is using this object.
+ * For example "aaudio" or "opensles".
+ * This may be logged or reported as part of MediaMetrics.
+ */
+ void setCallerName(const std::string &name) {
+ mCallerName = name;
+ }
+
+ std::string getCallerName() const {
+ return mCallerName;
+ };
+
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
* If the track was previously paused, volume is ramped up over the first mix buffer.
@@ -1259,6 +1272,7 @@
};
MediaMetrics mMediaMetrics;
std::string mMetricsId; // GUARDED_BY(mLock), could change in createTrack_l().
+ std::string mCallerName; // for example "aaudio"
void logBufferSizeUnderruns();
diff --git a/media/libmedia/Android.bp b/media/libmedia/Android.bp
index 217209d..f888752 100644
--- a/media/libmedia/Android.bp
+++ b/media/libmedia/Android.bp
@@ -187,7 +187,7 @@
srcs: ["MidiIoWrapper.cpp"],
static_libs: [
- "libsonivox",
+ "libsonivoxwithoutjet",
],
header_libs: [
@@ -314,7 +314,7 @@
"libutils",
"libbinder",
"libbinder_ndk",
- "libsonivox",
+ //"libsonivox",
"libandroidicu",
"libexpat",
"libcamera_client",
@@ -330,7 +330,7 @@
"libaudioclient",
"libbinder",
"libandroidicu",
- "libsonivox",
+ //"libsonivox",
"libmedia_omx",
],
diff --git a/media/libmedia/aidl/android/media/IResourceManagerService.aidl b/media/libmedia/aidl/android/media/IResourceManagerService.aidl
index 3dd0859..1b2d522 100644
--- a/media/libmedia/aidl/android/media/IResourceManagerService.aidl
+++ b/media/libmedia/aidl/android/media/IResourceManagerService.aidl
@@ -94,4 +94,12 @@
* remove existing override on originalPid if newPid is -1.
*/
void overridePid(int originalPid, int newPid);
+
+ /**
+ * Mark a client for pending removal
+ *
+ * @param pid pid from which the client's resources will be removed.
+ * @param clientId clientId within the pid that will be removed.
+ */
+ void markClientForPendingRemoval(int pid, long clientId);
}
diff --git a/media/libmediametrics/include/MediaMetricsConstants.h b/media/libmediametrics/include/MediaMetricsConstants.h
index 73dd2de..00da69a 100644
--- a/media/libmediametrics/include/MediaMetricsConstants.h
+++ b/media/libmediametrics/include/MediaMetricsConstants.h
@@ -86,10 +86,12 @@
// of suppressed in the Time Machine.
#define AMEDIAMETRICS_PROP_SUFFIX_CHAR_DUPLICATES_ALLOWED '#'
+#define AMEDIAMETRICS_PROP_ALLOWUID "_allowUid" // int32_t, allow client uid to post
#define AMEDIAMETRICS_PROP_AUXEFFECTID "auxEffectId" // int32 (AudioTrack)
#define AMEDIAMETRICS_PROP_BUFFERSIZEFRAMES "bufferSizeFrames" // int32
#define AMEDIAMETRICS_PROP_BUFFERCAPACITYFRAMES "bufferCapacityFrames" // int32
#define AMEDIAMETRICS_PROP_BURSTFRAMES "burstFrames" // int32
+#define AMEDIAMETRICS_PROP_CALLERNAME "callerName" // string, eg. "aaudio"
#define AMEDIAMETRICS_PROP_CHANNELCOUNT "channelCount" // int32
#define AMEDIAMETRICS_PROP_CHANNELMASK "channelMask" // int32
#define AMEDIAMETRICS_PROP_CONTENTTYPE "contentType" // string attributes (AudioTrack)
@@ -156,4 +158,16 @@
#define AMEDIAMETRICS_PROP_EVENT_VALUE_STOP "stop" // AudioTrack, AudioRecord
#define AMEDIAMETRICS_PROP_EVENT_VALUE_UNDERRUN "underrun" // from Thread
+// Possible values for AMEDIAMETRICS_PROP_CALLERNAME
+// Check within the framework for these strings as this header file may not be explicitly
+// included to avoid unnecessary cross-project dependencies.
+#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_AAUDIO "aaudio" // Native AAudio
+#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_JAVA "java" // Java API layer
+#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_MEDIA "media" // libmedia
+#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_OPENSLES "opensles" // Open SLES
+#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_RTP "rtp" // RTP communication
+#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL "soundpool" // SoundPool
+#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_TONEGENERATOR "tonegenerator" // dial tones
+#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_UNKNOWN "unknown" // callerName not set
+
#endif // ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H
diff --git a/media/libmediaplayerservice/Android.bp b/media/libmediaplayerservice/Android.bp
index 902d846..324f4ae 100644
--- a/media/libmediaplayerservice/Android.bp
+++ b/media/libmediaplayerservice/Android.bp
@@ -16,7 +16,6 @@
"android.hardware.media.c2@1.0",
"android.hardware.media.omx@1.0",
"libbase",
- "libandroid",
"libandroid_net",
"libaudioclient",
"libbinder",
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index b7313b5..555f459 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -2217,7 +2217,9 @@
targetSpeed,
mSelectedDeviceId);
}
-
+ // Set caller name so it can be logged in destructor.
+ // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_MEDIA
+ t->setCallerName("media");
if ((t == 0) || (t->initCheck() != NO_ERROR)) {
ALOGE("Unable to create audio track");
delete newcbd;
diff --git a/media/libmediaplayerservice/nuplayer/Android.bp b/media/libmediaplayerservice/nuplayer/Android.bp
index 7206eab..f5e44c7 100644
--- a/media/libmediaplayerservice/nuplayer/Android.bp
+++ b/media/libmediaplayerservice/nuplayer/Android.bp
@@ -48,8 +48,6 @@
},
shared_libs: [
- "libandroid",
- "libandroid_net",
"libbinder",
"libdatasource",
"libui",
diff --git a/media/libmediatranscoding/TranscodingClientManager.cpp b/media/libmediatranscoding/TranscodingClientManager.cpp
index bfa08a2..6bc8613 100644
--- a/media/libmediatranscoding/TranscodingClientManager.cpp
+++ b/media/libmediatranscoding/TranscodingClientManager.cpp
@@ -99,7 +99,7 @@
int32_t jobId = mNextJobId.fetch_add(1);
*_aidl_return =
- mOwner->mJobScheduler->submit(mClientId, jobId, mClientPid, in_request,
+ mOwner->mJobScheduler->submit(mClientId, jobId, mClientUid, in_request,
ITranscodingClientCallback::fromBinder(mClientCallback));
if (*_aidl_return) {
diff --git a/media/libmediatranscoding/TranscodingJobScheduler.cpp b/media/libmediatranscoding/TranscodingJobScheduler.cpp
index 9dd070c..6e235c6 100644
--- a/media/libmediatranscoding/TranscodingJobScheduler.cpp
+++ b/media/libmediatranscoding/TranscodingJobScheduler.cpp
@@ -27,7 +27,7 @@
namespace android {
-constexpr static pid_t OFFLINE_PID = -1;
+constexpr static uid_t OFFLINE_UID = -1;
//static
String8 TranscodingJobScheduler::jobToString(const JobKeyType& jobKey) {
@@ -36,12 +36,12 @@
TranscodingJobScheduler::TranscodingJobScheduler(
const std::shared_ptr<TranscoderInterface>& transcoder,
- const std::shared_ptr<ProcessInfoInterface>& procInfo)
- : mTranscoder(transcoder), mProcInfo(procInfo), mCurrentJob(nullptr), mResourceLost(false) {
+ const std::shared_ptr<UidPolicyInterface>& uidPolicy)
+ : mTranscoder(transcoder), mUidPolicy(uidPolicy), mCurrentJob(nullptr), mResourceLost(false) {
// Only push empty offline queue initially. Realtime queues are added when requests come in.
- mPidSortedList.push_back(OFFLINE_PID);
- mOfflinePidIterator = mPidSortedList.begin();
- mJobQueues.emplace(OFFLINE_PID, JobQueueType());
+ mUidSortedList.push_back(OFFLINE_UID);
+ mOfflineUidIterator = mUidSortedList.begin();
+ mJobQueues.emplace(OFFLINE_UID, JobQueueType());
}
TranscodingJobScheduler::~TranscodingJobScheduler() {}
@@ -50,8 +50,8 @@
if (mJobMap.empty()) {
return nullptr;
}
- pid_t topPid = *mPidSortedList.begin();
- JobKeyType topJobKey = *mJobQueues[topPid].begin();
+ uid_t topUid = *mUidSortedList.begin();
+ JobKeyType topJobKey = *mJobQueues[topUid].begin();
return &mJobMap[topJobKey];
}
@@ -92,20 +92,20 @@
return;
}
- // Remove job from pid's queue.
- const pid_t pid = mJobMap[jobKey].pid;
- JobQueueType& jobQueue = mJobQueues[pid];
+ // Remove job from uid's queue.
+ const uid_t uid = mJobMap[jobKey].uid;
+ JobQueueType& jobQueue = mJobQueues[uid];
auto it = std::find(jobQueue.begin(), jobQueue.end(), jobKey);
if (it == jobQueue.end()) {
- ALOGE("couldn't find job %s in queue for pid %d", jobToString(jobKey).c_str(), pid);
+ ALOGE("couldn't find job %s in queue for uid %d", jobToString(jobKey).c_str(), uid);
return;
}
jobQueue.erase(it);
- // If this is the last job in a real-time queue, remove this pid's queue.
- if (pid != OFFLINE_PID && jobQueue.empty()) {
- mPidSortedList.remove(pid);
- mJobQueues.erase(pid);
+ // If this is the last job in a real-time queue, remove this uid's queue.
+ if (uid != OFFLINE_UID && jobQueue.empty()) {
+ mUidSortedList.remove(uid);
+ mJobQueues.erase(uid);
}
// Clear current job.
@@ -117,12 +117,12 @@
mJobMap.erase(jobKey);
}
-bool TranscodingJobScheduler::submit(ClientIdType clientId, int32_t jobId, pid_t pid,
+bool TranscodingJobScheduler::submit(ClientIdType clientId, int32_t jobId, uid_t uid,
const TranscodingRequestParcel& request,
const std::weak_ptr<ITranscodingClientCallback>& callback) {
JobKeyType jobKey = std::make_pair(clientId, jobId);
- ALOGV("%s: job %s, pid %d, prioirty %d", __FUNCTION__, jobToString(jobKey).c_str(), pid,
+ ALOGV("%s: job %s, uid %d, prioirty %d", __FUNCTION__, jobToString(jobKey).c_str(), uid,
(int32_t)request.priority);
std::scoped_lock lock{mLock};
@@ -135,37 +135,37 @@
// TODO(chz): only support offline vs real-time for now. All kUnspecified jobs
// go to offline queue.
if (request.priority == TranscodingJobPriority::kUnspecified) {
- pid = OFFLINE_PID;
+ uid = OFFLINE_UID;
}
// Add job to job map.
mJobMap[jobKey].key = jobKey;
- mJobMap[jobKey].pid = pid;
+ mJobMap[jobKey].uid = uid;
mJobMap[jobKey].state = Job::NOT_STARTED;
mJobMap[jobKey].request = request;
mJobMap[jobKey].callback = callback;
// If it's an offline job, the queue was already added in constructor.
- // If it's a real-time jobs, check if a queue is already present for the pid,
+ // If it's a real-time jobs, check if a queue is already present for the uid,
// and add a new queue if needed.
- if (pid != OFFLINE_PID) {
- if (mJobQueues.count(pid) == 0) {
- if (mProcInfo->isProcessOnTop(pid)) {
- mPidSortedList.push_front(pid);
+ if (uid != OFFLINE_UID) {
+ if (mJobQueues.count(uid) == 0) {
+ if (mUidPolicy->isUidOnTop(uid)) {
+ mUidSortedList.push_front(uid);
} else {
// Shouldn't be submitting real-time requests from non-top app,
// put it in front of the offline queue.
- mPidSortedList.insert(mOfflinePidIterator, pid);
+ mUidSortedList.insert(mOfflineUidIterator, uid);
}
- } else if (pid != *mPidSortedList.begin()) {
- if (mProcInfo->isProcessOnTop(pid)) {
- mPidSortedList.remove(pid);
- mPidSortedList.push_front(pid);
+ } else if (uid != *mUidSortedList.begin()) {
+ if (mUidPolicy->isUidOnTop(uid)) {
+ mUidSortedList.remove(uid);
+ mUidSortedList.push_front(uid);
}
}
}
- // Append this job to the pid's queue.
- mJobQueues[pid].push_back(jobKey);
+ // Append this job to the uid's queue.
+ mJobQueues[uid].push_back(jobKey);
updateCurrentJob_l();
@@ -302,28 +302,28 @@
validateState_l();
}
-void TranscodingJobScheduler::onTopProcessChanged(pid_t pid) {
- ALOGV("%s: pid %d", __FUNCTION__, pid);
+void TranscodingJobScheduler::onTopUidChanged(uid_t uid) {
+ ALOGV("%s: uid %d", __FUNCTION__, uid);
std::scoped_lock lock{mLock};
- if (pid < 0) {
- ALOGW("bringProcessToTop: ignoring invalid pid %d", pid);
+ if (uid == OFFLINE_UID) {
+ ALOGW("%s: ignoring invalid uid %d", __FUNCTION__, uid);
return;
}
- // If this pid doesn't have any jobs, we don't care about it.
- if (mJobQueues.count(pid) == 0) {
- ALOGW("bringProcessToTop: ignoring pid %d without any jobs", pid);
+ // If this uid doesn't have any jobs, we don't care about it.
+ if (mJobQueues.count(uid) == 0) {
+ ALOGW("%s: ignoring uid %d without any jobs", __FUNCTION__, uid);
return;
}
- // If this pid is already top, don't do anything.
- if (pid == *mPidSortedList.begin()) {
- ALOGW("pid %d is already top", pid);
+ // If this uid is already top, don't do anything.
+ if (uid == *mUidSortedList.begin()) {
+ ALOGW("%s: uid %d is already top", __FUNCTION__, uid);
return;
}
- mPidSortedList.remove(pid);
- mPidSortedList.push_front(pid);
+ mUidSortedList.remove(uid);
+ mUidSortedList.push_front(uid);
updateCurrentJob_l();
@@ -343,26 +343,26 @@
void TranscodingJobScheduler::validateState_l() {
#ifdef VALIDATE_STATE
- LOG_ALWAYS_FATAL_IF(mJobQueues.count(OFFLINE_PID) != 1,
+ LOG_ALWAYS_FATAL_IF(mJobQueues.count(OFFLINE_UID) != 1,
"mJobQueues offline queue number is not 1");
- LOG_ALWAYS_FATAL_IF(*mOfflinePidIterator != OFFLINE_PID,
- "mOfflinePidIterator not pointing to offline pid");
- LOG_ALWAYS_FATAL_IF(mPidSortedList.size() != mJobQueues.size(),
- "mPidList and mJobQueues size mismatch");
+ LOG_ALWAYS_FATAL_IF(*mOfflineUidIterator != OFFLINE_UID,
+ "mOfflineUidIterator not pointing to offline uid");
+ LOG_ALWAYS_FATAL_IF(mUidSortedList.size() != mJobQueues.size(),
+ "mUidList and mJobQueues size mismatch");
int32_t totalJobs = 0;
- for (auto pidIt = mPidSortedList.begin(); pidIt != mPidSortedList.end(); pidIt++) {
- LOG_ALWAYS_FATAL_IF(mJobQueues.count(*pidIt) != 1, "mJobQueues count for pid %d is not 1",
- *pidIt);
- for (auto jobIt = mJobQueues[*pidIt].begin(); jobIt != mJobQueues[*pidIt].end(); jobIt++) {
+ for (auto uidIt = mUidSortedList.begin(); uidIt != mUidSortedList.end(); uidIt++) {
+ LOG_ALWAYS_FATAL_IF(mJobQueues.count(*uidIt) != 1, "mJobQueues count for uid %d is not 1",
+ *uidIt);
+ for (auto jobIt = mJobQueues[*uidIt].begin(); jobIt != mJobQueues[*uidIt].end(); jobIt++) {
LOG_ALWAYS_FATAL_IF(mJobMap.count(*jobIt) != 1, "mJobs count for job %s is not 1",
jobToString(*jobIt).c_str());
}
- totalJobs += mJobQueues[*pidIt].size();
+ totalJobs += mJobQueues[*uidIt].size();
}
LOG_ALWAYS_FATAL_IF(mJobMap.size() != totalJobs,
- "mJobs size doesn't match total jobs counted from pid queues");
+ "mJobs size doesn't match total jobs counted from uid queues");
#endif // VALIDATE_STATE
}
diff --git a/media/libmediatranscoding/include/media/ProcessInfoInterface.h b/media/libmediatranscoding/include/media/ProcessInfoInterface.h
deleted file mode 100644
index ef79266..0000000
--- a/media/libmediatranscoding/include/media/ProcessInfoInterface.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_MEDIA_PROCESS_INFO_INTERFACE_H
-#define ANDROID_MEDIA_PROCESS_INFO_INTERFACE_H
-
-namespace android {
-
-// Interface for the scheduler to query a process's info.
-class ProcessInfoInterface {
-public:
- // Determines if a process is currently running as top process.
- // TODO(chz): this should probably be replaced by a query that determines
- // which pid has the highest priority among a given set of pids. For now,
- // we assume that there is a way to determine based on a pid number whether
- // that pid is on "top", but this may not be possible in some cases, for
- // example, the client process with highest priority is actually a foreground
- // service (serving the top-app), but technically is not "top".
- virtual bool isProcessOnTop(pid_t pid) = 0;
-
-protected:
- virtual ~ProcessInfoInterface() = default;
-};
-
-// Interface for notifying the scheduler of a change in a process's state or
-// transcoding resource availability.
-class ProcessInfoCallbackInterface {
-public:
- // Called when a process with pid is brought to top.
- // TODO(chz): this should probably be replace by a callback when the pid
- // that was previously identified being the highest priority as in
- // ProcessInfoInterface::isProcessOnTop() has changed in priority.
- virtual void onTopProcessChanged(pid_t pid) = 0;
-
- // Called when resources become available for transcoding use. The scheduler
- // may use this as a signal to attempt restart transcoding activity that
- // were previously paused due to temporary resource loss.
- virtual void onResourceAvailable() = 0;
-
-protected:
- virtual ~ProcessInfoCallbackInterface() = default;
-};
-
-} // namespace android
-#endif // ANDROID_MEDIA_PROCESS_INFO_INTERFACE_H
diff --git a/media/libmediatranscoding/include/media/SchedulerClientInterface.h b/media/libmediatranscoding/include/media/SchedulerClientInterface.h
index b4cf463..6ccf117 100644
--- a/media/libmediatranscoding/include/media/SchedulerClientInterface.h
+++ b/media/libmediatranscoding/include/media/SchedulerClientInterface.h
@@ -31,7 +31,7 @@
// the status of a job.
class SchedulerClientInterface {
public:
- virtual bool submit(ClientIdType clientId, int32_t jobId, pid_t pid,
+ virtual bool submit(ClientIdType clientId, int32_t jobId, uid_t uid,
const TranscodingRequestParcel& request,
const std::weak_ptr<ITranscodingClientCallback>& clientCallback) = 0;
diff --git a/media/libmediatranscoding/include/media/TranscodingJobScheduler.h b/media/libmediatranscoding/include/media/TranscodingJobScheduler.h
index f4d98ba..77f6404 100644
--- a/media/libmediatranscoding/include/media/TranscodingJobScheduler.h
+++ b/media/libmediatranscoding/include/media/TranscodingJobScheduler.h
@@ -18,10 +18,10 @@
#define ANDROID_MEDIA_TRANSCODING_JOB_SCHEDULER_H
#include <aidl/android/media/TranscodingJobPriority.h>
-#include <media/ProcessInfoInterface.h>
#include <media/SchedulerClientInterface.h>
#include <media/TranscoderInterface.h>
#include <media/TranscodingRequest.h>
+#include <media/UidPolicyInterface.h>
#include <utils/String8.h>
#include <list>
@@ -32,14 +32,14 @@
using ::aidl::android::media::TranscodingJobPriority;
using ::aidl::android::media::TranscodingResultParcel;
-class TranscodingJobScheduler : public ProcessInfoCallbackInterface,
+class TranscodingJobScheduler : public UidPolicyCallbackInterface,
public SchedulerClientInterface,
public TranscoderCallbackInterface {
public:
virtual ~TranscodingJobScheduler();
// SchedulerClientInterface
- bool submit(ClientIdType clientId, int32_t jobId, pid_t pid,
+ bool submit(ClientIdType clientId, int32_t jobId, uid_t uid,
const TranscodingRequestParcel& request,
const std::weak_ptr<ITranscodingClientCallback>& clientCallback) override;
bool cancel(ClientIdType clientId, int32_t jobId) override;
@@ -52,10 +52,10 @@
void onResourceLost() override;
// ~TranscoderCallbackInterface
- // ProcessInfoCallbackInterface
- void onTopProcessChanged(int32_t pid) override;
+ // UidPolicyCallbackInterface
+ void onTopUidChanged(uid_t uid) override;
void onResourceAvailable() override;
- // ~ProcessInfoCallbackInterface
+ // ~UidPolicyCallbackInterface
private:
friend class MediaTranscodingService;
@@ -66,7 +66,7 @@
struct Job {
JobKeyType key;
- pid_t pid;
+ uid_t uid;
enum JobState {
NOT_STARTED,
RUNNING,
@@ -82,23 +82,23 @@
std::map<JobKeyType, Job> mJobMap;
- // Pid->JobQueue map (pid == -1: offline queue)
- std::map<pid_t, JobQueueType> mJobQueues;
+ // uid->JobQueue map (uid == -1: offline queue)
+ std::map<uid_t, JobQueueType> mJobQueues;
- // Pids, with the head being the most-recently-top app, 2nd item is the
+ // uids, with the head being the most-recently-top app, 2nd item is the
// previous top app, etc.
- std::list<pid_t> mPidSortedList;
- std::list<pid_t>::iterator mOfflinePidIterator;
+ std::list<uid_t> mUidSortedList;
+ std::list<uid_t>::iterator mOfflineUidIterator;
std::shared_ptr<TranscoderInterface> mTranscoder;
- std::shared_ptr<ProcessInfoInterface> mProcInfo;
+ std::shared_ptr<UidPolicyInterface> mUidPolicy;
Job* mCurrentJob;
bool mResourceLost;
// Only allow MediaTranscodingService and unit tests to instantiate.
TranscodingJobScheduler(const std::shared_ptr<TranscoderInterface>& transcoder,
- const std::shared_ptr<ProcessInfoInterface>& procInfo);
+ const std::shared_ptr<UidPolicyInterface>& uidPolicy);
Job* getTopJob_l();
void updateCurrentJob_l();
diff --git a/media/libmediatranscoding/include/media/UidPolicyInterface.h b/media/libmediatranscoding/include/media/UidPolicyInterface.h
new file mode 100644
index 0000000..e9a9da4
--- /dev/null
+++ b/media/libmediatranscoding/include/media/UidPolicyInterface.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_MEDIA_UID_POLICY_INTERFACE_H
+#define ANDROID_MEDIA_UID_POLICY_INTERFACE_H
+
+namespace android {
+
+// Interface for the scheduler to query a uid's info.
+class UidPolicyInterface {
+public:
+ // Determines if a uid is currently running as top.
+ // TODO(chz): this should probably be replaced by a query that determines
+ // which uid has the highest priority among a given set of uids.
+ virtual bool isUidOnTop(uid_t uid) = 0;
+
+protected:
+ virtual ~UidPolicyInterface() = default;
+};
+
+// Interface for notifying the scheduler of a change in a uid's state or
+// transcoding resource availability.
+class UidPolicyCallbackInterface {
+public:
+ // Called when a uid is brought to top.
+ // TODO(chz): this should probably be replace by a callback when the uid
+ // that was previously identified being the highest priority as in
+ // UidPolicyInterface::isUidOnTop() has changed in priority.
+ virtual void onTopUidChanged(uid_t uid) = 0;
+
+ // Called when resources become available for transcoding use. The scheduler
+ // may use this as a signal to attempt restart transcoding activity that
+ // were previously paused due to temporary resource loss.
+ virtual void onResourceAvailable() = 0;
+
+protected:
+ virtual ~UidPolicyCallbackInterface() = default;
+};
+
+} // namespace android
+#endif // ANDROID_MEDIA_UID_POLICY_INTERFACE_H
diff --git a/media/libmediatranscoding/tests/TranscodingClientManager_tests.cpp b/media/libmediatranscoding/tests/TranscodingClientManager_tests.cpp
index acc3082..7e5ae61 100644
--- a/media/libmediatranscoding/tests/TranscodingClientManager_tests.cpp
+++ b/media/libmediatranscoding/tests/TranscodingClientManager_tests.cpp
@@ -120,7 +120,7 @@
virtual ~TestScheduler() { ALOGI("TestScheduler Destroyed"); }
- bool submit(int64_t clientId, int32_t jobId, pid_t /*pid*/,
+ bool submit(int64_t clientId, int32_t jobId, uid_t /*uid*/,
const TranscodingRequestParcel& request,
const std::weak_ptr<ITranscodingClientCallback>& clientCallback) override {
JobKeyType jobKey = std::make_pair(clientId, jobId);
diff --git a/media/libmediatranscoding/tests/TranscodingJobScheduler_tests.cpp b/media/libmediatranscoding/tests/TranscodingJobScheduler_tests.cpp
index d062d93..6bc9e20 100644
--- a/media/libmediatranscoding/tests/TranscodingJobScheduler_tests.cpp
+++ b/media/libmediatranscoding/tests/TranscodingJobScheduler_tests.cpp
@@ -40,16 +40,16 @@
constexpr int64_t kClientId = 1000;
constexpr int32_t kClientJobId = 0;
-constexpr pid_t kClientPid = 5000;
-constexpr pid_t kInvalidPid = -1;
+constexpr uid_t kClientUid = 5000;
+constexpr uid_t kInvalidUid = (uid_t)-1;
#define CLIENT(n) (kClientId + (n))
#define JOB(n) (kClientJobId + (n))
-#define PID(n) (kClientPid + (n))
+#define UID(n) (kClientUid + (n))
-class TestCallback : public TranscoderInterface, public ProcessInfoInterface {
+class TestCallback : public TranscoderInterface, public UidPolicyInterface {
public:
- TestCallback() : mTopPid(-1), mLastError(TranscodingErrorCode::kUnknown) {}
+ TestCallback() : mTopUid(kInvalidUid), mLastError(TranscodingErrorCode::kUnknown) {}
virtual ~TestCallback() {}
// TranscoderInterface
@@ -63,8 +63,8 @@
mEventQueue.push_back(Resume(clientId, jobId));
}
- // ProcessInfoInterface
- bool isProcessOnTop(pid_t pid) override { return pid == mTopPid; }
+ // UidPolicyInterface
+ bool isUidOnTop(uid_t uid) override { return uid == mTopUid; }
void onFinished(int64_t clientId, int32_t jobId) {
mEventQueue.push_back(Finished(clientId, jobId));
@@ -75,7 +75,7 @@
mEventQueue.push_back(Failed(clientId, jobId));
}
- void setTop(pid_t pid) { mTopPid = pid; }
+ void setTop(uid_t uid) { mTopUid = uid; }
TranscodingErrorCode getLastError() {
TranscodingErrorCode result = mLastError;
@@ -115,7 +115,7 @@
private:
Event mPoppedEvent;
std::list<Event> mEventQueue;
- pid_t mTopPid;
+ uid_t mTopUid;
TranscodingErrorCode mLastError;
};
@@ -197,43 +197,43 @@
TEST_F(TranscodingJobSchedulerTest, TestSubmitJob) {
ALOGD("TestSubmitJob");
- // Start with PID(1) on top.
- mCallback->setTop(PID(1));
+ // Start with UID(1) on top.
+ mCallback->setTop(UID(1));
- // Submit offline job to CLIENT(0) in PID(0).
+ // Submit offline job to CLIENT(0) in UID(0).
// Should start immediately (because this is the only job).
- mScheduler->submit(CLIENT(0), JOB(0), PID(0), mOfflineRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(0), UID(0), mOfflineRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), 0));
// Submit real-time job to CLIENT(0).
- // Should pause offline job and start new job, even if PID(0) is not on top.
- mScheduler->submit(CLIENT(0), JOB(1), PID(0), mRealtimeRequest, mClientCallback0);
+ // Should pause offline job and start new job, even if UID(0) is not on top.
+ mScheduler->submit(CLIENT(0), JOB(1), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(0), JOB(0)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), JOB(1)));
// Submit real-time job to CLIENT(0), should be queued after the previous job.
- mScheduler->submit(CLIENT(0), JOB(2), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(2), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- // Submit real-time job to CLIENT(1) in same pid, should be queued after the previous job.
- mScheduler->submit(CLIENT(1), JOB(0), PID(0), mRealtimeRequest, mClientCallback1);
+ // Submit real-time job to CLIENT(1) in same uid, should be queued after the previous job.
+ mScheduler->submit(CLIENT(1), JOB(0), UID(0), mRealtimeRequest, mClientCallback1);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- // Submit real-time job to CLIENT(2) in PID(1).
- // Should pause previous job and start new job, because PID(1) is top.
- mCallback->setTop(PID(1));
- mScheduler->submit(CLIENT(2), JOB(0), PID(1), mRealtimeRequest, mClientCallback2);
+ // Submit real-time job to CLIENT(2) in UID(1).
+ // Should pause previous job and start new job, because UID(1) is top.
+ mCallback->setTop(UID(1));
+ mScheduler->submit(CLIENT(2), JOB(0), UID(1), mRealtimeRequest, mClientCallback2);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(0), JOB(1)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(2), JOB(0)));
// Submit offline job, shouldn't generate any event.
- mScheduler->submit(CLIENT(2), JOB(1), PID(1), mOfflineRequest, mClientCallback2);
+ mScheduler->submit(CLIENT(2), JOB(1), UID(1), mOfflineRequest, mClientCallback2);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- mCallback->setTop(PID(0));
- // Submit real-time job to CLIENT(1) in PID(0).
- // Should pause current job, and resume last job in PID(0).
- mScheduler->submit(CLIENT(1), JOB(1), PID(0), mRealtimeRequest, mClientCallback1);
+ mCallback->setTop(UID(0));
+ // Submit real-time job to CLIENT(1) in UID(0).
+ // Should pause current job, and resume last job in UID(0).
+ mScheduler->submit(CLIENT(1), JOB(1), UID(0), mRealtimeRequest, mClientCallback1);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(2), JOB(0)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Resume(CLIENT(0), JOB(1)));
}
@@ -242,15 +242,15 @@
ALOGD("TestCancelJob");
// Submit real-time job JOB(0), should start immediately.
- mScheduler->submit(CLIENT(0), JOB(0), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(0), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), JOB(0)));
// Submit real-time job JOB(1), should not start.
- mScheduler->submit(CLIENT(0), JOB(1), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(1), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Submit offline job JOB(2), should not start.
- mScheduler->submit(CLIENT(0), JOB(2), PID(0), mOfflineRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(2), UID(0), mOfflineRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Cancel queued real-time job.
@@ -262,7 +262,7 @@
EXPECT_TRUE(mScheduler->cancel(CLIENT(0), JOB(2)));
// Submit offline job JOB(3), shouldn't cause any event.
- mScheduler->submit(CLIENT(0), JOB(3), PID(0), mOfflineRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(3), UID(0), mOfflineRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Cancel running real-time job JOB(0).
@@ -281,26 +281,26 @@
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Submit offline job JOB(0), should start immediately.
- mScheduler->submit(CLIENT(0), JOB(0), PID(0), mOfflineRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(0), UID(0), mOfflineRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), JOB(0)));
// Submit real-time job JOB(1), should pause offline job and start immediately.
- mScheduler->submit(CLIENT(0), JOB(1), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(1), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(0), JOB(0)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), JOB(1)));
// Submit real-time job JOB(2), should not start.
- mScheduler->submit(CLIENT(0), JOB(2), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(2), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Fail when the job never started, should be ignored.
mScheduler->onFinish(CLIENT(0), JOB(2));
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- // PID(1) moves to top.
- mCallback->setTop(PID(1));
- // Submit real-time job to CLIENT(1) in PID(1), should pause previous job and start new job.
- mScheduler->submit(CLIENT(1), JOB(0), PID(1), mRealtimeRequest, mClientCallback1);
+ // UID(1) moves to top.
+ mCallback->setTop(UID(1));
+ // Submit real-time job to CLIENT(1) in UID(1), should pause previous job and start new job.
+ mScheduler->submit(CLIENT(1), JOB(0), UID(1), mRealtimeRequest, mClientCallback1);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(0), JOB(1)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(1), JOB(0)));
@@ -336,26 +336,26 @@
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Submit offline job JOB(0), should start immediately.
- mScheduler->submit(CLIENT(0), JOB(0), PID(0), mOfflineRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(0), UID(0), mOfflineRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), JOB(0)));
// Submit real-time job JOB(1), should pause offline job and start immediately.
- mScheduler->submit(CLIENT(0), JOB(1), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(1), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(0), JOB(0)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), JOB(1)));
// Submit real-time job JOB(2), should not start.
- mScheduler->submit(CLIENT(0), JOB(2), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(2), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Fail when the job never started, should be ignored.
mScheduler->onError(CLIENT(0), JOB(2), TranscodingErrorCode::kUnknown);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- // PID(1) moves to top.
- mCallback->setTop(PID(1));
- // Submit real-time job to CLIENT(1) in PID(1), should pause previous job and start new job.
- mScheduler->submit(CLIENT(1), JOB(0), PID(1), mRealtimeRequest, mClientCallback1);
+ // UID(1) moves to top.
+ mCallback->setTop(UID(1));
+ // Submit real-time job to CLIENT(1) in UID(1), should pause previous job and start new job.
+ mScheduler->submit(CLIENT(1), JOB(0), UID(1), mRealtimeRequest, mClientCallback1);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(0), JOB(1)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(1), JOB(0)));
@@ -384,33 +384,33 @@
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
}
-TEST_F(TranscodingJobSchedulerTest, TestTopProcessChanged) {
- ALOGD("TestTopProcessChanged");
+TEST_F(TranscodingJobSchedulerTest, TestTopUidChanged) {
+ ALOGD("TestTopUidChanged");
// Submit real-time job to CLIENT(0), job should start immediately.
- mScheduler->submit(CLIENT(0), JOB(0), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(0), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), JOB(0)));
// Submit offline job to CLIENT(0), should not start.
- mScheduler->submit(CLIENT(1), JOB(0), PID(0), mOfflineRequest, mClientCallback1);
+ mScheduler->submit(CLIENT(1), JOB(0), UID(0), mOfflineRequest, mClientCallback1);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- // Move PID(1) to top.
- mCallback->setTop(PID(1));
- // Submit real-time job to CLIENT(2) in different pid PID(1).
+ // Move UID(1) to top.
+ mCallback->setTop(UID(1));
+ // Submit real-time job to CLIENT(2) in different uid UID(1).
// Should pause previous job and start new job.
- mScheduler->submit(CLIENT(2), JOB(0), PID(1), mRealtimeRequest, mClientCallback2);
+ mScheduler->submit(CLIENT(2), JOB(0), UID(1), mRealtimeRequest, mClientCallback2);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(0), JOB(0)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(2), JOB(0)));
- // Bring PID(0) back to top.
- mCallback->setTop(PID(0));
- mScheduler->onTopProcessChanged(PID(0));
+ // Bring UID(0) back to top.
+ mCallback->setTop(UID(0));
+ mScheduler->onTopUidChanged(UID(0));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(2), JOB(0)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Resume(CLIENT(0), JOB(0)));
- // Bring invalid process to top.
- mScheduler->onTopProcessChanged(kInvalidPid);
+ // Bring invalid uid to top.
+ mScheduler->onTopUidChanged(kInvalidUid);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Finish job, next real-time job should resume.
@@ -428,19 +428,19 @@
ALOGD("TestResourceLost");
// Submit real-time job to CLIENT(0), job should start immediately.
- mScheduler->submit(CLIENT(0), JOB(0), PID(0), mRealtimeRequest, mClientCallback0);
+ mScheduler->submit(CLIENT(0), JOB(0), UID(0), mRealtimeRequest, mClientCallback0);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(0), JOB(0)));
// Submit offline job to CLIENT(0), should not start.
- mScheduler->submit(CLIENT(1), JOB(0), PID(0), mOfflineRequest, mClientCallback1);
+ mScheduler->submit(CLIENT(1), JOB(0), UID(0), mOfflineRequest, mClientCallback1);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- // Move PID(1) to top.
- mCallback->setTop(PID(1));
+ // Move UID(1) to top.
+ mCallback->setTop(UID(1));
- // Submit real-time job to CLIENT(2) in different pid PID(1).
+ // Submit real-time job to CLIENT(2) in different uid UID(1).
// Should pause previous job and start new job.
- mScheduler->submit(CLIENT(2), JOB(0), PID(1), mRealtimeRequest, mClientCallback2);
+ mScheduler->submit(CLIENT(2), JOB(0), UID(1), mRealtimeRequest, mClientCallback2);
EXPECT_EQ(mCallback->popEvent(), TestCallback::Pause(CLIENT(0), JOB(0)));
EXPECT_EQ(mCallback->popEvent(), TestCallback::Start(CLIENT(2), JOB(0)));
@@ -458,8 +458,8 @@
mScheduler->onResourceLost();
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- // Move PID(0) back to top, should have no resume due to no resource.
- mScheduler->onTopProcessChanged(PID(0));
+ // Move UID(0) back to top, should have no resume due to no resource.
+ mScheduler->onTopUidChanged(UID(0));
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Signal resource available, CLIENT(0) should resume.
@@ -471,11 +471,11 @@
mScheduler->onResourceLost();
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
- // Move PID(2) to top.
- mCallback->setTop(PID(2));
+ // Move UID(2) to top.
+ mCallback->setTop(UID(2));
- // Submit real-time job to CLIENT(3) in PID(2), job shouldn't start due to no resource.
- mScheduler->submit(CLIENT(3), JOB(0), PID(2), mRealtimeRequest, mClientCallback3);
+ // Submit real-time job to CLIENT(3) in UID(2), job shouldn't start due to no resource.
+ mScheduler->submit(CLIENT(3), JOB(0), UID(2), mRealtimeRequest, mClientCallback3);
EXPECT_EQ(mCallback->popEvent(), TestCallback::NoEvent);
// Signal resource available, CLIENT(3)'s job should start.
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 1a0010f..6941198 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -2054,17 +2054,34 @@
if (mIsVideo || mIsImage) {
// determine need for software renderer
bool usingSwRenderer = false;
- if (haveNativeWindow && mComponentName.startsWith("OMX.google.")) {
- usingSwRenderer = true;
- haveNativeWindow = false;
- (void)setPortMode(kPortIndexOutput, IOMX::kPortModePresetByteBuffer);
- } else if (haveNativeWindow && !storingMetadataInDecodedBuffers()) {
- err = setPortMode(kPortIndexOutput, IOMX::kPortModePresetANWBuffer);
- if (err != OK) {
- return err;
+ if (haveNativeWindow) {
+ bool requiresSwRenderer = false;
+ OMX_PARAM_U32TYPE param;
+ InitOMXParams(¶m);
+ param.nPortIndex = kPortIndexOutput;
+
+ status_t err = mOMXNode->getParameter(
+ (OMX_INDEXTYPE)OMX_IndexParamVideoAndroidRequiresSwRenderer,
+ ¶m, sizeof(param));
+
+ if (err == OK && param.nU32 == 1) {
+ requiresSwRenderer = true;
}
+
+ if (mComponentName.startsWith("OMX.google.") || requiresSwRenderer) {
+ usingSwRenderer = true;
+ haveNativeWindow = false;
+ (void)setPortMode(kPortIndexOutput, IOMX::kPortModePresetByteBuffer);
+ } else if (!storingMetadataInDecodedBuffers()) {
+ err = setPortMode(kPortIndexOutput, IOMX::kPortModePresetANWBuffer);
+ if (err != OK) {
+ return err;
+ }
+ }
+
}
+
if (encoder) {
err = setupVideoEncoder(mime, msg, outputFormat, inputFormat);
} else {
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index 00c5b40..4bc861e 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -108,6 +108,9 @@
selectedDeviceId,
selectedMicDirection,
selectedMicFieldDimension);
+ // Set caller name so it can be logged in destructor.
+ // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_MEDIA
+ mRecord->setCallerName("media");
mInitCheck = mRecord->initCheck();
if (mInitCheck != OK) {
mRecord.clear();
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index b597583..3ba87d6 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -56,6 +56,7 @@
#include <media/stagefright/CCodec.h>
#include <media/stagefright/MediaCodec.h>
#include <media/stagefright/MediaCodecList.h>
+#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaFilter.h>
@@ -199,6 +200,7 @@
void addResource(const MediaResourceParcel &resource);
void removeResource(const MediaResourceParcel &resource);
void removeClient();
+ void markClientForPendingRemoval();
bool reclaimResource(const std::vector<MediaResourceParcel> &resources);
private:
@@ -280,6 +282,14 @@
mService->removeClient(mPid, getId(mClient));
}
+void MediaCodec::ResourceManagerServiceProxy::markClientForPendingRemoval() {
+ Mutex::Autolock _l(mLock);
+ if (mService == nullptr) {
+ return;
+ }
+ mService->markClientForPendingRemoval(mPid, getId(mClient));
+}
+
bool MediaCodec::ResourceManagerServiceProxy::reclaimResource(
const std::vector<MediaResourceParcel> &resources) {
Mutex::Autolock _l(mLock);
@@ -297,6 +307,33 @@
////////////////////////////////////////////////////////////////////////////////
+class MediaCodec::ReleaseSurface {
+public:
+ ReleaseSurface() {
+ BufferQueue::createBufferQueue(&mProducer, &mConsumer);
+ mSurface = new Surface(mProducer, false /* controlledByApp */);
+ struct ConsumerListener : public BnConsumerListener {
+ void onFrameAvailable(const BufferItem&) override {}
+ void onBuffersReleased() override {}
+ void onSidebandStreamChanged() override {}
+ };
+ sp<ConsumerListener> listener{new ConsumerListener};
+ mConsumer->consumerConnect(listener, false);
+ mConsumer->setConsumerName(String8{"MediaCodec.release"});
+ }
+
+ const sp<Surface> &getSurface() {
+ return mSurface;
+ }
+
+private:
+ sp<IGraphicBufferProducer> mProducer;
+ sp<IGraphicBufferConsumer> mConsumer;
+ sp<Surface> mSurface;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
namespace {
enum {
@@ -1432,7 +1469,13 @@
status_t MediaCodec::release() {
sp<AMessage> msg = new AMessage(kWhatRelease, this);
+ sp<AMessage> response;
+ return PostAndAwaitResponse(msg, &response);
+}
+status_t MediaCodec::releaseAsync() {
+ sp<AMessage> msg = new AMessage(kWhatRelease, this);
+ msg->setInt32("async", 1);
sp<AMessage> response;
return PostAndAwaitResponse(msg, &response);
}
@@ -2263,7 +2306,7 @@
if (mSurface != nullptr && !mAllowFrameDroppingBySurface) {
// signal frame dropping mode in the input format as this may also be
// meaningful and confusing for an encoder in a transcoder scenario
- mInputFormat->setInt32("allow-frame-drop", mAllowFrameDroppingBySurface);
+ mInputFormat->setInt32(KEY_ALLOW_FRAME_DROP, mAllowFrameDroppingBySurface);
}
ALOGV("[%s] configured as input format: %s, output format: %s",
mComponentName.c_str(),
@@ -2600,7 +2643,9 @@
mResourceManagerProxy->removeClient();
- (new AMessage)->postReply(mReplyID);
+ if (mReplyID != nullptr) {
+ (new AMessage)->postReply(mReplyID);
+ }
break;
}
@@ -2720,7 +2765,7 @@
}
if (obj != NULL) {
- if (!format->findInt32("allow-frame-drop", &mAllowFrameDroppingBySurface)) {
+ if (!format->findInt32(KEY_ALLOW_FRAME_DROP, &mAllowFrameDroppingBySurface)) {
// allow frame dropping by surface by default
mAllowFrameDroppingBySurface = true;
}
@@ -2987,6 +3032,26 @@
break;
}
+ int32_t async = 0;
+ if (msg->findInt32("async", &async) && async) {
+ if ((mState == CONFIGURED || mState == STARTED || mState == FLUSHED)
+ && mSurface != NULL) {
+ if (!mReleaseSurface) {
+ mReleaseSurface.reset(new ReleaseSurface);
+ }
+ status_t err = connectToSurface(mReleaseSurface->getSurface());
+ ALOGW_IF(err != OK, "error connecting to release surface: err = %d", err);
+ if (err == OK && !(mFlags & kFlagUsesSoftwareRenderer)) {
+ err = mCodec->setSurface(mReleaseSurface->getSurface());
+ ALOGW_IF(err != OK, "error setting release surface: err = %d", err);
+ }
+ if (err == OK) {
+ (void)disconnectFromSurface();
+ mSurface = mReleaseSurface->getSurface();
+ }
+ }
+ }
+
mReplyID = replyID;
setState(msg->what() == kWhatStop ? STOPPING : RELEASING);
@@ -2999,6 +3064,12 @@
pushBlankBuffersToNativeWindow(mSurface.get());
}
+ if (async) {
+ mResourceManagerProxy->markClientForPendingRemoval();
+ (new AMessage)->postReply(mReplyID);
+ mReplyID = 0;
+ }
+
break;
}
diff --git a/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder.cpp b/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder.cpp
index ddc818e..c9c1cd4 100644
--- a/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder.cpp
+++ b/media/libstagefright/codecs/amrwb/src/pvamrwbdecoder.cpp
@@ -337,7 +337,10 @@
st = (Decoder_State *) spd_state;
/* mode verification */
-
+ if (mode < 0 || mode >= NUM_OF_MODES)
+ {
+ return (-1);
+ }
nb_bits = AMR_WB_COMPRESSED[mode];
*frame_length = AMR_WB_PCM_FRAME;
diff --git a/media/libstagefright/codecs/m4v_h263/dec/Android.bp b/media/libstagefright/codecs/m4v_h263/dec/Android.bp
index 27d20e9..f278f92 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/Android.bp
+++ b/media/libstagefright/codecs/m4v_h263/dec/Android.bp
@@ -5,20 +5,14 @@
shared_libs: ["liblog"],
srcs: [
- "src/adaptive_smooth_no_mmx.cpp",
"src/bitstream.cpp",
"src/block_idct.cpp",
"src/cal_dc_scaler.cpp",
- "src/chvr_filter.cpp",
- "src/chv_filter.cpp",
"src/combined_decode.cpp",
"src/conceal.cpp",
"src/datapart_decode.cpp",
"src/dcac_prediction.cpp",
"src/dec_pred_intra_dc.cpp",
- "src/deringing_chroma.cpp",
- "src/deringing_luma.cpp",
- "src/find_min_max.cpp",
"src/get_pred_adv_b_add.cpp",
"src/get_pred_outside.cpp",
"src/idct.cpp",
@@ -27,9 +21,6 @@
"src/mb_utils.cpp",
"src/packet_util.cpp",
"src/post_filter.cpp",
- "src/post_proc_semaphore.cpp",
- "src/pp_semaphore_chroma_inter.cpp",
- "src/pp_semaphore_luma.cpp",
"src/pvdec_api.cpp",
"src/scaling_tab.cpp",
"src/vlc_decode.cpp",
@@ -44,7 +35,6 @@
cflags: [
"-Werror",
- "-DDEC_NOPOSTPROC",
],
version_script: "exports.lds",
diff --git a/media/libstagefright/codecs/m4v_h263/dec/include/mp4dec_api.h b/media/libstagefright/codecs/m4v_h263/dec/include/mp4dec_api.h
index 1f404ce..06aee07 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/include/mp4dec_api.h
+++ b/media/libstagefright/codecs/m4v_h263/dec/include/mp4dec_api.h
@@ -42,13 +42,6 @@
#define OSCL_EXPORT_REF /* empty */
#endif
-/* flag for post-processing 4/25/00 */
-
-#ifdef DEC_NOPOSTPROC
-#undef PV_POSTPROC_ON /* enable compilation of post-processing code */
-#else
-#define PV_POSTPROC_ON
-#endif
#define PV_NO_POST_PROC 0
#define PV_DEBLOCK 1
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/adaptive_smooth_no_mmx.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/adaptive_smooth_no_mmx.cpp
deleted file mode 100644
index e2761eb..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/adaptive_smooth_no_mmx.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Description: Separated modules into one function per file and put into
- new template.
-
- Description: Optimizing C code and adding comments. Also changing variable
- names to make them more meaningful.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Rec_Y = pointer to 0th position in buffer containing luminance values
- of type uint8.
- y_start = value of y coordinate of type int that specifies the first
- row of pixels to be used in the filter algorithm.
- x_start = value of x coordinate of type int that specifies the first
- column of pixels to be used in the filter algorithm.
- y_blk_start = value of the y coordinate of type int that specifies the
- row of pixels which contains the start of a block. The row
- specified by y_blk_start+BLK_SIZE is the last row of pixels
- that are used in the filter algorithm.
- x_blk_start = value of the x coordinate of type int that specifies the
- column of pixels which contains the start of a block. The
- column specified by x_blk_start+BLK_SIZE is the last column of
- pixels that are used in the filter algorithm.
- thr = value of type int that is compared to the elements in Rec_Y to
- determine if a particular value in Rec_Y will be modified by
- the filter or not
- width = value of type int that specifies the width of the display
- in pixels (or pels, equivalently).
- max_diff = value of type int that specifies the value that may be added
- or subtracted from the pixel in Rec_Y that is being filtered
- if the filter algorithm decides to change that particular
- pixel's luminance value.
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- Buffer pointed to by Rec_Y is modified with the filtered
- luminance values.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function implements a motion compensated noise filter using adaptive
- weighted averaging of luminance values. *Rec_Y contains the luminance values
- that are being filtered.
-
- The picture below depicts a 3x3 group of pixel luminance values. The "u", "c",
- and "l" stand for "upper", "center" and "lower", respectively. The location
- of pelc0 is specified by x_start and y_start in the 1-D array "Rec_Y" as
- follows (assuming x_start=0):
-
- location of pelc0 = [(y_start+1) * width] + x_start
-
- Moving up or down 1 row (moving from pelu2 to pelc2, for example) is done by
- incrementing or decrementing "width" elements within Rec_Y.
-
- The coordinates of the upper left hand corner of a block (not the group of
- 9 pixels depicted in the figure below) is specified by
- (y_blk_start, x_blk_start). The width and height of the block is BLKSIZE.
- (y_start,x_start) may be specified independently of (y_blk_start, x_blk_start).
-
- (y_start,x_start)
- -----------|--------------------------
- | | | | |
- | X | pelu1 | pelu2 |
- | pelu0 | | |
- | | | |
- --------------------------------------
- | | | |
- | pelc0 | pelc1 | pelc2 |
- | | | |
- | | | |
- --------------------------------------
- | | | |
- | pell0 | pell1 | pell2 |
- | | | |
- | | | |
- --------------------------------------
-
- The filtering of the luminance values is achieved by comparing the 9
- luminance values to a threshold value ("thr") and then changing the
- luminance value of pelc1 if all of the values are above or all of the values
- are below the threshold. The amount that the luminance value is changed
- depends on a weighted sum of the 9 luminance values. The position of Pelc1
- is then advanced to the right by one (as well as all of the surrounding pixels)
- and the same calculation is performed again for the luminance value of the new
- Pelc1. This continues row-wise until pixels in the last row of the block are
- filtered.
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- None.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- ..\corelibs\decoder\common\src\post_proc.c
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "mp4dec_lib.h"
-#include "post_proc.h"
-#include "mp4def.h"
-
-#define OSCL_DISABLE_WARNING_CONV_POSSIBLE_LOSS_OF_DATA
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-#ifdef PV_POSTPROC_ON
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void AdaptiveSmooth_NoMMX(
- uint8 *Rec_Y, /* i/o */
- int y_start, /* i */
- int x_start, /* i */
- int y_blk_start, /* i */
- int x_blk_start, /* i */
- int thr, /* i */
- int width, /* i */
- int max_diff /* i */
-)
-{
-
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int sign_v[15];
- int sum_v[15];
- int *sum_V_ptr;
- int *sign_V_ptr;
- uint8 pelu;
- uint8 pelc;
- uint8 pell;
- uint8 *pelp;
- uint8 oldrow[15];
- int sum;
- int sum1;
- uint8 *Rec_Y_ptr;
- int32 addr_v;
- int row_cntr;
- int col_cntr;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- /* first row
- */
- addr_v = (int32)(y_start + 1) * width; /* y coord of 1st element in the row /
- /containing pelc pixel / */
- Rec_Y_ptr = &Rec_Y[addr_v + x_start]; /* initializing pointer to
- / pelc0 position */
- sum_V_ptr = &sum_v[0]; /* initializing pointer to 0th element of array
- / that will contain weighted sums of pixel
- / luminance values */
- sign_V_ptr = &sign_v[0]; /* initializing pointer to 0th element of
- / array that will contain sums that indicate
- / how many of the 9 pixels are above or below
- / the threshold value (thr) */
- pelp = &oldrow[0]; /* initializing pointer to the 0th element of array
- / that will contain current values of pelc that
- / are saved and used as values of pelu when the
- / next row of pixels are filtered */
-
- pelu = *(Rec_Y_ptr - width); /* assigning value of pelu0 to pelu */
- *pelp++ = pelc = *Rec_Y_ptr; /* assigning value of pelc0 to pelc and
- / storing this value in pelp which
- / will be used as value of pelu0 when
- / next row is filtered */
- pell = *(Rec_Y_ptr + width); /* assigning value of pell0 to pell */
- Rec_Y_ptr++; /* advancing pointer from pelc0 to pelc1 */
- *sum_V_ptr++ = pelu + (pelc << 1) + pell; /* weighted sum of pelu0,
- / pelc0 and pell0 */
- /* sum of 0's and 1's (0 if pixel value is below thr, 1 if value
- /is above thr) */
- *sign_V_ptr++ = INDEX(pelu, thr) + INDEX(pelc, thr) + INDEX(pell, thr);
-
-
- pelu = *(Rec_Y_ptr - width); /* assigning value of pelu1 to pelu */
- *pelp++ = pelc = *Rec_Y_ptr; /* assigning value of pelc1 to pelc and
- / storing this value in pelp which
- / will be used as the value of pelu1 when
- / next row is filtered */
- pell = *(Rec_Y_ptr + width); /* assigning value of pell1 to pell */
- Rec_Y_ptr++; /* advancing pointer from pelc1 to pelc2 */
- *sum_V_ptr++ = pelu + (pelc << 1) + pell; /* weighted sum of pelu1,
- / pelc1 and pell1 */
- /* sum of 0's and 1's (0 if pixel value is below thr, 1 if value
- /is above thr) */
- *sign_V_ptr++ = INDEX(pelu, thr) + INDEX(pelc, thr) + INDEX(pell, thr);
-
- /* The loop below performs the filtering for the first row of
- / pixels in the region. It steps across the remaining pixels in
- / the row and alters the luminance value of pelc1 if necessary,
- / depending on the luminance values of the adjacent pixels*/
-
- for (col_cntr = (x_blk_start + BLKSIZE - 1) - x_start; col_cntr > 0; col_cntr--)
- {
- pelu = *(Rec_Y_ptr - width); /* assigning value of pelu2 to
- / pelu */
- *pelp++ = pelc = *Rec_Y_ptr; /* assigning value of pelc2 to pelc
- / and storing this value in pelp
- / which will be used as value of pelu2
- / when next row is filtered */
- pell = *(Rec_Y_ptr + width); /* assigning value of pell2 to pell */
-
- /* weighted sum of pelu1, pelc1 and pell1 */
- *sum_V_ptr = pelu + (pelc << 1) + pell;
- /* sum of 0's and 1's (0 if pixel value is below thr,
- /1 if value is above thr) */
- *sign_V_ptr = INDEX(pelu, thr) + INDEX(pelc, thr) +
- INDEX(pell, thr);
- /* the value of sum1 indicates how many of the 9 pixels'
- /luminance values are above or equal to thr */
- sum1 = *(sign_V_ptr - 2) + *(sign_V_ptr - 1) + *sign_V_ptr;
-
- /* alter the luminance value of pelc1 if all 9 luminance values
- /are above or equal to thr or if all 9 values are below thr */
- if (sum1 == 0 || sum1 == 9)
- {
- /* sum is a weighted average of the 9 pixel luminance
- /values */
- sum = (*(sum_V_ptr - 2) + (*(sum_V_ptr - 1) << 1) +
- *sum_V_ptr + 8) >> 4;
-
- Rec_Y_ptr--; /* move pointer back to pelc1 */
- /* If luminance value of pelc1 is larger than
- / sum by more than max_diff, then subract max_diff
- / from luminance value of pelc1*/
- if ((int)(*Rec_Y_ptr - sum) > max_diff)
- {
- sum = *Rec_Y_ptr - max_diff;
- }
- /* If luminance value of pelc1 is smaller than
- / sum by more than max_diff, then add max_diff
- / to luminance value of pelc1*/
- else if ((int)(*Rec_Y_ptr - sum) < -max_diff)
- {
- sum = *Rec_Y_ptr + max_diff;
- }
- *Rec_Y_ptr++ = sum; /* assign value of sum to pelc1
- and advance pointer to pelc2 */
- }
- Rec_Y_ptr++; /* advance pointer to new value of pelc2
- / old pelc2 is now treated as pelc1*/
- sum_V_ptr++; /* pointer is advanced so next weighted sum may
- / be saved */
- sign_V_ptr++; /* pointer is advanced so next sum of 0's and
- / 1's may be saved */
- }
-
- /* The nested loops below perform the filtering for the remaining rows */
-
- addr_v = (y_start + 2) * width; /* advance addr_v to the next row
- / (corresponding to pell0)*/
- /* The outer loop steps throught the rows. */
- for (row_cntr = (y_blk_start + BLKSIZE) - (y_start + 2); row_cntr > 0; row_cntr--)
- {
- Rec_Y_ptr = &Rec_Y[addr_v + x_start]; /* advance pointer to
- /the old pell0, which has become the new pelc0 */
- addr_v += width; /* move addr_v down 1 row */
- sum_V_ptr = &sum_v[0]; /* re-initializing pointer */
- sign_V_ptr = &sign_v[0]; /* re-initilaizing pointer */
- pelp = &oldrow[0]; /* re-initializing pointer */
-
- pelu = *pelp; /* setting pelu0 to old value of pelc0 */
- *pelp++ = pelc = *Rec_Y_ptr;
- pell = *(Rec_Y_ptr + width);
- Rec_Y_ptr++;
- *sum_V_ptr++ = pelu + (pelc << 1) + pell;
- *sign_V_ptr++ = INDEX(pelu, thr) + INDEX(pelc, thr) +
- INDEX(pell, thr);
-
- pelu = *pelp; /* setting pelu1 to old value of pelc1 */
- *pelp++ = pelc = *Rec_Y_ptr;
- pell = *(Rec_Y_ptr + width);
- Rec_Y_ptr++;
- *sum_V_ptr++ = pelu + (pelc << 1) + pell;
- *sign_V_ptr++ = INDEX(pelu, thr) + INDEX(pelc, thr) +
- INDEX(pell, thr);
- /* The inner loop steps through the columns */
- for (col_cntr = (x_blk_start + BLKSIZE - 1) - x_start; col_cntr > 0; col_cntr--)
- {
- pelu = *pelp; /* setting pelu2 to old value of pelc2 */
- *pelp++ = pelc = *Rec_Y_ptr;
- pell = *(Rec_Y_ptr + width);
-
- *sum_V_ptr = pelu + (pelc << 1) + pell;
- *sign_V_ptr = INDEX(pelu, thr) + INDEX(pelc, thr) +
- INDEX(pell, thr);
-
- sum1 = *(sign_V_ptr - 2) + *(sign_V_ptr - 1) + *sign_V_ptr;
- /* the "if" statement below is the same as the one in
- / the first loop */
- if (sum1 == 0 || sum1 == 9)
- {
- sum = (*(sum_V_ptr - 2) + (*(sum_V_ptr - 1) << 1) +
- *sum_V_ptr + 8) >> 4;
-
- Rec_Y_ptr--;
- if ((int)(*Rec_Y_ptr - sum) > max_diff)
- {
- sum = *Rec_Y_ptr - max_diff;
- }
- else if ((int)(*Rec_Y_ptr - sum) < -max_diff)
- {
- sum = *Rec_Y_ptr + max_diff;
- }
- *Rec_Y_ptr++ = (uint8) sum;
- }
- Rec_Y_ptr++;
- sum_V_ptr++;
- sign_V_ptr++;
- }
- }
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
-}
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/chv_filter.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/chv_filter.cpp
deleted file mode 100644
index 6593b48..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/chv_filter.cpp
+++ /dev/null
@@ -1,654 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- [input_variable_name] = [description of the input to module, its type
- definition, and length (when applicable)]
-
- Local Stores/Buffers/Pointers Needed:
- [local_store_name] = [description of the local store, its type
- definition, and length (when applicable)]
- [local_buffer_name] = [description of the local buffer, its type
- definition, and length (when applicable)]
- [local_ptr_name] = [description of the local pointer, its type
- definition, and length (when applicable)]
-
- Global Stores/Buffers/Pointers Needed:
- [global_store_name] = [description of the global store, its type
- definition, and length (when applicable)]
- [global_buffer_name] = [description of the global buffer, its type
- definition, and length (when applicable)]
- [global_ptr_name] = [description of the global pointer, its type
- definition, and length (when applicable)]
-
- Outputs:
- [return_variable_name] = [description of data/pointer returned
- by module, its type definition, and length
- (when applicable)]
-
- Pointers and Buffers Modified:
- [variable_bfr_ptr] points to the [describe where the
- variable_bfr_ptr points to, its type definition, and length
- (when applicable)]
- [variable_bfr] contents are [describe the new contents of
- variable_bfr]
-
- Local Stores Modified:
- [local_store_name] = [describe new contents, its type
- definition, and length (when applicable)]
-
- Global Stores Modified:
- [global_store_name] = [describe new contents, its type
- definition, and length (when applicable)]
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- For fast Deblock filtering
- Newer version (macroblock based processing)
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- [List requirements to be satisfied by this module.]
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [List all references used in designing this module.]
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "mp4dec_lib.h"
-#include "post_proc.h"
-
-#define OSCL_DISABLE_WARNING_CONV_POSSIBLE_LOSS_OF_DATA
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-//#define FILTER_LEN_8
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-
-----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-#ifdef PV_POSTPROC_ON
-
-/*************************************************************************
- Function prototype : void CombinedHorzVertFilter( uint8 *rec,
- int width,
- int height,
- int *QP_store,
- int chr,
- uint8 *pp_mod)
- Parameters :
- rec : pointer to the decoded frame buffer.
- width : width of decoded frame.
- height : height of decoded frame
- QP_store: pointer to the array of QP corresponding to the decoded frame.
- It had only one value for each MB.
- chr : luma or color indication
- == 0 luma
- == 1 color
- pp_mod : The semphore used for deblocking
-
- Remark : The function do the deblocking on decoded frames.
- First based on the semaphore info., it is divided into hard and soft filtering.
- To differentiate real and fake edge, it then check the difference with QP to
- decide whether to do the filtering or not.
-
-*************************************************************************/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void CombinedHorzVertFilter(
- uint8 *rec,
- int width,
- int height,
- int16 *QP_store,
- int chr,
- uint8 *pp_mod)
-{
-
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int br, bc, mbr, mbc;
- int QP = 1;
- uint8 *ptr, *ptr_e;
- int pp_w, pp_h;
- int brwidth;
-
- int jVal0, jVal1, jVal2;
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- pp_w = (width >> 3);
- pp_h = (height >> 3);
-
- for (mbr = 0; mbr < pp_h; mbr += 2) /* row of blocks */
- {
- brwidth = mbr * pp_w; /* number of blocks above current block row */
- for (mbc = 0; mbc < pp_w; mbc += 2) /* col of blocks */
- {
- if (!chr)
- QP = QP_store[(brwidth>>2) + (mbc>>1)]; /* QP is per MB based value */
-
- /********* for each block **************/
- /****************** Horiz. Filtering ********************/
- for (br = mbr + 1; br < mbr + 3; br++) /* 2x2 blocks */
- {
- brwidth += pp_w; /* number of blocks above & left current block row */
- /* the profile on ARM920T shows separate these two boundary check is faster than combine them */
- if (br < pp_h) /* boundary : don't do it on the lowest row block */
- for (bc = mbc; bc < mbc + 2; bc++)
- {
- /****** check boundary for deblocking ************/
- if (bc < pp_w) /* boundary : don't do it on the most right col block */
- {
- ptr = rec + (brwidth << 6) + (bc << 3);
- jVal0 = brwidth + bc;
- if (chr) QP = QP_store[jVal0];
-
- ptr_e = ptr + 8; /* pointer to where the loop ends */
-
- if (((pp_mod[jVal0]&0x02)) && ((pp_mod[jVal0-pp_w]&0x02)))
- {
- /* Horiz Hard filter */
- do
- {
- jVal0 = *(ptr - width); /* C */
- jVal1 = *ptr; /* D */
- jVal2 = jVal1 - jVal0;
-
- if (((jVal2 > 0) && (jVal2 < (QP << 1)))
- || ((jVal2 < 0) && (jVal2 > -(QP << 1)))) /* (D-C) compared with 2QP */
- {
- /* differentiate between real and fake edge */
- jVal0 = ((jVal0 + jVal1) >> 1); /* (D+C)/2 */
- *(ptr - width) = (uint8)(jVal0); /* C */
- *ptr = (uint8)(jVal0); /* D */
-
- jVal0 = *(ptr - (width << 1)); /* B */
- jVal1 = *(ptr + width); /* E */
- jVal2 = jVal1 - jVal0; /* E-B */
-
- if (jVal2 > 0)
- {
- jVal0 += ((jVal2 + 3) >> 2);
- jVal1 -= ((jVal2 + 3) >> 2);
- *(ptr - (width << 1)) = (uint8)jVal0; /* store B */
- *(ptr + width) = (uint8)jVal1; /* store E */
- }
- else if (jVal2)
- {
- jVal0 -= ((3 - jVal2) >> 2);
- jVal1 += ((3 - jVal2) >> 2);
- *(ptr - (width << 1)) = (uint8)jVal0; /* store B */
- *(ptr + width) = (uint8)jVal1; /* store E */
- }
-
- jVal0 = *(ptr - (width << 1) - width); /* A */
- jVal1 = *(ptr + (width << 1)); /* F */
- jVal2 = jVal1 - jVal0; /* (F-A) */
-
- if (jVal2 > 0)
- {
- jVal0 += ((jVal2 + 7) >> 3);
- jVal1 -= ((jVal2 + 7) >> 3);
- *(ptr - (width << 1) - width) = (uint8)(jVal0);
- *(ptr + (width << 1)) = (uint8)(jVal1);
- }
- else if (jVal2)
- {
- jVal0 -= ((7 - jVal2) >> 3);
- jVal1 += ((7 - jVal2) >> 3);
- *(ptr - (width << 1) - width) = (uint8)(jVal0);
- *(ptr + (width << 1)) = (uint8)(jVal1);
- }
- }/* a3_0 > 2QP */
- }
- while (++ptr < ptr_e);
- }
- else /* Horiz soft filter*/
- {
- do
- {
- jVal0 = *(ptr - width); /* B */
- jVal1 = *ptr; /* C */
- jVal2 = jVal1 - jVal0; /* C-B */
-
- if (((jVal2 > 0) && (jVal2 < (QP)))
- || ((jVal2 < 0) && (jVal2 > -(QP)))) /* (C-B) compared with QP */
- {
-
- jVal0 = ((jVal0 + jVal1) >> 1); /* (B+C)/2 cannot overflow; ceil() */
- *(ptr - width) = (uint8)(jVal0); /* B = (B+C)/2 */
- *ptr = (uint8)jVal0; /* C = (B+C)/2 */
-
- jVal0 = *(ptr - (width << 1)); /* A */
- jVal1 = *(ptr + width); /* D */
- jVal2 = jVal1 - jVal0; /* D-A */
-
-
- if (jVal2 > 0)
- {
- jVal1 -= ((jVal2 + 7) >> 3);
- jVal0 += ((jVal2 + 7) >> 3);
- *(ptr - (width << 1)) = (uint8)jVal0; /* A */
- *(ptr + width) = (uint8)jVal1; /* D */
- }
- else if (jVal2)
- {
- jVal1 += ((7 - jVal2) >> 3);
- jVal0 -= ((7 - jVal2) >> 3);
- *(ptr - (width << 1)) = (uint8)jVal0; /* A */
- *(ptr + width) = (uint8)jVal1; /* D */
- }
- }
- }
- while (++ptr < ptr_e);
- } /* Soft filter*/
- }/* boundary checking*/
- }/*bc*/
- }/*br*/
- brwidth -= (pp_w << 1);
- /****************** Vert. Filtering ********************/
- for (br = mbr; br < mbr + 2; br++)
- {
- if (br < pp_h)
- for (bc = mbc + 1; bc < mbc + 3; bc++)
- {
- /****** check boundary for deblocking ************/
- if (bc < pp_w)
- {
- ptr = rec + (brwidth << 6) + (bc << 3);
- jVal0 = brwidth + bc;
- if (chr) QP = QP_store[jVal0];
-
- ptr_e = ptr + (width << 3);
-
- if (((pp_mod[jVal0-1]&0x01)) && ((pp_mod[jVal0]&0x01)))
- {
- /* Vert Hard filter */
- do
- {
- jVal1 = *ptr; /* D */
- jVal0 = *(ptr - 1); /* C */
- jVal2 = jVal1 - jVal0; /* D-C */
-
- if (((jVal2 > 0) && (jVal2 < (QP << 1)))
- || ((jVal2 < 0) && (jVal2 > -(QP << 1))))
- {
- jVal1 = (jVal0 + jVal1) >> 1; /* (C+D)/2 */
- *ptr = jVal1;
- *(ptr - 1) = jVal1;
-
- jVal1 = *(ptr + 1); /* E */
- jVal0 = *(ptr - 2); /* B */
- jVal2 = jVal1 - jVal0; /* E-B */
-
- if (jVal2 > 0)
- {
- jVal1 -= ((jVal2 + 3) >> 2); /* E = E -(E-B)/4 */
- jVal0 += ((jVal2 + 3) >> 2); /* B = B +(E-B)/4 */
- *(ptr + 1) = jVal1;
- *(ptr - 2) = jVal0;
- }
- else if (jVal2)
- {
- jVal1 += ((3 - jVal2) >> 2); /* E = E -(E-B)/4 */
- jVal0 -= ((3 - jVal2) >> 2); /* B = B +(E-B)/4 */
- *(ptr + 1) = jVal1;
- *(ptr - 2) = jVal0;
- }
-
- jVal1 = *(ptr + 2); /* F */
- jVal0 = *(ptr - 3); /* A */
-
- jVal2 = jVal1 - jVal0; /* (F-A) */
-
- if (jVal2 > 0)
- {
- jVal1 -= ((jVal2 + 7) >> 3); /* F -= (F-A)/8 */
- jVal0 += ((jVal2 + 7) >> 3); /* A += (F-A)/8 */
- *(ptr + 2) = jVal1;
- *(ptr - 3) = jVal0;
- }
- else if (jVal2)
- {
- jVal1 -= ((jVal2 - 7) >> 3); /* F -= (F-A)/8 */
- jVal0 += ((jVal2 - 7) >> 3); /* A += (F-A)/8 */
- *(ptr + 2) = jVal1;
- *(ptr - 3) = jVal0;
- }
- } /* end of ver hard filetering */
- }
- while ((ptr += width) < ptr_e);
- }
- else /* Vert soft filter*/
- {
- do
- {
- jVal1 = *ptr; /* C */
- jVal0 = *(ptr - 1); /* B */
- jVal2 = jVal1 - jVal0;
-
- if (((jVal2 > 0) && (jVal2 < (QP)))
- || ((jVal2 < 0) && (jVal2 > -(QP))))
- {
-
- jVal1 = (jVal0 + jVal1 + 1) >> 1;
- *ptr = jVal1; /* C */
- *(ptr - 1) = jVal1; /* B */
-
- jVal1 = *(ptr + 1); /* D */
- jVal0 = *(ptr - 2); /* A */
- jVal2 = (jVal1 - jVal0); /* D- A */
-
- if (jVal2 > 0)
- {
- jVal1 -= (((jVal2) + 7) >> 3); /* D -= (D-A)/8 */
- jVal0 += (((jVal2) + 7) >> 3); /* A += (D-A)/8 */
- *(ptr + 1) = jVal1;
- *(ptr - 2) = jVal0;
-
- }
- else if (jVal2)
- {
- jVal1 += ((7 - (jVal2)) >> 3); /* D -= (D-A)/8 */
- jVal0 -= ((7 - (jVal2)) >> 3); /* A += (D-A)/8 */
- *(ptr + 1) = jVal1;
- *(ptr - 2) = jVal0;
- }
- }
- }
- while ((ptr += width) < ptr_e);
- } /* Soft filter*/
- } /* boundary*/
- } /*bc*/
- brwidth += pp_w;
- }/*br*/
- brwidth -= (pp_w << 1);
- }/*mbc*/
- brwidth += (pp_w << 1);
- }/*mbr*/
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
-}
-void CombinedHorzVertFilter_NoSoftDeblocking(
- uint8 *rec,
- int width,
- int height,
- int16 *QP_store,
- int chr,
- uint8 *pp_mod)
-{
-
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int br, bc, mbr, mbc;
- int QP = 1;
- uint8 *ptr, *ptr_e;
- int pp_w, pp_h;
- int brwidth;
-
- int jVal0, jVal1, jVal2;
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- pp_w = (width >> 3);
- pp_h = (height >> 3);
-
- for (mbr = 0; mbr < pp_h; mbr += 2) /* row of blocks */
- {
- brwidth = mbr * pp_w; /* number of blocks above current block row */
- for (mbc = 0; mbc < pp_w; mbc += 2) /* col of blocks */
- {
- if (!chr)
- QP = QP_store[(brwidth>>2) + (mbc>>1)]; /* QP is per MB based value */
-
- /********* for each block **************/
- /****************** Horiz. Filtering ********************/
- for (br = mbr + 1; br < mbr + 3; br++) /* 2x2 blocks */
- {
- brwidth += pp_w; /* number of blocks above & left current block row */
- /* the profile on ARM920T shows separate these two boundary check is faster than combine them */
- if (br < pp_h) /* boundary : don't do it on the lowest row block */
- for (bc = mbc; bc < mbc + 2; bc++)
- {
- /****** check boundary for deblocking ************/
- if (bc < pp_w) /* boundary : don't do it on the most right col block */
- {
- ptr = rec + (brwidth << 6) + (bc << 3);
- jVal0 = brwidth + bc;
- if (chr) QP = QP_store[jVal0];
-
- ptr_e = ptr + 8; /* pointer to where the loop ends */
-
- if (((pp_mod[jVal0]&0x02)) && ((pp_mod[jVal0-pp_w]&0x02)))
- {
- /* Horiz Hard filter */
- do
- {
- jVal0 = *(ptr - width); /* C */
- jVal1 = *ptr; /* D */
- jVal2 = jVal1 - jVal0;
-
- if (((jVal2 > 0) && (jVal2 < (QP << 1)))
- || ((jVal2 < 0) && (jVal2 > -(QP << 1)))) /* (D-C) compared with 2QP */
- {
- /* differentiate between real and fake edge */
- jVal0 = ((jVal0 + jVal1) >> 1); /* (D+C)/2 */
- *(ptr - width) = (uint8)(jVal0); /* C */
- *ptr = (uint8)(jVal0); /* D */
-
- jVal0 = *(ptr - (width << 1)); /* B */
- jVal1 = *(ptr + width); /* E */
- jVal2 = jVal1 - jVal0; /* E-B */
-
- if (jVal2 > 0)
- {
- jVal0 += ((jVal2 + 3) >> 2);
- jVal1 -= ((jVal2 + 3) >> 2);
- *(ptr - (width << 1)) = (uint8)jVal0; /* store B */
- *(ptr + width) = (uint8)jVal1; /* store E */
- }
- else if (jVal2)
- {
- jVal0 -= ((3 - jVal2) >> 2);
- jVal1 += ((3 - jVal2) >> 2);
- *(ptr - (width << 1)) = (uint8)jVal0; /* store B */
- *(ptr + width) = (uint8)jVal1; /* store E */
- }
-
- jVal0 = *(ptr - (width << 1) - width); /* A */
- jVal1 = *(ptr + (width << 1)); /* F */
- jVal2 = jVal1 - jVal0; /* (F-A) */
-
- if (jVal2 > 0)
- {
- jVal0 += ((jVal2 + 7) >> 3);
- jVal1 -= ((jVal2 + 7) >> 3);
- *(ptr - (width << 1) - width) = (uint8)(jVal0);
- *(ptr + (width << 1)) = (uint8)(jVal1);
- }
- else if (jVal2)
- {
- jVal0 -= ((7 - jVal2) >> 3);
- jVal1 += ((7 - jVal2) >> 3);
- *(ptr - (width << 1) - width) = (uint8)(jVal0);
- *(ptr + (width << 1)) = (uint8)(jVal1);
- }
- }/* a3_0 > 2QP */
- }
- while (++ptr < ptr_e);
- }
-
- }/* boundary checking*/
- }/*bc*/
- }/*br*/
- brwidth -= (pp_w << 1);
- /****************** Vert. Filtering ********************/
- for (br = mbr; br < mbr + 2; br++)
- {
- if (br < pp_h)
- for (bc = mbc + 1; bc < mbc + 3; bc++)
- {
- /****** check boundary for deblocking ************/
- if (bc < pp_w)
- {
- ptr = rec + (brwidth << 6) + (bc << 3);
- jVal0 = brwidth + bc;
- if (chr) QP = QP_store[jVal0];
-
- ptr_e = ptr + (width << 3);
-
- if (((pp_mod[jVal0-1]&0x01)) && ((pp_mod[jVal0]&0x01)))
- {
- /* Vert Hard filter */
- do
- {
- jVal1 = *ptr; /* D */
- jVal0 = *(ptr - 1); /* C */
- jVal2 = jVal1 - jVal0; /* D-C */
-
- if (((jVal2 > 0) && (jVal2 < (QP << 1)))
- || ((jVal2 < 0) && (jVal2 > -(QP << 1))))
- {
- jVal1 = (jVal0 + jVal1) >> 1; /* (C+D)/2 */
- *ptr = jVal1;
- *(ptr - 1) = jVal1;
-
- jVal1 = *(ptr + 1); /* E */
- jVal0 = *(ptr - 2); /* B */
- jVal2 = jVal1 - jVal0; /* E-B */
-
- if (jVal2 > 0)
- {
- jVal1 -= ((jVal2 + 3) >> 2); /* E = E -(E-B)/4 */
- jVal0 += ((jVal2 + 3) >> 2); /* B = B +(E-B)/4 */
- *(ptr + 1) = jVal1;
- *(ptr - 2) = jVal0;
- }
- else if (jVal2)
- {
- jVal1 += ((3 - jVal2) >> 2); /* E = E -(E-B)/4 */
- jVal0 -= ((3 - jVal2) >> 2); /* B = B +(E-B)/4 */
- *(ptr + 1) = jVal1;
- *(ptr - 2) = jVal0;
- }
-
- jVal1 = *(ptr + 2); /* F */
- jVal0 = *(ptr - 3); /* A */
-
- jVal2 = jVal1 - jVal0; /* (F-A) */
-
- if (jVal2 > 0)
- {
- jVal1 -= ((jVal2 + 7) >> 3); /* F -= (F-A)/8 */
- jVal0 += ((jVal2 + 7) >> 3); /* A += (F-A)/8 */
- *(ptr + 2) = jVal1;
- *(ptr - 3) = jVal0;
- }
- else if (jVal2)
- {
- jVal1 -= ((jVal2 - 7) >> 3); /* F -= (F-A)/8 */
- jVal0 += ((jVal2 - 7) >> 3); /* A += (F-A)/8 */
- *(ptr + 2) = jVal1;
- *(ptr - 3) = jVal0;
- }
- } /* end of ver hard filetering */
- }
- while ((ptr += width) < ptr_e);
- }
-
- } /* boundary*/
- } /*bc*/
- brwidth += pp_w;
- }/*br*/
- brwidth -= (pp_w << 1);
- }/*mbc*/
- brwidth += (pp_w << 1);
- }/*mbr*/
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
-}
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/chvr_filter.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/chvr_filter.cpp
deleted file mode 100644
index 795cf71..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/chvr_filter.cpp
+++ /dev/null
@@ -1,565 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "mp4dec_lib.h"
-#include "post_proc.h"
-
-#ifdef PV_POSTPROC_ON
-
-void CombinedHorzVertRingFilter(
- uint8 *rec,
- int width,
- int height,
- int16 *QP_store,
- int chr,
- uint8 *pp_mod)
-{
-
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int index, counter;
- int br, bc, incr, mbr, mbc;
- int QP = 1;
- int v[5];
- uint8 *ptr, *ptr_c, *ptr_n;
- int w1, w2, w3, w4;
- int pp_w, pp_h, brwidth;
- int sum, delta;
- int a3_0, a3_1, a3_2, A3_0;
- /* for Deringing Threshold approach (MPEG4)*/
- int max_diff, thres, v0, h0, min_blk, max_blk;
- int cnthflag;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- /* Calculate the width and height of the area in blocks (divide by 8) */
- pp_w = (width >> 3);
- pp_h = (height >> 3);
-
- /* Set up various values needed for updating pointers into rec */
- w1 = width; /* Offset to next row in pixels */
- w2 = width << 1; /* Offset to two rows in pixels */
- w3 = w1 + w2; /* Offset to three rows in pixels */
- w4 = w2 << 1; /* Offset to four rows in pixels */
- incr = width - BLKSIZE; /* Offset to next row after processing block */
-
- /* Work through the area hortizontally by two rows per step */
- for (mbr = 0; mbr < pp_h; mbr += 2)
- {
- /* brwidth contains the block number of the leftmost block
- * of the current row */
- brwidth = mbr * pp_w;
-
- /* Work through the area vertically by two columns per step */
- for (mbc = 0; mbc < pp_w; mbc += 2)
- {
- /* if the data is luminance info, get the correct
- * quantization paramenter. One parameter per macroblock */
- if (!chr)
- {
- /* brwidth/4 is the macroblock number and mbc/2 is the macroblock col number*/
- QP = QP_store[(brwidth>>2) + (mbc>>1)];
- }
-
- /****************** Horiz. Filtering ********************/
- /* Process four blocks for the filtering */
- /********************************************************/
- /* Loop over two rows of blocks */
- for (br = mbr + 1; br < mbr + 3; br++) /* br is the row counter in blocks */
- {
- /* Set brwidth to the first (leftmost) block number of the next row */
- /* brwidth is used as an index when counting blocks */
- brwidth += pp_w;
-
- /* Loop over two columns of blocks in the row */
- for (bc = mbc; bc < mbc + 2; bc++) /* bc is the column counter in blocks */
- {
- /****** check boundary for deblocking ************/
- /* Execute if the row and column counters are within the area */
- if (br < pp_h && bc < pp_w)
- {
- /* Set the ptr to the first pixel of the first block of the second row
- * brwidth * 64 is the pixel row offset
- * bc * 8 is the pixel column offset */
- ptr = rec + (brwidth << 6) + (bc << 3);
-
- /* Set the index to the current block of the second row counting in blocks */
- index = brwidth + bc;
-
- /* if the data is chrominance info, get the correct
- * quantization paramenter. One parameter per block. */
- if (chr)
- {
- QP = QP_store[index];
- }
-
- /* Execute hard horizontal filter if semaphore for horizontal deblocking
- * is set for the current block and block immediately above it */
- if (((pp_mod[index]&0x02) != 0) && ((pp_mod[index-pp_w]&0x02) != 0))
- { /* Hard filter */
-
- /* Set HorzHflag (bit 4) in the pp_mod location */
- pp_mod[index-pp_w] |= 0x10; /* 4/26/00 reuse pp_mod for HorzHflag*/
-
- /* Filter across the 8 pixels of the block */
- for (index = BLKSIZE; index > 0; index--)
- {
- /* Difference between the current pixel and the pixel above it */
- a3_0 = *ptr - *(ptr - w1);
-
- /* if the magnitude of the difference is greater than the KThH threshold
- * and within the quantization parameter, apply hard filter */
- if ((a3_0 > KThH || a3_0 < -KThH) && a3_0<QP && a3_0> -QP)
- {
- ptr_c = ptr - w3; /* Points to pixel three rows above */
- ptr_n = ptr + w1; /* Points to pixel one row below */
- v[0] = (int)(*(ptr_c - w3));
- v[1] = (int)(*(ptr_c - w2));
- v[2] = (int)(*(ptr_c - w1));
- v[3] = (int)(*ptr_c);
- v[4] = (int)(*(ptr_c + w1));
-
- sum = v[0]
- + v[1]
- + v[2]
- + *ptr_c
- + v[4]
- + (*(ptr_c + w2))
- + (*(ptr_c + w3)); /* Current pixel */
-
- delta = (sum + *ptr_c + 4) >> 3; /* Average pixel values with rounding */
- *(ptr_c) = (uint8) delta;
-
- /* Move pointer down one row of pixels (points to pixel two rows
- * above current pixel) */
- ptr_c += w1;
-
- for (counter = 0; counter < 5; counter++)
- {
- /* Subtract off highest pixel and add in pixel below */
- sum = sum - v[counter] + *ptr_n;
- /* Average the pixel values with rounding */
- delta = (sum + *ptr_c + 4) >> 3;
- *ptr_c = (uint8)(delta);
-
- /* Increment pointers to next pixel row */
- ptr_c += w1;
- ptr_n += w1;
- }
- }
- /* Increment pointer to next pixel */
- ++ptr;
- } /* index*/
- }
- else
- { /* soft filter*/
-
- /* Clear HorzHflag (bit 4) in the pp_mod location */
- pp_mod[index-pp_w] &= 0xef; /* reset 1110,1111 */
-
- for (index = BLKSIZE; index > 0; index--)
- {
- /* Difference between the current pixel and the pixel above it */
- a3_0 = *(ptr) - *(ptr - w1);
-
- /* if the magnitude of the difference is greater than the KTh threshold,
- * apply soft filter */
- if ((a3_0 > KTh || a3_0 < -KTh))
- {
-
- /* Sum of weighted differences */
- a3_0 += ((*(ptr - w2) - *(ptr + w1)) << 1) + (a3_0 << 2);
-
- /* Check if sum is less than the quantization parameter */
- if (PV_ABS(a3_0) < (QP << 3))
- {
- a3_1 = *(ptr - w2) - *(ptr - w3);
- a3_1 += ((*(ptr - w4) - *(ptr - w1)) << 1) + (a3_1 << 2);
-
- a3_2 = *(ptr + w2) - *(ptr + w1);
- a3_2 += ((*(ptr) - *(ptr + w3)) << 1) + (a3_2 << 2);
-
- A3_0 = PV_ABS(a3_0) - PV_MIN(PV_ABS(a3_1), PV_ABS(a3_2));
-
- if (A3_0 > 0)
- {
- A3_0 += A3_0 << 2;
- A3_0 = (A3_0 + 32) >> 6;
- if (a3_0 > 0)
- {
- A3_0 = -A3_0;
- }
-
- delta = (*(ptr - w1) - *(ptr)) >> 1;
- if (delta >= 0)
- {
- if (delta >= A3_0)
- {
- delta = PV_MAX(A3_0, 0);
- }
- }
- else
- {
- if (A3_0 > 0)
- {
- delta = 0;
- }
- else
- {
- delta = PV_MAX(A3_0, delta);
- }
- }
-
- *(ptr - w1) = (uint8)(*(ptr - w1) - delta);
- *(ptr) = (uint8)(*(ptr) + delta);
- }
- } /*threshold*/
- }
- /* Increment pointer to next pixel */
- ++ptr;
- } /*index*/
- } /* Soft filter*/
- }/* boundary checking*/
- }/*bc*/
- }/*br*/
- brwidth -= (pp_w << 1);
-
-
- /****************** Vert. Filtering *********************/
- /* Process four blocks for the filtering */
- /********************************************************/
- /* Loop over two rows of blocks */
- for (br = mbr; br < mbr + 2; br++) /* br is the row counter in blocks */
- {
- for (bc = mbc + 1; bc < mbc + 3; bc++) /* bc is the column counter in blocks */
- {
- /****** check boundary for deblocking ************/
- /* Execute if the row and column counters are within the area */
- if (br < pp_h && bc < pp_w)
- {
- /* Set the ptr to the first pixel of the first block of the second row
- * brwidth * 64 is the pixel row offset
- * bc * 8 is the pixel column offset */
- ptr = rec + (brwidth << 6) + (bc << 3);
-
- /* Set the index to the current block of the second row counting in blocks */
- index = brwidth + bc;
-
- /* if the data is chrominance info, get the correct
- * quantization paramenter. One parameter per block. */
- if (chr)
- {
- QP = QP_store[index];
- }
-
- /* Execute hard vertical filter if semaphore for vertical deblocking
- * is set for the current block and block immediately left of it */
- if (((pp_mod[index-1]&0x01) != 0) && ((pp_mod[index]&0x01) != 0))
- { /* Hard filter */
-
- /* Set VertHflag (bit 5) in the pp_mod location of previous block*/
- pp_mod[index-1] |= 0x20; /* 4/26/00 reuse pp_mod for VertHflag*/
-
- /* Filter across the 8 pixels of the block */
- for (index = BLKSIZE; index > 0; index--)
- {
- /* Difference between the current pixel
- * and the pixel to left of it */
- a3_0 = *ptr - *(ptr - 1);
-
- /* if the magnitude of the difference is greater than the KThH threshold
- * and within the quantization parameter, apply hard filter */
- if ((a3_0 > KThH || a3_0 < -KThH) && a3_0<QP && a3_0> -QP)
- {
- ptr_c = ptr - 3;
- ptr_n = ptr + 1;
- v[0] = (int)(*(ptr_c - 3));
- v[1] = (int)(*(ptr_c - 2));
- v[2] = (int)(*(ptr_c - 1));
- v[3] = (int)(*ptr_c);
- v[4] = (int)(*(ptr_c + 1));
-
- sum = v[0]
- + v[1]
- + v[2]
- + *ptr_c
- + v[4]
- + (*(ptr_c + 2))
- + (*(ptr_c + 3));
-
- delta = (sum + *ptr_c + 4) >> 3;
- *(ptr_c) = (uint8) delta;
-
- /* Move pointer down one pixel to the right */
- ptr_c += 1;
- for (counter = 0; counter < 5; counter++)
- {
- /* Subtract off highest pixel and add in pixel below */
- sum = sum - v[counter] + *ptr_n;
- /* Average the pixel values with rounding */
- delta = (sum + *ptr_c + 4) >> 3;
- *ptr_c = (uint8)(delta);
-
- /* Increment pointers to next pixel */
- ptr_c += 1;
- ptr_n += 1;
- }
- }
- /* Increment pointers to next pixel row */
- ptr += w1;
- } /* index*/
- }
- else
- { /* soft filter*/
-
- /* Clear VertHflag (bit 5) in the pp_mod location */
- pp_mod[index-1] &= 0xdf; /* reset 1101,1111 */
- for (index = BLKSIZE; index > 0; index--)
- {
- /* Difference between the current pixel and the pixel above it */
- a3_0 = *(ptr) - *(ptr - 1);
-
- /* if the magnitude of the difference is greater than the KTh threshold,
- * apply soft filter */
- if ((a3_0 > KTh || a3_0 < -KTh))
- {
-
- /* Sum of weighted differences */
- a3_0 += ((*(ptr - 2) - *(ptr + 1)) << 1) + (a3_0 << 2);
-
- /* Check if sum is less than the quantization parameter */
- if (PV_ABS(a3_0) < (QP << 3))
- {
- a3_1 = *(ptr - 2) - *(ptr - 3);
- a3_1 += ((*(ptr - 4) - *(ptr - 1)) << 1) + (a3_1 << 2);
-
- a3_2 = *(ptr + 2) - *(ptr + 1);
- a3_2 += ((*(ptr) - *(ptr + 3)) << 1) + (a3_2 << 2);
-
- A3_0 = PV_ABS(a3_0) - PV_MIN(PV_ABS(a3_1), PV_ABS(a3_2));
-
- if (A3_0 > 0)
- {
- A3_0 += A3_0 << 2;
- A3_0 = (A3_0 + 32) >> 6;
- if (a3_0 > 0)
- {
- A3_0 = -A3_0;
- }
-
- delta = (*(ptr - 1) - *(ptr)) >> 1;
- if (delta >= 0)
- {
- if (delta >= A3_0)
- {
- delta = PV_MAX(A3_0, 0);
- }
- }
- else
- {
- if (A3_0 > 0)
- {
- delta = 0;
- }
- else
- {
- delta = PV_MAX(A3_0, delta);
- }
- }
-
- *(ptr - 1) = (uint8)(*(ptr - 1) - delta);
- *(ptr) = (uint8)(*(ptr) + delta);
- }
- } /*threshold*/
- }
- ptr += w1;
- } /*index*/
- } /* Soft filter*/
- } /* boundary*/
- } /*bc*/
- /* Increment pointer to next row of pixels */
- brwidth += pp_w;
- }/*br*/
- brwidth -= (pp_w << 1);
-
- /****************** Deringing ***************************/
- /* Process four blocks for the filtering */
- /********************************************************/
- /* Loop over two rows of blocks */
- for (br = mbr; br < mbr + 2; br++)
- {
- /* Loop over two columns of blocks in the row */
- for (bc = mbc; bc < mbc + 2; bc++)
- {
- /* Execute if the row and column counters are within the area */
- if (br < pp_h && bc < pp_w)
- {
- /* Set the index to the current block */
- index = brwidth + bc;
-
- /* Execute deringing if semaphore for deringing (bit-3 of pp_mod)
- * is set for the current block */
- if ((pp_mod[index]&0x04) != 0)
- {
- /* Don't process deringing if on an edge block */
- if (br > 0 && bc > 0 && br < pp_h - 1 && bc < pp_w - 1)
- {
- /* cnthflag = weighted average of HorzHflag of current,
- * one above, previous blocks*/
- cnthflag = ((pp_mod[index] & 0x10) +
- (pp_mod[index-pp_w] & 0x10) +
- ((pp_mod[index-1] >> 1) & 0x10) +
- ((pp_mod[index] >> 1) & 0x10)) >> 4; /* 4/26/00*/
-
- /* Do the deringing if decision flags indicate it's necessary */
- if (cnthflag < 3)
- {
- /* if the data is chrominance info, get the correct
- * quantization paramenter. One parameter per block. */
- if (chr)
- {
- QP = QP_store[index];
- }
-
- /* Set amount to change luminance if it needs to be changed
- * based on quantization parameter */
- max_diff = (QP >> 2) + 4;
-
- /* Set pointer to first pixel of current block */
- ptr = rec + (brwidth << 6) + (bc << 3);
-
- /* Find minimum and maximum value of pixel block */
- FindMaxMin(ptr, &min_blk, &max_blk, incr);
-
- /* threshold determination */
- thres = (max_blk + min_blk + 1) >> 1;
-
- /* If pixel range is greater or equal than DERING_THR, smooth the region */
- if ((max_blk - min_blk) >= DERING_THR) /*smooth 8x8 region*/
-#ifndef NoMMX
- {
- /* smooth all pixels in the block*/
- DeringAdaptiveSmoothMMX(ptr, width, thres, max_diff);
- }
-#else
- {
- /* Setup the starting point of the region to smooth */
- v0 = (br << 3) - 1;
- h0 = (bc << 3) - 1;
-
- /*smooth 8x8 region*/
- AdaptiveSmooth_NoMMX(rec, v0, h0, v0 + 1, h0 + 1, thres, width, max_diff);
- }
-#endif
- }/*cnthflag*/
- } /*dering br==1 or bc==1 (boundary block)*/
- else /* Process the boundary blocks */
- {
- /* Decide to perform deblocking based on the semaphore flags
- * of the neighboring blocks in each case. A certain number of
- * hard filtering flags have to be set in order to signal need
- * for smoothing */
- if (br > 0 && br < pp_h - 1)
- {
- if (bc > 0)
- {
- cnthflag = ((pp_mod[index-pp_w] & 0x10) +
- (pp_mod[index] & 0x10) +
- ((pp_mod[index-1] >> 1) & 0x10)) >> 4;
- }
- else
- {
- cnthflag = ((pp_mod[index] & 0x10) +
- (pp_mod[index-pp_w] & 0x10) +
- ((pp_mod[index] >> 1) & 0x10)) >> 4;
- }
- }
- else if (bc > 0 && bc < pp_w - 1)
- {
- if (br > 0)
- {
- cnthflag = ((pp_mod[index-pp_w] & 0x10) +
- ((pp_mod[index-1] >> 1) & 0x10) +
- ((pp_mod[index] >> 1) & 0x10)) >> 4;
- }
- else
- {
- cnthflag = ((pp_mod[index] & 0x10) +
- ((pp_mod[index-1] >> 1) & 0x10) +
- ((pp_mod[index] >> 1) & 0x10)) >> 4;
- }
- }
- else /* at the corner do default*/
- {
- cnthflag = 0;
- }
-
- /* Do the deringing if decision flags indicate it's necessary */
- if (cnthflag < 2)
- {
-
- /* if the data is chrominance info, get the correct
- * quantization paramenter. One parameter per block. */
- if (chr)
- {
- QP = QP_store[index];
- }
-
- /* Set amount to change luminance if it needs to be changed
- * based on quantization parameter */
- max_diff = (QP >> 2) + 4;
-
- /* Set pointer to first pixel of current block */
- ptr = rec + (brwidth << 6) + (bc << 3);
-
- /* Find minimum and maximum value of pixel block */
- FindMaxMin(ptr, &min_blk, &max_blk, incr);
-
- /* threshold determination */
- thres = (max_blk + min_blk + 1) >> 1;
-
- /* Setup the starting point of the region to smooth
- * This is going to be a 4x4 region */
- v0 = (br << 3) + 1;
- h0 = (bc << 3) + 1;
-
- /* If pixel range is greater or equal than DERING_THR, smooth the region */
- if ((max_blk - min_blk) >= DERING_THR)
- {
- /* Smooth 4x4 region */
- AdaptiveSmooth_NoMMX(rec, v0, h0, v0 - 3, h0 - 3, thres, width, max_diff);
- }
- }/*cnthflag*/
- } /* br==0, bc==0*/
- } /* dering*/
- } /*boundary condition*/
- }/*bc*/
- brwidth += pp_w;
- }/*br*/
- brwidth -= (pp_w << 1);
- }/*mbc*/
- brwidth += (pp_w << 1);
- }/*mbr*/
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return ;
-}
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/combined_decode.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/combined_decode.cpp
index 6499233..72cbe83 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/combined_decode.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/combined_decode.cpp
@@ -544,30 +544,12 @@
int16 DC_coeff;
PV_STATUS status;
-#ifdef PV_POSTPROC_ON
- /* post-processing */
- uint8 *pp_mod[6];
- int TotalMB = video->nTotalMB;
- int MB_in_width = video->nMBPerRow;
-#endif
int y_pos = video->mbnum_row;
int x_pos = video->mbnum_col;
int32 offset = (int32)(y_pos << 4) * width + (x_pos << 4);
/* Decode each 8-by-8 blocks. comp 0 ~ 3 are luminance blocks, 4 ~ 5 */
/* are chrominance blocks. 04/03/2000. */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- {
- /** post-processing ***/
- pp_mod[0] = video->pstprcTypCur + (y_pos << 1) * (MB_in_width << 1) + (x_pos << 1);
- pp_mod[1] = pp_mod[0] + 1;
- pp_mod[2] = pp_mod[0] + (MB_in_width << 1);
- pp_mod[3] = pp_mod[2] + 1;
- pp_mod[4] = video->pstprcTypCur + (TotalMB << 2) + mbnum;
- pp_mod[5] = pp_mod[4] + TotalMB;
- }
-#endif
/* oscl_memset(mblock->block, 0, sizeof(typeMBStore)); Aug 9,2005 */
@@ -645,10 +627,6 @@
}
no_coeff[comp] = ncoeffs[comp];
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[comp] = (uint8) PostProcSemaphore(dataBlock);
-#endif
}
MBlockIDCT(video);
}
@@ -677,20 +655,6 @@
BlockIDCT(c_comp + (comp&2)*(width << 2) + 8*(comp&1), mblock->pred_block + (comp&2)*64 + 8*(comp&1), mblock->block[comp], width, ncoeffs[comp],
mblock->bitmapcol[comp], mblock->bitmaprow[comp]);
-#ifdef PV_POSTPROC_ON
- /* for inter just test for ringing */
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[comp] = (uint8)((ncoeffs[comp] > 3) ? 4 : 0);
-#endif
- }
- else
- {
- /* no IDCT for all zeros blocks 03/28/2002 */
- /* BlockIDCT(); */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[comp] = 0;
-#endif
}
}
@@ -707,20 +671,6 @@
BlockIDCT(video->currVop->uChan + (offset >> 2) + (x_pos << 2), mblock->pred_block + 256, mblock->block[4], width >> 1, ncoeffs[4],
mblock->bitmapcol[4], mblock->bitmaprow[4]);
-#ifdef PV_POSTPROC_ON
- /* for inter just test for ringing */
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[4] = (uint8)((ncoeffs[4] > 3) ? 4 : 0);
-#endif
- }
- else
- {
- /* no IDCT for all zeros blocks 03/28/2002 */
- /* BlockIDCT(); */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[4] = 0;
-#endif
}
(*DC)[5] = mid_gray;
if (CBP & 1)
@@ -731,20 +681,6 @@
BlockIDCT(video->currVop->vChan + (offset >> 2) + (x_pos << 2), mblock->pred_block + 264, mblock->block[5], width >> 1, ncoeffs[5],
mblock->bitmapcol[5], mblock->bitmaprow[5]);
-#ifdef PV_POSTPROC_ON
- /* for inter just test for ringing */
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[5] = (uint8)((ncoeffs[5] > 3) ? 4 : 0);
-#endif
- }
- else
- {
- /* no IDCT for all zeros blocks 03/28/2002 */
- /* BlockIDCT(); */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[5] = 0;
-#endif
}
video->QPMB[mbnum] = QP; /* restore the QP values ANNEX_T*/
#else
@@ -759,20 +695,6 @@
BlockIDCT(c_comp + (comp&2)*(width << 2) + 8*(comp&1), mblock->pred_block + (comp&2)*64 + 8*(comp&1), mblock->block[comp], width, ncoeffs[comp],
mblock->bitmapcol[comp], mblock->bitmaprow[comp]);
-#ifdef PV_POSTPROC_ON
- /* for inter just test for ringing */
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[comp] = (uint8)((ncoeffs[comp] > 3) ? 4 : 0);
-#endif
- }
- else
- {
- /* no IDCT for all zeros blocks 03/28/2002 */
- /* BlockIDCT(); */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[comp] = 0;
-#endif
}
}
@@ -785,20 +707,11 @@
BlockIDCT(video->currVop->uChan + (offset >> 2) + (x_pos << 2), mblock->pred_block + 256, mblock->block[4], width >> 1, ncoeffs[4],
mblock->bitmapcol[4], mblock->bitmaprow[4]);
-#ifdef PV_POSTPROC_ON
- /* for inter just test for ringing */
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[4] = (uint8)((ncoeffs[4] > 3) ? 4 : 0);
-#endif
}
else
{
/* no IDCT for all zeros blocks 03/28/2002 */
/* BlockIDCT(); */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[4] = 0;
-#endif
}
(*DC)[5] = mid_gray;
if (CBP & 1)
@@ -809,20 +722,11 @@
BlockIDCT(video->currVop->vChan + (offset >> 2) + (x_pos << 2), mblock->pred_block + 264, mblock->block[5], width >> 1, ncoeffs[5],
mblock->bitmapcol[5], mblock->bitmaprow[5]);
-#ifdef PV_POSTPROC_ON
- /* for inter just test for ringing */
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[5] = (uint8)((ncoeffs[5] > 3) ? 4 : 0);
-#endif
}
else
{
/* no IDCT for all zeros blocks 03/28/2002 */
/* BlockIDCT(); */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[5] = 0;
-#endif
#endif // PV_ANNEX_IJKT_SUPPORT
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/datapart_decode.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/datapart_decode.cpp
index 00db04b..6071f40 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/datapart_decode.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/datapart_decode.cpp
@@ -635,29 +635,9 @@
int QP_tmp = QP;
int y_pos = video->mbnum_row;
-#ifdef PV_POSTPROC_ON
- uint8 *pp_mod[6];
- int TotalMB = video->nTotalMB;
- int MB_in_width = video->nMBPerRow;
-#endif
- /*****
- * Decoding of the 6 blocks (depending on transparent pattern)
- *****/
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- {
- /** post-processing ***/
- pp_mod[0] = video->pstprcTypCur + (y_pos << 1) * (MB_in_width << 1) + (x_pos << 1);
- pp_mod[1] = pp_mod[0] + 1;
- pp_mod[2] = pp_mod[0] + (MB_in_width << 1);
- pp_mod[3] = pp_mod[2] + 1;
- pp_mod[4] = video->pstprcTypCur + (TotalMB << 2) + mbnum;
- pp_mod[5] = pp_mod[4] + TotalMB;
- }
-#endif
/* oscl_memset(mblock->block, 0, sizeof(typeMBStore)); Aug 9,2005 */
@@ -698,10 +678,6 @@
/* modified to new semaphore for post-proc */
// Future work:: can be combined in the dequant function
// @todo Deblocking Semaphore for INTRA block
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[comp] = (uint8) PostProcSemaphore(dataBlock);
-#endif
}
MBlockIDCT(video);
}
@@ -738,10 +714,6 @@
}
/* @todo Deblocking Semaphore for INTRA block, for inter just test for ringing */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[comp] = (uint8)((ncoeffs[comp] > 3) ? 4 : 0);
-#endif
}
(*DC)[4] = mid_gray;
@@ -760,10 +732,6 @@
{
ncoeffs[4] = 0;
}
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[4] = (uint8)((ncoeffs[4] > 3) ? 4 : 0);
-#endif
(*DC)[5] = mid_gray;
if (CBP & 1)
{
@@ -780,10 +748,6 @@
{
ncoeffs[5] = 0;
}
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- *pp_mod[5] = (uint8)((ncoeffs[5] > 3) ? 4 : 0);
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/deringing_chroma.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/deringing_chroma.cpp
deleted file mode 100644
index ce779b0..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/deringing_chroma.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "mp4dec_lib.h"
-#include "post_proc.h"
-
-#ifdef PV_POSTPROC_ON
-
-void Deringing_Chroma(
- uint8 *Rec_C,
- int width,
- int height,
- int16 *QP_store,
- int,
- uint8 *pp_mod
-)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int thres;
- int v_blk, h_blk;
- int max_diff;
- int v_pel, h_pel;
- int max_blk, min_blk;
- int v0, h0;
- uint8 *ptr;
- int sum, sum1, incr;
- int32 addr_v;
- int sign_v[10], sum_v[10];
- int *ptr2, *ptr3;
- uint8 pelu, pelc, pell;
- incr = width - BLKSIZE;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- /* chrominance */
- /* Do the first line (7 pixels at a time => Don't use MMX)*/
- for (h_blk = 0; h_blk < width; h_blk += BLKSIZE)
- {
- max_diff = (QP_store[h_blk>>3] >> 2) + 4;
- ptr = &Rec_C[h_blk];
- max_blk = min_blk = *ptr;
- FindMaxMin(ptr, &min_blk, &max_blk, width);
- h0 = ((h_blk - 1) >= 1) ? (h_blk - 1) : 1;
-
- if (max_blk - min_blk >= 4)
- {
- thres = (max_blk + min_blk + 1) >> 1;
-
-
- for (v_pel = 1; v_pel < BLKSIZE - 1; v_pel++)
- {
- addr_v = (int32)v_pel * width;
- ptr = &Rec_C[addr_v + h0 - 1];
- ptr2 = &sum_v[0];
- ptr3 = &sign_v[0];
-
- pelu = *(ptr - width);
- pelc = *ptr;
- pell = *(ptr + width);
- ptr++;
- *ptr2++ = pelu + (pelc << 1) + pell;
- *ptr3++ = INDEX(pelu, thres) + INDEX(pelc, thres) + INDEX(pell, thres);
-
- pelu = *(ptr - width);
- pelc = *ptr;
- pell = *(ptr + width);
- ptr++;
- *ptr2++ = pelu + (pelc << 1) + pell;
- *ptr3++ = INDEX(pelu, thres) + INDEX(pelc, thres) + INDEX(pell, thres);
-
- for (h_pel = h0; h_pel < h_blk + BLKSIZE - 1; h_pel++)
- {
- pelu = *(ptr - width);
- pelc = *ptr;
- pell = *(ptr + width);
-
- *ptr2 = pelu + (pelc << 1) + pell;
- *ptr3 = INDEX(pelu, thres) + INDEX(pelc, thres) + INDEX(pell, thres);
-
- sum1 = *(ptr3 - 2) + *(ptr3 - 1) + *ptr3;
- if (sum1 == 0 || sum1 == 9)
- {
- sum = (*(ptr2 - 2) + (*(ptr2 - 1) << 1) + *ptr2 + 8) >> 4;
-
- ptr--;
- if (PV_ABS(*ptr - sum) > max_diff)
- {
- if (sum > *ptr)
- sum = *ptr + max_diff;
- else
- sum = *ptr - max_diff;
- }
- *ptr++ = (uint8) sum;
- }
- ptr++;
- ptr2++;
- ptr3++;
- }
- }
- }
- }
-
- for (v_blk = BLKSIZE; v_blk < height; v_blk += BLKSIZE)
- {
- v0 = v_blk - 1;
- /* Do the first block (pixels=7 => No MMX) */
- max_diff = (QP_store[((((int32)v_blk*width)>>3))>>3] >> 2) + 4;
- ptr = &Rec_C[(int32)v_blk * width];
- max_blk = min_blk = *ptr;
- FindMaxMin(ptr, &min_blk, &max_blk, incr);
-
- if (max_blk - min_blk >= 4)
- {
- thres = (max_blk + min_blk + 1) >> 1;
-
- for (v_pel = v0; v_pel < v_blk + BLKSIZE - 1; v_pel++)
- {
- addr_v = v_pel * width;
- ptr = &Rec_C[addr_v];
- ptr2 = &sum_v[0];
- ptr3 = &sign_v[0];
-
- pelu = *(ptr - width);
- pelc = *ptr;
- pell = *(ptr + width);
- ptr++;
- *ptr2++ = pelu + (pelc << 1) + pell;
- *ptr3++ = INDEX(pelu, thres) + INDEX(pelc, thres) + INDEX(pell, thres);
-
- pelu = *(ptr - width);
- pelc = *ptr;
- pell = *(ptr + width);
- ptr++;
- *ptr2++ = pelu + (pelc << 1) + pell;
- *ptr3++ = INDEX(pelu, thres) + INDEX(pelc, thres) + INDEX(pell, thres);
-
- for (h_pel = 1; h_pel < BLKSIZE - 1; h_pel++)
- {
- pelu = *(ptr - width);
- pelc = *ptr;
- pell = *(ptr + width);
-
- *ptr2 = pelu + (pelc << 1) + pell;
- *ptr3 = INDEX(pelu, thres) + INDEX(pelc, thres) + INDEX(pell, thres);
-
- sum1 = *(ptr3 - 2) + *(ptr3 - 1) + *ptr3;
- if (sum1 == 0 || sum1 == 9)
- {
- sum = (*(ptr2 - 2) + (*(ptr2 - 1) << 1) + *ptr2 + 8) >> 4;
-
- ptr--;
- if (PV_ABS(*ptr - sum) > max_diff)
- {
- if (sum > *ptr)
- sum = *ptr + max_diff;
- else
- sum = *ptr - max_diff;
- }
- *ptr++ = (uint8) sum;
- }
- ptr++;
- ptr2++;
- ptr3++;
- }
- }
- }
-
-
- /* Do the rest in MMX */
- for (h_blk = BLKSIZE; h_blk < width; h_blk += BLKSIZE)
- {
- if ((pp_mod[(v_blk/8)*(width/8)+h_blk/8]&0x4) != 0)
- {
- max_diff = (QP_store[((((int32)v_blk*width)>>3)+h_blk)>>3] >> 2) + 4;
- ptr = &Rec_C[(int32)v_blk * width + h_blk];
- max_blk = min_blk = *ptr;
- FindMaxMin(ptr, &min_blk, &max_blk, incr);
- h0 = h_blk - 1;
-
- if (max_blk - min_blk >= 4)
- {
- thres = (max_blk + min_blk + 1) >> 1;
-#ifdef NoMMX
- AdaptiveSmooth_NoMMX(Rec_C, v0, h0, v_blk, h_blk, thres, width, max_diff);
-#else
- DeringAdaptiveSmoothMMX(&Rec_C[(int32)v0*width+h0], width, thres, max_diff);
-#endif
- }
- }
- }
- } /* macroblock level */
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
-}
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/deringing_luma.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/deringing_luma.cpp
deleted file mode 100644
index b5574b4..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/deringing_luma.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "mp4dec_lib.h"
-#include "post_proc.h"
-
-#ifdef PV_POSTPROC_ON
-
-void Deringing_Luma(
- uint8 *Rec_Y,
- int width,
- int height,
- int16 *QP_store,
- int,
- uint8 *pp_mod)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int thres[4], range[4], max_range_blk, max_thres_blk;
- int MB_V, MB_H, BLK_V, BLK_H;
- int v_blk, h_blk;
- int max_diff;
- int max_blk, min_blk;
- int v0, h0;
- uint8 *ptr;
- int thr, blks, incr;
- int mb_indx, blk_indx;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- incr = width - BLKSIZE;
-
- /* Dering the first line of macro blocks */
- for (MB_H = 0; MB_H < width; MB_H += MBSIZE)
- {
- max_diff = (QP_store[(MB_H)>>4] >> 2) + 4;
-
- /* threshold determination */
- max_range_blk = max_thres_blk = 0;
- blks = 0;
-
- for (BLK_V = 0; BLK_V < MBSIZE; BLK_V += BLKSIZE)
- {
- for (BLK_H = 0; BLK_H < MBSIZE; BLK_H += BLKSIZE)
- {
- ptr = &Rec_Y[(int32)(BLK_V) * width + MB_H + BLK_H];
- FindMaxMin(ptr, &min_blk, &max_blk, incr);
-
- thres[blks] = (max_blk + min_blk + 1) >> 1;
- range[blks] = max_blk - min_blk;
-
- if (range[blks] >= max_range_blk)
- {
- max_range_blk = range[blks];
- max_thres_blk = thres[blks];
- }
- blks++;
- }
- }
-
- blks = 0;
- for (v_blk = 0; v_blk < MBSIZE; v_blk += BLKSIZE)
- {
- v0 = ((v_blk - 1) >= 1) ? (v_blk - 1) : 1;
- for (h_blk = MB_H; h_blk < MB_H + MBSIZE; h_blk += BLKSIZE)
- {
- h0 = ((h_blk - 1) >= 1) ? (h_blk - 1) : 1;
-
- /* threshold rearrangement for flat region adjacent to non-flat region */
- if (range[blks]<32 && max_range_blk >= 64)
- thres[blks] = max_thres_blk;
-
- /* threshold rearrangement for deblocking
- (blockiness annoying at DC dominant region) */
- if (max_range_blk >= 16)
- {
- /* adaptive smoothing */
- thr = thres[blks];
-
- AdaptiveSmooth_NoMMX(Rec_Y, v0, h0, v_blk, h_blk,
- thr, width, max_diff);
- }
- blks++;
- } /* block level (Luminance) */
- }
- } /* macroblock level */
-
-
- /* Do the rest of the macro-block-lines */
- for (MB_V = MBSIZE; MB_V < height; MB_V += MBSIZE)
- {
- /* First macro-block */
- max_diff = (QP_store[((((int32)MB_V*width)>>4))>>4] >> 2) + 4;
- /* threshold determination */
- max_range_blk = max_thres_blk = 0;
- blks = 0;
- for (BLK_V = 0; BLK_V < MBSIZE; BLK_V += BLKSIZE)
- {
- for (BLK_H = 0; BLK_H < MBSIZE; BLK_H += BLKSIZE)
- {
- ptr = &Rec_Y[(int32)(MB_V + BLK_V) * width + BLK_H];
- FindMaxMin(ptr, &min_blk, &max_blk, incr);
- thres[blks] = (max_blk + min_blk + 1) >> 1;
- range[blks] = max_blk - min_blk;
-
- if (range[blks] >= max_range_blk)
- {
- max_range_blk = range[blks];
- max_thres_blk = thres[blks];
- }
- blks++;
- }
- }
-
- blks = 0;
- for (v_blk = MB_V; v_blk < MB_V + MBSIZE; v_blk += BLKSIZE)
- {
- v0 = v_blk - 1;
- for (h_blk = 0; h_blk < MBSIZE; h_blk += BLKSIZE)
- {
- h0 = ((h_blk - 1) >= 1) ? (h_blk - 1) : 1;
-
- /* threshold rearrangement for flat region adjacent to non-flat region */
- if (range[blks]<32 && max_range_blk >= 64)
- thres[blks] = max_thres_blk;
-
- /* threshold rearrangement for deblocking
- (blockiness annoying at DC dominant region) */
- if (max_range_blk >= 16)
- {
- /* adaptive smoothing */
- thr = thres[blks];
-
- AdaptiveSmooth_NoMMX(Rec_Y, v0, h0, v_blk, h_blk,
- thr, width, max_diff);
- }
- blks++;
- }
- } /* block level (Luminance) */
-
- /* Rest of the macro-blocks */
- for (MB_H = MBSIZE; MB_H < width; MB_H += MBSIZE)
- {
- max_diff = (QP_store[((((int32)MB_V*width)>>4)+MB_H)>>4] >> 2) + 4;
-
- /* threshold determination */
- max_range_blk = max_thres_blk = 0;
- blks = 0;
-
- mb_indx = (MB_V / 8) * (width / 8) + MB_H / 8;
- for (BLK_V = 0; BLK_V < MBSIZE; BLK_V += BLKSIZE)
- {
- for (BLK_H = 0; BLK_H < MBSIZE; BLK_H += BLKSIZE)
- {
- blk_indx = mb_indx + (BLK_V / 8) * width / 8 + BLK_H / 8;
- /* Update based on pp_mod only */
- if ((pp_mod[blk_indx]&0x4) != 0)
- {
- ptr = &Rec_Y[(int32)(MB_V + BLK_V) * width + MB_H + BLK_H];
- FindMaxMin(ptr, &min_blk, &max_blk, incr);
- thres[blks] = (max_blk + min_blk + 1) >> 1;
- range[blks] = max_blk - min_blk;
-
- if (range[blks] >= max_range_blk)
- {
- max_range_blk = range[blks];
- max_thres_blk = thres[blks];
- }
- }
- blks++;
- }
- }
-
- blks = 0;
- for (v_blk = MB_V; v_blk < MB_V + MBSIZE; v_blk += BLKSIZE)
- {
- v0 = v_blk - 1;
- mb_indx = (v_blk / 8) * (width / 8);
- for (h_blk = MB_H; h_blk < MB_H + MBSIZE; h_blk += BLKSIZE)
- {
- h0 = h_blk - 1;
- blk_indx = mb_indx + h_blk / 8;
- if ((pp_mod[blk_indx]&0x4) != 0)
- {
- /* threshold rearrangement for flat region adjacent to non-flat region */
- if (range[blks]<32 && max_range_blk >= 64)
- thres[blks] = max_thres_blk;
-
- /* threshold rearrangement for deblocking
- (blockiness annoying at DC dominant region) */
- if (max_range_blk >= 16)
- {
- /* adaptive smoothing */
- thr = thres[blks];
-#ifdef NoMMX
- AdaptiveSmooth_NoMMX(Rec_Y, v0, h0, v_blk, h_blk,
- thr, width, max_diff);
-#else
- DeringAdaptiveSmoothMMX(&Rec_Y[v0*width+h0],
- width, thr, max_diff);
-#endif
- }
- }
- blks++;
- }
- } /* block level (Luminance) */
- } /* macroblock level */
- } /* macroblock level */
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
-}
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/find_min_max.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/find_min_max.cpp
deleted file mode 100644
index 1ac88a1..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/find_min_max.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- input_ptr = pointer to the buffer containing values of type UChar
- in a 2D block of data.
- min_ptr = pointer to the minimum value of type Int to be found in a
- square block of size BLKSIZE contained in 2D block of data.
- max_ptr = pointer to the maximum value of type Int to be found in a
- square block of size BLKSIZE contained in 2D block of data.
- incr = value of type Int representing the width of 2D block of data.
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- min_ptr points to the found minimum value in the square block of
- size BLKSIZE contained in 2D block of data.
-
- max_ptr points to the found maximum value in the square block of
- size BLKSIZE contained in 2D block of data.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function finds the maximum and the minimum values in a square block of
- data of size BLKSIZE * BLKSIZE. The data is contained in the buffer which
- represents a 2D block of data that is larger than BLKSIZE * BLKSIZE.
- This is illustrated below.
-
- mem loc x + 00h -> o o o o o o o o o o o o o o o o
- mem loc x + 10h -> o o o o o X X X X X X X X o o o
- mem loc x + 20h -> o o o o o X X X X X X X X o o o
- mem loc x + 30h -> o o o o o X X X X X X X X o o o
- mem loc x + 40h -> o o o o o X X X X X X X X o o o
- mem loc x + 50h -> o o o o o X X X X X X X X o o o
- mem loc x + 60h -> o o o o o X X X X X X X X o o o
- mem loc x + 70h -> o o o o o X X X X X X X X o o o
- mem loc x + 80h -> o o o o o X X X X X X X X o o o
- mem loc x + 90h -> o o o o o o o o o o o o o o o o
- mem loc x + A0h -> o o o o o o o o o o o o o o o o
- mem loc x + B0h -> o o o o o o o o o o o o o o o o
-
-For illustration purposes, the diagram assumes that BLKSIZE is equal to 8
-but this is not a requirement. In this diagram, the buffer starts at
-location x but the input pointer, input_ptr, passed into this function
-would be the first row of data to be searched which is at x + 15h. The
-value of incr passed onto this function represents the amount the input_ptr
-needs to be incremented to point to the next row of data.
-
-This function compares each value in a row to the current maximum and
-minimum. After each row, input_ptr is incremented to point to the next row.
-This is repeated until all rows have been processed. When the search is
-complete the location pointed to by min_ptr contains the minimum value
-found and the location pointed to by max_ptr contains the maximum value found.
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "mp4dec_lib.h"
-#include "post_proc.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-#ifdef PV_POSTPROC_ON
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void FindMaxMin(
- uint8 *input_ptr,
- int *min_ptr,
- int *max_ptr,
- int incr)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- uint i, j;
- int min, max;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- max = min = *input_ptr;
- /* incr = incr - BLKSIZE; */ /* 09/06/2001, already passed in as width - BLKSIZE */
-
- for (i = BLKSIZE; i > 0; i--)
- {
- for (j = BLKSIZE; j > 0; j--)
- {
- if (*input_ptr > max)
- {
- max = *input_ptr;
- }
- else if (*input_ptr < min)
- {
- min = *input_ptr;
- }
- input_ptr += 1;
- }
-
- /* set pointer to the beginning of the next row*/
- input_ptr += incr;
- }
-
- *max_ptr = max;
- *min_ptr = min;
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
-}
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/mb_motion_comp.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/mb_motion_comp.cpp
index 877723d..79760f5 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/mb_motion_comp.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/mb_motion_comp.cpp
@@ -154,14 +154,6 @@
int xpred, ypred;
int xsum;
int round1;
-#ifdef PV_POSTPROC_ON // 2/14/2001
- /* Total number of pixels in the VOL */
- int32 size = (int32) video->nTotalMB << 8;
- uint8 *pp_dec_y, *pp_dec_u;
- int ll[4];
- int tmp = 0;
- uint8 msk_deblock = 0;
-#endif
/*----------------------------------------------------------------------------
; Function body here
----------------------------------------------------------------------------*/
@@ -404,43 +396,6 @@
/* Call function to set de-blocking and de-ringing */
/* semaphores for luminance */
-#ifdef PV_POSTPROC_ON
- if (video->postFilterType != PV_NO_POST_PROC)
- {
- if (mode&INTER_1VMASK)
- {
- pp_dec_y = video->pstprcTypCur + imv;
- ll[0] = 1;
- ll[1] = mvwidth - 1;
- ll[2] = 1;
- ll[3] = -mvwidth - 1;
- msk_deblock = pp_semaphore_luma(xpred, ypred, pp_dec_y,
- video->pstprcTypPrv, ll, &tmp, px[0], py[0], mvwidth,
- width, height);
-
- pp_dec_u = video->pstprcTypCur + (size >> 6) +
- ((imv + (xpos >> 3)) >> 2);
-
- pp_semaphore_chroma_inter(xpred, ypred, pp_dec_u,
- video->pstprcTypPrv, dx, dy, mvwidth, height, size,
- tmp, msk_deblock);
- }
- else
- {
- /* Post-processing mode (MBM_INTER8) */
- /* deblocking and deringing) */
- pp_dec_y = video->pstprcTypCur + imv;
- *pp_dec_y = 4;
- *(pp_dec_y + 1) = 4;
- *(pp_dec_y + mvwidth) = 4;
- *(pp_dec_y + mvwidth + 1) = 4;
- pp_dec_u = video->pstprcTypCur + (size >> 6) +
- ((imv + (xpos >> 3)) >> 2);
- *pp_dec_u = 4;
- pp_dec_u[size>>8] = 4;
- }
- }
-#endif
/* xpred and ypred calculation for Chrominance is */
@@ -566,13 +521,6 @@
PIXEL *cv_comp, *cv_prev;
int width, width_uv;
int32 offset;
-#ifdef PV_POSTPROC_ON // 2/14/2001
- int imv;
- int32 size = (int32) video->nTotalMB << 8;
- uint8 *pp_dec_y, *pp_dec_u;
- uint8 *pp_prev1;
- int mvwidth = video->nMBPerRow << 1;
-#endif
width = video->width;
width_uv = width >> 1;
@@ -609,28 +557,6 @@
PutSKIPPED_B(cv_comp, cv_prev, width_uv);
/* 10/24/2000 post_processing semaphore generation */
-#ifdef PV_POSTPROC_ON // 2/14/2001
- if (video->postFilterType != PV_NO_POST_PROC)
- {
- imv = (offset >> 6) - (xpos >> 6) + (xpos >> 3);
- /* Post-processing mode (copy previous MB) */
- pp_prev1 = video->pstprcTypPrv + imv;
- pp_dec_y = video->pstprcTypCur + imv;
- *pp_dec_y = *pp_prev1;
- *(pp_dec_y + 1) = *(pp_prev1 + 1);
- *(pp_dec_y + mvwidth) = *(pp_prev1 + mvwidth);
- *(pp_dec_y + mvwidth + 1) = *(pp_prev1 + mvwidth + 1);
-
- /* chrominance */
- /*4*MB_in_width*MB_in_height*/
- pp_prev1 = video->pstprcTypPrv + (size >> 6) +
- ((imv + (xpos >> 3)) >> 2);
- pp_dec_u = video->pstprcTypCur + (size >> 6) +
- ((imv + (xpos >> 3)) >> 2);
- *pp_dec_u = *pp_prev1;
- pp_dec_u[size>>8] = pp_prev1[size>>8];
- }
-#endif
/*----------------------------------------------------------------------------
; Return nothing or data or data pointer
----------------------------------------------------------------------------*/
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/mp4dec_lib.h b/media/libstagefright/codecs/m4v_h263/dec/src/mp4dec_lib.h
index 9cd4edc..ce6f9c3 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/mp4dec_lib.h
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/mp4dec_lib.h
@@ -170,37 +170,6 @@
/*--------------------------------------------------------------------------*/
/* defined in pp_semaphore_chroma_inter.c */
-#ifdef PV_POSTPROC_ON
- void pp_semaphore_chroma_inter(
- int xpred, /* i */
- int ypred, /* i */
- uint8 *pp_dec_u, /* i/o */
- uint8 *pstprcTypPrv, /* i */
- int dx, /* i */
- int dy, /* i */
- int mvwidth, /* i */
- int height, /* i */
- int32 size, /* i */
- int mv_loc, /* i */
- uint8 msk_deblock /* i */
- );
-
- /*--------------------------------------------------------------------------*/
- /* defined in pp_semaphore_luma.c */
- uint8 pp_semaphore_luma(
- int xpred, /* i */
- int ypred, /* i */
- uint8 *pp_dec_y, /* i/o */
- uint8 *pstprcTypPrv, /* i */
- int *ll, /* i */
- int *mv_loc, /* i/o */
- int dx, /* i */
- int dy, /* i */
- int mvwidth, /* i */
- int width, /* i */
- int height /* i */
- );
-#endif
/*--------------------------------------------------------------------------*/
/* defined in get_pred_adv_mb_add.c */
int GetPredAdvancedMB(
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/post_filter.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/post_filter.cpp
index b36050c..37a03a0 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/post_filter.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/post_filter.cpp
@@ -24,152 +24,6 @@
const static int STRENGTH_tab[] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12};
#endif
-#ifdef PV_POSTPROC_ON
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void PostFilter(
- VideoDecData *video,
- int filter_type,
- uint8 *output)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- uint8 *pp_mod;
- int16 *QP_store;
- int combined_with_deblock_filter;
- int nTotalMB = video->nTotalMB;
- int width, height;
- int32 size;
- int softDeblocking;
- uint8 *decodedFrame = video->videoDecControls->outputFrame;
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- width = video->width;
- height = video->height;
- size = (int32)width * height;
-
- oscl_memcpy(output, decodedFrame, size);
- oscl_memcpy(output + size, decodedFrame + size, (size >> 2));
- oscl_memcpy(output + size + (size >> 2), decodedFrame + size + (size >> 2), (size >> 2));
-
- if (filter_type == 0)
- return;
-
- /* The softDecoding cutoff corresponds to ~93000 bps for QCIF 15fps clip */
- if (PVGetDecBitrate(video->videoDecControls) > (100*video->frameRate*(size >> 12))) // MC_sofDeblock
- softDeblocking = FALSE;
- else
- softDeblocking = TRUE;
-
- combined_with_deblock_filter = filter_type & PV_DEBLOCK;
- QP_store = video->QPMB;
-
- /* Luma */
- pp_mod = video->pstprcTypCur;
-
- if ((filter_type & PV_DEBLOCK) && (filter_type & PV_DERING))
- {
- CombinedHorzVertRingFilter(output, width, height, QP_store, 0, pp_mod);
- }
- else
- {
- if (filter_type & PV_DEBLOCK)
- {
- if (softDeblocking)
- {
- CombinedHorzVertFilter(output, width, height,
- QP_store, 0, pp_mod);
- }
- else
- {
- CombinedHorzVertFilter_NoSoftDeblocking(output, width, height,
- QP_store, 0, pp_mod);
- }
- }
- if (filter_type & PV_DERING)
- {
- Deringing_Luma(output, width, height, QP_store,
- combined_with_deblock_filter, pp_mod);
-
- }
- }
-
- /* Chroma */
-
- pp_mod += (nTotalMB << 2);
- output += size;
-
- if ((filter_type & PV_DEBLOCK) && (filter_type & PV_DERING))
- {
- CombinedHorzVertRingFilter(output, (int)(width >> 1), (int)(height >> 1), QP_store, (int) 1, pp_mod);
- }
- else
- {
- if (filter_type & PV_DEBLOCK)
- {
- if (softDeblocking)
- {
- CombinedHorzVertFilter(output, (int)(width >> 1),
- (int)(height >> 1), QP_store, (int) 1, pp_mod);
- }
- else
- {
- CombinedHorzVertFilter_NoSoftDeblocking(output, (int)(width >> 1),
- (int)(height >> 1), QP_store, (int) 1, pp_mod);
- }
- }
- if (filter_type & PV_DERING)
- {
- Deringing_Chroma(output, (int)(width >> 1),
- (int)(height >> 1), QP_store,
- combined_with_deblock_filter, pp_mod);
- }
- }
-
- pp_mod += nTotalMB;
- output += (size >> 2);
-
- if ((filter_type & PV_DEBLOCK) && (filter_type & PV_DERING))
- {
- CombinedHorzVertRingFilter(output, (int)(width >> 1), (int)(height >> 1), QP_store, (int) 1, pp_mod);
- }
- else
- {
- if (filter_type & PV_DEBLOCK)
- {
- if (softDeblocking)
- {
- CombinedHorzVertFilter(output, (int)(width >> 1),
- (int)(height >> 1), QP_store, (int) 1, pp_mod);
- }
- else
- {
- CombinedHorzVertFilter_NoSoftDeblocking(output, (int)(width >> 1),
- (int)(height >> 1), QP_store, (int) 1, pp_mod);
- }
- }
- if (filter_type & PV_DERING)
- {
- Deringing_Chroma(output, (int)(width >> 1),
- (int)(height >> 1), QP_store,
- combined_with_deblock_filter, pp_mod);
- }
- }
-
- /* swap current pp_mod to prev_frame pp_mod */
- pp_mod = video->pstprcTypCur;
- video->pstprcTypCur = video->pstprcTypPrv;
- video->pstprcTypPrv = pp_mod;
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
-}
-#endif
#ifdef PV_ANNEX_IJKT_SUPPORT
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/post_proc_semaphore.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/post_proc_semaphore.cpp
deleted file mode 100644
index 3abc6be..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/post_proc_semaphore.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- q_block = pointer to buffer of inverse quantized DCT coefficients of type
- int for intra-VOP mode or buffer of residual data of type int
- for inter-VOP mode
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- postmode = post processing semaphore with the vertical deblocking,
- horizontal deblocking, and deringing bits set up accordingly
-
- Pointers and Buffers Modified:
- None
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function sets up the postmode semaphore based on the contents of the
- buffer pointed to by q_block. The function starts out with the assumption
- that all entries of q_block, except for the first entry (q_block[0]), are
- zero. This case can induce horizontal and vertical blocking artifacts,
- therefore, both horizontal and vertical deblocking bits are enabled.
-
- The following conditions are tested when setting up the horizontal/vertical
- deblocking and deringing bits:
- 1. When only the elements of the top row of the B_SIZE x B_SIZE block
- (q_block[n], n = 0,..., B_SIZE-1) are non-zero, vertical blocking artifacts
- may result, therefore, only the vertical deblocking bit is enabled.
- Otherwise, the vertical deblocking bit is disabled.
- 2. When only the elements of the far left column of the B_SIZE x B_SIZE block
- (q_block[n*B_SIZE], n = 0, ..., B_SIZE-1) are non-zero, horizontal blocking
- artifacts may result, therefore, only the horizontal deblocking bit is
- enabled. Otherwise, the horizontal deblocking bit is disabled.
- 3. If any non-zero elements exist in positions other than q_block[0],
- q_block[1], or q_block[B_SIZE], the deringing bit is enabled. Otherwise,
- it is disabled.
-
- The 3 least significant bits of postmode defines vertical or horizontal
- deblocking and deringing.
-
- The valid values are shown below:
- -------------------------------------------------------
- | Type | Enabled | Disabled |
- -------------------------------------------------------
- | Vertical Deblocking (Bit #0) | 1 | 0 |
- -------------------------------------------------------
- | Horizontal Deblocking (Bit #1) | 1 | 0 |
- -------------------------------------------------------
- | Deringing (Bit #2) | 1 | 0 |
- -------------------------------------------------------
-
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "mp4dec_lib.h"
-#include "mp4def.h"
-#include "post_proc.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-#ifdef PV_POSTPROC_ON
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-int PostProcSemaphore(
- int16 *q_block)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int i, j;
-
- /* Set default value to vertical and horizontal deblocking enabled */
- /* Initial assumption is that only q_block[0] element is non-zero, */
- /* therefore, vertical and horizontal deblocking bits are set to 1 */
- int postmode = 0x3;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- /* Vertical deblocking bit is enabled when only the entire top row of */
- /* the B_SIZE x B_SIZE block, i.e., q_block[n], n = 0,..., B_SIZE-1, */
- /* are non-zero. Since initial assumption is that all elements, except */
- /* q_block[0], is zero, we need to check the remaining elements in the */
- /* top row to determine if all or some are non-zero. */
- if (q_block[1] != 0)
- {
- /* At this point, q_block[0] and q_block[1] are non-zero, while */
- /* q_block[n], n = 2,..., B_SIZE-1, are zero. Therefore, we */
- /* need to disable vertical deblocking */
- postmode &= 0xE;
- }
-
- for (i = 2; i < B_SIZE; i++)
- {
- if (q_block[i])
- {
- /* Check if q_block[n], n = 2,..., B_SIZE-1, are non-zero.*/
- /* If any of them turn out to be non-zero, we need to */
- /* disable vertical deblocking. */
- postmode &= 0xE;
-
- /* Deringing is enabled if any nonzero elements exist in */
- /* positions other than q_block[0], q_block[1] or */
- /* q_block[B_SIZE]. */
- postmode |= 0x4;
-
- break;
- }
- }
-
- /* Horizontal deblocking bit is enabled when only the entire far */
- /* left column, i.e., q_block[n*B_SIZE], n = 0, ..., B_SIZE-1, */
- /* are non-zero. Since initial assumption is that all elements, */
- /* except q_block[0], is zero, we need to check the remaining */
- /* elements in the far left column to determine if all or some */
- /* are non-zero. */
- if (q_block[B_SIZE])
- {
- /* At this point, only q_block[0] and q_block[B_SIZE] are non-zero, */
- /* while q_block[n*B_SIZE], n = 2, 3,..., B_SIZE-1, are zero. */
- /* Therefore, we need to disable horizontal deblocking. */
- postmode &= 0xD;
- }
-
- for (i = 16; i < NCOEFF_BLOCK; i += B_SIZE)
- {
- if (q_block[i])
- {
- /* Check if q_block[n], n = 2*B_SIZE,...,(B_SIZE-1)*B_SIZE, */
- /* are non-zero. If any of them turn out to be non-zero, */
- /* we need to disable horizontal deblocking. */
- postmode &= 0xD;
-
- /* Deringing is enabled if any nonzero elements exist in */
- /* positions other than q_block[0], q_block[1] or */
- /* q_block[B_SIZE]. */
- postmode |= 0x4;
-
- break;
- }
- }
-
- /* At this point, only the first row and far left column elements */
- /* have been tested. If deringing bit is still not set at this */
- /* point, check the rest of q_block to determine if the elements */
- /* are non-zero. If all elements, besides q_block[0], q_block[1], */
- /* or q_block[B_SIZE] are non-zero, deringing bit must be set */
- if ((postmode & 0x4) == 0)
- {
- for (i = 1; i < B_SIZE; i++)
- {
- for (j = 1; j < B_SIZE; j++)
- {
- if (q_block[(i<<3)+j])
- {
- /* At this point, q_block[0] and another q_block */
- /* element are non-zero, therefore, we need to */
- /* disable vertical and horizontal deblocking */
- postmode &= 0xC;
-
- /* Deringing is enabled if any nonzero elements exist in */
- /* positions other than q_block[0], q_block[1] or */
- /* q_block[B_SIZE]. */
- postmode |= 0x4;
-
- /* Set outer FOR loop count to B_SIZE to get out of */
- /* outer FOR loop */
- i = B_SIZE;
-
- /* Get out of inner FOR loop */
- break;
- }
- }
- }
- }
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return (postmode);
-}
-
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/pp_semaphore_chroma_inter.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/pp_semaphore_chroma_inter.cpp
deleted file mode 100644
index 7c20222..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/pp_semaphore_chroma_inter.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- xpred = x-axis coordinate of the block used for prediction (int)
- ypred = y-axis coordinate of the block used for prediction (int)
- pp_dec_u = pointer to the post processing semaphore for chrominance
- (uint8)
- pstprcTypPrv = pointer the previous frame's post processing type
- (uint8)
- dx = horizontal component of the motion vector (int)
- dy = vertical component of the motion vector (int)
- mvwidth = number of blocks per row in the luminance VOP (int)
- height = luminance VOP height in pixels (int)
- size = total number of pixel in the current luminance VOP (int)
- mv_loc = flag indicating location of the motion compensated
- (x,y) position with respect to the luminance MB (int);
- 0 -> inside MB, 1 -> outside MB
- msk_deblock = flag indicating whether to perform deblocking
- (msk_deblock = 0) or not (msk_deblock = 1) (uint8)
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- pp_dec_u contents are the updated semaphore propagation data
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This functions performs post processing semaphore propagation processing
- after chrominance prediction in interframe processing mode.
-
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "mp4dec_api.h"
-#include "mp4def.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-#ifdef PV_POSTPROC_ON
-#ifdef __cplusplus
-extern "C"
-{
-#endif
- /*----------------------------------------------------------------------------
- ; FUNCTION CODE
- ----------------------------------------------------------------------------*/
- void pp_semaphore_chroma_inter(
- int xpred, /* i */
- int ypred, /* i */
- uint8 *pp_dec_u, /* i/o */
- uint8 *pstprcTypPrv, /* i */
- int dx, /* i */
- int dy, /* i */
- int mvwidth, /* i */
- int height, /* i */
- int32 size, /* i */
- int mv_loc, /* i */
- uint8 msk_deblock /* i */
- )
- {
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int mmvy, mmvx, nmvy, nmvx;
- uint8 *pp_prev1, *pp_prev2, *pp_prev3, *pp_prev4;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
-
- /* 09/28/2000, modify semaphore propagation to */
- /* accommodate smart indexing */
- mmvx = xpred >> 4; /* block x coor */
- nmvx = mmvx;
-
- mmvy = ypred >> 4; /* block y coor */
- nmvy = mmvy;
-
- /* Check if MV is outside the frame */
- if (mv_loc == 1)
- {
- /* Perform boundary check */
- if (nmvx < 0)
- {
- nmvx = 0;
- }
- else if (nmvx > mvwidth - 1)
- {
- nmvx = mvwidth - 1;
- }
-
- if (nmvy < 0)
- {
- nmvy = 0;
- }
- else if (nmvy > (height >> 4) - 1)
- {
- nmvy = (height >> 4) - 1;
- }
- }
-
- /* Calculate pointer to first chrominance b semaphores in */
- /* pstprcTypPrv, i.e., first chrominance b semaphore is in */
- /* (pstprcTypPrv + (size>>6)). */
- /* Since total number of chrominance blocks per row in a VOP */
- /* is half of the total number of luminance blocks per row in a */
- /* VOP, we use (mvwidth >> 1) when calculating the row offset. */
- pp_prev1 = pstprcTypPrv + (size >> 6) + nmvx + nmvy * (mvwidth >> 1) ;
-
- /* Check if MV is a multiple of 16 */
- /* 1/5/01, make sure it doesn't go out of bound */
- if (((dy&0xF) != 0) && (mmvy + 1 < (height >> 4) - 1))
- { /* dy is not a multiple of 16 */
-
- /* pp_prev3 is the block below pp_prev1 block */
- pp_prev3 = pp_prev1 + (mvwidth >> 1);
- }
- else
- { /* dy is a multiple of 16 */
- pp_prev3 = pp_prev1;
- }
-
- /* 1/5/01, make sure it doesn't go out of bound */
- if (((dx&0xF) != 0) && (mmvx + 1 < (mvwidth >> 1) - 1))
- { /* dx is not a multiple of 16 */
-
- /* pp_prev2 is the block to the right of pp_prev1 block */
- pp_prev2 = pp_prev1 + 1;
-
- /* pp_prev4 is the block to the right of the block */
- /* below pp_prev1 block */
- pp_prev4 = pp_prev3 + 1;
- }
- else
- { /* dx is a multiple of 16 */
-
- pp_prev2 = pp_prev1;
- pp_prev4 = pp_prev3;
- }
-
- /* Advance offset to location of first Chrominance R semaphore in */
- /* pstprcTypPrv. Since the number of pixels in a Chrominance VOP */
- /* is (number of pixels in Luminance VOP/4), and there are 64 */
- /* pixels in an 8x8 Chrominance block, the offset can be */
- /* calculated as: */
- /* mv_loc = (number of pixels in Luminance VOP/(4*64)) */
- /* = size/256 = size>>8 */
- mv_loc = (size >> 8);
-
- /* 11/3/00, change the propagation for deblocking */
- if (msk_deblock == 0)
- {
-
- /* Deblocking semaphore propagation for Chrominance */
- /* b semaphores */
- *(pp_dec_u) = 0;
-
- /* Advance offset to point to Chrominance r semaphores */
- pp_dec_u += mv_loc;
-
- /* Deblocking semaphore propagation for Chrominance */
- /* r semaphores */
- *(pp_dec_u) = 0;
- }
- else
- {
- /* Deringing semaphore propagation for Chrominance B block */
- if ((*(pp_dec_u)&4) == 0)
- {
- *(pp_dec_u) |= ((*(pp_prev1) | *(pp_prev2) |
- *(pp_prev3) | *(pp_prev4)) & 0x4);
- }
-
- /* Advance offset to point to Chrominance r semaphores */
- pp_dec_u += mv_loc;
- pp_prev1 += mv_loc;
- pp_prev2 += mv_loc;
- pp_prev3 += mv_loc;
- pp_prev4 += mv_loc;
-
- /* Deringing semaphore propagation for Chrominance R */
- if ((*(pp_dec_u)&4) == 0)
- {
- *(pp_dec_u) |= ((*(pp_prev1) | *(pp_prev2) |
- *(pp_prev3) | *(pp_prev4)) & 0x4);
- }
- }
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
- }
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/pp_semaphore_luma.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/pp_semaphore_luma.cpp
deleted file mode 100644
index b3a1ebd..0000000
--- a/media/libstagefright/codecs/m4v_h263/dec/src/pp_semaphore_luma.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- xpred = x-axis coordinate of the MB used for prediction (int)
- ypred = y-axis coordinate of the MB used for prediction (int)
- pp_dec_y = pointer to the post processing semaphore for current
- luminance frame (uint8)
- pstprcTypPrv = pointer the previous frame's post processing type
- (uint8)
- ll = pointer to the buffer (int)
- mv_loc = flag indicating location of the motion compensated
- (x,y) position with respect to the luminance MB (int);
- 0 -> inside MB, 1 -> outside MB
- dx = horizontal component of the motion vector (int)
- dy = vertical component of the motion vector (int)
- mvwidth = number of blocks per row (int)
- width = luminance VOP width in pixels (int)
- height = luminance VOP height in pixels (int)
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- msk_deblock = flag that indicates whether deblocking is to be
- performed (msk_deblock = 0) or not (msk_deblock =
- 1) (uint8)
-
- Pointers and Buffers Modified:
- pp_dec_y contents are the updated semapohore propagation data
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This functions performs post processing semaphore propagation processing
- after luminance prediction.
-
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "mp4dec_api.h"
-#include "mp4def.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-#ifdef PV_POSTPROC_ON
-#ifdef __cplusplus
-extern "C"
-{
-#endif
- /*----------------------------------------------------------------------------
- ; FUNCTION CODE
- ----------------------------------------------------------------------------*/
- uint8 pp_semaphore_luma(
- int xpred, /* i */
- int ypred, /* i */
- uint8 *pp_dec_y, /* i/o */
- uint8 *pstprcTypPrv, /* i */
- int *ll, /* i */
- int *mv_loc, /* i/o */
- int dx, /* i */
- int dy, /* i */
- int mvwidth, /* i */
- int width, /* i */
- int height /* i */
- )
- {
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- int kk, mmvy, mmvx, nmvx, nmvy;
- uint8 *pp_prev1, *pp_prev2, *pp_prev3, *pp_prev4;
- uint8 msk_deblock = 0; /* 11/3/00 */
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- /* Interframe Processing - 1 MV per MB */
-
- /* check whether the MV points outside the frame */
- if (xpred >= 0 && xpred <= ((width << 1) - (2*MB_SIZE)) && ypred >= 0 &&
- ypred <= ((height << 1) - (2*MB_SIZE)))
- { /*****************************/
- /* (x,y) is inside the frame */
- /*****************************/
-
- /* 10/24/2000 post_processing semaphore */
- /* generation */
-
- /* 10/23/2000 no boundary checking*/
- *mv_loc = 0;
-
- /* Calculate block x coordinate. Divide by 16 is for */
- /* converting half-pixel resolution to block */
- mmvx = xpred >> 4;
-
- /* Calculate block y coordinate. Divide by 16 is for */
- /* converting half-pixel resolution to block */
- mmvy = ypred >> 4;
-
- /* Find post processing semaphore location for block */
- /* used for prediction, i.e., */
- /* pp_prev1 = &pstprcTypPrv[mmvy*mvwidth][mmvx] */
- pp_prev1 = pstprcTypPrv + mmvx + mmvy * mvwidth;
-
- /* Check if MV is a multiple of 16 */
- if ((dx&0xF) != 0)
- { /* dx is not a multiple of 16 */
-
- /* pp_prev2 is the block to the right of */
- /* pp_prev1 block */
- pp_prev2 = pp_prev1 + 1;
-
- if ((dy&0xF) != 0)
- { /* dy is not a multiple of 16 */
-
- /* pp_prev3 is the block below */
- /* pp_prev1 block */
- pp_prev3 = pp_prev1 + mvwidth;
- }
- else
- { /* dy is a multiple of 16 */
-
- pp_prev3 = pp_prev1;
- }
-
- /* pp_prev4 is the block to the right of */
- /* pp_prev3 block. */
- pp_prev4 = pp_prev3 + 1;
- }
- else
- { /* dx is a multiple of 16 */
-
- pp_prev2 = pp_prev1;
-
- if ((dy&0xF) != 0)
- { /* dy is not a multiple of 16 */
-
- /* pp_prev3 is the block below */
- /* pp_prev1 block. */
- pp_prev3 = pp_prev1 + mvwidth;
- }
- else
- { /* dy is a multiple of 16 */
-
- pp_prev3 = pp_prev1;
- msk_deblock = 0x3;
- }
-
- pp_prev4 = pp_prev3;
- }
-
- /* Perform post processing semaphore propagation for each */
- /* of the 4 blocks in a MB. */
- for (kk = 0; kk < 4; kk++)
- {
- /* Deringing semaphore propagation */
- if ((*(pp_dec_y) & 4) == 0)
- {
- *(pp_dec_y) |= ((*(pp_prev1) | *(pp_prev2) |
- *(pp_prev3) | *(pp_prev4)) & 0x4);
- }
- /* Deblocking semaphore propagation */
- /* 11/3/00, change the propagation for deblocking */
- if (msk_deblock == 0)
- {
- *(pp_dec_y) = 0;
- }
-
- pp_dec_y += ll[kk];
- pp_prev1 += ll[kk];
- pp_prev2 += ll[kk];
- pp_prev3 += ll[kk];
- pp_prev4 += ll[kk];
- }
-
- }
- else
- { /******************************/
- /* (x,y) is outside the frame */
- /******************************/
-
- /* 10/24/2000 post_processing semaphore */
- /* generation */
-
- /* 10/23/2000 boundary checking*/
- *mv_loc = 1;
-
- /* Perform post processing semaphore propagation for each */
- /* of the 4 blocks in a MB. */
- for (kk = 0; kk < 4; kk++)
- {
- /* Calculate block x coordinate and round (?). */
- /* Divide by 16 is for converting half-pixel */
- /* resolution to block. */
- mmvx = (xpred + ((kk & 1) << 3)) >> 4;
- nmvx = mmvx;
-
- /* Calculate block y coordinate and round (?). */
- /* Divide by 16 is for converting half-pixel */
- /* resolution to block. */
- mmvy = (ypred + ((kk & 2) << 2)) >> 4;
- nmvy = mmvy;
-
- /* Perform boundary checking */
- if (nmvx < 0)
- {
- nmvx = 0;
- }
- else if (nmvx > mvwidth - 1)
- {
- nmvx = mvwidth - 1;
- }
-
- if (nmvy < 0)
- {
- nmvy = 0;
- }
- else if (nmvy > (height >> 3) - 1)
- {
- nmvy = (height >> 3) - 1;
- }
-
- /* Find post processing semaphore location for block */
- /* used for prediction, i.e., */
- /* pp_prev1 = &pstprcTypPrv[nmvy*mvwidth][nmvx] */
- pp_prev1 = pstprcTypPrv + nmvx + nmvy * mvwidth;
-
- /* Check if x component of MV is a multiple of 16 */
- /* and check if block x coordinate is out of bounds */
- if (((dx&0xF) != 0) && (mmvx + 1 < mvwidth - 1))
- { /* dx is not a multiple of 16 and the block */
- /* x coordinate is within the bounds */
-
- /* pp_prev2 is the block to the right of */
- /* pp_prev1 block */
- pp_prev2 = pp_prev1 + 1;
-
- /* Check if y component of MV is a multiple */
- /* of 16 and check if block y coordinate is */
- /* out of bounds */
- if (((dy&0xF) != 0) && (mmvy + 1 < (height >> 3) - 1))
- { /* dy is not a multiple of 16 and */
- /* the block y coordinate is */
- /* within the bounds */
-
- /* pp_prev3 is the block below */
- /* pp_prev1 block */
- pp_prev3 = pp_prev1 + mvwidth;
-
- /* all prediction are from different blocks */
- msk_deblock = 0x3;
- }
- else
- { /* dy is a multiple of 16 or the block */
- /* y coordinate is out of bounds */
-
- pp_prev3 = pp_prev1;
- }
-
- /* pp_prev4 is the block to the right of */
- /* pp_prev3 block. */
- pp_prev4 = pp_prev3 + 1;
- }
- else
- { /* dx is a multiple of 16 or the block x */
- /* coordinate is out of bounds */
-
- pp_prev2 = pp_prev1;
-
- /* Check if y component of MV is a multiple */
- /* of 16 and check if block y coordinate is */
- /* out of bounds */
- if (((dy&0xF) != 0) && (mmvy + 1 < (height >> 3) - 1))
- { /* dy is not a multiple of 16 and */
- /* the block y coordinate is */
- /* within the bounds */
-
- /* pp_prev3 is the block below */
- /* pp_prev1 block. */
- pp_prev3 = pp_prev1 + mvwidth;
- }
- else
- { /* dy is a multiple of 16 or the block */
- /* y coordinate is out of bounds */
-
- pp_prev3 = pp_prev1;
- }
-
- pp_prev4 = pp_prev3;
- }
-
- /* Deringing semaphore propagation */
- if ((*(pp_dec_y)&4) == 0)
- {
- *(pp_dec_y) |= ((*(pp_prev1) |
- *(pp_prev2) | *(pp_prev3) |
- *(pp_prev4)) & 0x4);
- }
- /* Deblocking semaphore propagation */
- /* 11/3/00, change the propaga= */
- /* tion for deblocking */
- if (msk_deblock == 0)
- {
- *(pp_dec_y) = 0;
- }
-
- pp_dec_y += ll[kk];
- }
- }
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return (msk_deblock);
- }
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/media/libstagefright/codecs/m4v_h263/dec/src/pvdec_api.cpp b/media/libstagefright/codecs/m4v_h263/dec/src/pvdec_api.cpp
index 6c336c8..b0828e4 100644
--- a/media/libstagefright/codecs/m4v_h263/dec/src/pvdec_api.cpp
+++ b/media/libstagefright/codecs/m4v_h263/dec/src/pvdec_api.cpp
@@ -512,60 +512,6 @@
video->memoryUsage += (sizeof(MOT) * 8 * nTotalMB);
#endif
-#ifdef PV_POSTPROC_ON
- /* Allocating space for post-processing Mode */
-#ifdef DEC_INTERNAL_MEMORY_OPT
- video->pstprcTypCur = IMEM_pstprcTypCur;
- video->memoryUsage += (nTotalMB * 6);
- if (video->pstprcTypCur == NULL)
- {
- status = PV_FALSE;
- }
- else
- {
- oscl_memset(video->pstprcTypCur, 0, 4*nTotalMB + 2*nTotalMB);
- }
-
- video->pstprcTypPrv = IMEM_pstprcTypPrv;
- video->memoryUsage += (nTotalMB * 6);
- if (video->pstprcTypPrv == NULL)
- {
- status = PV_FALSE;
- }
- else
- {
- oscl_memset(video->pstprcTypPrv, 0, nTotalMB*6);
- }
-
-#else
- if (nTotalMB > INT32_MAX / 6) {
- return PV_FALSE;
- }
- video->pstprcTypCur = (uint8 *) oscl_malloc(nTotalMB * 6);
- video->memoryUsage += (nTotalMB * 6);
- if (video->pstprcTypCur == NULL)
- {
- status = PV_FALSE;
- }
- else
- {
- oscl_memset(video->pstprcTypCur, 0, 4*nTotalMB + 2*nTotalMB);
- }
-
- video->pstprcTypPrv = (uint8 *) oscl_malloc(nTotalMB * 6);
- video->memoryUsage += (nTotalMB * 6);
- if (video->pstprcTypPrv == NULL)
- {
- status = PV_FALSE;
- }
- else
- {
- oscl_memset(video->pstprcTypPrv, 0, nTotalMB*6);
- }
-
-#endif
-
-#endif
/* initialize the decoder library */
video->prevVop->predictionType = I_VOP;
@@ -631,10 +577,6 @@
#ifdef DEC_INTERNAL_MEMORY_OPT
if (video)
{
-#ifdef PV_POSTPROC_ON
- video->pstprcTypCur = NULL;
- video->pstprcTypPrv = NULL;
-#endif
video->acPredFlag = NULL;
video->sliceNo = NULL;
@@ -699,10 +641,6 @@
if (video)
{
-#ifdef PV_POSTPROC_ON
- if (video->pstprcTypCur) oscl_free(video->pstprcTypCur);
- if (video->pstprcTypPrv) oscl_free(video->pstprcTypPrv);
-#endif
if (video->predDC) oscl_free(video->predDC);
video->predDCAC_row = NULL;
if (video->predDCAC_col) oscl_free(video->predDCAC_col);
@@ -830,14 +768,10 @@
OSCL_EXPORT_REF void PVSetPostProcType(VideoDecControls *decCtrl, int mode)
{
VideoDecData *video = (VideoDecData *)decCtrl->videoDecoderData;
-#ifdef PV_POSTPROC_ON
- video->postFilterType = mode;
-#else
if (mode != 0) {
ALOGE("Post processing filters are not supported");
}
video->postFilterType = 0;
-#endif
}
@@ -1628,43 +1562,8 @@
void PVDecPostProcess(VideoDecControls *decCtrl, uint8 *outputYUV)
{
uint8 *outputBuffer;
-#ifdef PV_POSTPROC_ON
- VideoDecData *video = (VideoDecData *) decCtrl->videoDecoderData;
- int32 tmpvar;
- if (outputYUV)
- {
- outputBuffer = outputYUV;
- }
- else
- {
- if (video->postFilterType)
- {
- outputBuffer = video->currVop->yChan;
- }
- else
- {
- outputBuffer = decCtrl->outputFrame;
- }
- }
-
- if (video->postFilterType)
- {
- /* Post-processing, */
- PostFilter(video, video->postFilterType, outputBuffer);
- }
- else
- {
- if (outputYUV)
- {
- /* Copy decoded frame to the output buffer. */
- tmpvar = (int32)video->width * video->height;
- oscl_memcpy(outputBuffer, decCtrl->outputFrame, tmpvar*3 / 2); /* 3/3/01 */
- }
- }
-#else
outputBuffer = decCtrl->outputFrame;
outputYUV;
-#endif
decCtrl->outputFrame = outputBuffer;
return;
}
diff --git a/media/libstagefright/foundation/TEST_MAPPING b/media/libstagefright/foundation/TEST_MAPPING
index 6bd3a3a..1bd56a6 100644
--- a/media/libstagefright/foundation/TEST_MAPPING
+++ b/media/libstagefright/foundation/TEST_MAPPING
@@ -1,6 +1,9 @@
// mappings for frameworks/av/media/libstagefright/foundation
{
"presubmit": [
+ // b/148094059: unit tests not allowed to download content
+ //{ "name": "OpusHeaderTest" },
+
{ "name": "sf_foundation_test" },
{ "name": "MetaDataBaseUnitTest"}
]
diff --git a/media/libstagefright/id3/test/ID3Test.cpp b/media/libstagefright/id3/test/ID3Test.cpp
index cd5cd9e..a3e8238 100644
--- a/media/libstagefright/id3/test/ID3Test.cpp
+++ b/media/libstagefright/id3/test/ID3Test.cpp
@@ -67,7 +67,7 @@
ID3 tag(&helper);
ASSERT_TRUE(tag.isValid()) << "No valid ID3 tag found for " << path.c_str() << "\n";
ASSERT_TRUE(tag.version() >= versionNumber)
- << "Expected version: " << tag.version() << " Found version: " << versionNumber;
+ << "Found version: " << tag.version() << " Expected version: " << versionNumber;
}
TEST_P(ID3textTagTest, TextTagTest) {
@@ -114,7 +114,7 @@
if (data) {
ALOGV("Found album art: size = %zu mime = %s \n", dataSize, mime.string());
}
- ASSERT_NE(data, nullptr) << "Expected album art, found none!" << path;
+ ASSERT_NE(data, nullptr) << "Expected album art, found none! " << path;
} else {
ASSERT_EQ(data, nullptr) << "Found album art when expected none!";
}
@@ -150,7 +150,7 @@
hexdump(data, dataSize > 128 ? 128 : dataSize);
#endif
}
- ASSERT_NE(data, nullptr) << "Expected album art, found none!" << path;
+ ASSERT_NE(data, nullptr) << "Expected album art, found none! " << path;
}
it.next();
}
@@ -168,16 +168,18 @@
"bbb_44100hz_2ch_128kbps_mp3_5mins_largeSize.mp3",
"bbb_44100hz_2ch_128kbps_mp3_30sec_moreTextFrames.mp3"));
+// TODO: need some data that is not V2.3
INSTANTIATE_TEST_SUITE_P(
id3TestAll, ID3versionTest,
- ::testing::Values(make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec.mp3", 4),
- make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec_1_image.mp3", 4),
- make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec_2_image.mp3", 4),
- make_pair("bbb_44100hz_2ch_128kbps_mp3_5mins.mp3", 4),
- make_pair("bbb_44100hz_2ch_128kbps_mp3_5mins_1_image.mp3", 4),
- make_pair("bbb_44100hz_2ch_128kbps_mp3_5mins_2_image.mp3", 4),
- make_pair("bbb_44100hz_2ch_128kbps_mp3_5mins_largeSize.mp3", 4),
- make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec_moreTextFrames.mp3", 4)));
+ ::testing::Values(
+ make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec.mp3", ID3::ID3_V2_3),
+ make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec_1_image.mp3", ID3::ID3_V2_3),
+ make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec_2_image.mp3", ID3::ID3_V2_3),
+ make_pair("bbb_44100hz_2ch_128kbps_mp3_5mins.mp3", ID3::ID3_V2_3),
+ make_pair("bbb_44100hz_2ch_128kbps_mp3_5mins_1_image.mp3", ID3::ID3_V2_3),
+ make_pair("bbb_44100hz_2ch_128kbps_mp3_5mins_2_image.mp3", ID3::ID3_V2_3),
+ make_pair("bbb_44100hz_2ch_128kbps_mp3_5mins_largeSize.mp3", ID3::ID3_V2_3),
+ make_pair("bbb_44100hz_2ch_128kbps_mp3_30sec_moreTextFrames.mp3", ID3::ID3_V2_3)));
INSTANTIATE_TEST_SUITE_P(
id3TestAll, ID3textTagTest,
diff --git a/media/libstagefright/include/media/stagefright/MediaCodec.h b/media/libstagefright/include/media/stagefright/MediaCodec.h
index 736f626..c6b6639 100644
--- a/media/libstagefright/include/media/stagefright/MediaCodec.h
+++ b/media/libstagefright/include/media/stagefright/MediaCodec.h
@@ -146,6 +146,8 @@
// object.
status_t release();
+ status_t releaseAsync();
+
status_t flush();
status_t queueInputBuffer(
@@ -516,6 +518,9 @@
// when low latency is on
int64_t mInputBufferCounter; // number of input buffers queued since last reset/flush
+ class ReleaseSurface;
+ std::unique_ptr<ReleaseSurface> mReleaseSurface;
+
sp<BatteryChecker> mBatteryChecker;
void statsBufferSent(int64_t presentationUs);
diff --git a/media/libstagefright/include/media/stagefright/MediaCodecConstants.h b/media/libstagefright/include/media/stagefright/MediaCodecConstants.h
index 178d334..9c67338 100644
--- a/media/libstagefright/include/media/stagefright/MediaCodecConstants.h
+++ b/media/libstagefright/include/media/stagefright/MediaCodecConstants.h
@@ -744,6 +744,7 @@
constexpr char KEY_AAC_MAX_OUTPUT_CHANNEL_COUNT[] = "aac-max-output-channel_count";
constexpr char KEY_AAC_PROFILE[] = "aac-profile";
constexpr char KEY_AAC_SBR_MODE[] = "aac-sbr-mode";
+constexpr char KEY_ALLOW_FRAME_DROP[] = "allow-frame-drop";
constexpr char KEY_AUDIO_SESSION_ID[] = "audio-session-id";
constexpr char KEY_BIT_RATE[] = "bitrate";
constexpr char KEY_BITRATE_MODE[] = "bitrate-mode";
diff --git a/media/libstagefright/rtsp/ASessionDescription.cpp b/media/libstagefright/rtsp/ASessionDescription.cpp
index 4502f62..5b5b4b1 100644
--- a/media/libstagefright/rtsp/ASessionDescription.cpp
+++ b/media/libstagefright/rtsp/ASessionDescription.cpp
@@ -27,6 +27,8 @@
namespace android {
+constexpr unsigned kDefaultAs = 960; // kbps?
+
ASessionDescription::ASessionDescription()
: mIsValid(false) {
}
@@ -401,7 +403,7 @@
sdp.append("\r\n");
sdp.append("b=AS:");
- sdp.append(as > 0 ? as : 960);
+ sdp.append(as > 0 ? as : kDefaultAs);
sdp.append("\r\n");
sdp.append("a=rtpmap:");
@@ -420,7 +422,7 @@
sdp.append("\r\n");
}
- if (width > 0 && height > 0) {
+ if (!isAudio && width > 0 && height > 0) {
sdp.append("a=framesize:");
sdp.append(payloadType);
sdp.append(" ");
diff --git a/media/libstagefright/rtsp/Android.bp b/media/libstagefright/rtsp/Android.bp
index 84a47af..6179142 100644
--- a/media/libstagefright/rtsp/Android.bp
+++ b/media/libstagefright/rtsp/Android.bp
@@ -22,7 +22,6 @@
],
shared_libs: [
- "libandroid",
"libandroid_net",
"libcrypto",
"libdatasource",
diff --git a/media/libstagefright/timedtext/TEST_MAPPING b/media/libstagefright/timedtext/TEST_MAPPING
new file mode 100644
index 0000000..4528b32
--- /dev/null
+++ b/media/libstagefright/timedtext/TEST_MAPPING
@@ -0,0 +1,7 @@
+// mappings for frameworks/av/media/libstagefright/timedtext
+{
+ "presubmit": [
+ // b/148094059: unit tests not allowed to download content
+ //{ "name": "TimedTextUnitTest" }
+ ]
+}
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 0e96522..2b618ab 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3050,6 +3050,10 @@
{
if (!mMasterMute) {
char value[PROPERTY_VALUE_MAX];
+ if (mOutDeviceTypeAddrs.empty()) {
+ ALOGD("ro.audio.silent is ignored since no output device is set");
+ return;
+ }
if (isSingleDeviceType(outDeviceTypes(), AUDIO_DEVICE_OUT_REMOTE_SUBMIX)) {
ALOGD("ro.audio.silent will be ignored for threads on AUDIO_DEVICE_OUT_REMOTE_SUBMIX");
return;
@@ -4226,6 +4230,7 @@
(mPatch.sinks[0].id != sinkPortId);
mPatch = *patch;
mOutDeviceTypeAddrs = deviceTypeAddrs;
+ checkSilentMode_l();
if (mOutput->audioHwDev->supportsAudioPatches()) {
sp<DeviceHalInterface> hwDevice = mOutput->audioHwDev->hwDevice();
@@ -9152,6 +9157,7 @@
if (isOutput()) {
sendIoConfigEvent_l(AUDIO_OUTPUT_CONFIG_CHANGED);
mOutDeviceTypeAddrs = sinkDeviceTypeAddrs;
+ checkSilentMode_l();
} else {
sendIoConfigEvent_l(AUDIO_INPUT_CONFIG_CHANGED);
mInDeviceTypeAddr = sourceDeviceTypeAddr;
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index bc33fd0..66a7b6f 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -605,6 +605,7 @@
mediametrics::LogItem(mMetricsId)
.setPid(creatorPid)
.setUid(uid)
+ .set(AMEDIAMETRICS_PROP_ALLOWUID, (int32_t)uid)
.set(AMEDIAMETRICS_PROP_EVENT,
AMEDIAMETRICS_PROP_PREFIX_SERVER AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR)
.record();
@@ -2184,6 +2185,7 @@
mediametrics::LogItem(mMetricsId)
.setPid(creatorPid)
.setUid(uid)
+ .set(AMEDIAMETRICS_PROP_ALLOWUID, (int32_t)uid)
.set(AMEDIAMETRICS_PROP_EVENT, "server." AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR)
.record();
}
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioPolicyMix.h b/services/audiopolicy/common/managerdefinitions/include/AudioPolicyMix.h
index a757551..b82305d 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioPolicyMix.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioPolicyMix.h
@@ -72,8 +72,8 @@
*/
status_t getOutputForAttr(const audio_attributes_t& attributes, uid_t uid,
audio_output_flags_t flags,
- sp<SwAudioOutputDescriptor> &primaryDesc,
- std::vector<sp<SwAudioOutputDescriptor>> *secondaryDescs);
+ sp<AudioPolicyMix> &primaryMix,
+ std::vector<sp<AudioPolicyMix>> *secondaryMixes);
sp<DeviceDescriptor> getDeviceAndMixForInputSource(audio_source_t inputSource,
const DeviceVector &availableDeviceTypes,
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
index ed51389..fc1a59f 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
@@ -150,11 +150,11 @@
status_t AudioPolicyMixCollection::getOutputForAttr(
const audio_attributes_t& attributes, uid_t uid,
audio_output_flags_t flags,
- sp<SwAudioOutputDescriptor> &primaryDesc,
- std::vector<sp<SwAudioOutputDescriptor>> *secondaryDescs)
+ sp<AudioPolicyMix> &primaryMix,
+ std::vector<sp<AudioPolicyMix>> *secondaryMixes)
{
ALOGV("getOutputForAttr() querying %zu mixes:", size());
- primaryDesc = 0;
+ primaryMix.clear();
for (size_t i = 0; i < size(); i++) {
sp<AudioPolicyMix> policyMix = itemAt(i);
const bool primaryOutputMix = !is_mix_loopback_render(policyMix->mRouteFlags);
@@ -169,13 +169,7 @@
return INVALID_OPERATION;
}
- sp<SwAudioOutputDescriptor> policyDesc = policyMix->getOutput();
- if (!policyDesc) {
- ALOGV("%s: Skiping %zu: Mix has no output", __func__, i);
- continue;
- }
-
- if (primaryOutputMix && primaryDesc != 0) {
+ if (primaryOutputMix && primaryMix != nullptr) {
ALOGV("%s: Skiping %zu: Primary output already found", __func__, i);
continue; // Primary output already found
}
@@ -191,18 +185,13 @@
case MixMatchStatus::MATCH:;
}
- policyDesc->mPolicyMix = policyMix;
if (primaryOutputMix) {
- primaryDesc = policyDesc;
+ primaryMix = policyMix;
ALOGV("%s: Mix %zu: set primary desc", __func__, i);
} else {
- if (policyDesc->mIoHandle == AUDIO_IO_HANDLE_NONE) {
- ALOGV("%s: Mix %zu ignored as secondaryOutput because not opened yet", __func__, i);
- } else {
- ALOGV("%s: Add a secondary desc %zu", __func__, i);
- if (secondaryDescs != nullptr) {
- secondaryDescs->push_back(policyDesc);
- }
+ ALOGV("%s: Add a secondary desc %zu", __func__, i);
+ if (secondaryMixes != nullptr) {
+ secondaryMixes->push_back(policyMix);
}
}
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
index 886e4c9..d31e443 100644
--- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
@@ -320,7 +320,7 @@
{
String8 devAddress = (address == nullptr || !matchAddress) ? String8("") : String8(address);
// handle legacy remote submix case where the address was not always specified
- if (device_distinguishes_on_address(deviceType) && (devAddress.length() == 0)) {
+ if (audio_is_remote_submix_device(deviceType) && (devAddress.length() == 0)) {
devAddress = String8("0");
}
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index f1c2ab5..bcf6f38 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -907,7 +907,7 @@
audio_output_flags_t *flags,
audio_port_handle_t *selectedDeviceId,
bool *isRequestedDeviceForExclusiveUse,
- std::vector<sp<SwAudioOutputDescriptor>> *secondaryDescs,
+ std::vector<sp<AudioPolicyMix>> *secondaryMixes,
output_type_t *outputType)
{
DeviceVector outputDevices;
@@ -932,29 +932,45 @@
// The primary output is the explicit routing (eg. setPreferredDevice) if specified,
// otherwise, fallback to the dynamic policies, if none match, query the engine.
// Secondary outputs are always found by dynamic policies as the engine do not support them
- sp<SwAudioOutputDescriptor> policyDesc;
- status = mPolicyMixes.getOutputForAttr(*resultAttr, uid, *flags, policyDesc, secondaryDescs);
+ sp<AudioPolicyMix> primaryMix;
+ status = mPolicyMixes.getOutputForAttr(*resultAttr, uid, *flags, primaryMix, secondaryMixes);
if (status != OK) {
return status;
}
// Explicit routing is higher priority then any dynamic policy primary output
- bool usePrimaryOutputFromPolicyMixes = requestedDevice == nullptr && policyDesc != nullptr;
+ bool usePrimaryOutputFromPolicyMixes = requestedDevice == nullptr && primaryMix != nullptr;
// FIXME: in case of RENDER policy, the output capabilities should be checked
- if ((usePrimaryOutputFromPolicyMixes || !secondaryDescs->empty())
+ if ((usePrimaryOutputFromPolicyMixes
+ || (secondaryMixes != nullptr && !secondaryMixes->empty()))
&& !audio_is_linear_pcm(config->format)) {
ALOGD("%s: rejecting request as dynamic audio policy only support pcm", __func__);
return BAD_VALUE;
}
if (usePrimaryOutputFromPolicyMixes) {
- *output = policyDesc->mIoHandle;
- sp<AudioPolicyMix> mix = policyDesc->mPolicyMix.promote();
- if (mix != nullptr) {
- sp<DeviceDescriptor> deviceDesc =
- mAvailableOutputDevices.getDevice(mix->mDeviceType,
- mix->mDeviceAddress,
- AUDIO_FORMAT_DEFAULT);
+ sp<DeviceDescriptor> deviceDesc =
+ mAvailableOutputDevices.getDevice(primaryMix->mDeviceType,
+ primaryMix->mDeviceAddress,
+ AUDIO_FORMAT_DEFAULT);
+ sp<SwAudioOutputDescriptor> policyDesc = primaryMix->getOutput();
+ if (deviceDesc != nullptr
+ && (policyDesc == nullptr || (policyDesc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT))) {
+ audio_io_handle_t newOutput;
+ status = openDirectOutput(
+ *stream, session, config,
+ (audio_output_flags_t)(*flags | AUDIO_OUTPUT_FLAG_DIRECT),
+ DeviceVector(deviceDesc), &newOutput);
+ if (status != NO_ERROR) {
+ policyDesc = nullptr;
+ } else {
+ policyDesc = mOutputs.valueFor(newOutput);
+ primaryMix->setOutput(policyDesc);
+ }
+ }
+ if (policyDesc != nullptr) {
+ policyDesc->mPolicyMix = primaryMix;
+ *output = policyDesc->mIoHandle;
*selectedDeviceId = deviceDesc != 0 ? deviceDesc->getId() : AUDIO_PORT_HANDLE_NONE;
ALOGV("getOutputForAttr() returns output %d", *output);
@@ -1050,7 +1066,7 @@
const audio_port_handle_t requestedPortId = *selectedDeviceId;
audio_attributes_t resultAttr;
bool isRequestedDeviceForExclusiveUse = false;
- std::vector<sp<SwAudioOutputDescriptor>> secondaryOutputDescs;
+ std::vector<sp<AudioPolicyMix>> secondaryMixes;
const sp<DeviceDescriptor> requestedDevice =
mAvailableOutputDevices.getDeviceFromId(requestedPortId);
@@ -1061,14 +1077,20 @@
status_t status = getOutputForAttrInt(&resultAttr, output, session, attr, stream, uid,
config, flags, selectedDeviceId, &isRequestedDeviceForExclusiveUse,
- &secondaryOutputDescs, outputType);
+ secondaryOutputs != nullptr ? &secondaryMixes : nullptr, outputType);
if (status != NO_ERROR) {
return status;
}
std::vector<wp<SwAudioOutputDescriptor>> weakSecondaryOutputDescs;
- for (auto& secondaryDesc : secondaryOutputDescs) {
- secondaryOutputs->push_back(secondaryDesc->mIoHandle);
- weakSecondaryOutputDescs.push_back(secondaryDesc);
+ if (secondaryOutputs != nullptr) {
+ for (auto &secondaryMix : secondaryMixes) {
+ sp<SwAudioOutputDescriptor> outputDesc = secondaryMix->getOutput();
+ if (outputDesc != nullptr &&
+ outputDesc->mIoHandle != AUDIO_IO_HANDLE_NONE) {
+ secondaryOutputs->push_back(outputDesc->mIoHandle);
+ weakSecondaryOutputDescs.push_back(outputDesc);
+ }
+ }
}
audio_config_base_t clientConfig = {.sample_rate = config->sample_rate,
@@ -1093,6 +1115,118 @@
return NO_ERROR;
}
+status_t AudioPolicyManager::openDirectOutput(audio_stream_type_t stream,
+ audio_session_t session,
+ const audio_config_t *config,
+ audio_output_flags_t flags,
+ const DeviceVector &devices,
+ audio_io_handle_t *output) {
+
+ *output = AUDIO_IO_HANDLE_NONE;
+
+ // skip direct output selection if the request can obviously be attached to a mixed output
+ // and not explicitly requested
+ if (((flags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) &&
+ audio_is_linear_pcm(config->format) && config->sample_rate <= SAMPLE_RATE_HZ_MAX &&
+ audio_channel_count_from_out_mask(config->channel_mask) <= 2) {
+ return NAME_NOT_FOUND;
+ }
+
+ // Do not allow offloading if one non offloadable effect is enabled or MasterMono is enabled.
+ // This prevents creating an offloaded track and tearing it down immediately after start
+ // when audioflinger detects there is an active non offloadable effect.
+ // FIXME: We should check the audio session here but we do not have it in this context.
+ // This may prevent offloading in rare situations where effects are left active by apps
+ // in the background.
+ sp<IOProfile> profile;
+ if (((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) ||
+ !(mEffects.isNonOffloadableEffectEnabled() || mMasterMono)) {
+ profile = getProfileForOutput(
+ devices, config->sample_rate, config->format, config->channel_mask,
+ flags, true /* directOnly */);
+ }
+
+ if (profile == nullptr) {
+ return NAME_NOT_FOUND;
+ }
+
+ // exclusive outputs for MMAP and Offload are enforced by different session ids.
+ for (size_t i = 0; i < mOutputs.size(); i++) {
+ sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
+ if (!desc->isDuplicated() && (profile == desc->mProfile)) {
+ // reuse direct output if currently open by the same client
+ // and configured with same parameters
+ if ((config->sample_rate == desc->getSamplingRate()) &&
+ (config->format == desc->getFormat()) &&
+ (config->channel_mask == desc->getChannelMask()) &&
+ (session == desc->mDirectClientSession)) {
+ desc->mDirectOpenCount++;
+ ALOGI("%s reusing direct output %d for session %d", __func__,
+ mOutputs.keyAt(i), session);
+ *output = mOutputs.keyAt(i);
+ return NO_ERROR;
+ }
+ }
+ }
+
+ if (!profile->canOpenNewIo()) {
+ return NAME_NOT_FOUND;
+ }
+
+ sp<SwAudioOutputDescriptor> outputDesc =
+ new SwAudioOutputDescriptor(profile, mpClientInterface);
+
+ String8 address = getFirstDeviceAddress(devices);
+
+ // MSD patch may be using the only output stream that can service this request. Release
+ // MSD patch to prioritize this request over any active output on MSD.
+ AudioPatchCollection msdPatches = getMsdPatches();
+ for (size_t i = 0; i < msdPatches.size(); i++) {
+ const auto& patch = msdPatches[i];
+ for (size_t j = 0; j < patch->mPatch.num_sinks; ++j) {
+ const struct audio_port_config *sink = &patch->mPatch.sinks[j];
+ if (sink->type == AUDIO_PORT_TYPE_DEVICE &&
+ devices.containsDeviceWithType(sink->ext.device.type) &&
+ (address.isEmpty() || strncmp(sink->ext.device.address, address.string(),
+ AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0)) {
+ releaseAudioPatch(patch->getHandle(), mUidCached);
+ break;
+ }
+ }
+ }
+
+ status_t status = outputDesc->open(config, devices, stream, flags, output);
+
+ // only accept an output with the requested parameters
+ if (status != NO_ERROR ||
+ (config->sample_rate != 0 && config->sample_rate != outputDesc->getSamplingRate()) ||
+ (config->format != AUDIO_FORMAT_DEFAULT && config->format != outputDesc->getFormat()) ||
+ (config->channel_mask != 0 && config->channel_mask != outputDesc->getChannelMask())) {
+ ALOGV("%s failed opening direct output: output %d sample rate %d %d,"
+ "format %d %d, channel mask %04x %04x", __func__, *output, config->sample_rate,
+ outputDesc->getSamplingRate(), config->format, outputDesc->getFormat(),
+ config->channel_mask, outputDesc->getChannelMask());
+ if (*output != AUDIO_IO_HANDLE_NONE) {
+ outputDesc->close();
+ }
+ // fall back to mixer output if possible when the direct output could not be open
+ if (audio_is_linear_pcm(config->format) &&
+ config->sample_rate <= SAMPLE_RATE_HZ_MAX) {
+ return NAME_NOT_FOUND;
+ }
+ *output = AUDIO_IO_HANDLE_NONE;
+ return BAD_VALUE;
+ }
+ outputDesc->mDirectOpenCount = 1;
+ outputDesc->mDirectClientSession = session;
+
+ addOutput(*output, outputDesc);
+ mPreviousOutputs = mOutputs;
+ ALOGV("%s returns new direct output %d", __func__, *output);
+ mpClientInterface->onAudioPortListUpdate();
+ return NO_ERROR;
+}
+
audio_io_handle_t AudioPolicyManager::getOutputForDevices(
const DeviceVector &devices,
audio_session_t session,
@@ -1102,7 +1236,6 @@
bool forceMutingHaptic)
{
audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
- status_t status;
// Discard haptic channel mask when forcing muting haptic channels.
audio_channel_mask_t channelMask = forceMutingHaptic
@@ -1137,112 +1270,13 @@
ALOGV("Set VoIP and Direct output flags for PCM format");
}
-
- sp<IOProfile> profile;
-
- // skip direct output selection if the request can obviously be attached to a mixed output
- // and not explicitly requested
- if (((*flags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) &&
- audio_is_linear_pcm(config->format) && config->sample_rate <= SAMPLE_RATE_HZ_MAX &&
- audio_channel_count_from_out_mask(channelMask) <= 2) {
- goto non_direct_output;
- }
-
- // Do not allow offloading if one non offloadable effect is enabled or MasterMono is enabled.
- // This prevents creating an offloaded track and tearing it down immediately after start
- // when audioflinger detects there is an active non offloadable effect.
- // FIXME: We should check the audio session here but we do not have it in this context.
- // This may prevent offloading in rare situations where effects are left active by apps
- // in the background.
-
- if (((*flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) ||
- !(mEffects.isNonOffloadableEffectEnabled() || mMasterMono)) {
- profile = getProfileForOutput(devices,
- config->sample_rate,
- config->format,
- channelMask,
- (audio_output_flags_t)*flags,
- true /* directOnly */);
- }
-
- if (profile != 0) {
- // exclusive outputs for MMAP and Offload are enforced by different session ids.
- for (size_t i = 0; i < mOutputs.size(); i++) {
- sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
- if (!desc->isDuplicated() && (profile == desc->mProfile)) {
- // reuse direct output if currently open by the same client
- // and configured with same parameters
- if ((config->sample_rate == desc->getSamplingRate()) &&
- (config->format == desc->getFormat()) &&
- (channelMask == desc->getChannelMask()) &&
- (session == desc->mDirectClientSession)) {
- desc->mDirectOpenCount++;
- ALOGI("%s reusing direct output %d for session %d", __func__,
- mOutputs.keyAt(i), session);
- return mOutputs.keyAt(i);
- }
- }
- }
-
- if (!profile->canOpenNewIo()) {
- goto non_direct_output;
- }
-
- sp<SwAudioOutputDescriptor> outputDesc =
- new SwAudioOutputDescriptor(profile, mpClientInterface);
-
- String8 address = getFirstDeviceAddress(devices);
-
- // MSD patch may be using the only output stream that can service this request. Release
- // MSD patch to prioritize this request over any active output on MSD.
- AudioPatchCollection msdPatches = getMsdPatches();
- for (size_t i = 0; i < msdPatches.size(); i++) {
- const auto& patch = msdPatches[i];
- for (size_t j = 0; j < patch->mPatch.num_sinks; ++j) {
- const struct audio_port_config *sink = &patch->mPatch.sinks[j];
- if (sink->type == AUDIO_PORT_TYPE_DEVICE &&
- devices.containsDeviceWithType(sink->ext.device.type) &&
- (address.isEmpty() || strncmp(sink->ext.device.address, address.string(),
- AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0)) {
- releaseAudioPatch(patch->getHandle(), mUidCached);
- break;
- }
- }
- }
-
- status = outputDesc->open(config, devices, stream, *flags, &output);
-
- // only accept an output with the requested parameters
- if (status != NO_ERROR ||
- (config->sample_rate != 0 && config->sample_rate != outputDesc->getSamplingRate()) ||
- (config->format != AUDIO_FORMAT_DEFAULT && config->format != outputDesc->getFormat()) ||
- (channelMask != 0 && channelMask != outputDesc->getChannelMask())) {
- ALOGV("%s failed opening direct output: output %d sample rate %d %d,"
- "format %d %d, channel mask %04x %04x", __func__, output, config->sample_rate,
- outputDesc->getSamplingRate(), config->format, outputDesc->getFormat(),
- channelMask, outputDesc->getChannelMask());
- if (output != AUDIO_IO_HANDLE_NONE) {
- outputDesc->close();
- }
- // fall back to mixer output if possible when the direct output could not be open
- if (audio_is_linear_pcm(config->format) &&
- config->sample_rate <= SAMPLE_RATE_HZ_MAX) {
- goto non_direct_output;
- }
- return AUDIO_IO_HANDLE_NONE;
- }
- outputDesc->mDirectOpenCount = 1;
- outputDesc->mDirectClientSession = session;
-
- addOutput(output, outputDesc);
- mPreviousOutputs = mOutputs;
- ALOGV("%s returns new direct output %d", __func__, output);
- mpClientInterface->onAudioPortListUpdate();
+ audio_config_t directConfig = *config;
+ directConfig.channel_mask = channelMask;
+ status_t status = openDirectOutput(stream, session, &directConfig, *flags, devices, &output);
+ if (status != NAME_NOT_FOUND) {
return output;
}
-non_direct_output:
-
// A request for HW A/V sync cannot fallback to a mixed output because time
// stamps are embedded in audio data
if ((*flags & (AUDIO_OUTPUT_FLAG_HW_AV_SYNC | AUDIO_OUTPUT_FLAG_MMAP_NOIRQ)) != 0) {
@@ -2146,7 +2180,7 @@
if (!profile->canOpenNewIo()) {
for (size_t i = 0; i < mInputs.size(); ) {
- sp <AudioInputDescriptor> desc = mInputs.valueAt(i);
+ sp<AudioInputDescriptor> desc = mInputs.valueAt(i);
if (desc->mProfile != profile) {
i++;
continue;
@@ -2886,8 +2920,8 @@
}
audio_config_t outputConfig = mix.mFormat;
audio_config_t inputConfig = mix.mFormat;
- // NOTE: audio flinger mixer does not support mono output: configure remote submix HAL in
- // stereo and let audio flinger do the channel conversion if needed.
+ // NOTE: audio flinger mixer does not support mono output: configure remote submix HAL
+ // in stereo and let audio flinger do the channel conversion if needed.
outputConfig.channel_mask = AUDIO_CHANNEL_OUT_STEREO;
inputConfig.channel_mask = AUDIO_CHANNEL_IN_STEREO;
rSubmixModule->addOutputProfile(address.c_str(), &outputConfig,
@@ -2917,10 +2951,11 @@
}
bool foundOutput = false;
- for (size_t j = 0 ; j < mOutputs.size() ; j++) {
+ // First try to find an already opened output supporting the device
+ for (size_t j = 0 ; j < mOutputs.size() && !foundOutput && res == NO_ERROR; j++) {
sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(j);
- if (desc->supportedDevices().contains(device)) {
+ if (!desc->isDuplicated() && desc->supportedDevices().contains(device)) {
if (mPolicyMixes.registerMix(mix, desc) != NO_ERROR) {
ALOGE("Could not register mix RENDER, dev=0x%X addr=%s", type,
address.string());
@@ -2928,10 +2963,26 @@
} else {
foundOutput = true;
}
- break;
}
}
-
+ // If no output found, try to find a direct output profile supporting the device
+ for (size_t i = 0; i < mHwModules.size() && !foundOutput && res == NO_ERROR; i++) {
+ sp<HwModule> module = mHwModules[i];
+ for (size_t j = 0;
+ j < module->getOutputProfiles().size() && !foundOutput && res == NO_ERROR;
+ j++) {
+ sp<IOProfile> profile = module->getOutputProfiles()[j];
+ if (profile->isDirectOutput() && profile->supportsDevice(device)) {
+ if (mPolicyMixes.registerMix(mix, nullptr) != NO_ERROR) {
+ ALOGE("Could not register mix RENDER, dev=0x%X addr=%s", type,
+ address.string());
+ res = INVALID_OPERATION;
+ } else {
+ foundOutput = true;
+ }
+ }
+ }
+ }
if (res != NO_ERROR) {
ALOGE(" Error registering mix %zu for device 0x%X addr %s",
i, type, address.string());
@@ -3014,58 +3065,67 @@
}
}
+// Returns true if all devices types match the predicate and are supported by one HW module
+bool AudioPolicyManager::areAllDevicesSupported(
+ const Vector<AudioDeviceTypeAddr>& devices,
+ std::function<bool(audio_devices_t)> predicate,
+ const char *context) {
+ for (size_t i = 0; i < devices.size(); i++) {
+ sp<DeviceDescriptor> devDesc = mHwModules.getDeviceDescriptor(
+ devices[i].mType, devices[i].mAddress.c_str(), String8(),
+ AUDIO_FORMAT_DEFAULT, false /*allowToCreate*/, true /*matchAddress*/);
+ if (devDesc == nullptr || (predicate != nullptr && !predicate(devices[i].mType))) {
+ ALOGE("%s: device type %#x address %s not supported or not an output device",
+ context, devices[i].mType, devices[i].mAddress.c_str());
+ return false;
+ }
+ }
+ return true;
+}
+
status_t AudioPolicyManager::setUidDeviceAffinities(uid_t uid,
const Vector<AudioDeviceTypeAddr>& devices) {
ALOGV("%s() uid=%d num devices %zu", __FUNCTION__, uid, devices.size());
- // uid/device affinity is only for output devices
- for (size_t i = 0; i < devices.size(); i++) {
- if (!audio_is_output_device(devices[i].mType)) {
- ALOGE("setUidDeviceAffinities() device=%08x is NOT an output device",
- devices[i].mType);
- return BAD_VALUE;
- }
+ if (!areAllDevicesSupported(devices, audio_is_output_device, __func__)) {
+ return BAD_VALUE;
}
status_t res = mPolicyMixes.setUidDeviceAffinities(uid, devices);
- if (res == NO_ERROR) {
- // reevaluate outputs for all given devices
- for (size_t i = 0; i < devices.size(); i++) {
- sp<DeviceDescriptor> devDesc = mHwModules.getDeviceDescriptor(
- devices[i].mType, devices[i].mAddress.c_str(), String8(),
- AUDIO_FORMAT_DEFAULT);
- SortedVector<audio_io_handle_t> outputs;
- if (checkOutputsForDevice(devDesc, AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
- outputs) != NO_ERROR) {
- ALOGE("setUidDeviceAffinities() error in checkOutputsForDevice for device=%08x"
- " addr=%s", devices[i].mType, devices[i].mAddress.c_str());
- return INVALID_OPERATION;
- }
- }
+ if (res != NO_ERROR) {
+ ALOGE("%s() Could not set all device affinities for uid = %d", __FUNCTION__, uid);
+ return res;
}
- return res;
+
+ checkForDeviceAndOutputChanges();
+ updateCallAndOutputRouting();
+
+ return NO_ERROR;
}
status_t AudioPolicyManager::removeUidDeviceAffinities(uid_t uid) {
ALOGV("%s() uid=%d", __FUNCTION__, uid);
status_t res = mPolicyMixes.removeUidDeviceAffinities(uid);
if (res != NO_ERROR) {
- ALOGE("%s() Could not remove all device affinities fo uid = %d",
+ ALOGE("%s() Could not remove all device affinities for uid = %d",
__FUNCTION__, uid);
return INVALID_OPERATION;
}
+ checkForDeviceAndOutputChanges();
+ updateCallAndOutputRouting();
+
return res;
}
status_t AudioPolicyManager::setPreferredDeviceForStrategy(product_strategy_t strategy,
const AudioDeviceTypeAddr &device) {
- ALOGI("%s() strategy=%d device=%08x addr=%s", __FUNCTION__,
+ ALOGV("%s() strategy=%d device=%08x addr=%s", __FUNCTION__,
strategy, device.mType, device.mAddress.c_str());
- // strategy preferred device is only for output devices
- if (!audio_is_output_device(device.mType)) {
- ALOGE("%s() device=%08x is NOT an output device", __FUNCTION__, device.mType);
+
+ Vector<AudioDeviceTypeAddr> devices;
+ devices.add(device);
+ if (!areAllDevicesSupported(devices, audio_is_output_device, __func__)) {
return BAD_VALUE;
}
-
status_t status = mEngine->setPreferredDeviceForStrategy(strategy, device);
if (status != NO_ERROR) {
ALOGW("Engine could not set preferred device %08x %s for strategy %d",
@@ -3124,17 +3184,10 @@
status_t AudioPolicyManager::setUserIdDeviceAffinities(int userId,
const Vector<AudioDeviceTypeAddr>& devices) {
- ALOGI("%s() userId=%d num devices %zu", __FUNCTION__, userId, devices.size());
- // userId/device affinity is only for output devices
- for (size_t i = 0; i < devices.size(); i++) {
- if (!audio_is_output_device(devices[i].mType)) {
- ALOGE("%s() device=%08x is NOT an output device",
- __FUNCTION__,
- devices[i].mType);
- return BAD_VALUE;
- }
+ ALOGI("%s() userId=%d num devices %zu", __FUNCTION__, userId, devices.size());\
+ if (!areAllDevicesSupported(devices, audio_is_output_device, __func__)) {
+ return BAD_VALUE;
}
-
status_t status = mPolicyMixes.setUserIdDeviceAffinities(userId, devices);
if (status != NO_ERROR) {
ALOGE("%s() could not set device affinity for userId %d",
@@ -3641,12 +3694,11 @@
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE;
audio_port_handle_t selectedDeviceId = AUDIO_PORT_HANDLE_NONE;
bool isRequestedDeviceForExclusiveUse = false;
- std::vector<sp<SwAudioOutputDescriptor>> secondaryOutputs;
output_type_t outputType;
getOutputForAttrInt(&resultAttr, &output, AUDIO_SESSION_NONE, &attributes,
&stream, sourceDesc->uid(), &config, &flags,
&selectedDeviceId, &isRequestedDeviceForExclusiveUse,
- &secondaryOutputs, &outputType);
+ nullptr, &outputType);
if (output == AUDIO_IO_HANDLE_NONE) {
ALOGV("%s no output for device %s",
__FUNCTION__, sinkDevice->toString().c_str());
@@ -4551,9 +4603,6 @@
mTtsOutputAvailable = true;
}
- if ((outProfile->getFlags() & AUDIO_OUTPUT_FLAG_DIRECT) != 0) {
- continue;
- }
const DeviceVector &supportedDevices = outProfile->getSupportedDevices();
DeviceVector availProfileDevices = supportedDevices.filter(mOutputDevicesAll);
sp<DeviceDescriptor> supportedDevice = 0;
@@ -4594,12 +4643,16 @@
outProfile->getFlags() & AUDIO_OUTPUT_FLAG_PRIMARY) {
mPrimaryOutput = outputDesc;
}
- addOutput(output, outputDesc);
- setOutputDevices(outputDesc,
- DeviceVector(supportedDevice),
- true,
- 0,
- NULL);
+ if ((outProfile->getFlags() & AUDIO_OUTPUT_FLAG_DIRECT) != 0) {
+ outputDesc->close();
+ } else {
+ addOutput(output, outputDesc);
+ setOutputDevices(outputDesc,
+ DeviceVector(supportedDevice),
+ true,
+ 0,
+ NULL);
+ }
}
// open input streams needed to access attached devices to validate
// mAvailableInputDevices list
@@ -4785,7 +4838,7 @@
if (output != AUDIO_IO_HANDLE_NONE) {
addOutput(output, desc);
- if (device_distinguishes_on_address(deviceType) && address != "0") {
+ if (audio_is_remote_submix_device(deviceType) && address != "0") {
sp<AudioPolicyMix> policyMix;
if (mPolicyMixes.getAudioPolicyMix(deviceType, address, policyMix)
== NO_ERROR) {
@@ -5275,10 +5328,19 @@
for (size_t i = 0; i < mOutputs.size(); i++) {
const sp<SwAudioOutputDescriptor>& outputDescriptor = mOutputs[i];
for (const sp<TrackClientDescriptor>& client : outputDescriptor->getClientIterable()) {
- sp<SwAudioOutputDescriptor> desc;
- std::vector<sp<SwAudioOutputDescriptor>> secondaryDescs;
+ sp<AudioPolicyMix> primaryMix;
+ std::vector<sp<AudioPolicyMix>> secondaryMixes;
status_t status = mPolicyMixes.getOutputForAttr(client->attributes(), client->uid(),
- client->flags(), desc, &secondaryDescs);
+ client->flags(), primaryMix, &secondaryMixes);
+ std::vector<sp<SwAudioOutputDescriptor>> secondaryDescs;
+ for (auto &secondaryMix : secondaryMixes) {
+ sp<SwAudioOutputDescriptor> outputDesc = secondaryMix->getOutput();
+ if (outputDesc != nullptr &&
+ outputDesc->mIoHandle != AUDIO_IO_HANDLE_NONE) {
+ secondaryDescs.push_back(outputDesc);
+ }
+ }
+
if (status != OK ||
!std::equal(client->getSecondaryOutputs().begin(),
client->getSecondaryOutputs().end(),
@@ -5482,21 +5544,17 @@
}
// check dynamic policies but only for primary descriptors (secondary not used for audible
// audio routing, only used for duplication for playback capture)
- sp<SwAudioOutputDescriptor> policyDesc;
+ sp<AudioPolicyMix> policyMix;
status_t status = mPolicyMixes.getOutputForAttr(attr, 0 /*uid unknown here*/,
- AUDIO_OUTPUT_FLAG_NONE, policyDesc, nullptr);
+ AUDIO_OUTPUT_FLAG_NONE, policyMix, nullptr);
if (status != OK) {
return status;
}
- if (policyDesc != nullptr) {
- sp<AudioPolicyMix> mix = policyDesc->mPolicyMix.promote();
- if (mix != nullptr) {
- AudioDeviceTypeAddr device(mix->mDeviceType, mix->mDeviceAddress.c_str());
- devices->push_back(device);
- return NO_ERROR;
- }
+ if (policyMix != nullptr && policyMix->getOutput() != nullptr) {
+ AudioDeviceTypeAddr device(policyMix->mDeviceType, policyMix->mDeviceAddress.c_str());
+ devices->push_back(device);
+ return NO_ERROR;
}
-
DeviceVector curDevices = mEngine->getOutputDevicesForAttributes(attr, nullptr, false);
for (const auto& device : curDevices) {
devices->push_back(device->getDeviceTypeAddr());
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index c142880..b588f89 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -837,7 +837,7 @@
audio_output_flags_t *flags,
audio_port_handle_t *selectedDeviceId,
bool *isRequestedDeviceForExclusiveUse,
- std::vector<sp<SwAudioOutputDescriptor>> *secondaryDescs,
+ std::vector<sp<AudioPolicyMix>> *secondaryMixes,
output_type_t *outputType);
// internal method to return the output handle for the given device and format
audio_io_handle_t getOutputForDevices(
@@ -848,6 +848,16 @@
audio_output_flags_t *flags,
bool forceMutingHaptic = false);
+ // Internal method checking if a direct output can be opened matching the requested
+ // attributes, flags, config and devices.
+ // If NAME_NOT_FOUND is returned, an attempt can be made to open a mixed output.
+ status_t openDirectOutput(
+ audio_stream_type_t stream,
+ audio_session_t session,
+ const audio_config_t *config,
+ audio_output_flags_t flags,
+ const DeviceVector &devices,
+ audio_io_handle_t *output);
/**
* @brief getInputForDevice selects an input handle for a given input device and
* requester context
@@ -926,6 +936,12 @@
int delayMs,
uid_t uid,
sp<AudioPatch> *patchDescPtr);
+
+ bool areAllDevicesSupported(
+ const Vector<AudioDeviceTypeAddr>& devices,
+ std::function<bool(audio_devices_t)> predicate,
+ const char* context);
+
};
};
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index d743be9..a15970a 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -676,6 +676,7 @@
case AUDIO_SOURCE_VOICE_CALL:
case AUDIO_SOURCE_REMOTE_SUBMIX:
case AUDIO_SOURCE_FM_TUNER:
+ case AUDIO_SOURCE_ECHO_REFERENCE:
return true;
default:
break;
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 2d46122..b00a2d9 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -2344,6 +2344,21 @@
}
}
+bool Camera3Device::checkAbandonedStreamsLocked() {
+ if ((mInputStream.get() != nullptr) && (mInputStream->isAbandoned())) {
+ return true;
+ }
+
+ for (size_t i = 0; i < mOutputStreams.size(); i++) {
+ auto stream = mOutputStreams[i];
+ if ((stream.get() != nullptr) && (stream->isAbandoned())) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
bool Camera3Device::reconfigureCamera(const CameraMetadata& sessionParams) {
ATRACE_CALL();
bool ret = false;
@@ -2352,6 +2367,12 @@
nsecs_t maxExpectedDuration = getExpectedInFlightDuration();
Mutex::Autolock l(mLock);
+ if (checkAbandonedStreamsLocked()) {
+ ALOGW("%s: Abandoned stream detected, session parameters can't be applied correctly!",
+ __FUNCTION__);
+ return true;
+ }
+
auto rc = internalPauseAndWaitLocked(maxExpectedDuration);
if (rc == NO_ERROR) {
mNeedConfig = true;
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index b373a64..19ecf4b 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -648,6 +648,12 @@
bool reconfigureCamera(const CameraMetadata& sessionParams);
/**
+ * Return true in case of any output or input abandoned streams,
+ * otherwise return false.
+ */
+ bool checkAbandonedStreamsLocked();
+
+ /**
* Filter stream session parameters and configure camera HAL.
*/
status_t filterParamsAndConfigureLocked(const CameraMetadata& sessionParams,
diff --git a/services/camera/libcameraservice/device3/ZoomRatioMapper.cpp b/services/camera/libcameraservice/device3/ZoomRatioMapper.cpp
index 84da45a..a87de77 100644
--- a/services/camera/libcameraservice/device3/ZoomRatioMapper.cpp
+++ b/services/camera/libcameraservice/device3/ZoomRatioMapper.cpp
@@ -243,10 +243,15 @@
if (weight == 0) {
continue;
}
- // Top-left is inclusively clamped
- scaleCoordinates(entry.data.i32 + j, 1, zoomRatio, ClampInclusive);
- // Bottom-right is exclusively clamped
- scaleCoordinates(entry.data.i32 + j + 2, 1, zoomRatio, ClampExclusive);
+ // Top left (inclusive)
+ scaleCoordinates(entry.data.i32 + j, 1, zoomRatio, true /*clamp*/);
+ // Bottom right (exclusive): Use adjacent inclusive pixel to
+ // calculate.
+ entry.data.i32[j+2] -= 1;
+ entry.data.i32[j+3] -= 1;
+ scaleCoordinates(entry.data.i32 + j + 2, 1, zoomRatio, true /*clamp*/);
+ entry.data.i32[j+2] += 1;
+ entry.data.i32[j+3] += 1;
}
}
@@ -258,7 +263,7 @@
if (isResult) {
for (auto pts : kResultPointsToCorrectNoClamp) {
entry = metadata->find(pts);
- scaleCoordinates(entry.data.i32, entry.count / 2, zoomRatio, ClampOff);
+ scaleCoordinates(entry.data.i32, entry.count / 2, zoomRatio, false /*clamp*/);
}
}
@@ -282,10 +287,15 @@
if (weight == 0) {
continue;
}
- // Top-left is inclusively clamped
- scaleCoordinates(entry.data.i32 + j, 1, 1.0 / zoomRatio, ClampInclusive);
- // Bottom-right is exclusively clamped
- scaleCoordinates(entry.data.i32 + j + 2, 1, 1.0 / zoomRatio, ClampExclusive);
+ // Top-left (inclusive)
+ scaleCoordinates(entry.data.i32 + j, 1, 1.0 / zoomRatio, true /*clamp*/);
+ // Bottom-right (exclusive): Use adjacent inclusive pixel to
+ // calculate.
+ entry.data.i32[j+2] -= 1;
+ entry.data.i32[j+3] -= 1;
+ scaleCoordinates(entry.data.i32 + j + 2, 1, 1.0 / zoomRatio, true /*clamp*/);
+ entry.data.i32[j+2] += 1;
+ entry.data.i32[j+3] += 1;
}
}
for (auto rect : kRectsToCorrect) {
@@ -295,7 +305,7 @@
if (isResult) {
for (auto pts : kResultPointsToCorrectNoClamp) {
entry = metadata->find(pts);
- scaleCoordinates(entry.data.i32, entry.count / 2, 1.0 / zoomRatio, ClampOff);
+ scaleCoordinates(entry.data.i32, entry.count / 2, 1.0 / zoomRatio, false /*clamp*/);
}
}
@@ -309,28 +319,31 @@
}
void ZoomRatioMapper::scaleCoordinates(int32_t* coordPairs, int coordCount,
- float scaleRatio, ClampMode clamp) {
+ float scaleRatio, bool clamp) {
+ // A pixel's coordinate is represented by the position of its top-left corner.
+ // To avoid the rounding error, we use the coordinate for the center of the
+ // pixel instead:
+ // 1. First shift the coordinate system half pixel both horizontally and
+ // vertically, so that [x, y] is the center of the pixel, not the top-left corner.
+ // 2. Do zoom operation to scale the coordinate relative to the center of
+ // the active array (shifted by 0.5 pixel as well).
+ // 3. Shift the coordinate system back by directly using the pixel center
+ // coordinate.
for (int i = 0; i < coordCount * 2; i += 2) {
float x = coordPairs[i];
float y = coordPairs[i + 1];
- float xCentered = x - mArrayWidth / 2;
- float yCentered = y - mArrayHeight / 2;
+ float xCentered = x - (mArrayWidth - 2) / 2;
+ float yCentered = y - (mArrayHeight - 2) / 2;
float scaledX = xCentered * scaleRatio;
float scaledY = yCentered * scaleRatio;
- scaledX += mArrayWidth / 2;
- scaledY += mArrayHeight / 2;
+ scaledX += (mArrayWidth - 2) / 2;
+ scaledY += (mArrayHeight - 2) / 2;
+ coordPairs[i] = static_cast<int32_t>(std::round(scaledX));
+ coordPairs[i+1] = static_cast<int32_t>(std::round(scaledY));
// Clamp to within activeArray/preCorrectionActiveArray
- coordPairs[i] = static_cast<int32_t>(scaledX);
- coordPairs[i+1] = static_cast<int32_t>(scaledY);
- if (clamp != ClampOff) {
- int32_t right, bottom;
- if (clamp == ClampInclusive) {
- right = mArrayWidth - 1;
- bottom = mArrayHeight - 1;
- } else {
- right = mArrayWidth;
- bottom = mArrayHeight;
- }
+ if (clamp) {
+ int32_t right = mArrayWidth - 1;
+ int32_t bottom = mArrayHeight - 1;
coordPairs[i] =
std::min(right, std::max(0, coordPairs[i]));
coordPairs[i+1] =
@@ -343,25 +356,25 @@
void ZoomRatioMapper::scaleRects(int32_t* rects, int rectCount,
float scaleRatio) {
for (int i = 0; i < rectCount * 4; i += 4) {
- // Map from (l, t, width, height) to (l, t, r, b).
- // [l, t] is inclusive, and [r, b] is exclusive.
+ // Map from (l, t, width, height) to (l, t, l+width-1, t+height-1),
+ // where both top-left and bottom-right are inclusive.
int32_t coords[4] = {
rects[i],
rects[i + 1],
- rects[i] + rects[i + 2],
- rects[i + 1] + rects[i + 3]
+ rects[i] + rects[i + 2] - 1,
+ rects[i + 1] + rects[i + 3] - 1
};
// top-left
- scaleCoordinates(coords, 1, scaleRatio, ClampInclusive);
+ scaleCoordinates(coords, 1, scaleRatio, true /*clamp*/);
// bottom-right
- scaleCoordinates(coords+2, 1, scaleRatio, ClampExclusive);
+ scaleCoordinates(coords+2, 1, scaleRatio, true /*clamp*/);
// Map back to (l, t, width, height)
rects[i] = coords[0];
rects[i + 1] = coords[1];
- rects[i + 2] = coords[2] - coords[0];
- rects[i + 3] = coords[3] - coords[1];
+ rects[i + 2] = coords[2] - coords[0] + 1;
+ rects[i + 3] = coords[3] - coords[1] + 1;
}
}
diff --git a/services/camera/libcameraservice/device3/ZoomRatioMapper.h b/services/camera/libcameraservice/device3/ZoomRatioMapper.h
index aa3d913..698f87f 100644
--- a/services/camera/libcameraservice/device3/ZoomRatioMapper.h
+++ b/services/camera/libcameraservice/device3/ZoomRatioMapper.h
@@ -65,14 +65,8 @@
status_t updateCaptureResult(CameraMetadata *request, bool requestedZoomRatioIs1);
public: // Visible for testing. Do not use concurently.
- enum ClampMode {
- ClampOff,
- ClampInclusive,
- ClampExclusive,
- };
-
void scaleCoordinates(int32_t* coordPairs, int coordCount,
- float scaleRatio, ClampMode clamp);
+ float scaleRatio, bool clamp);
bool isValid() { return mIsValid; }
private:
diff --git a/services/camera/libcameraservice/tests/ZoomRatioTest.cpp b/services/camera/libcameraservice/tests/ZoomRatioTest.cpp
index 300da09..4e94991 100644
--- a/services/camera/libcameraservice/tests/ZoomRatioTest.cpp
+++ b/services/camera/libcameraservice/tests/ZoomRatioTest.cpp
@@ -171,35 +171,35 @@
std::array<int32_t, 16> originalCoords = {
0, 0, // top-left
- width, 0, // top-right
- 0, height, // bottom-left
- width, height, // bottom-right
- width / 2, height / 2, // center
- width / 4, height / 4, // top-left after 2x
- width / 3, height * 2 / 3, // bottom-left after 3x zoom
- width * 7 / 8, height / 2, // middle-right after 1.33x zoom
+ width - 1, 0, // top-right
+ 0, height - 1, // bottom-left
+ width - 1, height - 1, // bottom-right
+ (width - 1) / 2, (height - 1) / 2, // center
+ (width - 1) / 4, (height - 1) / 4, // top-left after 2x
+ (width - 1) / 3, (height - 1) * 2 / 3, // bottom-left after 3x zoom
+ (width - 1) * 7 / 8, (height - 1) / 2, // middle-right after 1.33x zoom
};
// Verify 1.0x zoom doesn't change the coordinates
auto coords = originalCoords;
- mapper.scaleCoordinates(coords.data(), coords.size()/2, 1.0f, ZoomRatioMapper::ClampOff);
+ mapper.scaleCoordinates(coords.data(), coords.size()/2, 1.0f, false /*clamp*/);
for (size_t i = 0; i < coords.size(); i++) {
EXPECT_EQ(coords[i], originalCoords[i]);
}
// Verify 2.0x zoom work as expected (no clamping)
std::array<float, 16> expected2xCoords = {
- - width / 2.0f, - height / 2.0f,// top-left
- width * 3 / 2.0f, - height / 2.0f, // top-right
- - width / 2.0f, height * 3 / 2.0f, // bottom-left
- width * 3 / 2.0f, height * 3 / 2.0f, // bottom-right
- width / 2.0f, height / 2.0f, // center
+ - (width - 1) / 2.0f, - (height - 1) / 2.0f,// top-left
+ (width - 1) * 3 / 2.0f, - (height - 1) / 2.0f, // top-right
+ - (width - 1) / 2.0f, (height - 1) * 3 / 2.0f, // bottom-left
+ (width - 1) * 3 / 2.0f, (height - 1) * 3 / 2.0f, // bottom-right
+ (width - 1) / 2.0f, (height - 1) / 2.0f, // center
0, 0, // top-left after 2x
- width / 6.0f, height - height / 6.0f, // bottom-left after 3x zoom
- width + width / 4.0f, height / 2.0f, // middle-right after 1.33x zoom
+ (width - 1) / 6.0f, (height - 1) * 5.0f / 6.0f, // bottom-left after 3x zoom
+ (width - 1) * 5.0f / 4.0f, (height - 1) / 2.0f, // middle-right after 1.33x zoom
};
coords = originalCoords;
- mapper.scaleCoordinates(coords.data(), coords.size()/2, 2.0f, ZoomRatioMapper::ClampOff);
+ mapper.scaleCoordinates(coords.data(), coords.size()/2, 2.0f, false /*clamp*/);
for (size_t i = 0; i < coords.size(); i++) {
EXPECT_LE(std::abs(coords[i] - expected2xCoords[i]), kMaxAllowedPixelError);
}
@@ -207,16 +207,16 @@
// Verify 2.0x zoom work as expected (with inclusive clamping)
std::array<float, 16> expected2xCoordsClampedInc = {
0, 0, // top-left
- static_cast<float>(width) - 1, 0, // top-right
- 0, static_cast<float>(height) - 1, // bottom-left
- static_cast<float>(width) - 1, static_cast<float>(height) - 1, // bottom-right
- width / 2.0f, height / 2.0f, // center
+ width - 1.0f, 0, // top-right
+ 0, height - 1.0f, // bottom-left
+ width - 1.0f, height - 1.0f, // bottom-right
+ (width - 1) / 2.0f, (height - 1) / 2.0f, // center
0, 0, // top-left after 2x
- width / 6.0f, height - height / 6.0f , // bottom-left after 3x zoom
- static_cast<float>(width) - 1, height / 2.0f, // middle-right after 1.33x zoom
+ (width - 1) / 6.0f, (height - 1) * 5.0f / 6.0f , // bottom-left after 3x zoom
+ width - 1.0f, (height - 1) / 2.0f, // middle-right after 1.33x zoom
};
coords = originalCoords;
- mapper.scaleCoordinates(coords.data(), coords.size()/2, 2.0f, ZoomRatioMapper::ClampInclusive);
+ mapper.scaleCoordinates(coords.data(), coords.size()/2, 2.0f, true /*clamp*/);
for (size_t i = 0; i < coords.size(); i++) {
EXPECT_LE(std::abs(coords[i] - expected2xCoordsClampedInc[i]), kMaxAllowedPixelError);
}
@@ -224,33 +224,33 @@
// Verify 2.0x zoom work as expected (with exclusive clamping)
std::array<float, 16> expected2xCoordsClampedExc = {
0, 0, // top-left
- static_cast<float>(width), 0, // top-right
- 0, static_cast<float>(height), // bottom-left
- static_cast<float>(width), static_cast<float>(height), // bottom-right
+ width - 1.0f, 0, // top-right
+ 0, height - 1.0f, // bottom-left
+ width - 1.0f, height - 1.0f, // bottom-right
width / 2.0f, height / 2.0f, // center
0, 0, // top-left after 2x
- width / 6.0f, height - height / 6.0f , // bottom-left after 3x zoom
- static_cast<float>(width), height / 2.0f, // middle-right after 1.33x zoom
+ (width - 1) / 6.0f, (height - 1) * 5.0f / 6.0f , // bottom-left after 3x zoom
+ width - 1.0f, height / 2.0f, // middle-right after 1.33x zoom
};
coords = originalCoords;
- mapper.scaleCoordinates(coords.data(), coords.size()/2, 2.0f, ZoomRatioMapper::ClampExclusive);
+ mapper.scaleCoordinates(coords.data(), coords.size()/2, 2.0f, true /*clamp*/);
for (size_t i = 0; i < coords.size(); i++) {
EXPECT_LE(std::abs(coords[i] - expected2xCoordsClampedExc[i]), kMaxAllowedPixelError);
}
// Verify 0.33x zoom work as expected
std::array<float, 16> expectedZoomOutCoords = {
- width / 3.0f, height / 3.0f, // top-left
- width * 2 / 3.0f, height / 3.0f, // top-right
- width / 3.0f, height * 2 / 3.0f, // bottom-left
- width * 2 / 3.0f, height * 2 / 3.0f, // bottom-right
- width / 2.0f, height / 2.0f, // center
- width * 5 / 12.0f, height * 5 / 12.0f, // top-left after 2x
- width * 4 / 9.0f, height * 5 / 9.0f, // bottom-left after 3x zoom-in
- width * 5 / 8.0f, height / 2.0f, // middle-right after 1.33x zoom-in
+ (width - 1) / 3.0f, (height - 1) / 3.0f, // top-left
+ (width - 1) * 2 / 3.0f, (height - 1) / 3.0f, // top-right
+ (width - 1) / 3.0f, (height - 1) * 2 / 3.0f, // bottom-left
+ (width - 1) * 2 / 3.0f, (height - 1) * 2 / 3.0f, // bottom-right
+ (width - 1) / 2.0f, (height - 1) / 2.0f, // center
+ (width - 1) * 5 / 12.0f, (height - 1) * 5 / 12.0f, // top-left after 2x
+ (width - 1) * 4 / 9.0f, (height - 1) * 5 / 9.0f, // bottom-left after 3x zoom-in
+ (width - 1) * 5 / 8.0f, (height - 1) / 2.0f, // middle-right after 1.33x zoom-in
};
coords = originalCoords;
- mapper.scaleCoordinates(coords.data(), coords.size()/2, 1.0f/3, ZoomRatioMapper::ClampOff);
+ mapper.scaleCoordinates(coords.data(), coords.size()/2, 1.0f/3, false /*clamp*/);
for (size_t i = 0; i < coords.size(); i++) {
EXPECT_LE(std::abs(coords[i] - expectedZoomOutCoords[i]), kMaxAllowedPixelError);
}
@@ -323,7 +323,8 @@
entry = metadata.find(ANDROID_SCALER_CROP_REGION);
ASSERT_EQ(entry.count, 4U);
for (int i = 0; i < 4; i++) {
- EXPECT_EQ(entry.data.i32[i], testDefaultCropSize[index][i]);
+ EXPECT_LE(std::abs(entry.data.i32[i] - testDefaultCropSize[index][i]),
+ kMaxAllowedPixelError);
}
entry = metadata.find(ANDROID_CONTROL_ZOOM_RATIO);
EXPECT_NEAR(entry.data.f[0], 2.0f, kMaxAllowedRatioError);
@@ -335,7 +336,7 @@
entry = metadata.find(ANDROID_SCALER_CROP_REGION);
ASSERT_EQ(entry.count, 4U);
for (int i = 0; i < 4; i++) {
- EXPECT_EQ(entry.data.i32[i], test2xCropRegion[index][i]);
+ EXPECT_LE(std::abs(entry.data.i32[i] - test2xCropRegion[index][i]), kMaxAllowedPixelError);
}
// Letter boxing crop region, zoomRatio is 1.0
diff --git a/services/mediametrics/TimeMachine.h b/services/mediametrics/TimeMachine.h
index 6861c78..c82778b 100644
--- a/services/mediametrics/TimeMachine.h
+++ b/services/mediametrics/TimeMachine.h
@@ -75,21 +75,30 @@
class KeyHistory {
public:
template <typename T>
- KeyHistory(T key, pid_t pid, uid_t uid, int64_t time)
+ KeyHistory(T key, uid_t allowUid, int64_t time)
: mKey(key)
- , mPid(pid)
- , mUid(uid)
+ , mAllowUid(allowUid)
, mCreationTime(time)
, mLastModificationTime(time)
{
- putValue(BUNDLE_PID, (int32_t)pid, time);
- putValue(BUNDLE_UID, (int32_t)uid, time);
+ // allowUid allows an untrusted client with a matching uid to set properties
+ // in this key.
+ // If allowUid == (uid_t)-1, no untrusted client may set properties in the key.
+ if (allowUid != (uid_t)-1) {
+ // Set ALLOWUID property here; does not change after key creation.
+ putValue(AMEDIAMETRICS_PROP_ALLOWUID, (int32_t)allowUid, time);
+ }
}
KeyHistory(const KeyHistory &other) = default;
+ // Return NO_ERROR only if the passed in uidCheck is -1 or matches
+ // the internal mAllowUid.
+ // An external submit will always have a valid uidCheck parameter.
+ // An internal get request within mediametrics will have a uidCheck == -1 which
+ // we allow to proceed.
status_t checkPermission(uid_t uidCheck) const {
- return uidCheck != (uid_t)-1 && uidCheck != mUid ? PERMISSION_DENIED : NO_ERROR;
+ return uidCheck != (uid_t)-1 && uidCheck != mAllowUid ? PERMISSION_DENIED : NO_ERROR;
}
template <typename T>
@@ -199,8 +208,7 @@
}
const std::string mKey;
- const pid_t mPid __unused;
- const uid_t mUid;
+ const uid_t mAllowUid;
const int64_t mCreationTime __unused;
int64_t mLastModificationTime;
@@ -276,10 +284,13 @@
(void)gc(garbage);
+ // We set the allowUid for client access on key creation.
+ int32_t allowUid = -1;
+ (void)item->get(AMEDIAMETRICS_PROP_ALLOWUID, &allowUid);
// no keylock needed here as we are sole owner
// until placed on mHistory.
keyHistory = std::make_shared<KeyHistory>(
- key, item->getPid(), item->getUid(), time);
+ key, allowUid, time);
mHistory[key] = keyHistory;
} else {
keyHistory = it->second;
diff --git a/services/mediametrics/tests/mediametrics_tests.cpp b/services/mediametrics/tests/mediametrics_tests.cpp
index 78eb71c..cf0dceb 100644
--- a/services/mediametrics/tests/mediametrics_tests.cpp
+++ b/services/mediametrics/tests/mediametrics_tests.cpp
@@ -813,6 +813,42 @@
ASSERT_LT(9, audioAnalytics.dump(1000).second /* lines */);
}
+TEST(mediametrics_tests, audio_analytics_permission2) {
+ constexpr int32_t transactionUid = 1010; // arbitrary
+ auto item = std::make_shared<mediametrics::Item>("audio.1");
+ (*item).set("one", (int32_t)1)
+ .set("two", (int32_t)2)
+ .set(AMEDIAMETRICS_PROP_ALLOWUID, transactionUid)
+ .setTimestamp(10);
+
+ // item2 submitted untrusted
+ auto item2 = std::make_shared<mediametrics::Item>("audio.1");
+ (*item2).set("three", (int32_t)3)
+ .setUid(transactionUid)
+ .setTimestamp(11);
+
+ auto item3 = std::make_shared<mediametrics::Item>("audio.2");
+ (*item3).set("four", (int32_t)4)
+ .setTimestamp(12);
+
+ android::mediametrics::AudioAnalytics audioAnalytics;
+
+ // untrusted entities cannot create a new key.
+ ASSERT_EQ(PERMISSION_DENIED, audioAnalytics.submit(item, false /* isTrusted */));
+ ASSERT_EQ(PERMISSION_DENIED, audioAnalytics.submit(item2, false /* isTrusted */));
+
+ // TODO: Verify contents of AudioAnalytics.
+ // Currently there is no getter API in AudioAnalytics besides dump.
+ ASSERT_EQ(9, audioAnalytics.dump(1000).second /* lines */);
+
+ ASSERT_EQ(NO_ERROR, audioAnalytics.submit(item, true /* isTrusted */));
+ // untrusted entities can add to an existing key
+ ASSERT_EQ(NO_ERROR, audioAnalytics.submit(item2, false /* isTrusted */));
+
+ // Check that we have some info in the dump.
+ ASSERT_LT(9, audioAnalytics.dump(1000).second /* lines */);
+}
+
TEST(mediametrics_tests, audio_analytics_dump) {
auto item = std::make_shared<mediametrics::Item>("audio.1");
(*item).set("one", (int32_t)1)
diff --git a/services/mediaresourcemanager/ResourceManagerService.cpp b/services/mediaresourcemanager/ResourceManagerService.cpp
index be5af00..ff45c87 100644
--- a/services/mediaresourcemanager/ResourceManagerService.cpp
+++ b/services/mediaresourcemanager/ResourceManagerService.cpp
@@ -114,6 +114,7 @@
info.uid = uid;
info.clientId = clientId;
info.client = client;
+ info.pendingRemoval = false;
index = infos.add(clientId, info);
}
@@ -648,6 +649,36 @@
return Status::ok();
}
+Status ResourceManagerService::markClientForPendingRemoval(int32_t pid, int64_t clientId) {
+ String8 log = String8::format(
+ "markClientForPendingRemoval(pid %d, clientId %lld)",
+ pid, (long long) clientId);
+ mServiceLog->add(log);
+
+ Mutex::Autolock lock(mLock);
+ if (!mProcessInfo->isValidPid(pid)) {
+ ALOGE("Rejected markClientForPendingRemoval call with invalid pid.");
+ return Status::fromServiceSpecificError(BAD_VALUE);
+ }
+ ssize_t index = mMap.indexOfKey(pid);
+ if (index < 0) {
+ ALOGV("markClientForPendingRemoval: didn't find pid %d for clientId %lld",
+ pid, (long long)clientId);
+ return Status::ok();
+ }
+ ResourceInfos &infos = mMap.editValueAt(index);
+
+ index = infos.indexOfKey(clientId);
+ if (index < 0) {
+ ALOGV("markClientForPendingRemoval: didn't find clientId %lld", (long long) clientId);
+ return Status::ok();
+ }
+
+ ResourceInfo &info = infos.editValueAt(index);
+ info.pendingRemoval = true;
+ return Status::ok();
+}
+
bool ResourceManagerService::getPriority_l(int pid, int* priority) {
int newPid = pid;
@@ -693,6 +724,12 @@
int lowestPriorityPid;
int lowestPriority;
int callingPriority;
+
+ // Before looking into other processes, check if we have clients marked for
+ // pending removal in the same process.
+ if (getBiggestClient_l(callingPid, type, client, true /* pendingRemovalOnly */)) {
+ return true;
+ }
if (!getPriority_l(callingPid, &callingPriority)) {
ALOGE("getLowestPriorityBiggestClient_l: can't get process priority for pid %d",
callingPid);
@@ -761,7 +798,8 @@
}
bool ResourceManagerService::getBiggestClient_l(
- int pid, MediaResource::Type type, std::shared_ptr<IResourceManagerClient> *client) {
+ int pid, MediaResource::Type type, std::shared_ptr<IResourceManagerClient> *client,
+ bool pendingRemovalOnly) {
ssize_t index = mMap.indexOfKey(pid);
if (index < 0) {
ALOGE("getBiggestClient_l: can't find resource info for pid %d", pid);
@@ -773,6 +811,9 @@
const ResourceInfos &infos = mMap.valueAt(index);
for (size_t i = 0; i < infos.size(); ++i) {
const ResourceList &resources = infos[i].resources;
+ if (pendingRemovalOnly && !infos[i].pendingRemoval) {
+ continue;
+ }
for (auto it = resources.begin(); it != resources.end(); it++) {
const MediaResourceParcel &resource = it->second;
if (resource.type == type) {
diff --git a/services/mediaresourcemanager/ResourceManagerService.h b/services/mediaresourcemanager/ResourceManagerService.h
index 92048c3..49c247e 100644
--- a/services/mediaresourcemanager/ResourceManagerService.h
+++ b/services/mediaresourcemanager/ResourceManagerService.h
@@ -18,6 +18,8 @@
#ifndef ANDROID_MEDIA_RESOURCEMANAGERSERVICE_H
#define ANDROID_MEDIA_RESOURCEMANAGERSERVICE_H
+#include <map>
+
#include <aidl/android/media/BnResourceManagerService.h>
#include <arpa/inet.h>
#include <media/MediaResource.h>
@@ -50,6 +52,7 @@
std::shared_ptr<IResourceManagerClient> client;
sp<DeathNotifier> deathNotifier;
ResourceList resources;
+ bool pendingRemoval{false};
};
// TODO: convert these to std::map
@@ -122,6 +125,8 @@
int originalPid,
int newPid) override;
+ Status markClientForPendingRemoval(int32_t pid, int64_t clientId) override;
+
Status removeResource(int pid, int64_t clientId, bool checkValid);
private:
@@ -146,7 +151,8 @@
// Gets the client who owns biggest piece of specified resource type from pid.
// Returns false if failed. The client will remain unchanged if failed.
bool getBiggestClient_l(int pid, MediaResource::Type type,
- std::shared_ptr<IResourceManagerClient> *client);
+ std::shared_ptr<IResourceManagerClient> *client,
+ bool pendingRemovalOnly = false);
bool isCallingPriorityHigher_l(int callingPid, int pid);
diff --git a/services/mediaresourcemanager/test/ResourceManagerService_test.cpp b/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
index 5d839fa..702935d 100644
--- a/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
+++ b/services/mediaresourcemanager/test/ResourceManagerService_test.cpp
@@ -472,6 +472,56 @@
}
}
+ void testMarkClientForPendingRemoval() {
+ bool result;
+
+ {
+ addResource();
+ mService->mSupportsSecureWithNonSecureCodec = true;
+
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 1));
+
+ // Remove low priority clients
+ mService->removeClient(kTestPid1, getId(mTestClient1));
+
+ // no lower priority client
+ CHECK_STATUS_FALSE(mService->reclaimResource(kTestPid2, resources, &result));
+ verifyClients(false /* c1 */, false /* c2 */, false /* c3 */);
+
+ mService->markClientForPendingRemoval(kTestPid2, getId(mTestClient2));
+
+ // client marked for pending removal from the same process got reclaimed
+ CHECK_STATUS_TRUE(mService->reclaimResource(kTestPid2, resources, &result));
+ verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+
+ // clean up client 3 which still left
+ mService->removeClient(kTestPid2, getId(mTestClient3));
+ }
+
+ {
+ addResource();
+ mService->mSupportsSecureWithNonSecureCodec = true;
+
+ std::vector<MediaResourceParcel> resources;
+ resources.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 1));
+
+ mService->markClientForPendingRemoval(kTestPid2, getId(mTestClient2));
+
+ // client marked for pending removal from the same process got reclaimed
+ // first, even though there are lower priority process
+ CHECK_STATUS_TRUE(mService->reclaimResource(kTestPid2, resources, &result));
+ verifyClients(false /* c1 */, true /* c2 */, false /* c3 */);
+
+ // lower priority client got reclaimed
+ CHECK_STATUS_TRUE(mService->reclaimResource(kTestPid2, resources, &result));
+ verifyClients(true /* c1 */, false /* c2 */, false /* c3 */);
+
+ // clean up client 3 which still left
+ mService->removeClient(kTestPid2, getId(mTestClient3));
+ }
+ }
+
void testRemoveClient() {
addResource();
@@ -900,4 +950,8 @@
testOverridePid();
}
+TEST_F(ResourceManagerServiceTest, markClientForPendingRemoval) {
+ testMarkClientForPendingRemoval();
+}
+
} // namespace android
diff --git a/services/mediatranscoding/MediaTranscodingService.cpp b/services/mediatranscoding/MediaTranscodingService.cpp
index 0289613..a13bec0 100644
--- a/services/mediatranscoding/MediaTranscodingService.cpp
+++ b/services/mediatranscoding/MediaTranscodingService.cpp
@@ -48,7 +48,7 @@
}
}
-// DummyTranscoder and DummyProcessInfo are currently used to instantiate
+// DummyTranscoder and DummyUidPolicy are currently used to instantiate
// MediaTranscodingService on service side for testing, so that we could
// actually test the IPC calls of MediaTranscodingService to expose some
// issues that's observable only over IPC.
@@ -67,21 +67,21 @@
}
};
-class DummyProcessInfo : public ProcessInfoInterface {
- bool isProcessOnTop(int32_t pid) override {
- (void)pid;
+class DummyUidPolicy : public UidPolicyInterface {
+ bool isUidOnTop(uid_t uid) override {
+ (void)uid;
return true;
}
};
MediaTranscodingService::MediaTranscodingService()
: MediaTranscodingService(std::make_shared<DummyTranscoder>(),
- std::make_shared<DummyProcessInfo>()) {}
+ std::make_shared<DummyUidPolicy>()) {}
MediaTranscodingService::MediaTranscodingService(
const std::shared_ptr<TranscoderInterface>& transcoder,
- const std::shared_ptr<ProcessInfoInterface>& procInfo)
- : mJobScheduler(new TranscodingJobScheduler(transcoder, procInfo)),
+ const std::shared_ptr<UidPolicyInterface>& uidPolicy)
+ : mJobScheduler(new TranscodingJobScheduler(transcoder, uidPolicy)),
mClientManager(new TranscodingClientManager(mJobScheduler)) {
ALOGV("MediaTranscodingService is created");
}
diff --git a/services/mediatranscoding/MediaTranscodingService.h b/services/mediatranscoding/MediaTranscodingService.h
index 36db9b3..f7ac336 100644
--- a/services/mediatranscoding/MediaTranscodingService.h
+++ b/services/mediatranscoding/MediaTranscodingService.h
@@ -31,7 +31,7 @@
class TranscodingClientManager;
class TranscodingJobScheduler;
class TranscoderInterface;
-class ProcessInfoInterface;
+class UidPolicyInterface;
class MediaTranscodingService : public BnMediaTranscodingService {
public:
@@ -40,7 +40,7 @@
MediaTranscodingService();
MediaTranscodingService(const std::shared_ptr<TranscoderInterface>& transcoder,
- const std::shared_ptr<ProcessInfoInterface>& procInfo);
+ const std::shared_ptr<UidPolicyInterface>& uidPolicy);
virtual ~MediaTranscodingService();
static void instantiate();
diff --git a/services/oboeservice/AAudioServiceStreamBase.cpp b/services/oboeservice/AAudioServiceStreamBase.cpp
index 044c361..dba9fb9 100644
--- a/services/oboeservice/AAudioServiceStreamBase.cpp
+++ b/services/oboeservice/AAudioServiceStreamBase.cpp
@@ -105,6 +105,7 @@
mediametrics::LogItem(mMetricsId)
.setPid(getOwnerProcessId())
.setUid(getOwnerUserId())
+ .set(AMEDIAMETRICS_PROP_ALLOWUID, (int32_t)getOwnerUserId())
.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_OPEN)
// the following are immutable
.set(AMEDIAMETRICS_PROP_BUFFERCAPACITYFRAMES, (int32_t)getBufferCapacity())