/src/libxaac/encoder/ixheaace_psy_utils_spreading.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 "ixheaac_type_def.h" |
22 | | #include "ixheaac_constants.h" |
23 | | #include "ixheaace_aac_constants.h" |
24 | | |
25 | | #include "ixheaace_psy_utils_spreading.h" |
26 | | |
27 | | VOID ia_enhaacplus_enc_spreading_max(const WORD32 sfb_active, const FLOAT32 *ptr_mask_low_factor, |
28 | | const FLOAT32 *ptr_mask_high_factor, |
29 | 2.46M | FLOAT32 *ptr_spreaded_energy) { |
30 | 2.46M | WORD32 i; |
31 | 2.46M | FLOAT32 temp; |
32 | 2.46M | const FLOAT32 *ptr_mask_low = &ptr_mask_low_factor[sfb_active - 2]; |
33 | 2.46M | const FLOAT32 *ptr_mask_high = &ptr_mask_high_factor[1]; |
34 | 2.46M | FLOAT32 temp_nrg = ptr_spreaded_energy[0]; |
35 | 2.46M | FLOAT32 *ptr_spreaded_temp = ptr_spreaded_energy; |
36 | | |
37 | 54.5M | for (i = sfb_active - 2; i >= 0; i--) { |
38 | 52.0M | FLOAT32 temp_mask = *ptr_mask_high++; |
39 | 52.0M | temp = (temp_mask * temp_nrg); |
40 | 52.0M | temp_nrg = *++ptr_spreaded_temp; |
41 | 52.0M | if (temp_nrg < temp) { |
42 | 15.6M | *ptr_spreaded_temp = temp; |
43 | 15.6M | temp_nrg = temp; |
44 | 15.6M | } |
45 | 52.0M | } |
46 | | |
47 | 2.46M | temp_nrg = ptr_spreaded_energy[sfb_active - 1]; |
48 | | |
49 | 54.5M | for (i = sfb_active - 2; i >= 0; i--) { |
50 | 52.0M | FLOAT32 temp_mask = *ptr_mask_low--; |
51 | 52.0M | temp = (temp_mask * temp_nrg); |
52 | 52.0M | temp_nrg = ptr_spreaded_energy[i]; |
53 | 52.0M | if (temp_nrg < temp) { |
54 | 210k | ptr_spreaded_energy[i] = temp; |
55 | 210k | temp_nrg = temp; |
56 | 210k | } |
57 | 52.0M | } |
58 | 2.46M | } |