32-bit floating point samples, adjustable bandwidth
Some checks failed
CMake / build (push) Has been cancelled

This commit is contained in:
wrapper 2025-08-04 20:52:12 +07:00
parent 433d6c3eb6
commit 17b657d7c3
3 changed files with 23 additions and 11 deletions

View file

@ -831,7 +831,7 @@ static IA_ERRORCODE ixheaace_set_config_params(ixheaace_api_struct *pstr_api_str
return err_code;
}
if (pstr_input_config->ui_pcm_wd_sz != 16) {
if (pstr_input_config->ui_pcm_wd_sz != 16 && pstr_input_config->ui_pcm_wd_sz != 32) {
return (IA_EXHEAACE_CONFIG_FATAL_PCM_WDSZ);
}
if ((pstr_input_config->aac_config.inv_quant != 0) &&
@ -1213,6 +1213,8 @@ static IA_ERRORCODE ixheaace_set_config_params(ixheaace_api_struct *pstr_api_str
}
pstr_api_struct->config[0].aac_config.full_bandwidth =
pstr_input_config->aac_config.full_bandwidth;
pstr_api_struct->config[0].aac_config.band_width =
pstr_input_config->aac_config.bandwidth;
}
return IA_NO_ERROR;
@ -2692,6 +2694,7 @@ static IA_ERRORCODE ia_enhaacplus_enc_execute(ixheaace_api_struct *pstr_api_stru
iexheaac_encoder_str **pstr_aac_enc;
iaace_config *pstr_aac_config;
pWORD16 pw_inp_buf = NULL;
pFLOAT32 pw_inp_buf_float = NULL;
pUWORD8 pub_out_buf = NULL;
FLOAT32 *ptr_input_buffer = NULL;
FLOAT32 *ptr_input_buffer_mps = NULL;
@ -2729,6 +2732,8 @@ static IA_ERRORCODE ia_enhaacplus_enc_execute(ixheaace_api_struct *pstr_api_stru
pstr_aac_enc = pstr_api_struct->pstr_state->aac_enc_pers_mem;
pw_inp_buf = (pWORD16)pstr_api_struct->pp_mem[IA_ENHAACPLUSENC_INPUT_IDX];
pw_inp_buf_float = (pFLOAT32)pstr_api_struct->pp_mem[IA_ENHAACPLUSENC_INPUT_IDX];
if (ele_idx == 0) {
pstr_api_struct->pstr_state->i_out_bytes = 0;
pub_out_buf = ((pUWORD8)pstr_api_struct->pp_mem[IA_ENHAACPLUSENC_OUTPUT_IDX]);
@ -2851,25 +2856,25 @@ static IA_ERRORCODE ia_enhaacplus_enc_execute(ixheaace_api_struct *pstr_api_stru
(!((pstr_api_struct->pstr_mps_212_enc != NULL) &&
pstr_api_struct->pstr_state->mps_enable))) {
for (idx = 0; idx < (num_samples_read); idx++) {
ptr_input_buffer[write_off_set + idx] = (FLOAT32)pw_inp_buf[idx];
ptr_input_buffer[write_off_set + idx] = pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[idx] : (pw_inp_buf_float[idx] * 32767);
}
} else if (pstr_api_struct->config[ele_idx].i_channels == 1) {
for (idx = 0; idx < num_samples_read; idx++) {
ptr_input_buffer[write_off_set + (IXHEAACE_MAX_CH_IN_BS_ELE * idx)] =
(FLOAT32)pw_inp_buf[idx];
pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[idx] : (pw_inp_buf_float[idx] * 32767);
}
} else if ((pstr_api_struct->pstr_mps_212_enc != NULL) &&
pstr_api_struct->pstr_state->mps_enable) {
ptr_input_buffer_mps = pstr_api_struct->pstr_state->time_signal_mps;
for (idx = 0; idx < (num_samples_read / 2); idx++) {
ptr_input_buffer_mps[idx] = (FLOAT32)pw_inp_buf[2 * idx];
ptr_input_buffer_mps[idx] = pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[2 * idx] : (pw_inp_buf_float[2 * idx] * 32767);
ptr_input_buffer_mps[(num_samples_read / 2) + idx] =
(FLOAT32)pw_inp_buf[(2 * idx) + 1];
pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[(2 * idx) + 1] : (pw_inp_buf_float[(2 * idx) + 1] * 32767);
}
}
} else {
for (idx = 0; idx < (num_samples_read + write_off_set); idx++) {
ptr_input_buffer[idx] = (FLOAT32)pw_inp_buf[idx];
ptr_input_buffer[idx] = pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[idx] : (pw_inp_buf_float[idx] * 32767);
}
}
} else {
@ -2877,9 +2882,9 @@ static IA_ERRORCODE ia_enhaacplus_enc_execute(ixheaace_api_struct *pstr_api_stru
slot = pstr_api_struct->config[ele_idx].element_slot;
for (idx = 0; idx < num_samples_read / 2; idx++) {
ptr_input_buffer[2 * idx + write_off_set] =
(FLOAT32)pw_inp_buf[total_channels * idx + slot];
pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[total_channels * idx + slot] : (pw_inp_buf_float[total_channels * idx + slot] * 32767);
ptr_input_buffer[2 * idx + write_off_set + 1] =
(FLOAT32)pw_inp_buf[total_channels * idx + slot + 1];
pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[total_channels * idx + slot + 1] : (pw_inp_buf_float[total_channels * idx + slot + 1] * 32767);
}
}
@ -2887,14 +2892,14 @@ static IA_ERRORCODE ia_enhaacplus_enc_execute(ixheaace_api_struct *pstr_api_stru
slot = pstr_api_struct->config[ele_idx].element_slot;
for (idx = 0; idx < num_samples_read; idx++) {
ptr_input_buffer[write_off_set + (IXHEAACE_MAX_CH_IN_BS_ELE * idx)] =
(FLOAT32)pw_inp_buf[total_channels * idx + slot];
pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[total_channels * idx + slot] : (pw_inp_buf_float[total_channels * idx + slot] * 32767);
}
}
if (pstr_api_struct->config[ele_idx].i_channels == 6) {
ptr_input_buffer_mps = pstr_api_struct->pstr_state->time_signal_mps;
for (idx = 0; idx < num_samples_read; idx++) {
ptr_input_buffer_mps[idx] = (FLOAT32)pw_inp_buf[idx];
ptr_input_buffer_mps[idx] = pstr_api_struct->config->ui_pcm_wd_sz == 16 ? (FLOAT32)pw_inp_buf[idx] : (pw_inp_buf_float[idx] * 32767);
}
}
}

View file

@ -310,7 +310,7 @@ WORD32 ia_enhaacplus_enc_write_ADTS_header(pUWORD8 buffer, WORD32 bytes_used, WO
if (write_flag) {
/* Fixed ADTS header */
ia_enhaacplus_enc_putbit(pstr_bitstream, 0xFFFF, 12); /* 12 bit Syncword */
ia_enhaacplus_enc_putbit(pstr_bitstream, 1 /*aacStateStruct->aacConfigSturct.mpegVersion*/,
ia_enhaacplus_enc_putbit(pstr_bitstream, 0 /*aacStateStruct->aacConfigSturct.mpegVersion*/,
1); /* ID == 0 for MPEG4 AAC, 1 for MPEG2 AAC */
ia_enhaacplus_enc_putbit(pstr_bitstream, 0, 2); /* layer == 0 */
ia_enhaacplus_enc_putbit(pstr_bitstream, 1, 1); /* protection absent */

View file

@ -218,6 +218,7 @@ void ia_enhaacplus_enc_print_usage() {
printf("\n[-aot:<audio_object_type>]");
printf("\n[-esbr:<esbr_flag>]");
printf("\n[-full_bandwidth:<enable_full_bandwidth>]");
printf("\n[-bandwidth:<bandwidth>]");
printf("\n[-max_out_buffer_per_ch:<bitreservoir_size>]");
printf("\n[-tree_cfg:<tree_config>]");
printf("\n[-usac:<usac_encoding_mode>]");
@ -269,6 +270,7 @@ void ia_enhaacplus_enc_print_usage() {
printf(
"\n <enable_full_bandwidth> Enable use of full bandwidth of input. Valid values are "
"0(disable full bandwidth) and 1(enable full bandwidth). Default is 0.");
printf("\n <bandwidth> specifies the bandwidth for the input (cutoff). Default is 0.");
printf("\n <bitreservoir_size> is the maximum size of bit reservoir to be used.");
printf(
"\n Valid values are from -1 to 6144. -1 will omit use of bit reservoir. Default is "
@ -362,6 +364,11 @@ static VOID ixheaace_parse_config_param(WORD32 argc, pWORD8 argv[], pVOID ptr_en
char *pb_arg_val = (char *)argv[i] + 16;
pstr_enc_api->input_config.aac_config.full_bandwidth = atoi(pb_arg_val);
}
/* Bandwidth */
if (!strncmp((const char *)argv[i], "-bandwidth:", 11)) {
char *pb_arg_val = (char *)argv[i] + 11;
pstr_enc_api->input_config.aac_config.bandwidth = atoi(pb_arg_val);
}
/* frame size */
if (!strncmp((const char *)argv[i], "-framesize:", 11)) {
char *pb_arg_val = (char *)argv[i] + 11;