mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00
Delete header file rtc_base/memory/aligned_array.h
Move definition of AlignedArray to the only code using it, the test-only LappedTransform class, and delete unused methods. Bug: webrtc:6424, webrtc:9577 Change-Id: I1bb5f57400f7217345b7ec7376235ad4c4bae858 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168701 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30576}
This commit is contained in:
parent
9a4eb32477
commit
dbf5416a80
6 changed files with 45 additions and 153 deletions
|
@ -51,7 +51,6 @@ rtc_library("common_audio") {
|
||||||
"../rtc_base:gtest_prod",
|
"../rtc_base:gtest_prod",
|
||||||
"../rtc_base:rtc_base_approved",
|
"../rtc_base:rtc_base_approved",
|
||||||
"../rtc_base:sanitizer",
|
"../rtc_base:sanitizer",
|
||||||
"../rtc_base/memory:aligned_array",
|
|
||||||
"../rtc_base/memory:aligned_malloc",
|
"../rtc_base/memory:aligned_malloc",
|
||||||
"../rtc_base/system:arch",
|
"../rtc_base/system:arch",
|
||||||
"../rtc_base/system:file_wrapper",
|
"../rtc_base/system:file_wrapper",
|
||||||
|
|
|
@ -30,7 +30,7 @@ if (rtc_include_tests) {
|
||||||
"../../../../../common_audio",
|
"../../../../../common_audio",
|
||||||
"../../../../../common_audio:common_audio_c",
|
"../../../../../common_audio:common_audio_c",
|
||||||
"../../../../../rtc_base:checks",
|
"../../../../../rtc_base:checks",
|
||||||
"../../../../../rtc_base/memory:aligned_array",
|
"../../../../../rtc_base/memory:aligned_malloc",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,53 @@
|
||||||
|
|
||||||
#include "common_audio/real_fourier.h"
|
#include "common_audio/real_fourier.h"
|
||||||
#include "modules/audio_coding/codecs/opus/test/blocker.h"
|
#include "modules/audio_coding/codecs/opus/test/blocker.h"
|
||||||
#include "rtc_base/memory/aligned_array.h"
|
#include "rtc_base/memory/aligned_malloc.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
// Wrapper class for aligned arrays. Every row (and the first dimension) are
|
||||||
|
// aligned to the given byte alignment.
|
||||||
|
template <typename T>
|
||||||
|
class AlignedArray {
|
||||||
|
public:
|
||||||
|
AlignedArray(size_t rows, size_t cols, size_t alignment)
|
||||||
|
: rows_(rows), cols_(cols) {
|
||||||
|
RTC_CHECK_GT(alignment, 0);
|
||||||
|
head_row_ =
|
||||||
|
static_cast<T**>(AlignedMalloc(rows_ * sizeof(*head_row_), alignment));
|
||||||
|
for (size_t i = 0; i < rows_; ++i) {
|
||||||
|
head_row_[i] = static_cast<T*>(
|
||||||
|
AlignedMalloc(cols_ * sizeof(**head_row_), alignment));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~AlignedArray() {
|
||||||
|
for (size_t i = 0; i < rows_; ++i) {
|
||||||
|
AlignedFree(head_row_[i]);
|
||||||
|
}
|
||||||
|
AlignedFree(head_row_);
|
||||||
|
}
|
||||||
|
|
||||||
|
T* const* Array() { return head_row_; }
|
||||||
|
|
||||||
|
const T* const* Array() const { return head_row_; }
|
||||||
|
|
||||||
|
T* Row(size_t row) {
|
||||||
|
RTC_CHECK_LE(row, rows_);
|
||||||
|
return head_row_[row];
|
||||||
|
}
|
||||||
|
|
||||||
|
const T* Row(size_t row) const {
|
||||||
|
RTC_CHECK_LE(row, rows_);
|
||||||
|
return head_row_[row];
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t rows_;
|
||||||
|
size_t cols_;
|
||||||
|
T** head_row_;
|
||||||
|
};
|
||||||
|
|
||||||
// Helper class for audio processing modules which operate on frequency domain
|
// Helper class for audio processing modules which operate on frequency domain
|
||||||
// input derived from the windowed time domain audio stream.
|
// input derived from the windowed time domain audio stream.
|
||||||
//
|
//
|
||||||
|
|
|
@ -12,14 +12,6 @@ if (is_android) {
|
||||||
import("//build/config/android/rules.gni")
|
import("//build/config/android/rules.gni")
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_source_set("aligned_array") {
|
|
||||||
sources = [ "aligned_array.h" ]
|
|
||||||
deps = [
|
|
||||||
":aligned_malloc",
|
|
||||||
"..:checks",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_library("aligned_malloc") {
|
rtc_library("aligned_malloc") {
|
||||||
sources = [
|
sources = [
|
||||||
"aligned_malloc.cc",
|
"aligned_malloc.cc",
|
||||||
|
@ -45,12 +37,10 @@ rtc_library("fifo_buffer") {
|
||||||
rtc_library("unittests") {
|
rtc_library("unittests") {
|
||||||
testonly = true
|
testonly = true
|
||||||
sources = [
|
sources = [
|
||||||
"aligned_array_unittest.cc",
|
|
||||||
"aligned_malloc_unittest.cc",
|
"aligned_malloc_unittest.cc",
|
||||||
"fifo_buffer_unittest.cc",
|
"fifo_buffer_unittest.cc",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":aligned_array",
|
|
||||||
":aligned_malloc",
|
":aligned_malloc",
|
||||||
":fifo_buffer",
|
":fifo_buffer",
|
||||||
"../../test:test_support",
|
"../../test:test_support",
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef RTC_BASE_MEMORY_ALIGNED_ARRAY_H_
|
|
||||||
#define RTC_BASE_MEMORY_ALIGNED_ARRAY_H_
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include "rtc_base/checks.h"
|
|
||||||
#include "rtc_base/memory/aligned_malloc.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
// Wrapper class for aligned arrays. Every row (and the first dimension) are
|
|
||||||
// aligned to the given byte alignment.
|
|
||||||
template <typename T>
|
|
||||||
class AlignedArray {
|
|
||||||
public:
|
|
||||||
AlignedArray(size_t rows, size_t cols, size_t alignment)
|
|
||||||
: rows_(rows), cols_(cols) {
|
|
||||||
RTC_CHECK_GT(alignment, 0);
|
|
||||||
head_row_ =
|
|
||||||
static_cast<T**>(AlignedMalloc(rows_ * sizeof(*head_row_), alignment));
|
|
||||||
for (size_t i = 0; i < rows_; ++i) {
|
|
||||||
head_row_[i] = static_cast<T*>(
|
|
||||||
AlignedMalloc(cols_ * sizeof(**head_row_), alignment));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~AlignedArray() {
|
|
||||||
for (size_t i = 0; i < rows_; ++i) {
|
|
||||||
AlignedFree(head_row_[i]);
|
|
||||||
}
|
|
||||||
AlignedFree(head_row_);
|
|
||||||
}
|
|
||||||
|
|
||||||
T* const* Array() { return head_row_; }
|
|
||||||
|
|
||||||
const T* const* Array() const { return head_row_; }
|
|
||||||
|
|
||||||
T* Row(size_t row) {
|
|
||||||
RTC_CHECK_LE(row, rows_);
|
|
||||||
return head_row_[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
const T* Row(size_t row) const {
|
|
||||||
RTC_CHECK_LE(row, rows_);
|
|
||||||
return head_row_[row];
|
|
||||||
}
|
|
||||||
|
|
||||||
T& At(size_t row, size_t col) {
|
|
||||||
RTC_CHECK_LE(col, cols_);
|
|
||||||
return Row(row)[col];
|
|
||||||
}
|
|
||||||
|
|
||||||
const T& At(size_t row, size_t col) const {
|
|
||||||
RTC_CHECK_LE(col, cols_);
|
|
||||||
return Row(row)[col];
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t rows() const { return rows_; }
|
|
||||||
|
|
||||||
size_t cols() const { return cols_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
size_t rows_;
|
|
||||||
size_t cols_;
|
|
||||||
T** head_row_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // RTC_BASE_MEMORY_ALIGNED_ARRAY_H_
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "rtc_base/memory/aligned_array.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "test/gtest.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
bool IsAligned(const void* ptr, size_t alignment) {
|
|
||||||
return reinterpret_cast<uintptr_t>(ptr) % alignment == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
TEST(AlignedArrayTest, CheckAlignment) {
|
|
||||||
AlignedArray<bool> arr(10, 7, 128);
|
|
||||||
ASSERT_TRUE(IsAligned(arr.Array(), 128));
|
|
||||||
for (size_t i = 0; i < 10; ++i) {
|
|
||||||
ASSERT_TRUE(IsAligned(arr.Row(i), 128));
|
|
||||||
ASSERT_EQ(arr.Row(i), arr.Array()[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(AlignedArrayTest, CheckOverlap) {
|
|
||||||
AlignedArray<size_t> arr(10, 7, 128);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 10; ++i) {
|
|
||||||
for (size_t j = 0; j < 7; ++j) {
|
|
||||||
arr.At(i, j) = 20 * i + j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 10; ++i) {
|
|
||||||
for (size_t j = 0; j < 7; ++j) {
|
|
||||||
ASSERT_EQ(arr.At(i, j), 20 * i + j);
|
|
||||||
ASSERT_EQ(arr.Row(i)[j], 20 * i + j);
|
|
||||||
ASSERT_EQ(arr.Array()[i][j], 20 * i + j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(AlignedArrayTest, CheckRowsCols) {
|
|
||||||
AlignedArray<bool> arr(10, 7, 128);
|
|
||||||
ASSERT_EQ(arr.rows(), 10u);
|
|
||||||
ASSERT_EQ(arr.cols(), 7u);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
Loading…
Reference in a new issue