/src/libxaac/encoder/ixheaace_resampler_init.c
Line | Count | Source (jump to first uncovered line) |
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 | | #include <string.h> |
21 | | #include "ixheaac_type_def.h" |
22 | | #include "ixheaac_constants.h" |
23 | | #include "ixheaace_aac_constants.h" |
24 | | #include "ixheaace_sbr_def.h" |
25 | | #include "ixheaace_resampler.h" |
26 | | #include "ixheaace_sbr_rom.h" |
27 | | #include "ixheaace_error_codes.h" |
28 | | #include "ixheaac_error_standards.h" |
29 | | |
30 | | IA_ERRORCODE ia_enhaacplus_enc_init_iir_resampler(ixheaace_iir21_resampler *pstr_resampler, |
31 | | WORD32 ratio, |
32 | | ixheaace_resampler_table *pstr_resampler_table) |
33 | | |
34 | 16.1k | { |
35 | 16.1k | struct ixheaace_iir_params const *current_set = NULL; |
36 | 16.1k | IA_ERRORCODE error = IA_NO_ERROR; |
37 | | |
38 | 16.1k | if (pstr_resampler == NULL) { |
39 | 0 | return IA_EXHEAACE_INIT_FATAL_RESAMPLER_INIT_FAILED; |
40 | 0 | } |
41 | | |
42 | 16.1k | memset(pstr_resampler->iir_filter.ring_buf_1, 0, |
43 | 16.1k | (LEN_RING_BUF * sizeof(pstr_resampler->iir_filter.ring_buf_1[0]))); |
44 | 16.1k | memset(pstr_resampler->iir_filter.ring_buf_2, 0, |
45 | 16.1k | (LEN_RING_BUF * sizeof(pstr_resampler->iir_filter.ring_buf_2[0]))); |
46 | | |
47 | 16.1k | current_set = &(pstr_resampler_table->iir_param_set); |
48 | | |
49 | 16.1k | pstr_resampler->iir_filter.ptr_coeff_iir_den = current_set->coeff_iir_den; |
50 | 16.1k | pstr_resampler->iir_filter.ptr_coeff_iir_num = current_set->coeff_iir_num; |
51 | 16.1k | pstr_resampler->iir_filter.max = current_set->max; |
52 | 16.1k | pstr_resampler->delay = current_set->delay; |
53 | 16.1k | pstr_resampler->ratio = ratio; |
54 | 16.1k | pstr_resampler->pending = ratio - 1; |
55 | | |
56 | 16.1k | return error; |
57 | 16.1k | } |
58 | | IA_ERRORCODE |
59 | | ia_enhaacplus_enc_init_iir_sos_resampler(ixheaace_iir_sos_resampler *pstr_resampler, WORD32 ratio, |
60 | | ixheaace_resampler_sos_table *pstr_resampler_table) |
61 | | |
62 | 1.80k | { |
63 | 1.80k | struct ixheaace_iir_params_sos const *current_set = NULL; |
64 | 1.80k | IA_ERRORCODE error = IA_NO_ERROR; |
65 | | |
66 | 1.80k | if (pstr_resampler == NULL) { |
67 | 0 | error = IA_EXHEAACE_INIT_FATAL_USAC_RESAMPLER_INIT_FAILED; |
68 | 0 | return error; |
69 | 0 | } |
70 | | |
71 | 1.80k | memset(pstr_resampler->iir_filter.ring_buf_sos_1, 0, |
72 | 1.80k | (LEN_RING_BUF_SOS_1 * sizeof(pstr_resampler->iir_filter.ring_buf_sos_1[0]))); |
73 | 1.80k | memset(pstr_resampler->iir_filter.ring_buf_sos_2, 0, |
74 | 1.80k | (LEN_RING_BUF_SOS_2 * sizeof(pstr_resampler->iir_filter.ring_buf_sos_2[0]))); |
75 | | |
76 | 1.80k | current_set = &(pstr_resampler_table->iir_param_set_sos); |
77 | | |
78 | 1.80k | pstr_resampler->iir_filter.ptr_coeff_iir_den = ¤t_set->coeff_iir_sos_den[0][0]; |
79 | 1.80k | pstr_resampler->iir_filter.ptr_coeff_iir_num = ¤t_set->coeff_iir_sos_num[0][0]; |
80 | 1.80k | pstr_resampler->ratio = ratio; |
81 | 1.80k | pstr_resampler->pending = ratio - 1; |
82 | 1.80k | pstr_resampler->iir_filter.gain_sos = current_set->gain_sos; |
83 | 1.80k | pstr_resampler->delay = current_set->delay; |
84 | | |
85 | 1.80k | return error; |
86 | 1.80k | } |