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
ia_enhaacplus_enc_spreading_max(const WORD32 sfb_active,const FLOAT32 * ptr_mask_low_factor,const FLOAT32 * ptr_mask_high_factor,FLOAT32 * ptr_spreaded_energy)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 FLOAT32 *ptr_spreaded_energy) {
30 WORD32 i;
31 FLOAT32 temp;
32 const FLOAT32 *ptr_mask_low = &ptr_mask_low_factor[sfb_active - 2];
33 const FLOAT32 *ptr_mask_high = &ptr_mask_high_factor[1];
34 FLOAT32 temp_nrg = ptr_spreaded_energy[0];
35 FLOAT32 *ptr_spreaded_temp = ptr_spreaded_energy;
36
37 for (i = sfb_active - 2; i >= 0; i--) {
38 FLOAT32 temp_mask = *ptr_mask_high++;
39 temp = (temp_mask * temp_nrg);
40 temp_nrg = *++ptr_spreaded_temp;
41 if (temp_nrg < temp) {
42 *ptr_spreaded_temp = temp;
43 temp_nrg = temp;
44 }
45 }
46
47 temp_nrg = ptr_spreaded_energy[sfb_active - 1];
48
49 for (i = sfb_active - 2; i >= 0; i--) {
50 FLOAT32 temp_mask = *ptr_mask_low--;
51 temp = (temp_mask * temp_nrg);
52 temp_nrg = ptr_spreaded_energy[i];
53 if (temp_nrg < temp) {
54 ptr_spreaded_energy[i] = temp;
55 temp_nrg = temp;
56 }
57 }
58 }
59