1 /****************************************************************************** 2 * * 3 * Copyright (C) 2024 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 #pragma once 22 23 #define IXHEAACE_LOUDNESS_NUM_TAPS (3) 24 #define IXHEAACE_LOUDNESS_PRE_FLT (0) 25 #define IXHEAACE_LOUDNESS_RLB_FLT (1) 26 #define IXHEAACE_LOUDNESS_DONT_PASS (-1) 27 #define IXHEAACE_ABS_GATE (-70) 28 #define IXHEAACE_MOMENTARY_LOUDNESS_OVERLAP (3) 29 #define IXHEAACE_SL_OVERLAP (20) 30 #define BYTE_ALIGN_8 (8) 31 #define MAX(a, b) ((a) > (b) ? (a) : (b)) 32 #define IXHEAACE_DEFAULT_SHORT_TERM_LOUDENSS (-1000) 33 #define IXHEAACE_DEFAULT_MOMENTARY_LOUDENSS (-1000) 34 #define IXHEAACE_SEC_TO_100MS_FACTOR (60 * 10) 35 #define IXHEAACE_SUM_SQUARE_EPS (1/32768.0f * 1/32768.0f) 36 37 typedef struct { 38 BOOL passes_abs_gate; 39 FLOAT64 short_term_loudness; 40 FLOAT64 int_val; 41 } short_term_frame_t; 42 43 typedef struct { 44 BOOL passes_abs_gate; 45 FLOAT64 momentary_loudness; 46 FLOAT64 int_val; 47 } momentary_frame_t; 48 typedef struct { 49 UWORD32 num_samples_per_ch; 50 UWORD32 n_channels; 51 UWORD32 length; 52 UWORD32 sample_rate; 53 UWORD32 pcm_sz; 54 FLOAT64 sum_square; 55 FLOAT64 prev_four_sum_square[4]; 56 FLOAT64 w[2][2][4]; 57 UWORD32 count_fn_call_mmstl; 58 UWORD32 mom_loudness_first_time_flag; 59 FLOAT64 average_loudness_val; 60 FLOAT64 prev_thirty_sum_square[30]; 61 WORD32 sl_first_time_flag; 62 WORD32 local_sl_count; 63 UWORD32 short_term_loudness_overlap; 64 short_term_frame_t stf_instances[100]; 65 UWORD32 no_of_stf; 66 UWORD32 curr_stf_no; 67 UWORD32 loop_curr_stf_no; 68 UWORD32 no_of_stf_passing_abs_gate; 69 FLOAT64 tot_int_val_stf_passing_abs_gate; 70 FLOAT64 temp_stf_instances_loudness[100]; 71 BOOL get_LRA; 72 UWORD32 max_lra_count; 73 UWORD32 no_of_mf; 74 75 UWORD32 no_of_mf_passing_abs_gate; 76 FLOAT64 tot_int_val_mf_passing_abs_gate; 77 UWORD32 no_of_mf_passing_rel_gate; 78 FLOAT64 tot_int_val_mf_passing_rel_gate; 79 FLOAT64 rel_gate; 80 UWORD32 ml_count_fn_call; 81 UWORD32 loop_ml_count_fn_call; 82 momentary_frame_t mf_instances[1000]; 83 WORD32 get_intergrated_loudness; 84 UWORD32 max_il_buf_size; 85 FLOAT64 max_sample_val; 86 WORD32 sample_rate_idx; 87 } ixheaace_loudness_struct; 88 89 IA_ERRORCODE ixheaace_loudness_init_params(pVOID loudness_handle, 90 ixheaace_input_config *pstr_input_config, 91 ixheaace_output_config *pstr_output_config); 92 93 FLOAT64 ixheaace_measure_loudness(pVOID loudness_handle, WORD16 **samples); 94 95 FLOAT64 ixheaace_measure_integrated_loudness(pVOID loudness_handle); 96 97 WORD32 ixheaace_loudness_info_get_handle_size(); 98 99 FLOAT32 ixheaace_measure_sample_peak_value(pVOID loudness_handle);