/src/libxaac/encoder/ixheaace_mps_vector_functions.c
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * * |
3 | | * Copyright (C) 2023 The Android Open Source Project |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at: |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | * |
17 | | ***************************************************************************** |
18 | | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
19 | | */ |
20 | | |
21 | | #include <math.h> |
22 | | #include "ixheaac_type_def.h" |
23 | | #include "ixheaace_mps_common_fix.h" |
24 | | #include "ixheaace_mps_defines.h" |
25 | | #include "ixheaace_mps_common_define.h" |
26 | | |
27 | | FLOAT32 |
28 | | ixheaace_mps_212_sum_up_cplx_pow_2_dim_2(ixheaace_cmplx_str inp[MAX_ANA_TIME_SLOT][MAX_QMF_BANDS], |
29 | | const WORD32 start_dim_1, const WORD32 stop_dim_1, |
30 | 10.8M | const WORD32 start_dim_2, const WORD32 stop_dim_2) { |
31 | 10.8M | WORD32 idx_1, idx_2; |
32 | | |
33 | 10.8M | FLOAT32 sum; |
34 | 10.8M | sum = 0.0f; |
35 | 741M | for (idx_1 = start_dim_1; idx_1 < stop_dim_1; idx_1++) { |
36 | 1.46G | for (idx_2 = start_dim_2; idx_2 < stop_dim_2; idx_2++) { |
37 | 730M | sum += inp[idx_1][idx_2].re * inp[idx_1][idx_2].re; |
38 | 730M | sum += inp[idx_1][idx_2].im * inp[idx_1][idx_2].im; |
39 | 730M | } |
40 | 730M | } |
41 | 10.8M | return (sum / 2); |
42 | 10.8M | } |
43 | | |
44 | | VOID ixheaace_mps_212_cplx_scalar_product( |
45 | | ixheaace_cmplx_str *const out, ixheaace_cmplx_str inp_1[MAX_ANA_TIME_SLOT][MAX_QMF_BANDS], |
46 | | ixheaace_cmplx_str inp_2[MAX_ANA_TIME_SLOT][MAX_QMF_BANDS], const WORD32 start_dim_1, |
47 | 5.44M | const WORD32 stop_dim_1, const WORD32 start_dim_2, const WORD32 stop_dim_2) { |
48 | 5.44M | WORD32 idx_1, idx_2; |
49 | 5.44M | FLOAT32 re_x, re_y, im_x, im_y, re, im; |
50 | 5.44M | re = 0.0f; |
51 | 5.44M | im = 0.0f; |
52 | | |
53 | 370M | for (idx_1 = start_dim_1; idx_1 < stop_dim_1; idx_1++) { |
54 | 730M | for (idx_2 = start_dim_2; idx_2 < stop_dim_2; idx_2++) { |
55 | 365M | re_x = inp_1[idx_1][idx_2].re; |
56 | 365M | im_x = inp_1[idx_1][idx_2].im; |
57 | 365M | re_y = inp_2[idx_1][idx_2].re; |
58 | 365M | im_y = inp_2[idx_1][idx_2].im; |
59 | 365M | re += (re_x * re_y) + (im_x * im_y); |
60 | 365M | im += (im_x * re_y) - (re_x * im_y); |
61 | 365M | } |
62 | 365M | } |
63 | | |
64 | 5.44M | out->re = re / 2; |
65 | 5.44M | out->im = im / 2; |
66 | 5.44M | } |
67 | | |
68 | | FLOAT32 ixheaace_mps_212_sum_up_cplx_pow_2(const ixheaace_cmplx_str *const inp, |
69 | 6.41M | const WORD32 len) { |
70 | 6.41M | WORD32 idx; |
71 | 6.41M | FLOAT32 sum; |
72 | 6.41M | sum = 0.0f; |
73 | | |
74 | 380M | for (idx = 0; idx < len; idx++) { |
75 | 374M | sum += inp[idx].re * inp[idx].re; |
76 | 374M | sum += inp[idx].im * inp[idx].im; |
77 | 374M | } |
78 | | |
79 | 6.41M | return (sum / 2); |
80 | 6.41M | } |