/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
staticdouble dct_matrix(double n, double k, int size) { return cos(PI * (2 * n + 1) * k / (2 * size));
}
void reference_dct_1d(constdouble *in, double *out, int size) { for (int k = 0; k < size; ++k) {
out[k] = 0; for (int n = 0; n < size; ++n) {
out[k] += in[n] * dct_matrix(n, k, size);
} if (k == 0) out[k] = out[k] * invSqrt2;
}
}
void reference_idct_1d(constdouble *in, double *out, int size) { for (int k = 0; k < size; ++k) {
out[k] = 0; for (int n = 0; n < size; ++n) { if (n == 0)
out[k] += invSqrt2 * in[n] * dct_matrix(k, n, size); else
out[k] += in[n] * dct_matrix(k, n, size);
}
}
}
// TODO(any): Copied from the old 'fadst4' (same as the new 'av1_fadst4' // function). Should be replaced by a proper reference function that takes // 'double' input & output. staticvoid fadst4_new(const tran_low_t *input, tran_low_t *output) {
tran_high_t x0, x1, x2, x3;
tran_high_t s0, s1, s2, s3, s4, s5, s6, s7;
// For rectangular transforms, we need to multiply by an extra factor. constint rect_type = get_rect_tx_log_ratio(tx_width, tx_height); if (abs(rect_type) == 1) {
amplify_factor *= pow(2, 0.5);
} return amplify_factor;
}
void reference_hybrid_2d(double *in, double *out, TX_TYPE tx_type,
TX_SIZE tx_size) { // Get transform type and size of each dimension.
TYPE_TXFM type0;
TYPE_TXFM type1;
get_txfm1d_type(tx_type, &type0, &type1); constint tx_width = tx_size_wide[tx_size]; constint tx_height = tx_size_high[tx_size];
std::unique_ptr<double[]> temp_in( new (std::nothrow) double[AOMMAX(tx_width, tx_height)]);
std::unique_ptr<double[]> temp_out( new (std::nothrow) double[AOMMAX(tx_width, tx_height)]);
std::unique_ptr<double[]> out_interm( new (std::nothrow) double[tx_width * tx_height]);
ASSERT_NE(temp_in, nullptr);
ASSERT_NE(temp_out, nullptr);
ASSERT_NE(out_interm, nullptr);
// Transform columns. for (int c = 0; c < tx_width; ++c) { for (int r = 0; r < tx_height; ++r) {
temp_in[r] = in[r * tx_width + c];
}
reference_hybrid_1d(temp_in.get(), temp_out.get(), tx_height, type0); for (int r = 0; r < tx_height; ++r) {
out_interm[r * tx_width + c] = temp_out[r];
}
}
// Transform rows. for (int r = 0; r < tx_height; ++r) {
reference_hybrid_1d(out_interm.get() + r * tx_width, temp_out.get(),
tx_width, type1); for (int c = 0; c < tx_width; ++c) {
out[c * tx_height + r] = temp_out[c];
}
}
// These transforms use an approximate 2D DCT transform, by only keeping the // top-left quarter of the coefficients, and repacking them in the first // quarter indices. // TODO(urvang): Refactor this code. if (tx_width == 64 && tx_height == 64) { // tx_size == TX_64X64 // Zero out top-right 32x32 area. for (int col = 0; col < 32; ++col) {
memset(out + col * 64 + 32, 0, 32 * sizeof(*out));
} // Zero out the bottom 64x32 area.
memset(out + 32 * 64, 0, 32 * 64 * sizeof(*out)); // Re-pack non-zero coeffs in the first 32x32 indices. for (int col = 1; col < 32; ++col) {
memcpy(out + col * 32, out + col * 64, 32 * sizeof(*out));
}
} elseif (tx_width == 32 && tx_height == 64) { // tx_size == TX_32X64 // Zero out right 32x32 area. for (int col = 0; col < 32; ++col) {
memset(out + col * 64 + 32, 0, 32 * sizeof(*out));
} // Re-pack non-zero coeffs in the first 32x32 indices. for (int col = 1; col < 32; ++col) {
memcpy(out + col * 32, out + col * 64, 32 * sizeof(*out));
}
} elseif (tx_width == 64 && tx_height == 32) { // tx_size == TX_64X32 // Zero out the bottom 32x32 area.
memset(out + 32 * 32, 0, 32 * 32 * sizeof(*out)); // Note: no repacking needed here.
} elseif (tx_width == 16 && tx_height == 64) { // tx_size == TX_16X64 // Note: no repacking needed here. // Zero out right 32x16 area. for (int col = 0; col < 16; ++col) {
memset(out + col * 64 + 32, 0, 32 * sizeof(*out));
} // Re-pack non-zero coeffs in the first 32x16 indices. for (int col = 1; col < 16; ++col) {
memcpy(out + col * 32, out + col * 64, 32 * sizeof(*out));
}
} elseif (tx_width == 64 && tx_height == 16) { // tx_size == TX_64X16 // Zero out the bottom 16x32 area.
memset(out + 16 * 32, 0, 16 * 32 * sizeof(*out));
}
// Apply appropriate scale. constdouble amplify_factor = get_amplification_factor(tx_type, tx_size); for (int c = 0; c < tx_width; ++c) { for (int r = 0; r < tx_height; ++r) {
out[c * tx_height + r] *= amplify_factor;
}
}
}
template <typename Type> void fliplr(Type *dest, int width, int height, int stride) { for (int r = 0; r < height; ++r) { for (int c = 0; c < width / 2; ++c) { const Type tmp = dest[r * stride + c];
dest[r * stride + c] = dest[r * stride + width - 1 - c];
dest[r * stride + width - 1 - c] = tmp;
}
}
}
template <typename Type> void flipud(Type *dest, int width, int height, int stride) { for (int c = 0; c < width; ++c) { for (int r = 0; r < height / 2; ++r) { const Type tmp = dest[r * stride + c];
dest[r * stride + c] = dest[(height - 1 - r) * stride + c];
dest[(height - 1 - r) * stride + c] = tmp;
}
}
}
template <typename Type> void fliplrud(Type *dest, int width, int height, int stride) { for (int r = 0; r < height / 2; ++r) { for (int c = 0; c < width; ++c) { const Type tmp = dest[r * stride + c];
dest[r * stride + c] = dest[(height - 1 - r) * stride + width - 1 - c];
dest[(height - 1 - r) * stride + width - 1 - c] = tmp;
}
}
}
templatevoid fliplr<double>(double *dest, int width, int height, int stride); templatevoid flipud<double>(double *dest, int width, int height, int stride); templatevoid fliplrud<double>(double *dest, int width, int height, int stride);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.