From b8360ba0423a034f110d06c8be056b4412cc4f0b Mon Sep 17 00:00:00 2001 From: Rumaan Khan <100922@ittiam.com> Date: Thu, 26 Jun 2025 17:55:06 +0530 Subject: [PATCH 01/28] mp4 supp changes --- test/decoder/ixheaacd_main.c | 455 +++++++++++++++++++++++++++++++++-- test/decoder/xaacdec.cmake | 27 ++- 2 files changed, 465 insertions(+), 17 deletions(-) diff --git a/test/decoder/ixheaacd_main.c b/test/decoder/ixheaacd_main.c index 987baec..775b812 100644 --- a/test/decoder/ixheaacd_main.c +++ b/test/decoder/ixheaacd_main.c @@ -33,6 +33,16 @@ #include "ixheaacd_metadata_read.h" #include "impd_drc_config_params.h" +#ifdef SUPPORT_MP4 +#include "ISOMovies.h" +#define _IA_HANDLE_ERROR_MP4(a) \ +if (a) \ +{ \ + printf("ISOBMFF parser library error. Error No: %d\n", a); \ + exit(1); \ +} +#endif + IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value); @@ -100,13 +110,23 @@ FileWrapperPtr g_pf_inp; /* file pointer to bitstream file (mp4) */ WORD32 mpeg_d_drc_on = 0; +#ifndef SUPPORT_MP4 metadata_info meta_info; // metadata pointer; WORD32 ixheaacd_i_bytes_to_read; -WORD32 prev_i_bytes_to_read; -WORD32 flush_frame = 0; FILE *g_pf_meta; WORD32 raw_testing = 0; +#else +WORD32 mp4_flag = 0; +WORD32 ixheaacd_i_bytes_to_read; +ISOMedia media; +ISOTrack trak; +ISOTrackReader reader; +ISOHandle sample_hdl; +ISOHandle decoder_cfg_hdl; +#endif +WORD32 prev_i_bytes_to_read; +WORD32 flush_frame = 0; WORD32 eld_testing = 0; WORD32 ec_enable = 0; WORD32 esbr_testing = 1; @@ -387,6 +407,7 @@ IA_ERRORCODE ixheaacd_set_config_param(WORD32 argc, pWORD8 argv[], ia_error_info_struct *p_proc_err_info = &ixheaacd_error_info; for (i = 0; i < argc; i++) { +#ifndef SUPPORT_MP4 /* To indicate if its a MP4 file or not. */ if (!strncmp((pCHAR8)argv[i], "-mp4:", 5)) { pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 5); @@ -396,6 +417,7 @@ IA_ERRORCODE ixheaacd_set_config_param(WORD32 argc, pWORD8 argv[], IA_XHEAAC_DEC_CONFIG_PARAM_MP4FLAG, &ui_mp4_flag); _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); } +#endif /* PCM WORD Size (For single input file) */ if (!strncmp((pCHAR8)argv[i], "-pcmsz:", 7)) { pCHAR8 pb_arg_val = (pCHAR8)(argv[i] + 7); @@ -679,6 +701,15 @@ IA_ERRORCODE ixheaacd_set_config_param(WORD32 argc, pWORD8 argv[], } #endif } +#ifdef SUPPORT_MP4 + { + UWORD32 ui_mp4_flag = mp4_flag; + err_code = (*p_ia_process_api)( + p_ia_process_api_obj, IA_API_CMD_SET_CONFIG_PARAM, + IA_ENHAACPLUS_DEC_CONFIG_PARAM_ISMP4, &ui_mp4_flag); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } +#endif return IA_NO_ERROR; } @@ -883,6 +914,11 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { WORD32 prev_sampling_rate = 0; WORD32 skip_samples = 0; WORD32 total_samples = 0; +#ifdef SUPPORT_MP4 + s64 segment_duration = 0; + s64 start_offset_duration = 0; + u32 entryIndex = 1; +#endif WORD32 write_flag = 1; WORD32 bytes_to_write = 0; WORD32 ixheaacd_drc_offset = 0; @@ -933,6 +969,10 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { /* The process error info structure */ ia_error_info_struct *p_proc_err_info; +#ifdef SUPPORT_MP4 + ISOErr err = ISONoErr; +#endif + /* Process struct initing */ p_ia_process_api = ixheaacd_dec_api; p_set_config_param = ixheaacd_set_config_param; @@ -1210,6 +1250,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { do { i_bytes_read = 0; +#ifndef SUPPORT_MP4 if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; @@ -1272,8 +1313,72 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { #endif return 1; } +#else + if (!mp4_flag) + { + if ((ui_inp_size - (i_buff_size - i_bytes_consumed)) > 0) { + for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { + pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; + } + FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + i_buff_size - + i_bytes_consumed), + (ui_inp_size - (i_buff_size - i_bytes_consumed)), + (pUWORD32)&i_bytes_read); + + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); + + /* Tell input is over, if algorithm returns with insufficient input and + there is no + more input left in the bitstream*/ + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) + { + i_buff_size = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + } + } + + if ((i_buff_size <= 0) || + ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) { + i_buff_size = 0; + /* Tell that the input is over in this buffer */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); +#ifdef WAV_HEADER +#ifndef ARM_PROFILE_BOARD + /* ******************************************************************/ + /* Get config params from API */ + /* ******************************************************************/ + + err_code = + (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, + &i_num_chan, &i_pcm_wd_sz, &i_channel_mask, + &i_sbr_mode, &ui_aot); + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + // This is done in those cases, where file decodes ends at init time + // Since init is incomplete, sampling freq might be zero and will result + // in + // writing invalid wave header + + if (i_samp_freq == 0) i_samp_freq = prev_sampling_rate; + + if (!fseek(g_pf_out, 0, SEEK_SET)) + write_wav_header(g_pf_out, i_total_bytes, i_samp_freq, i_num_chan, + i_pcm_wd_sz, i_channel_mask); +#endif +#endif + return 1; + } + } +#endif if (init_iteration == 1) { +#ifndef SUPPORT_MP4 if (raw_testing) ixheaacd_i_bytes_to_read = get_metadata_dec_info_init(meta_info); else @@ -1284,8 +1389,52 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &ixheaacd_i_bytes_to_read); init_iteration++; +#else + if (!mp4_flag) + { + ixheaacd_i_bytes_to_read = i_buff_size; + /* Set number of bytes to be processed */ + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, + 0, &ixheaacd_i_bytes_to_read); + } + else + { + u32 samp_desc_idx = 1, obj_type = 0, output_size; + u32 avg_br = 0, max_br = 0, strm_type = 0, strm_up = 0; + err = MP4GetMediaDecoderInformation(media, + samp_desc_idx, + &obj_type, + &strm_type, + &output_size, + &strm_up, + &max_br, + &avg_br, + decoder_cfg_hdl); + _IA_HANDLE_ERROR_MP4(err); + err = MP4GetHandleSize(decoder_cfg_hdl, &ixheaacd_i_bytes_to_read); + _IA_HANDLE_ERROR_MP4(err); + if (ixheaacd_i_bytes_to_read > (WORD32)ui_inp_size) + return IA_FATAL_ERROR; + /* Set number of bytes to be processed */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES, 0, + &ixheaacd_i_bytes_to_read); + memcpy(pb_inp_buf, *decoder_cfg_hdl, ixheaacd_i_bytes_to_read); + if (ixheaacd_i_bytes_to_read <= 0) { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + return IA_NO_ERROR; + } + } + init_iteration++; +#endif } else { +#ifndef SUPPORT_MP4 if (raw_testing) { ixheaacd_i_bytes_to_read = get_metadata_dec_exec(meta_info, frame_counter); @@ -1312,6 +1461,44 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { err_code = (*p_ia_process_api)( pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); } +#else + if (mp4_flag) { + u32 unit_size; + s32 cts; + s32 dts; + u32 sample_flags; + err = MP4TrackReaderGetNextAccessUnit( + reader, sample_hdl, &unit_size, &sample_flags, &cts, &dts); + if (err) + { + if (err == ISOEOF) err = ISONoErr; + break; + } + ixheaacd_i_bytes_to_read = unit_size; + i_bytes_read = ixheaacd_i_bytes_to_read; + if (ixheaacd_i_bytes_to_read > (WORD32)ui_inp_size) + return IA_FATAL_ERROR; + + if (ixheaacd_i_bytes_to_read <= 0) { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + return IA_NO_ERROR; + } + + /* Set number of bytes to be processed */ + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_SET_INPUT_BYTES, 0, + &ixheaacd_i_bytes_to_read); + memcpy(pb_inp_buf, *((char **)sample_hdl), ixheaacd_i_bytes_to_read); + init_iteration++; + } else { + /* Set number of bytes to be processed */ + err_code = (*p_ia_process_api)( + pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); + } +#endif } _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); @@ -1675,6 +1862,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { if (ui_aot == 42) esbr_testing = 1; +#ifndef SUPPORT_MP4 if (raw_testing) { skip_samples = get_start_offset_in_samples(meta_info); if (ui_aot >= 23 && esbr_testing) { @@ -1685,6 +1873,21 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { } if (eld_testing == 0) total_samples = get_play_time_in_samples(meta_info); } +#else + if (mp4_flag) { + u32 entry_count = 1; + err = ISOGetTrackEditlistEntryCount(trak, &entry_count); + if (err == MP4NoErr) + { + err = ISOGetTrackEditlist(trak, &segment_duration, &start_offset_duration, 1); + if (err == MP4NoErr) + { + skip_samples = (WORD32)start_offset_duration; + if (eld_testing == 0) total_samples = (WORD32)segment_duration; + } + } + } +#endif /* End second part */ @@ -1701,26 +1904,67 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { #endif prev_sampling_rate = i_samp_freq; +#if SUPPORT_MP4 + UWORD32 number_of_frames = 0; + err = ISOGetMediaSampleCount(media, &number_of_frames); + if (err) return err; +#else + UWORD32 number_of_frames = meta_info.ia_mp4_stsz_entries; +#endif + do { if (((WORD32)ui_inp_size - (WORD32)(i_buff_size - i_bytes_consumed)) > 0) { if (i_sbr_mode && (ui_aot < 23) && esbr_testing) { - if (meta_info.ia_mp4_stsz_entries != frame_counter) { + if (number_of_frames != frame_counter) { for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; } - +#ifndef SUPPORT_MP4 FileWrapper_Read( g_pf_inp, (unsigned char *)(pb_inp_buf + i_buff_size - i_bytes_consumed), ((WORD32)ui_inp_size - (WORD32)(i_buff_size - i_bytes_consumed)), (pUWORD32)&i_bytes_read); - +#else + if (!mp4_flag) + { + FileWrapper_Read( + g_pf_inp, + (unsigned char *)(pb_inp_buf + i_buff_size - i_bytes_consumed), + ((WORD32)ui_inp_size - (WORD32)(i_buff_size - i_bytes_consumed)), + (pUWORD32)&i_bytes_read); + } + else + { + if (i_bytes_consumed) + { + u32 unit_size; + s32 cts; + s32 dts; + u32 sample_flags; + err = MP4TrackReaderGetNextAccessUnit( + reader, sample_hdl, &unit_size, &sample_flags, &cts, &dts); + if (err) + { + if (err == ISOEOF) err = ISONoErr; + break; + } + i_bytes_read = unit_size; + memcpy(pb_inp_buf, *((char **)sample_hdl), i_bytes_read); + } + } +#endif + i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); if ((i_buff_size <= 0) || ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) { i_buff_size = 0; +#ifndef SUPPORT_MP4 raw_testing = 0; +#else + mp4_flag = 0; +#endif /* Tell that the input is over in this buffer */ err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INPUT_OVER, 0, NULL); @@ -1732,19 +1976,49 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { for (i = 0; i < (i_buff_size - i_bytes_consumed); i++) { pb_inp_buf[i] = pb_inp_buf[i + i_bytes_consumed]; } - +#ifndef SUPPORT_MP4 FileWrapper_Read(g_pf_inp, (unsigned char *)(pb_inp_buf + i_buff_size - i_bytes_consumed), ((WORD32)ui_inp_size - (WORD32)(i_buff_size - i_bytes_consumed)), (pUWORD32)&i_bytes_read); - +#else + if (!mp4_flag) + { + FileWrapper_Read(g_pf_inp, + (unsigned char *)(pb_inp_buf + i_buff_size - i_bytes_consumed), + ((WORD32)ui_inp_size - (WORD32)(i_buff_size - i_bytes_consumed)), + (pUWORD32)&i_bytes_read); + } + else + { + if (i_bytes_consumed) + { + u32 unit_size; + s32 cts; + s32 dts; + u32 sample_flags; + err = MP4TrackReaderGetNextAccessUnit( + reader, sample_hdl, &unit_size, &sample_flags, &cts, &dts); + if (err) + { + if (err == ISOEOF) err = ISONoErr; + break; + } + i_bytes_read = unit_size; + memcpy(pb_inp_buf, *((char **)sample_hdl), i_bytes_read); + } + } +#endif i_buff_size = i_buff_size - (i_bytes_consumed - i_bytes_read); if ((i_buff_size <= 0) || ((err_code_reinit == 0x00001804) && i_bytes_read == 0)) { i_buff_size = 0; +#ifndef SUPPORT_MP4 raw_testing = 0; - +#else + mp4_flag = 0; +#endif err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_INPUT_OVER, 0, NULL); @@ -1753,7 +2027,8 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { } } if (i_sbr_mode && (ui_aot < 23) && esbr_testing) { - if (meta_info.ia_mp4_stsz_entries != frame_counter) { + if (number_of_frames != frame_counter) { +#ifndef SUPPORT_MP4 if (raw_testing) { ixheaacd_i_bytes_to_read = get_metadata_dec_exec(meta_info, frame_counter); @@ -1772,11 +2047,31 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &ixheaacd_i_bytes_to_read); } else { +#else + if (mp4_flag) { + ixheaacd_i_bytes_to_read = i_bytes_read; + + if (ixheaacd_i_bytes_to_read > (WORD32)ui_inp_size) + return IA_FATAL_ERROR; + if (ixheaacd_i_bytes_to_read <= 0 && ec_enable == 0) { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + return IA_NO_ERROR; + } + err_code = + (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, + 0, &ixheaacd_i_bytes_to_read); + } else { +#endif err_code = (*p_ia_process_api)( pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); } } } else { +#ifndef SUPPORT_MP4 if (raw_testing) { ixheaacd_i_bytes_to_read = get_metadata_dec_exec(meta_info, frame_counter); @@ -1807,6 +2102,37 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { &ixheaacd_i_bytes_to_read); } } else { +#else + if (mp4_flag) { + ixheaacd_i_bytes_to_read = i_bytes_read; + + if (ixheaacd_i_bytes_to_read > (WORD32)ui_inp_size) return IA_FATAL_ERROR; + + if (ixheaacd_i_bytes_to_read <= 0) { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, + IA_API_CMD_INPUT_OVER, 0, NULL); + + _IA_HANDLE_ERROR(p_proc_err_info, (pWORD8) "", err_code); + + return IA_NO_ERROR; + } + + if (ec_enable == 1) { + if (ixheaacd_i_bytes_to_read != 0) { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, + &ixheaacd_i_bytes_to_read); + } else { + if (i_buff_size != 0) { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, + &i_buff_size); + } + } + } else { + err_code = (*p_ia_process_api)(pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, + &ixheaacd_i_bytes_to_read); + } + } else { +#endif /* Set number of bytes to be processed */ err_code = (*p_ia_process_api)( pv_ia_process_api_obj, IA_API_CMD_SET_INPUT_BYTES, 0, &i_buff_size); @@ -2093,7 +2419,13 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { if (total_samples != 0) // Usac stream { +#ifndef SUPPORT_MP4 if (raw_testing) { +#else + if (mp4_flag) { + WORD32 frame_size = i_out_bytes / (i_num_chan * (i_pcm_wd_sz >> 3)); + skip_samples = skip_samples % frame_size; +#endif if (i_total_bytes <= skip_samples * i_num_chan * (i_pcm_wd_sz >> 3)) { err_code = (*p_get_config_param)(pv_ia_process_api_obj, &i_samp_freq, @@ -2117,6 +2449,7 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { } } +#ifndef SUPPORT_MP4 if (raw_testing) { samples_written += current_samples; @@ -2126,6 +2459,17 @@ int ixheaacd_main_process(WORD32 argc, pWORD8 argv[]) { if (i_out_bytes < 0) i_out_bytes = 0; } } +#else + if (mp4_flag) { + samples_written += current_samples; + + if (samples_written > total_samples) { + i_out_bytes = (total_samples - (samples_written - current_samples)) * + (i_num_chan * (i_pcm_wd_sz >> 3)); + if (i_out_bytes < 0) i_out_bytes = 0; + } + } +#endif } if (write_flag) { @@ -2362,10 +2706,17 @@ void print_usage() { int main(WORD32 argc, char *argv[]) { WORD32 i, err_code = IA_NO_ERROR; +#ifdef SUPPORT_MP4 + ISOErr err; + u32 handler_type; + ISOMovie moov; +#endif ia_testbench_error_handler_init(); g_pf_inp = NULL; +#ifndef SUPPORT_MP4 g_pf_meta = NULL; +#endif g_pf_out = NULL; for (i = 1; i < argc; i++) { @@ -2373,7 +2724,7 @@ int main(WORD32 argc, char *argv[]) { if (!strncmp((const char *)argv[i], "-ifile:", 7)) { pWORD8 pb_arg_val = (pWORD8)argv[i] + 7; - +#ifndef SUPPORT_MP4 g_pf_inp = FileWrapper_Open((char *)pb_arg_val); if (g_pf_inp == NULL) { err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; @@ -2382,8 +2733,43 @@ int main(WORD32 argc, char *argv[]) { exit(1); } raw_testing = 0; +#else + err = ISOOpenMovieFile(&moov, (char *)pb_arg_val, + MP4OpenMovieNormal); + if (err != MP4NoErr) + { + mp4_flag = 0; + g_pf_inp = FileWrapper_Open((char *)pb_arg_val); + if (g_pf_inp == NULL) { + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input File", err_code); + exit(1); + } + } + else + { + u32 tot_num_tracks = 0; + mp4_flag = 1; + err = ISOGetMovieTrackCount(moov, &tot_num_tracks); + _IA_HANDLE_ERROR_MP4(err); + err = ISOGetMovieIndTrack(moov, tot_num_tracks, &trak); + _IA_HANDLE_ERROR_MP4(err); + err = ISOGetTrackMedia(trak, &media); + _IA_HANDLE_ERROR_MP4(err); + err = ISOGetMediaHandlerDescription( + media, &handler_type, NULL); + _IA_HANDLE_ERROR_MP4(err); + err = ISONewHandle(0, &decoder_cfg_hdl); + _IA_HANDLE_ERROR_MP4(err); + err = ISONewHandle(0, &sample_hdl); + _IA_HANDLE_ERROR_MP4(err); + err = ISOCreateTrackReader(trak, &reader); + _IA_HANDLE_ERROR_MP4(err); + } +#endif } - +#ifndef SUPPORT_MP4 if (!strncmp((const char *)argv[i], "-imeta:", 7)) { pWORD8 pb_arg_val = (pWORD8)argv[i] + 7; @@ -2403,6 +2789,7 @@ int main(WORD32 argc, char *argv[]) { } raw_testing = 1; } +#endif if (!strncmp((const char *)argv[i], "-ofile:", 7)) { pWORD8 pb_arg_val = (pWORD8)argv[i] + 7; @@ -2417,6 +2804,7 @@ int main(WORD32 argc, char *argv[]) { } } +#ifndef SUPPORT_MP4 if ((g_pf_inp == NULL) || (g_pf_out == NULL)) { print_usage(); err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; @@ -2424,11 +2812,33 @@ int main(WORD32 argc, char *argv[]) { (pWORD8) "Input or Output File", err_code); exit(1); } +#else + if (!mp4_flag) + { + if ((g_pf_inp == NULL) || (g_pf_out == NULL)) { + print_usage(); + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Input or Output File", err_code); + exit(1); + } + } + else + { + if (g_pf_out == NULL) { + print_usage(); + err_code = IA_TESTBENCH_MFMAN_FATAL_FILE_OPEN_FAILED; + ixheaacd_error_handler(&ixheaacd_ia_testbench_error_info, + (pWORD8) "Output File", err_code); + exit(1); + } + } +#endif g_w_malloc_count = 0; printf("\n"); - +#ifndef SUPPORT_MP4 for (i = 0; i < argc; i++) { if (!strcmp((pCHAR8)argv[i], "-mp4:1")) { if (g_pf_meta == NULL) { @@ -2440,7 +2850,7 @@ int main(WORD32 argc, char *argv[]) { } } } - +#endif for (i = 0; i < argc; i++) { if (strcmp((pCHAR8)argv[i], "-eld_testing:1")) eld_testing = 0; @@ -2456,12 +2866,29 @@ int main(WORD32 argc, char *argv[]) { if (g_pv_arr_alloc_memory[i]) free(g_pv_arr_alloc_memory[i]); } if (g_pf_out) fclose(g_pf_out); - +#ifndef SUPPORT_MP4 if (g_pf_meta) { fclose(g_pf_meta); metadata_mp4_stsz_size_free(&meta_info); } FileWrapper_Close(g_pf_inp); +#else + if (!mp4_flag) + { + FileWrapper_Close(g_pf_inp); + } + else + { + err = ISODisposeHandle(sample_hdl); + _IA_HANDLE_ERROR_MP4(err); + err = ISODisposeHandle(decoder_cfg_hdl); + _IA_HANDLE_ERROR_MP4(err); + err = ISODisposeTrackReader(reader); + _IA_HANDLE_ERROR_MP4(err); + err = ISODisposeMovie(moov); + _IA_HANDLE_ERROR_MP4(err); + } +#endif mpeg_d_drc_on = 0; return IA_NO_ERROR; diff --git a/test/decoder/xaacdec.cmake b/test/decoder/xaacdec.cmake index f849989..5bb7c7d 100644 --- a/test/decoder/xaacdec.cmake +++ b/test/decoder/xaacdec.cmake @@ -5,23 +5,44 @@ list(APPEND XAACDEC_SRCS "${XAAC_ROOT}/test/decoder/ixheaacd_error.c" set(LIBXAACDEC_INCLUDES ${XAAC_ROOT}/decoder ${XAAC_ROOT}/test/decoder/ ${XAAC_ROOT}/decoder/drc_src) -include_directories(${LIBXAACDEC_INCLUDES}) +if(SUPPORT_MP4) + set(LIBISOMEDIA_INCLUDES $(XAAC_ROOT)/../isobmff/IsoLib/libisomediafile/src) + + set(LIBISOOSW32_INCLUDES $(XAAC_ROOT)/../isobmff/IsoLib/libisomediafile/w32) + + include_directories(${LIBXAACDEC_INCLUDES} ${LIBISOMEDIA_INCLUDES} ${LIBISOOSW32_INCLUDES}) +else() + include_directories(${LIBXAACDEC_INCLUDES}) +endif() libxaac_add_executable(xaacdec libxaacdec SOURCES ${XAACDEC_SRCS} INCLUDES ${LIBXAACDEC_INCLUDES}) +if(SUPPORT_MP4) + include_external_msproject(libisomediafile + ${XAAC_ROOT}/../isobmff/build/IsoLib/libisomediafile/libisomediafile.vcxproj) + + add_dependencies(xaacdec libisomediafile) +endif() + +set(COMMON_FLAGS "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DECLIPSE -DWIN32 -DLOUDNESS_LEVELING_SUPPORT") + +if(SUPPORT_MP4) + set(MP4_FLAG "-DSUPPORT_MP4") +endif() + if(MSVC) set_target_properties( xaacdec PROPERTIES COMPILE_FLAGS - "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DECLIPSE -DWIN32 -D_CRT_SECURE_NO_WARNINGS -DLOUDNESS_LEVELING_SUPPORT" + "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DECLIPSE -DWIN32 -D_CRT_SECURE_NO_WARNINGS ${MP4_FLAG}" ) else() set_target_properties( xaacdec PROPERTIES COMPILE_FLAGS - "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DECLIPSE -DWIN32 -DLOUDNESS_LEVELING_SUPPORT" + "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DECLIPSE -DWIN32 ${MP4_FLAG}" ) endif() From 7e1a54d5d667df30d6656275c1618dd74e2553be Mon Sep 17 00:00:00 2001 From: Rumaan Khan <100922@ittiam.com> Date: Tue, 1 Jul 2025 15:56:13 +0530 Subject: [PATCH 02/28] add supp for linux --- test/decoder/xaacdec.cmake | 54 +++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/test/decoder/xaacdec.cmake b/test/decoder/xaacdec.cmake index 5bb7c7d..f499ea8 100644 --- a/test/decoder/xaacdec.cmake +++ b/test/decoder/xaacdec.cmake @@ -1,48 +1,70 @@ -list(APPEND XAACDEC_SRCS "${XAAC_ROOT}/test/decoder/ixheaacd_error.c" - "${XAAC_ROOT}/test/decoder/ixheaacd_fileifc.c" "${XAAC_ROOT}/test/decoder/ixheaacd_main.c" - "${XAAC_ROOT}/test/decoder/ixheaacd_metadata_read.c") +list(APPEND XAACDEC_SRCS + "${XAAC_ROOT}/test/decoder/ixheaacd_error.c" + "${XAAC_ROOT}/test/decoder/ixheaacd_fileifc.c" + "${XAAC_ROOT}/test/decoder/ixheaacd_main.c" + "${XAAC_ROOT}/test/decoder/ixheaacd_metadata_read.c" +) -set(LIBXAACDEC_INCLUDES ${XAAC_ROOT}/decoder ${XAAC_ROOT}/test/decoder/ - ${XAAC_ROOT}/decoder/drc_src) +set(LIBXAACDEC_INCLUDES + ${XAAC_ROOT}/decoder + ${XAAC_ROOT}/test/decoder/ + ${XAAC_ROOT}/decoder/drc_src +) if(SUPPORT_MP4) - set(LIBISOMEDIA_INCLUDES $(XAAC_ROOT)/../isobmff/IsoLib/libisomediafile/src) + set(LIBISOMEDIA_INCLUDES "${XAAC_ROOT}/../isobmff/IsoLib/libisomediafile/src") - set(LIBISOOSW32_INCLUDES $(XAAC_ROOT)/../isobmff/IsoLib/libisomediafile/w32) - - include_directories(${LIBXAACDEC_INCLUDES} ${LIBISOMEDIA_INCLUDES} ${LIBISOOSW32_INCLUDES}) + # Platform-specific includes + if(MSVC) + set(LIBISOOSW32_INCLUDES "${XAAC_ROOT}/../isobmff/IsoLib/libisomediafile/w32") + include_directories(${LIBXAACDEC_INCLUDES} ${LIBISOMEDIA_INCLUDES} ${LIBISOOSW32_INCLUDES}) + else() + set(LIBISOMEDIA_PLATFORM_INCLUDES ${XAAC_ROOT}/../isobmff/IsoLib/libisomediafile/linux) + include_directories(${LIBXAACDEC_INCLUDES} ${LIBISOMEDIA_INCLUDES} ${LIBISOMEDIA_PLATFORM_INCLUDES}) + endif() else() include_directories(${LIBXAACDEC_INCLUDES}) endif() -libxaac_add_executable(xaacdec libxaacdec SOURCES ${XAACDEC_SRCS} INCLUDES - ${LIBXAACDEC_INCLUDES}) +# Add xaacdec executable +libxaac_add_executable(xaacdec libxaacdec SOURCES ${XAACDEC_SRCS} INCLUDES ${LIBXAACDEC_INCLUDES}) +# Platform-specific linking of MP4 library if(SUPPORT_MP4) - include_external_msproject(libisomediafile - ${XAAC_ROOT}/../isobmff/build/IsoLib/libisomediafile/libisomediafile.vcxproj) + if(MSVC) + # Use Visual Studio project on Windows + include_external_msproject(libisomediafile + ${XAAC_ROOT}/../isobmff/build/IsoLib/libisomediafile/libisomediafile.vcxproj) - add_dependencies(xaacdec libisomediafile) + add_dependencies(xaacdec libisomediafile) + + else() + # Linux: link prebuilt static .a library + set(LIBISOMEDIA_LIB_PATH "${XAAC_ROOT}/../isobmff/lib/liblibisomediafile.a") + target_link_libraries(xaacdec ${LIBISOMEDIA_LIB_PATH}) + endif() endif() +# Common compile flags set(COMMON_FLAGS "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DECLIPSE -DWIN32 -DLOUDNESS_LEVELING_SUPPORT") if(SUPPORT_MP4) set(MP4_FLAG "-DSUPPORT_MP4") endif() +# Apply compile flags per platform if(MSVC) set_target_properties( xaacdec PROPERTIES COMPILE_FLAGS - "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DECLIPSE -DWIN32 -D_CRT_SECURE_NO_WARNINGS ${MP4_FLAG}" + "${COMMON_FLAGS} -D_CRT_SECURE_NO_WARNINGS ${MP4_FLAG}" ) else() set_target_properties( xaacdec PROPERTIES COMPILE_FLAGS - "-UARM_PROFILE_HW -UARM_PROFILE_BOARD -DDRC_ENABLE -DMULTICHANNEL_ENABLE -DECLIPSE -DWIN32 ${MP4_FLAG}" + "${COMMON_FLAGS} ${MP4_FLAG}" ) endif() From 229e7da0ad65efecacb09b7192a3f26f375aca06 Mon Sep 17 00:00:00 2001 From: Rumaan Khan <100922@ittiam.com> Date: Wed, 30 Jul 2025 14:34:02 +0530 Subject: [PATCH 03/28] WIP: Loudness leveling support with uniDRCv0 config support --- decoder/drc_src/impd_drc_dynamic_payload.c | 2 +- encoder/drc_src/impd_drc_mux.c | 16 ++- test/encoder/impd_drc_config_params.txt | 118 ++++++++++++--------- 3 files changed, 82 insertions(+), 54 deletions(-) diff --git a/decoder/drc_src/impd_drc_dynamic_payload.c b/decoder/drc_src/impd_drc_dynamic_payload.c index e005198..dbca07b 100644 --- a/decoder/drc_src/impd_drc_dynamic_payload.c +++ b/decoder/drc_src/impd_drc_dynamic_payload.c @@ -673,7 +673,7 @@ IA_ERROR_CODE impd_leveling_instructions(ia_bit_buf_struct* it_bit_buff, } err = impd_parse_drc_instructions_uni_drc( - it_bit_buff, 1, pstr_drc_config, + it_bit_buff, 0, pstr_drc_config, &pstr_drc_config ->str_drc_instruction_str[pstr_drc_config->drc_instructions_uni_drc_count - 1]); diff --git a/encoder/drc_src/impd_drc_mux.c b/encoder/drc_src/impd_drc_mux.c index fa3aac1..d71fbff 100644 --- a/encoder/drc_src/impd_drc_mux.c +++ b/encoder/drc_src/impd_drc_mux.c @@ -3101,9 +3101,17 @@ IA_ERRORCODE impd_drc_write_uni_drc_config(ia_drc_enc_state *pstr_drc_state, WOR bit_cnt_local += iusace_write_bits_buf(it_bit_buf, pstr_uni_drc_config->drc_coefficients_uni_drc_count, 3); +#ifdef LOUDNESS_LEVELING_SUPPORT + UWORD32 num_ducking_only_drc_sets = + get_num_ducking_only_drc_sets(pstr_uni_drc_config->str_drc_instructions_uni_drc, + pstr_uni_drc_config->drc_instructions_uni_drc_count); + bit_cnt_local += iusace_write_bits_buf( + it_bit_buf, pstr_uni_drc_config->drc_instructions_uni_drc_count - num_ducking_only_drc_sets, + 6); +#else bit_cnt_local += iusace_write_bits_buf(it_bit_buf, pstr_uni_drc_config->drc_instructions_uni_drc_count, 6); - +#endif bit_cnt_local += iusace_write_bits_buf(it_bit_buf, pstr_uni_drc_config->str_channel_layout.base_ch_count, 7); bit_cnt_local += iusace_write_bits_buf( @@ -3138,6 +3146,12 @@ IA_ERRORCODE impd_drc_write_uni_drc_config(ia_drc_enc_state *pstr_drc_state, WOR } for (idx = 0; idx < pstr_uni_drc_config->drc_instructions_uni_drc_count; idx++) { +#ifdef LOUDNESS_LEVELING_SUPPORT + if (idx > 0 && + pstr_uni_drc_config->str_drc_instructions_uni_drc[idx - 1].ducking_only_set_present) { + continue; + } +#endif err_code = impd_drc_write_drc_instruct_uni_drc( it_bit_buf, version, pstr_uni_drc_config, pstr_gain_enc, &(pstr_uni_drc_config->str_drc_instructions_uni_drc[idx]), ptr_scratch, &bit_cnt_local); diff --git a/test/encoder/impd_drc_config_params.txt b/test/encoder/impd_drc_config_params.txt index da7e9a1..fa6eb44 100644 --- a/test/encoder/impd_drc_config_params.txt +++ b/test/encoder/impd_drc_config_params.txt @@ -2,41 +2,11 @@ #For a given DRC effect, when both `leveling_present` and `ducking_only_set` are set to 1, automatically the next drc instruction is treated as ducking only set. #For example, if the second DRC effect is marked as 2048/4096 with `leveling_present` is set to 1 and `ducking_only_set` is set to 1, then the third DRC effect will be treated as ducking-only. #For the last drc instruction, `leveling_present` and `ducking_only_set` fields are ignored and reset to 0. Maximum supported instructions are 8. - #####str_drc_instructions_uni_drc##### -drc_instructions_uni_drc_count:0 -#####str_drc_coefficients_uni_drc##### -drc_coefficients_uni_drc_count:0 -#####str_downmix_instructions_v1##### -downmix_instructions_v1_count:1 -#n=0 -target_layout:1 -#s=0 -downmix_coeff:0.70794578438 -#end downmix coeeficients -#####str_drc_coefficients_uni_drc_v1##### -drc_coefficients_uni_drc_count_v1:1 -#n=0 -gain_set_count:1 -#s=0 -band_count:1 -#gain parameters m=0 -nb_points:3 -x:-60.0 -y:-40.0 -x:-30.0 -y:-30.0 -x:0.0 -y:-20.0 -width:0.01 -attack:2.0 -decay:5.0 -#end gain parameters -#####str_drc_instructions_uni_drc_v1##### -drc_instructions_uni_drc_count_v1:3 +drc_instructions_uni_drc_count:3 #n=0 downmix_id:0 -drc_set_effect:0x0001 +drc_set_effect:1 gain_set_channels:8 gain_set_index:0 gain_set_index:0 @@ -51,29 +21,73 @@ num_drc_channel_groups:1 downmix_id:0 drc_set_effect:0x800 gain_set_channels:8 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 +gain_set_index:1 +gain_set_index:1 +gain_set_index:1 +gain_set_index:1 +gain_set_index:1 +gain_set_index:1 +gain_set_index:1 +gain_set_index:1 num_drc_channel_groups:1 -#leveling present flag leveling_present:1 -#if ducking_only_set is one next drc instruction's set effect is set to 0x800 (ducking/leveling self) ducking_only_set:1 #n=2 downmix_id:0 -drc_set_effect:0x0800 +drc_set_effect:0x800 gain_set_channels:8 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -gain_set_index:0 -num_drc_channel_groups:1 \ No newline at end of file +gain_set_index:2 +gain_set_index:2 +gain_set_index:2 +gain_set_index:2 +gain_set_index:2 +gain_set_index:2 +gain_set_index:2 +gain_set_index:2 +num_drc_channel_groups:1 +leveling_present:0 +ducking_only_set:0 +#####str_drc_coefficients_uni_drc##### +drc_coefficients_uni_drc_count:1 +#n=0 +gain_set_count:3 +#s=0 +band_count:1 +#gain parameters m=0 +nb_points:3 +x:-60.0 +y:-40.0 +x:-30.0 +y:-30.0 +x:0.0 +y:-20.0 +width:0.01 +attack:2.0 +decay:5.0 +#end gain parameters +#s=0 +band_count:1 +#gain parameters m=0 +nb_points:2 +x:-50.0 +y:-50.0 +x:0.0 +y:-10.0 +width:0.01 +attack:2.0 +decay:5.0 +#end gain parameters +#s=0 +band_count:1 +#gain parameters m=0 +nb_points:3 +x:-60.0 +y:-60.0 +x:-20.0 +y:-15.0 +x:0.0 +y:-5.0 +width:0.01 +attack:2.0 +decay:5.0 +#end gain parameters From 433d6c3eb6d5177fecf2cf34bff84c8f434f6d55 Mon Sep 17 00:00:00 2001 From: wrapper Date: Mon, 4 Aug 2025 20:50:17 +0700 Subject: [PATCH 04/28] fix ASC, fix full bandwidth for non USAC --- encoder/ixheaace_asc_write.c | 16 +++++++--------- encoder/ixheaace_enc_init.c | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/encoder/ixheaace_asc_write.c b/encoder/ixheaace_asc_write.c index 3bf2736..356dc11 100644 --- a/encoder/ixheaace_asc_write.c +++ b/encoder/ixheaace_asc_write.c @@ -412,6 +412,7 @@ WORD32 ixheaace_get_audiospecific_config_bytes( pstr_audio_specific_config->sampling_frequency /= 2; if ((AOT_SBR == aot) || (AOT_PS == aot)) { + ext_aot = aot; aot = AOT_AAC_LC; } } @@ -460,9 +461,12 @@ WORD32 ixheaace_get_audiospecific_config_bytes( bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, (pstr_audio_specific_config->channel_configuration), 4); + if (ext_aot != -1) aot = ext_aot; + if ((AOT_SBR == aot) || (AOT_PS == aot)) { ext_aot = AOT_SBR; sbr_present_flag = 1; + tmp = 0x0f; for (i = 0; i < sizeof(ia_sampl_freq_table) / sizeof(ia_sampl_freq_table[0]); i++) { if (ia_sampl_freq_table[i] == pstr_audio_specific_config->ext_sampling_frequency) { @@ -470,18 +474,12 @@ WORD32 ixheaace_get_audiospecific_config_bytes( break; } } + pstr_audio_specific_config->ext_samp_freq_index = (UWORD32)tmp; - bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, - (pstr_audio_specific_config->ext_samp_freq_index), 4); - if (pstr_audio_specific_config->ext_samp_freq_index == 0xf) { - bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, - (pstr_audio_specific_config->ext_sampling_frequency), 24); - } + if (AOT_PS == aot) { ps_present_flag = 1; } - - bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, AOT_AAC_LC, 5); } switch (aot) { case AOT_AAC_ELD: { @@ -506,7 +504,7 @@ WORD32 ixheaace_get_audiospecific_config_bytes( ext_id = 0x2b7; bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, ext_id, 11); - bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, aot, 5); + bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, ext_aot, 5); bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, sbr_present_flag, 1); if (sbr_present_flag) { bit_cnt += iusace_write_bits_buf(pstr_it_bit_buff, diff --git a/encoder/ixheaace_enc_init.c b/encoder/ixheaace_enc_init.c index dc6ba74..da43291 100644 --- a/encoder/ixheaace_enc_init.c +++ b/encoder/ixheaace_enc_init.c @@ -374,7 +374,7 @@ IA_ERRORCODE ia_enhaacplus_enc_aac_enc_open(iexheaac_encoder_str **ppstr_exheaac WORD32 tns_mask = config.use_tns; if (config.full_bandwidth) { - pstr_exheaac_encoder->config.band_width = config.core_sample_rate >> 2; + pstr_exheaac_encoder->config.band_width = config.core_sample_rate >> (aot == AOT_USAC ? 2 : 1); } else { ixheaace_determine_bandwidth(pstr_exheaac_encoder->config.band_width, config.bit_rate, config.core_sample_rate, pstr_element_info->n_channels_in_el, From 17b657d7c3ff4ef8950e75016821d792669227b8 Mon Sep 17 00:00:00 2001 From: wrapper Date: Mon, 4 Aug 2025 20:52:12 +0700 Subject: [PATCH 05/28] 32-bit floating point samples, adjustable bandwidth --- encoder/ixheaace_api.c | 25 +++++++++++++++---------- encoder/ixheaace_write_adts_adif.c | 2 +- test/encoder/ixheaace_testbench.c | 7 +++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/encoder/ixheaace_api.c b/encoder/ixheaace_api.c index 6d5c47e..406026a 100644 --- a/encoder/ixheaace_api.c +++ b/encoder/ixheaace_api.c @@ -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); } } } diff --git a/encoder/ixheaace_write_adts_adif.c b/encoder/ixheaace_write_adts_adif.c index 2cda5bb..0442ef8 100644 --- a/encoder/ixheaace_write_adts_adif.c +++ b/encoder/ixheaace_write_adts_adif.c @@ -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 */ diff --git a/test/encoder/ixheaace_testbench.c b/test/encoder/ixheaace_testbench.c index 7b6290d..624a9da 100644 --- a/test/encoder/ixheaace_testbench.c +++ b/test/encoder/ixheaace_testbench.c @@ -218,6 +218,7 @@ void ia_enhaacplus_enc_print_usage() { printf("\n[-aot:]"); printf("\n[-esbr:]"); printf("\n[-full_bandwidth:]"); + printf("\n[-bandwidth:]"); printf("\n[-max_out_buffer_per_ch:]"); printf("\n[-tree_cfg:]"); printf("\n[-usac:]"); @@ -269,6 +270,7 @@ void ia_enhaacplus_enc_print_usage() { printf( "\n Enable use of full bandwidth of input. Valid values are " "0(disable full bandwidth) and 1(enable full bandwidth). Default is 0."); + printf("\n specifies the bandwidth for the input (cutoff). Default is 0."); printf("\n 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; From 07e7c9dde81e483f25c285c00721ccb764f22ca4 Mon Sep 17 00:00:00 2001 From: wrapper Date: Wed, 6 Aug 2025 19:24:37 +0700 Subject: [PATCH 06/28] floating --- decoder/ixheaacd_api.c | 2 +- decoder/ixheaacd_decode_main.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index 5e6a0ac..c4ae8e0 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -579,7 +579,7 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_xheaac_dec_obj, WORD32 i_cmd, break; } case IA_XHEAAC_DEC_CONFIG_PARAM_PCM_WDSZ: { - if ((*pui_value != 16) && (*pui_value != 24)) { + if ((*pui_value != 16) && (*pui_value != 24) && (*pui_value != 32)) { p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_PCM_WDSZ); } diff --git a/decoder/ixheaacd_decode_main.c b/decoder/ixheaacd_decode_main.c index 982a6aa..d827687 100644 --- a/decoder/ixheaacd_decode_main.c +++ b/decoder/ixheaacd_decode_main.c @@ -88,6 +88,7 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, FLOAT32 write_local_float; WORD16 *out_buf = (WORD16 *)outbuffer; + FLOAT32 *out_buf_float = (FLOAT32 *)outbuffer; num = num_channel_out * num_samples_out; @@ -105,6 +106,20 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, } *out_bytes = num * sizeof(WORD16); + } else if (pcmsize == 32) { + for (i = 0; i < num; i++) { + write_local_float = + (out_samples[i % num_channel_out][i / num_channel_out]); + + if (write_local_float > 32767.0f) { + write_local_float = 32767.0f; + } else if (write_local_float < -32768.0f) { + write_local_float = -32768.0f; + } + out_buf_float[i] = write_local_float / 32767; + } + + *out_bytes = num * sizeof(FLOAT32); } else { WORD8 *out_24bit = (WORD8 *)out_buf; for (i = 0; i < num; i++) { From 56a15e2211a82b0f3e3b5635c30291ee302fc7a5 Mon Sep 17 00:00:00 2001 From: wrapper Date: Sat, 9 Aug 2025 23:06:33 +0700 Subject: [PATCH 07/28] disable sample rate limit --- encoder/ixheaace_sbr_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index 893d215..2089c8b 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -386,6 +386,7 @@ ixheaace_is_sbr_setting_available(UWORD32 bitrate, UWORD32 num_output_channels, WORD32 idx_ch; WORD32 idx_entry; +#if 0 switch (num_output_channels) { case MONO: if (sample_rate_input < 16000 || sample_rate_input > 48000) { @@ -396,6 +397,7 @@ ixheaace_is_sbr_setting_available(UWORD32 bitrate, UWORD32 num_output_channels, return 0; } } +#endif *ptr_core_sr = sample_rate_input / 2; From 3d995a0119a8b6bd781b5c831942b9c28d2e948c Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 10 Aug 2025 10:09:01 +0700 Subject: [PATCH 08/28] new encode tables --- encoder/ixheaace_api.c | 2 + encoder/ixheaace_rom.c | 43 +++++++ encoder/ixheaace_sbr_main.c | 2 +- encoder/ixheaace_sbr_rom.c | 232 ++++++++++++++++++++++++++++++++++++ 4 files changed, 278 insertions(+), 1 deletion(-) diff --git a/encoder/ixheaace_api.c b/encoder/ixheaace_api.c index 406026a..22fe7e4 100644 --- a/encoder/ixheaace_api.c +++ b/encoder/ixheaace_api.c @@ -901,6 +901,7 @@ static IA_ERRORCODE ixheaace_set_config_params(ixheaace_api_struct *pstr_api_str (AOT_AAC_ELD == pstr_input_config->aot)) { pstr_api_struct->config[ele_idx].aac_classic = 0; } +#ifndef AAC_NEW_TABLES if (pstr_api_struct->config[ele_idx].sample_rate < 32000) { if (pstr_api_struct->config[ele_idx].aac_classic == 0) { pstr_api_struct->config[ele_idx].aac_classic = 1; @@ -912,6 +913,7 @@ static IA_ERRORCODE ixheaace_set_config_params(ixheaace_api_struct *pstr_api_str pstr_input_config->aot = AOT_AAC_LD; } } +#endif pstr_api_struct->config[ele_idx].eldsbr_found = !(pstr_api_struct->config[ele_idx].aac_classic); } diff --git a/encoder/ixheaace_rom.c b/encoder/ixheaace_rom.c index 532fee9..732e64a 100644 --- a/encoder/ixheaace_rom.c +++ b/encoder/ixheaace_rom.c @@ -1620,6 +1620,7 @@ const ixheaace_temporal_noise_shaping_tables ixheaace_enhaacplus_enc_tns_tab = { {8000, 39, 14, 39, 14, 31, 30}}, /*tns_info_tab[5]*/ +#ifndef AAC_NEW_TABLES {{4000, 12000, {1.2f, 1800, 16000, 0.6f}, @@ -1654,7 +1655,49 @@ const ixheaace_temporal_noise_shaping_tables ixheaace_enhaacplus_enc_tns_tab = { {1.41f, 3750, 16000, 0.3f}, {1.41f, 2500, 16000, 0.5f}, {1.41f, 3750, 16000, 0.3f}}}, +#else + {{4000, + 12000, + {1.2f, 1800, 16000, 0.6f}, + {1.2f, 2500, 16000, 0.6f}, + {1.2f, 1800, 16000, 0.6f}, + {1.2f, 2500, 16000, 0.6f}}, + {12001, + 20000, + {1.41f, 2500, 16000, 0.6f}, + {1.41f, 3750, 16000, 0.6f}, + {1.41f, 2500, 16000, 0.6f}, + {1.41f, 3750, 16000, 0.6f}}, + + {20001, + 28000, + {1.41f, 2500, 16000, 0.5f}, + {1.41f, 3750, 16000, 0.5f}, + {1.41f, 2500, 16000, 0.5f}, + {1.41f, 3750, 16000, 0.5f}}, + + {28001, + 36000, + {1.41f, 2500, 16000, 0.8f}, + {1.41f, 3750, 16000, 0.3f}, + {1.41f, 2500, 16000, 0.5f}, + {1.41f, 3750, 16000, 0.3f}}, + + {36001, + 52000, + {1.41f, 2500, 16000, 0.5f}, + {1.41f, 3750, 16000, 0.1f}, + {1.41f, 2500, 16000, 0.5f}, + {1.41f, 3750, 16000, 0.1f}}, + + {52001, + 576000, + {1.41f, 2500, 16000, 0.3f}, + {1.41f, 3750, 16000, 0.1f}, + {1.41f, 2500, 16000, 0.3f}, + {1.41f, 3750, 16000, 0.1f}}}, +#endif /*tns_coeff_3[8]*/ {-0.98480773f, -0.866025389f, -0.642787576f, -0.342020154f, 0.0f, 0.433883727f, 0.781831503f, diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index 2089c8b..522870d 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -386,7 +386,7 @@ ixheaace_is_sbr_setting_available(UWORD32 bitrate, UWORD32 num_output_channels, WORD32 idx_ch; WORD32 idx_entry; -#if 0 +#ifndef AAC_NEW_TABLES switch (num_output_channels) { case MONO: if (sample_rate_input < 16000 || sample_rate_input > 48000) { diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 90e94c5..5ecdc6c 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -621,6 +621,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {0.05857864376269f, 0.2f, 0.34142135623731f, 0.4f}, {8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000}, +#ifndef AAC_NEW_TABLES {{{{8000, 10000, {7, 11}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {11, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 48001, {14, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -738,6 +739,237 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {0}}} }, +#else + {{{ + /*** 8000hz 1ch ***/ + {8000, 10000, {7, 11}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {10000, 12000, {11, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {12000, 16000, {14, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 24000, {14, 14}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {24000, 32000, {14, 14}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {32000, 48001, {14, 15}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 8000hz 2ch ***/ + {16000, 24000, {6, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {9, 11}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 36000, {11, 11}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {13, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {14, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 11025hz 1ch ***/ + {8000, 10000, {5, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {10000, 12000, {8, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {12000, 16000, {12, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 20000, {12, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {20000, 24000, {13, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {24000, 32000, {14, 14}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {32000, 48000, {15, 15}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {48000, 64001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 11025hz 2ch ***/ + {16000, 24000, {7, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {10, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 36000, {12, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {13, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {14, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 12000hz 1ch ***/ + {8000, 10000, {4, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {10000, 12000, {7, 11}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {12000, 16000, {11, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 20000, {11, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {20000, 24000, {12, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {24000, 32000, {13, 13}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {32000, 48000, {14, 14}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {48000, 64001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 12000hz 2ch ***/ + {16000, 24000, {6, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {9, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 36000, {11, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {12, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {13, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {14, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 16000hz 1ch ***/ + {6000, 8000, {0, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {8000, 10000, {1, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {10000, 12000, {2, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {12000, 16000, {4, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 18000, {4, 8}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {18000, 22000, {6, 11}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {22000, 28000, {10, 12}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {28000, 36000, {12, 13}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 44000, {14, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 64001, {15, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 16000hz 2ch ***/ + {16000, 24000, {4, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {8, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 36000, {10, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {13, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {15, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 22050hz 1ch ***/ + {8000, 11369, {1, 1}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {11369, 16000, {3, 4}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 18000, {3, 5}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {18000, 22000, {4, 8}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {22000, 28000, {7, 8}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {28000, 36000, {10, 9}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 44000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 52000, {13, 11}, 1, {2, 0, 0}, IXHEAACE_SBR_MODE_MONO}, + {52000, 68000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {68000, 96001, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 22050hz 2ch ***/ + {16000, 24000, {2, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {5, 6}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 32000, {5, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {32000, 36000, {7, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {10, 9}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {12, 9}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 101000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {101000, 128001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 24000hz 1ch ***/ + {8000, 12000, {1, 1}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {12000, 16000, {3, 4}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 18000, {3, 5}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {18000, 22000, {4, 8}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {22000, 28000, {7, 8}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {28000, 36000, {10, 9}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 44000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 52000, {13, 11}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, + {52000, 68000, {15, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {68000, 96001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 24000hz 2ch ***/ + {16000, 24000, {2, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {5, 6}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 36000, {7, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {10, 9}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {12, 9}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 76000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 128001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 32000hz 1ch ***/ + {24000, 36000, {4, 4}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 60000, {7, 6}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 8}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {72000, 100000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 160001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 32000hz 2ch ***/ + {32000, 60000, {4, 4}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {11, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {12, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 256001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 44100hz 1ch ***/ + {12000, 16000, {0, 0}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {16000, 22000, {1, 1}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {22000, 30000, {2, 3}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {30000, 36000, {4, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 40000, {5, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {40000, 48000, {6, 5}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {48000, 60000, {7, 6}, 1, {3, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 6}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, + {72000, 88000, {10, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {88000, 160001, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {160001, 288001, {13, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 44100hz 2ch ***/ + {12000, 16000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {16000, 22000, {1, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {22000, 26000, {2, 1}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {26000, 30000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {30000, 34000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {34000, 38000, {4, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {38000, 44000, {5, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {44000, 52000, {6, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {52000, 60000, {8, 5}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {60000, 68000, {9, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {68000, 76000, {10, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 90000, {11, 7}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {90000, 112000, {11, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 132000, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {132000, 180000, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {180000, 288001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 48000hz 1ch ***/ + {12000, 16000, {0, 0}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {16000, 22000, {1, 1}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {22000, 30000, {2, 3}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {30000, 36000, {4, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 40000, {5, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {40000, 48000, {6, 5}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {48000, 60000, {7, 6}, 1, {3, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 6}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, + {72000, 88000, {10, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {88000, 160001, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {160001, 288001, {13, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 48000hz 2ch ***/ + {12000, 16000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {16000, 22000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {22000, 26000, {1, 1}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {26000, 30000, {2, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {30000, 34000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {34000, 38000, {4, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {38000, 44000, {2, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {44000, 52000, {6, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {52000, 60000, {8, 5}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {60000, 68000, {9, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {68000, 76000, {10, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 90000, {11, 7}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {90000, 112000, {11, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 132000, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {132000, 180000, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {180000, 288001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}} + + }, +#endif {{{{0}}}, {{{0}}}, From 65ed01a2f40b9635a85ef0036ccd730641afbccf Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 10 Aug 2025 10:15:44 +0700 Subject: [PATCH 09/28] update encode --- cmake/utils.cmake | 1 + encoder/ixheaace_sbr_main.c | 2 +- encoder/ixheaace_sbr_rom.h | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 5d9cd37..3196501 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -51,6 +51,7 @@ function(libxaac_add_definitions) add_definitions(-DX86_64 -D_X86_64_) endif() add_definitions(-DLOUDNESS_LEVELING_SUPPORT) + add_definitions(-DAAC_NEW_TABLES) endfunction() # Adds libraries needed for executables diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index 522870d..9e00eab 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -100,7 +100,7 @@ FLOAT32 *ixheaace_get_hbe_resample_buffer(ixheaace_pstr_sbr_enc pstr_env_enc) { static FLAG ia_enhaacplus_enc_get_sbr_tuning_table_idx( UWORD32 bitrate, UWORD32 num_ch, UWORD32 sample_rate, ixheaace_str_qmf_tabs *pstr_qmf_tab, UWORD32 *ptr_closest_br, WORD32 *ptr_idx_sr, WORD32 *ptr_idx_ch, WORD32 *ptr_idx_entry, - ixheaace_sbr_tuning_tables sbr_tune_table[10][2][10]) { + ixheaace_sbr_tuning_tables sbr_tune_table[10][2][16]) { WORD32 found = 0; WORD32 i_sr, br_closest_lower_idx_sr = -1, br_closest_upper_idx_sr = -1; WORD32 br_closest_lower_idx_ch = -1, br_closest_upper_idx_sch = -1; diff --git a/encoder/ixheaace_sbr_rom.h b/encoder/ixheaace_sbr_rom.h index c4dc0e6..55ec490 100644 --- a/encoder/ixheaace_sbr_rom.h +++ b/encoder/ixheaace_sbr_rom.h @@ -120,8 +120,8 @@ typedef struct { ixheaace_str_frame_info_sbr frame_480_info4_2048; const FLOAT32 ptr_smooth_filter[4]; UWORD32 supported_sample_rate[9]; - ixheaace_sbr_tuning_tables sbr_tuning_table_lc[10][2][10]; - ixheaace_sbr_tuning_tables sbr_tuning_table_ld[10][2][10]; + ixheaace_sbr_tuning_tables sbr_tuning_table_lc[10][2][16]; + ixheaace_sbr_tuning_tables sbr_tuning_table_ld[10][2][16]; } ixheaace_str_qmf_tabs; typedef struct { From b21dc24ee59ae227f8e4719fef7f352983fd05db Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 10 Aug 2025 10:18:01 +0700 Subject: [PATCH 10/28] size again --- encoder/ixheaace_sbr_main.c | 2 +- encoder/ixheaace_sbr_rom.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index 9e00eab..9e13b13 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -100,7 +100,7 @@ FLOAT32 *ixheaace_get_hbe_resample_buffer(ixheaace_pstr_sbr_enc pstr_env_enc) { static FLAG ia_enhaacplus_enc_get_sbr_tuning_table_idx( UWORD32 bitrate, UWORD32 num_ch, UWORD32 sample_rate, ixheaace_str_qmf_tabs *pstr_qmf_tab, UWORD32 *ptr_closest_br, WORD32 *ptr_idx_sr, WORD32 *ptr_idx_ch, WORD32 *ptr_idx_entry, - ixheaace_sbr_tuning_tables sbr_tune_table[10][2][16]) { + ixheaace_sbr_tuning_tables sbr_tune_table[10][2][20]) { WORD32 found = 0; WORD32 i_sr, br_closest_lower_idx_sr = -1, br_closest_upper_idx_sr = -1; WORD32 br_closest_lower_idx_ch = -1, br_closest_upper_idx_sch = -1; diff --git a/encoder/ixheaace_sbr_rom.h b/encoder/ixheaace_sbr_rom.h index 55ec490..59b2eef 100644 --- a/encoder/ixheaace_sbr_rom.h +++ b/encoder/ixheaace_sbr_rom.h @@ -120,8 +120,8 @@ typedef struct { ixheaace_str_frame_info_sbr frame_480_info4_2048; const FLOAT32 ptr_smooth_filter[4]; UWORD32 supported_sample_rate[9]; - ixheaace_sbr_tuning_tables sbr_tuning_table_lc[10][2][16]; - ixheaace_sbr_tuning_tables sbr_tuning_table_ld[10][2][16]; + ixheaace_sbr_tuning_tables sbr_tuning_table_lc[10][2][20]; + ixheaace_sbr_tuning_tables sbr_tuning_table_ld[10][2][20]; } ixheaace_str_qmf_tabs; typedef struct { From 938e3892fb1274eb08705c3693b84104e4cf1a10 Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 10 Aug 2025 10:20:00 +0700 Subject: [PATCH 11/28] tns too --- encoder/ixheaace_rom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_rom.h b/encoder/ixheaace_rom.h index eb9e882..e85b300 100644 --- a/encoder/ixheaace_rom.h +++ b/encoder/ixheaace_rom.h @@ -100,7 +100,7 @@ typedef struct { extern const ixheaace_quant_tables ixheaace_enc_quant_tab; typedef struct { const ixheaace_temporal_noise_shaping_max_table tns_max_bands_table[12]; - const ixheaace_temporal_noise_shaping_info_tab tns_info_tab[5]; + const ixheaace_temporal_noise_shaping_info_tab tns_info_tab[6]; const FLOAT32 tns_coeff_3[8]; const FLOAT32 tns_coeff_3_borders[8]; const FLOAT32 tns_coeff_4[16]; From aadabc426a99c8aca593c838d10756a0fc6ff475 Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 10 Aug 2025 11:46:26 +0700 Subject: [PATCH 12/28] new eld bitrates --- encoder/ixheaace_sbr_rom.c | 140 +++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 5ecdc6c..1a9daa7 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -970,6 +970,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { }, #endif +#ifndef AAC_NEW_TABLES {{{{0}}}, {{{0}}}, @@ -1056,7 +1057,146 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {144000, 176000, {12, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {176000, 256001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}} +#else + {{{{0}}}, + {{{0}}}, + + {{ + /*** 12000hz 1ch ***/ + {8000, 32000, {1, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + {0}}}, + + {{ + /*** 16000hz 1ch ***/ + {8000, 10000, {1, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {10000, 12000, {2, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {12000, 16000, {4, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 18000, {4, 9}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {18000, 22000, {7, 12}, 3, {1, 6, 9}, IXHEAACE_SBR_MODE_MONO}, + {22000, 28000, {6, 9}, 3, {2, 3, 6}, IXHEAACE_SBR_MODE_MONO}, + {28000, 36000, {8, 12}, 3, {2, 9, 12}, IXHEAACE_SBR_MODE_MONO}, + {36000, 44000, {10, 12}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 64001, {11, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 16000hz 2ch ***/ + {16000, 24000, {4, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {8, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 36000, {10, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {13, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {10, 11}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 76000, {14, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 22050hz 1ch ***/ + {8000, 11369, {1, 1}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {11369, 16000, {1, 3}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 18000, {2, 4}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {18000, 22000, {4, 5}, 3, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {22000, 28000, {5, 6}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {28000, 36000, {7, 8}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 44000, {9, 9}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 52000, {12, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {52000, 70000, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {70000, 88001, {14, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 22050hz 2ch ***/ + {16000, 24000, {0, 0}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {3, 5}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 32000, {3, 7}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {32000, 36000, {5, 7}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {5, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {7, 8}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {9, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 76000, {10, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 82000, {12, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {82000, 128001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 24000hz 1ch ***/ + {8000, 12000, {1, 1}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {12000, 16000, {1, 3}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {16000, 18000, {1, 4}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, + {18000, 22000, {4, 8}, 2, {2, 3, 6}, IXHEAACE_SBR_MODE_MONO}, + {22000, 28000, {3, 8}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {28000, 36000, {4, 8}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 56000, {8, 9}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {56000, 70000, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {70000, 88001, {14, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 24000hz 2ch ***/ + {16000, 24000, {0, 0}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {24000, 28000, {3, 5}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {28000, 36000, {5, 7}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {36000, 44000, {4, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {44000, 52000, {6, 8}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {52000, 60000, {9, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 76000, {11, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 88000, {12, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {88000, 128001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 32000hz 1ch ***/ + {24000, 36000, {4, 4}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 60000, {7, 6}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 8}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {72000, 100000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 160001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 32000hz 2ch ***/ + {32000, 60000, {4, 4}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {9, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {11, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 256001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 44100hz 1ch ***/ + {24000, 36000, {4, 9}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 60000, {8, 6}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {72000, 100000, {11, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 160001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 44100hz 2ch ***/ + {32000, 60000, {4, 4}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {10, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {12, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 256001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}, + + {{ + /*** 48000hz 1ch ***/ + {24000, 36000, {4, 3}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 60000, {4, 4}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {72000, 100000, {11, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 160001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {0}}, + { + /*** 48000hz 2ch ***/ + {32000, 60000, {4, 9}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 10}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {9, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {11, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 176000, {12, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {176000, 256001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {0}}}} +#endif }; /*End of QMF Tables*/ From 80a67bda85225d6c4a1b122691004dec170c0612 Mon Sep 17 00:00:00 2001 From: wrapper Date: Mon, 11 Aug 2025 13:01:12 +0700 Subject: [PATCH 13/28] fix broken freq scaling --- encoder/ixheaace_sbr_freq_scaling.c | 66 ++++++++++++++++++----------- encoder/ixheaace_sbr_rom.c | 3 ++ encoder/ixheaace_sbr_rom.h | 3 ++ 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/encoder/ixheaace_sbr_freq_scaling.c b/encoder/ixheaace_sbr_freq_scaling.c index 7eec5a9..192907e 100644 --- a/encoder/ixheaace_sbr_freq_scaling.c +++ b/encoder/ixheaace_sbr_freq_scaling.c @@ -158,31 +158,31 @@ static WORD32 ixheaace_get_start_freq(WORD32 fs, WORD32 start_freq) { WORD32 minimum_k0; switch (fs) { - case 16000: + case 8000: minimum_k0 = 24; break; - case 22050: + case 11025: minimum_k0 = 17; break; - case 24000: + case 12000: minimum_k0 = 16; break; - case 32000: + case 16000: minimum_k0 = 16; break; - case 44100: + case 22050: minimum_k0 = 12; break; - case 48000: + case 24000: minimum_k0 = 11; break; - case 64000: + case 32000: minimum_k0 = 10; break; - case 88200: + case 44100: minimum_k0 = 7; break; - case 96000: + case 48000: minimum_k0 = 7; break; default: @@ -190,30 +190,30 @@ static WORD32 ixheaace_get_start_freq(WORD32 fs, WORD32 start_freq) { } switch (fs) { - case 16000: { + case 8000: { return (minimum_k0 + vector_offset_16k[start_freq]); } break; - case 22050: { + case 11025: { return (minimum_k0 + vector_offset_22k[start_freq]); } break; - case 24000: { + case 12000: { return (minimum_k0 + vector_offset_24k[start_freq]); } break; - case 32000: { + case 16000: { return (minimum_k0 + vector_offset_32k[start_freq]); } break; - case 44100: - case 48000: - case 64000: { + case 22050: + case 24000: + case 32000: { return (minimum_k0 + vector_offset_44_48_64[start_freq]); } break; - case 88200: - case 96000: { + case 44100: + case 48000: { return (minimum_k0 + vector_offset_88_96[start_freq]); } break; @@ -230,36 +230,54 @@ static WORD32 ixheaace_get_stop_freq(WORD32 fs, WORD32 stop_freq) { WORD32 v_dstop[13]; switch (fs) { - case 16000: + case 8000: k1_min = ixheaace_stop_freq_16k[0]; v_stop_freq = (WORD32 *)&ixheaace_stop_freq_16k[0]; break; - case 22050: + case 11025: k1_min = ixheaace_stop_freq_22k[0]; v_stop_freq = (WORD32 *)&ixheaace_stop_freq_22k[0]; break; - case 24000: + case 12000: k1_min = ixheaace_stop_freq_24k[0]; v_stop_freq = (WORD32 *)&ixheaace_stop_freq_24k[0]; break; - case 32000: + case 16000: k1_min = 32; v_stop_freq = (WORD32 *)vector_stop_freq_32; break; - case 44100: + case 22050: k1_min = 23; v_stop_freq = (WORD32 *)vector_stop_freq_44; break; - case 48000: + case 24000: k1_min = 21; v_stop_freq = (WORD32 *)vector_stop_freq_48; break; + case 32000: + k1_min = 20; + + v_stop_freq = (WORD32 *)vector_stop_freq_64; + break; + + case 44100: + k1_min = 15; + + v_stop_freq = (WORD32 *)vector_stop_freq_88; + break; + + case 48000: + k1_min = 13; + + v_stop_freq = (WORD32 *)vector_stop_freq_96; + break; + default: v_stop_freq = (WORD32 *)vector_stop_freq_32; k1_min = 21; /* illegal fs */ diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 1a9daa7..435fc2e 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -48,6 +48,9 @@ const WORD32 vector_offset_def[] = {0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 2 const WORD32 vector_stop_freq_32[14] = {32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64}; const WORD32 vector_stop_freq_44[14] = {23, 25, 27, 29, 32, 34, 37, 40, 43, 47, 51, 55, 59, 64}; const WORD32 vector_stop_freq_48[14] = {21, 23, 25, 27, 30, 32, 35, 38, 42, 45, 49, 54, 59, 64}; +const WORD32 vector_stop_freq_64[14] = {20, 22, 24, 26, 28, 31, 34, 37, 41, 45, 49, 54, 59, 64}; +const WORD32 vector_stop_freq_88[14] = {15, 17, 19, 21, 23, 26, 29, 33, 37, 41, 46, 51, 57, 64}; +const WORD32 vector_stop_freq_96[14] = {13, 15, 17, 19, 21, 24, 27, 31, 35, 39, 44, 50, 57, 64}; const ixheaace_str_ps_tab ia_enhaacplus_enc_ps_tab = { /*a_hyb_res[3]*/ diff --git a/encoder/ixheaace_sbr_rom.h b/encoder/ixheaace_sbr_rom.h index 59b2eef..02ca808 100644 --- a/encoder/ixheaace_sbr_rom.h +++ b/encoder/ixheaace_sbr_rom.h @@ -181,6 +181,9 @@ extern const WORD32 vector_offset_def[]; extern const WORD32 vector_stop_freq_32[14]; extern const WORD32 vector_stop_freq_44[14]; extern const WORD32 vector_stop_freq_48[14]; +extern const WORD32 vector_stop_freq_64[14]; +extern const WORD32 vector_stop_freq_88[14]; +extern const WORD32 vector_stop_freq_96[14]; /* Resampler tables */ extern const ixheaace_resampler_table ixheaace_resamp_2_to_1_iir_filt_params; From b743f48ca1b6e828fbaec722218711c8413da02f Mon Sep 17 00:00:00 2001 From: wrapper Date: Mon, 11 Aug 2025 17:27:52 +0700 Subject: [PATCH 14/28] going pic --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82539b7..4996c67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,3 +27,5 @@ include("${XAAC_ROOT}/encoder/libxaacenc.cmake") include("${XAAC_ROOT}/test/encoder/xaacenc.cmake") include("${XAAC_ROOT}/fuzzer/xaac_enc_fuzzer.cmake") +set_property(TARGET libxaacenc PROPERTY POSITION_INDEPENDENT_CODE 1) +set_property(TARGET libxaacdec PROPERTY POSITION_INDEPENDENT_CODE 1) From d3d43727c5cfc3f16ce75af7b3961921acbf26af Mon Sep 17 00:00:00 2001 From: wrapper Date: Wed, 13 Aug 2025 07:17:36 +0700 Subject: [PATCH 15/28] fix freq scaling again --- encoder/ixheaace_api.c | 2 +- encoder/ixheaace_sbr_freq_scaling.c | 64 ++++++++++++++--------------- encoder/ixheaace_sbr_main.c | 2 +- encoder/ixheaace_sbr_rom.c | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/encoder/ixheaace_api.c b/encoder/ixheaace_api.c index 22fe7e4..ea870d4 100644 --- a/encoder/ixheaace_api.c +++ b/encoder/ixheaace_api.c @@ -1215,7 +1215,7 @@ 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_api_struct->config[0].aac_config.band_width = pstr_input_config->aac_config.bandwidth; } diff --git a/encoder/ixheaace_sbr_freq_scaling.c b/encoder/ixheaace_sbr_freq_scaling.c index 192907e..e3e7921 100644 --- a/encoder/ixheaace_sbr_freq_scaling.c +++ b/encoder/ixheaace_sbr_freq_scaling.c @@ -158,31 +158,31 @@ static WORD32 ixheaace_get_start_freq(WORD32 fs, WORD32 start_freq) { WORD32 minimum_k0; switch (fs) { - case 8000: + case 16000: minimum_k0 = 24; break; - case 11025: + case 22050: minimum_k0 = 17; break; - case 12000: - minimum_k0 = 16; - break; - case 16000: - minimum_k0 = 16; - break; - case 22050: - minimum_k0 = 12; - break; case 24000: - minimum_k0 = 11; + minimum_k0 = 16; break; case 32000: - minimum_k0 = 10; + minimum_k0 = 16; break; case 44100: - minimum_k0 = 7; + minimum_k0 = 12; break; case 48000: + minimum_k0 = 11; + break; + case 64000: + minimum_k0 = 10; + break; + case 88200: + minimum_k0 = 7; + break; + case 96000: minimum_k0 = 7; break; default: @@ -190,30 +190,30 @@ static WORD32 ixheaace_get_start_freq(WORD32 fs, WORD32 start_freq) { } switch (fs) { - case 8000: { + case 16000: { return (minimum_k0 + vector_offset_16k[start_freq]); } break; - case 11025: { + case 22050: { return (minimum_k0 + vector_offset_22k[start_freq]); } break; - case 12000: { + case 24000: { return (minimum_k0 + vector_offset_24k[start_freq]); } break; - case 16000: { + case 32000: { return (minimum_k0 + vector_offset_32k[start_freq]); } break; - case 22050: - case 24000: - case 32000: { + case 44100: + case 48000: + case 64000: { return (minimum_k0 + vector_offset_44_48_64[start_freq]); } break; - case 44100: - case 48000: { + case 88200: + case 96000: { return (minimum_k0 + vector_offset_88_96[start_freq]); } break; @@ -230,49 +230,49 @@ static WORD32 ixheaace_get_stop_freq(WORD32 fs, WORD32 stop_freq) { WORD32 v_dstop[13]; switch (fs) { - case 8000: + case 16000: k1_min = ixheaace_stop_freq_16k[0]; v_stop_freq = (WORD32 *)&ixheaace_stop_freq_16k[0]; break; - case 11025: + case 22050: k1_min = ixheaace_stop_freq_22k[0]; v_stop_freq = (WORD32 *)&ixheaace_stop_freq_22k[0]; break; - case 12000: + case 24000: k1_min = ixheaace_stop_freq_24k[0]; v_stop_freq = (WORD32 *)&ixheaace_stop_freq_24k[0]; break; - case 16000: + case 32000: k1_min = 32; v_stop_freq = (WORD32 *)vector_stop_freq_32; break; - case 22050: + case 44100: k1_min = 23; v_stop_freq = (WORD32 *)vector_stop_freq_44; break; - case 24000: + case 48000: k1_min = 21; v_stop_freq = (WORD32 *)vector_stop_freq_48; break; - case 32000: + case 64000: k1_min = 20; v_stop_freq = (WORD32 *)vector_stop_freq_64; break; - case 44100: + case 88200: k1_min = 15; v_stop_freq = (WORD32 *)vector_stop_freq_88; break; - case 48000: + case 96000: k1_min = 13; v_stop_freq = (WORD32 *)vector_stop_freq_96; diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index 9e13b13..b8594e8 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -967,7 +967,7 @@ ixheaace_env_open(ixheaace_pstr_sbr_enc *pstr_env_encoder, ixheaace_pstr_sbr_cfg pstr_env_enc->str_sbr_cfg.stereo_mode = (params->codec_settings.num_channels == 2) ? params->stereo_mode : IXHEAACE_SBR_MODE_MONO; - if (params->codec_settings.sample_freq <= 24000) { + if (params->codec_settings.sample_freq <= 24000 || !params->is_ld_sbr) { pstr_env_enc->str_sbr_hdr.sample_rate_mode = IXHEAACE_DUAL_RATE; if (params->sbr_codec == USAC_SBR) { pstr_env_enc->str_sbr_cfg.sample_freq = 2 * params->codec_settings.sample_freq; diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 435fc2e..8856138 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -1068,7 +1068,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {{ /*** 12000hz 1ch ***/ {8000, 32000, {1, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, - {0}}, + {0}}, { {0}}}, From 68e3e867f82fac0c38a331dfc09cd30b9f0b5c41 Mon Sep 17 00:00:00 2001 From: wrapper Date: Thu, 14 Aug 2025 09:56:39 +0700 Subject: [PATCH 16/28] fix stop freq --- encoder/ixheaace_sbr_rom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 8856138..576b3bc 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -48,7 +48,7 @@ const WORD32 vector_offset_def[] = {0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 2 const WORD32 vector_stop_freq_32[14] = {32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64}; const WORD32 vector_stop_freq_44[14] = {23, 25, 27, 29, 32, 34, 37, 40, 43, 47, 51, 55, 59, 64}; const WORD32 vector_stop_freq_48[14] = {21, 23, 25, 27, 30, 32, 35, 38, 42, 45, 49, 54, 59, 64}; -const WORD32 vector_stop_freq_64[14] = {20, 22, 24, 26, 28, 31, 34, 37, 41, 45, 49, 54, 59, 64}; +const WORD32 vector_stop_freq_64[14] = {20, 22, 24, 26, 29, 31, 34, 37, 41, 45, 49, 54, 59, 64}; const WORD32 vector_stop_freq_88[14] = {15, 17, 19, 21, 23, 26, 29, 33, 37, 41, 46, 51, 57, 64}; const WORD32 vector_stop_freq_96[14] = {13, 15, 17, 19, 21, 24, 27, 31, 35, 39, 44, 50, 57, 64}; From 06aa3c1ba5aa49f1b96c4e99d33a4862424eed3f Mon Sep 17 00:00:00 2001 From: wrapper Date: Thu, 14 Aug 2025 10:58:44 +0700 Subject: [PATCH 17/28] fix stop freq 2 --- encoder/ixheaace_sbr_freq_scaling.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/encoder/ixheaace_sbr_freq_scaling.c b/encoder/ixheaace_sbr_freq_scaling.c index e3e7921..1f08fbd 100644 --- a/encoder/ixheaace_sbr_freq_scaling.c +++ b/encoder/ixheaace_sbr_freq_scaling.c @@ -231,16 +231,16 @@ static WORD32 ixheaace_get_stop_freq(WORD32 fs, WORD32 stop_freq) { switch (fs) { case 16000: - k1_min = ixheaace_stop_freq_16k[0]; - v_stop_freq = (WORD32 *)&ixheaace_stop_freq_16k[0]; + k1_min = ixheaace_usac_stop_freq_16k[0]; + v_stop_freq = (WORD32 *)&ixheaace_usac_stop_freq_16k[0]; break; case 22050: - k1_min = ixheaace_stop_freq_22k[0]; - v_stop_freq = (WORD32 *)&ixheaace_stop_freq_22k[0]; + k1_min = ixheaace_usac_stop_freq_22k[0]; + v_stop_freq = (WORD32 *)&ixheaace_usac_stop_freq_22k[0]; break; case 24000: - k1_min = ixheaace_stop_freq_24k[0]; - v_stop_freq = (WORD32 *)&ixheaace_stop_freq_24k[0]; + k1_min = ixheaace_usac_stop_freq_24k[0]; + v_stop_freq = (WORD32 *)&ixheaace_usac_stop_freq_24k[0]; break; case 32000: k1_min = 32; From b828e892751ddf59aca1dc624045133baad031e5 Mon Sep 17 00:00:00 2001 From: wrapper Date: Thu, 14 Aug 2025 13:42:29 +0700 Subject: [PATCH 18/28] fix sbr setting --- encoder/ixheaace_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_api.c b/encoder/ixheaace_api.c index ea870d4..749cac6 100644 --- a/encoder/ixheaace_api.c +++ b/encoder/ixheaace_api.c @@ -2478,7 +2478,7 @@ static IA_ERRORCODE ia_enhaacplus_enc_init(ixheaace_api_struct *pstr_api_struct, pstr_aac_config->bit_rate, (pstr_api_struct->pstr_state->mps_enable ? 1 - : pstr_api_struct->config[ele_idx].chmode_nchannels), + : pstr_aac_config->num_out_channels), pstr_aac_config->sample_rate, &core_sample_rate, pstr_api_struct->spectral_band_replication_tabs.ptr_qmf_tab, pstr_api_struct->pstr_state->aot)) { From ddcb11cbc86158269439ff2c9d234bbd89a242b6 Mon Sep 17 00:00:00 2001 From: wrapper Date: Thu, 14 Aug 2025 16:55:43 +0700 Subject: [PATCH 19/28] fix mean division by 0 --- encoder/ixheaace_sbr_noise_floor_est.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/encoder/ixheaace_sbr_noise_floor_est.c b/encoder/ixheaace_sbr_noise_floor_est.c index c5fcd99..344d2b0 100644 --- a/encoder/ixheaace_sbr_noise_floor_est.c +++ b/encoder/ixheaace_sbr_noise_floor_est.c @@ -136,8 +136,10 @@ static VOID ia_enhaacplus_enc_qmf_based_noise_floor_detection( mean_org += ton_org; mean_sbr += ton_sbr; } - mean_org /= (stop_channel - start_channel); - mean_sbr /= (stop_channel - start_channel); + if ((stop_channel - start_channel) > 0) { + mean_org /= (stop_channel - start_channel); + mean_sbr /= (stop_channel - start_channel); + } } if (mean_org < SBR_TON_MEAN_P0009 && mean_sbr < SBR_TON_MEAN_P0009) { From f398a9836342e6d57ec7eb8e837936fa6796c25e Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 15 Aug 2025 13:12:09 +0700 Subject: [PATCH 20/28] correct aot --- decoder/ixheaacd_api.c | 3 +++ decoder/ixheaacd_struct_def.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index c4ae8e0..53cb371 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -940,6 +940,7 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_xheaac_dec_obj, WORD32 i_cmd, } else { *pui_value = p_obj_exhaacplus_dec->p_state_aac->audio_object_type; } + if (*pui_value == AOT_AAC_LC) *pui_value = p_obj_exhaacplus_dec->p_state_aac->init_sbr_flag ? (p_obj_exhaacplus_dec->p_state_aac->init_ps_flag ? AOT_PS : AOT_SBR) : AOT_AAC_LC; } else { *pui_value = AOT_AAC_LC; } @@ -2530,6 +2531,8 @@ IA_ERRORCODE ixheaacd_dec_init( p_obj_exhaacplus_dec->aac_config.ui_n_channels = num_channels_1; p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; p_state_enhaacplus_dec->ui_init_done = 1; + p_state_enhaacplus_dec->init_sbr_flag = sbr_present_flag; + p_state_enhaacplus_dec->init_ps_flag = p_obj_exhaacplus_dec->aac_config.ui_sbr_mode == 1; memcpy(it_bit_buff, &temp_bit_buff, sizeof(struct ia_bit_buf_struct)); diff --git a/decoder/ixheaacd_struct_def.h b/decoder/ixheaacd_struct_def.h index fea3b56..8518407 100644 --- a/decoder/ixheaacd_struct_def.h +++ b/decoder/ixheaacd_struct_def.h @@ -162,6 +162,8 @@ typedef struct ia_aac_dec_state_struct { UWORD32 ui_input_over; UWORD32 header_dec_done; WORD32 frame_counter; + WORD32 init_sbr_flag; + WORD32 init_ps_flag; ia_aac_decoder_struct *pstr_aac_dec_info[MAX_BS_ELEMENT]; UWORD32 ch_config; From 90c8770efeb21a51f0707c13bfc6747b94333421 Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 15 Aug 2025 14:13:18 +0700 Subject: [PATCH 21/28] fix aot detect --- decoder/ixheaacd_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index 53cb371..2645d4a 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -2532,7 +2532,7 @@ IA_ERRORCODE ixheaacd_dec_init( p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; p_state_enhaacplus_dec->ui_init_done = 1; p_state_enhaacplus_dec->init_sbr_flag = sbr_present_flag; - p_state_enhaacplus_dec->init_ps_flag = p_obj_exhaacplus_dec->aac_config.ui_sbr_mode == 1; + p_state_enhaacplus_dec->init_ps_flag = p_obj_exhaacplus_dec->aac_config.ui_channel_mode == 1; memcpy(it_bit_buff, &temp_bit_buff, sizeof(struct ia_bit_buf_struct)); From 1feae4f6e0c884610b19feb65ae08c3497bb6caf Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 15 Aug 2025 14:18:49 +0700 Subject: [PATCH 22/28] again --- decoder/ixheaacd_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index 2645d4a..3504a10 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -2532,7 +2532,7 @@ IA_ERRORCODE ixheaacd_dec_init( p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; p_state_enhaacplus_dec->ui_init_done = 1; p_state_enhaacplus_dec->init_sbr_flag = sbr_present_flag; - p_state_enhaacplus_dec->init_ps_flag = p_obj_exhaacplus_dec->aac_config.ui_channel_mode == 1; + p_state_enhaacplus_dec->init_ps_flag = !p_obj_exhaacplus_dec->aac_config.ui_channel_mode; memcpy(it_bit_buff, &temp_bit_buff, sizeof(struct ia_bit_buf_struct)); From ce9ef54af5d08f4ffdde2b11b8436cdf4a73d076 Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 22 Aug 2025 16:06:28 +0700 Subject: [PATCH 23/28] add downsampled frequency scaling --- encoder/ixheaace_sbr_freq_scaling.c | 38 +++++++++++++++++++++++++++++ encoder/ixheaace_sbr_freq_scaling.h | 4 +++ encoder/ixheaace_sbr_main.c | 13 ++++++++++ encoder/ixheaace_sbr_main.h | 2 ++ 4 files changed, 57 insertions(+) diff --git a/encoder/ixheaace_sbr_freq_scaling.c b/encoder/ixheaace_sbr_freq_scaling.c index 1f08fbd..3df4e07 100644 --- a/encoder/ixheaace_sbr_freq_scaling.c +++ b/encoder/ixheaace_sbr_freq_scaling.c @@ -371,6 +371,44 @@ ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs) return result; } +WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs) { + WORD32 result; + + if (stop_freq < 0 || stop_freq > 13) { + return -1; + } + + result = ixheaace_get_stop_freq(fs, stop_freq); + + result = (result * fs / qmf_bands + 1) >> 1; + + return result; +} + +WORD32 ixheaace_get_downsampled_stop_freq(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs, + WORD32 start_freq, ixheaace_sr_mode sample_rate_mode, + WORD32 sbr_ratio_idx, ixheaace_sbr_codec_type sbr_codec) +{ + WORD32 new_stop_freq; + WORD32 stop_freq_downsampled = fs / 4; + WORD32 result; + WORD32 k0; + WORD32 k2; + + while (stop_freq && ixheaace_get_sbr_stop_freq_raw(stop_freq, qmf_bands, fs) > stop_freq_downsampled) { + stop_freq--; + } + + new_stop_freq = ixheaace_get_sbr_stop_freq_raw(stop_freq, qmf_bands, fs); + if (new_stop_freq > stop_freq_downsampled) return -1; + + result = ixheaace_find_start_and_stop_band(fs, qmf_bands / 2, start_freq, stop_freq, + sample_rate_mode, &k0, &k2, sbr_ratio_idx, sbr_codec); + if (result != IA_NO_ERROR) return -1; + + return stop_freq; +} + static WORD32 ixheaace_number_of_bands(WORD32 b_p_o, WORD32 start, WORD32 stop, FLOAT32 warp_fac) { WORD32 result = 0; diff --git a/encoder/ixheaace_sbr_freq_scaling.h b/encoder/ixheaace_sbr_freq_scaling.h index fe107e1..29e74b1 100644 --- a/encoder/ixheaace_sbr_freq_scaling.h +++ b/encoder/ixheaace_sbr_freq_scaling.h @@ -43,3 +43,7 @@ ixheaace_find_start_and_stop_band(const WORD32 sampling_freq, const WORD32 num_c ixheaace_sbr_codec_type sbr_codec); WORD32 ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs); +WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs); +WORD32 ixheaace_get_downsampled_stop_freq(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs, + WORD32 start_freq, ixheaace_sr_mode sample_rate_mode, + WORD32 sbr_ratio_idx, ixheaace_sbr_codec_type sbr_codec); \ No newline at end of file diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index b8594e8..273446f 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -435,6 +435,7 @@ VOID ixheaace_adjust_sbr_settings(const ixheaace_pstr_sbr_cfg pstr_config, UWORD UWORD32 std_br, ixheaace_str_qmf_tabs *pstr_qmf_tab, WORD32 aot, WORD32 is_esbr_4_1) { FLAG table_found = IXHEAACE_TABLE_IDX_NOT_FOUND; + WORD32 downsample_stop; WORD32 idx_sr = 0; WORD32 idx_ch = 0; WORD32 idx_entry = 0; @@ -514,6 +515,16 @@ VOID ixheaace_adjust_sbr_settings(const ixheaace_pstr_sbr_cfg pstr_config, UWORD } } + if (pstr_config->is_single_rate) { + downsample_stop = ixheaace_get_downsampled_stop_freq(pstr_config->stop_freq, IXHEAACE_QMF_CHANNELS, fs_core, + pstr_config->start_freq, IXHEAACE_SINGLE_RATE, pstr_config->sbr_ratio_idx, + pstr_config->sbr_codec); + if (downsample_stop >= 0) { + pstr_config->is_single_rate_found = 1; + pstr_config->stop_freq = downsample_stop; + } + } + if (pstr_config->sbr_codec == ELD_SBR) { pstr_config->send_header_data_time = -1; if ((num_ch == NUM_CHANS_MONO) && (bit_rate <= 22000)) { @@ -597,6 +608,8 @@ VOID ixheaace_initialize_sbr_defaults(ixheaace_pstr_sbr_cfg pstr_config) { pstr_config->sbr_harmonic = 0; pstr_config->sbr_ratio_idx = 0; // NO_SBR pstr_config->use_low_freq_res = 0; + pstr_config->is_single_rate = 0; + pstr_config->is_single_rate_found = 0; } static IA_ERRORCODE ia_enhaacplus_enc_update_freq_band_tab( diff --git a/encoder/ixheaace_sbr_main.h b/encoder/ixheaace_sbr_main.h index f84dccd..9456ca9 100644 --- a/encoder/ixheaace_sbr_main.h +++ b/encoder/ixheaace_sbr_main.h @@ -85,6 +85,8 @@ typedef struct ixheaace_str_sbr_cfg { WORD32 hq_esbr; ixheaace_sbr_codec_type sbr_codec; WORD32 use_low_freq_res; + WORD32 is_single_rate; + WORD32 is_single_rate_found; } ixheaace_str_sbr_cfg, *ixheaace_pstr_sbr_cfg; typedef struct ixheaace_str_sbr_enc *ixheaace_pstr_sbr_enc; From c10720f05ddcff8022bf61df5ab0283be9dcdda1 Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 22 Aug 2025 19:34:35 +0700 Subject: [PATCH 24/28] Revert "add downsampled frequency scaling" This reverts commit ce9ef54af5d08f4ffdde2b11b8436cdf4a73d076. --- encoder/ixheaace_sbr_freq_scaling.c | 38 ----------------------------- encoder/ixheaace_sbr_freq_scaling.h | 4 --- encoder/ixheaace_sbr_main.c | 13 ---------- encoder/ixheaace_sbr_main.h | 2 -- 4 files changed, 57 deletions(-) diff --git a/encoder/ixheaace_sbr_freq_scaling.c b/encoder/ixheaace_sbr_freq_scaling.c index 3df4e07..1f08fbd 100644 --- a/encoder/ixheaace_sbr_freq_scaling.c +++ b/encoder/ixheaace_sbr_freq_scaling.c @@ -371,44 +371,6 @@ ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs) return result; } -WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs) { - WORD32 result; - - if (stop_freq < 0 || stop_freq > 13) { - return -1; - } - - result = ixheaace_get_stop_freq(fs, stop_freq); - - result = (result * fs / qmf_bands + 1) >> 1; - - return result; -} - -WORD32 ixheaace_get_downsampled_stop_freq(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs, - WORD32 start_freq, ixheaace_sr_mode sample_rate_mode, - WORD32 sbr_ratio_idx, ixheaace_sbr_codec_type sbr_codec) -{ - WORD32 new_stop_freq; - WORD32 stop_freq_downsampled = fs / 4; - WORD32 result; - WORD32 k0; - WORD32 k2; - - while (stop_freq && ixheaace_get_sbr_stop_freq_raw(stop_freq, qmf_bands, fs) > stop_freq_downsampled) { - stop_freq--; - } - - new_stop_freq = ixheaace_get_sbr_stop_freq_raw(stop_freq, qmf_bands, fs); - if (new_stop_freq > stop_freq_downsampled) return -1; - - result = ixheaace_find_start_and_stop_band(fs, qmf_bands / 2, start_freq, stop_freq, - sample_rate_mode, &k0, &k2, sbr_ratio_idx, sbr_codec); - if (result != IA_NO_ERROR) return -1; - - return stop_freq; -} - static WORD32 ixheaace_number_of_bands(WORD32 b_p_o, WORD32 start, WORD32 stop, FLOAT32 warp_fac) { WORD32 result = 0; diff --git a/encoder/ixheaace_sbr_freq_scaling.h b/encoder/ixheaace_sbr_freq_scaling.h index 29e74b1..fe107e1 100644 --- a/encoder/ixheaace_sbr_freq_scaling.h +++ b/encoder/ixheaace_sbr_freq_scaling.h @@ -43,7 +43,3 @@ ixheaace_find_start_and_stop_band(const WORD32 sampling_freq, const WORD32 num_c ixheaace_sbr_codec_type sbr_codec); WORD32 ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs); -WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs); -WORD32 ixheaace_get_downsampled_stop_freq(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs, - WORD32 start_freq, ixheaace_sr_mode sample_rate_mode, - WORD32 sbr_ratio_idx, ixheaace_sbr_codec_type sbr_codec); \ No newline at end of file diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index 273446f..b8594e8 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -435,7 +435,6 @@ VOID ixheaace_adjust_sbr_settings(const ixheaace_pstr_sbr_cfg pstr_config, UWORD UWORD32 std_br, ixheaace_str_qmf_tabs *pstr_qmf_tab, WORD32 aot, WORD32 is_esbr_4_1) { FLAG table_found = IXHEAACE_TABLE_IDX_NOT_FOUND; - WORD32 downsample_stop; WORD32 idx_sr = 0; WORD32 idx_ch = 0; WORD32 idx_entry = 0; @@ -515,16 +514,6 @@ VOID ixheaace_adjust_sbr_settings(const ixheaace_pstr_sbr_cfg pstr_config, UWORD } } - if (pstr_config->is_single_rate) { - downsample_stop = ixheaace_get_downsampled_stop_freq(pstr_config->stop_freq, IXHEAACE_QMF_CHANNELS, fs_core, - pstr_config->start_freq, IXHEAACE_SINGLE_RATE, pstr_config->sbr_ratio_idx, - pstr_config->sbr_codec); - if (downsample_stop >= 0) { - pstr_config->is_single_rate_found = 1; - pstr_config->stop_freq = downsample_stop; - } - } - if (pstr_config->sbr_codec == ELD_SBR) { pstr_config->send_header_data_time = -1; if ((num_ch == NUM_CHANS_MONO) && (bit_rate <= 22000)) { @@ -608,8 +597,6 @@ VOID ixheaace_initialize_sbr_defaults(ixheaace_pstr_sbr_cfg pstr_config) { pstr_config->sbr_harmonic = 0; pstr_config->sbr_ratio_idx = 0; // NO_SBR pstr_config->use_low_freq_res = 0; - pstr_config->is_single_rate = 0; - pstr_config->is_single_rate_found = 0; } static IA_ERRORCODE ia_enhaacplus_enc_update_freq_band_tab( diff --git a/encoder/ixheaace_sbr_main.h b/encoder/ixheaace_sbr_main.h index 9456ca9..f84dccd 100644 --- a/encoder/ixheaace_sbr_main.h +++ b/encoder/ixheaace_sbr_main.h @@ -85,8 +85,6 @@ typedef struct ixheaace_str_sbr_cfg { WORD32 hq_esbr; ixheaace_sbr_codec_type sbr_codec; WORD32 use_low_freq_res; - WORD32 is_single_rate; - WORD32 is_single_rate_found; } ixheaace_str_sbr_cfg, *ixheaace_pstr_sbr_cfg; typedef struct ixheaace_str_sbr_enc *ixheaace_pstr_sbr_enc; From e33d5a718e134f8014cc6e4bb82ffc8c13d5ab2f Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 22 Aug 2025 19:35:23 +0700 Subject: [PATCH 25/28] make dual rate unlikely --- encoder/ixheaace_sbr_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index b8594e8..f67cbad 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -967,7 +967,7 @@ ixheaace_env_open(ixheaace_pstr_sbr_enc *pstr_env_encoder, ixheaace_pstr_sbr_cfg pstr_env_enc->str_sbr_cfg.stereo_mode = (params->codec_settings.num_channels == 2) ? params->stereo_mode : IXHEAACE_SBR_MODE_MONO; - if (params->codec_settings.sample_freq <= 24000 || !params->is_ld_sbr) { + if (0) { pstr_env_enc->str_sbr_hdr.sample_rate_mode = IXHEAACE_DUAL_RATE; if (params->sbr_codec == USAC_SBR) { pstr_env_enc->str_sbr_cfg.sample_freq = 2 * params->codec_settings.sample_freq; From 29b7a4eb4c532f37e41e26c86d5f9d16ae05d9c3 Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 22 Aug 2025 19:48:17 +0700 Subject: [PATCH 26/28] fix --- encoder/ixheaace_sbr_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index f67cbad..62928da 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -967,7 +967,7 @@ ixheaace_env_open(ixheaace_pstr_sbr_enc *pstr_env_encoder, ixheaace_pstr_sbr_cfg pstr_env_enc->str_sbr_cfg.stereo_mode = (params->codec_settings.num_channels == 2) ? params->stereo_mode : IXHEAACE_SBR_MODE_MONO; - if (0) { + if (1) { pstr_env_enc->str_sbr_hdr.sample_rate_mode = IXHEAACE_DUAL_RATE; if (params->sbr_codec == USAC_SBR) { pstr_env_enc->str_sbr_cfg.sample_freq = 2 * params->codec_settings.sample_freq; From d2211d963d3b1827c00580be94f6684ebc8de2d0 Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 24 Aug 2025 09:14:50 +0700 Subject: [PATCH 27/28] retweak --- encoder/ixheaace_sbr_rom.c | 144 ++++++++++++++----------------------- 1 file changed, 53 insertions(+), 91 deletions(-) diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 576b3bc..0a739ed 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -744,7 +744,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { }, #else {{{ - /*** 8000hz 1ch ***/ + /*** 8000hz 1ch SBR_AAC ***/ {8000, 10000, {7, 11}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {11, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 16000, {14, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -753,7 +753,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {32000, 48001, {14, 15}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 8000hz 2ch ***/ + /*** 8000hz 2ch SBR_AAC ***/ {16000, 24000, {6, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {9, 11}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {11, 11}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -765,7 +765,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {0}}}, {{ - /*** 11025hz 1ch ***/ + /*** 11025hz 1ch SBR_AAC ***/ {8000, 10000, {5, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {8, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 16000, {12, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -773,10 +773,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {20000, 24000, {13, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {24000, 32000, {14, 14}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {32000, 48000, {15, 15}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {48000, 64001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {48000, 66001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 11025hz 2ch ***/ + /*** 11025hz 2ch SBR_AAC ***/ {16000, 24000, {7, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {10, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {12, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -784,11 +784,11 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {14, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 132301, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 12000hz 1ch ***/ + /*** 12000hz 1ch SBR_AAC ***/ {8000, 10000, {4, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {7, 11}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 16000, {11, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -796,10 +796,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {20000, 24000, {12, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {24000, 32000, {13, 13}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {32000, 48000, {14, 14}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {48000, 64001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {48000, 72001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 12000hz 2ch ***/ + /*** 12000hz 2ch SBR_AAC ***/ {16000, 24000, {6, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {9, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {11, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -807,11 +807,11 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {13, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {14, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 144001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 16000hz 1ch ***/ + /*** 16000hz 1ch SBR_AAC ***/ {6000, 8000, {0, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {8000, 10000, {1, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {2, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -821,10 +821,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {22000, 28000, {10, 12}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {28000, 36000, {12, 13}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {36000, 44000, {14, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {44000, 64001, {15, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 96001, {15, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 16000hz 2ch ***/ + /*** 16000hz 2ch SBR_AAC ***/ {16000, 24000, {4, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {8, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {10, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -832,11 +832,11 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {15, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 192001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 22050hz 1ch ***/ + /*** 22050hz 1ch SBR_AAC ***/ {8000, 11369, {1, 1}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {11369, 16000, {3, 4}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {16000, 18000, {3, 5}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -844,12 +844,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {22000, 28000, {7, 8}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {28000, 36000, {10, 9}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {36000, 44000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {44000, 52000, {13, 11}, 1, {2, 0, 0}, IXHEAACE_SBR_MODE_MONO}, - {52000, 68000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {68000, 96001, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 132151, {13, 12}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 22050hz 2ch ***/ + /*** 22050hz 2ch SBR_AAC ***/ {16000, 24000, {2, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {5, 6}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 32000, {5, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -858,11 +856,11 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {12, 9}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 101000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {101000, 128001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {101000, 264601, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 24000hz 1ch ***/ + /*** 24000hz 1ch SBR_AAC ***/ {8000, 12000, {1, 1}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 16000, {3, 4}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {16000, 18000, {3, 5}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -870,12 +868,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {22000, 28000, {7, 8}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {28000, 36000, {10, 9}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {36000, 44000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {44000, 52000, {13, 11}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, - {52000, 68000, {15, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {68000, 96001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 144001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 24000hz 2ch ***/ + /*** 24000hz 2ch SBR_AAC ***/ {16000, 24000, {2, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {5, 6}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {7, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -883,92 +879,58 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {12, 9}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 76000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 128001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 288001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 32000hz 1ch ***/ + /*** 32000hz 1ch SBR_AAC ***/ {24000, 36000, {4, 4}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {36000, 60000, {7, 6}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {60000, 72000, {9, 8}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {72000, 100000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {100000, 160001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 192001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 32000hz 2ch ***/ + /*** 32000hz 2ch SBR_AAC ***/ {32000, 60000, {4, 4}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {60000, 80000, {11, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {80000, 112000, {12, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {112000, 144000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {144000, 256001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {60000, 80000, {7, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {9, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {11, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 384001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 44100hz 1ch ***/ - {12000, 16000, {0, 0}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {16000, 22000, {1, 1}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {22000, 30000, {2, 3}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {30000, 36000, {4, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {36000, 40000, {5, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {40000, 48000, {6, 5}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {48000, 60000, {7, 6}, 1, {3, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {60000, 72000, {9, 6}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, - {72000, 88000, {10, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {88000, 160001, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {160001, 288001, {13, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + /*** 44100hz 1ch SBR_AAC ***/ + {24000, 36000, {4, 4}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 60000, {7, 6}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 8}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {72000, 100000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 264601, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 44100hz 2ch ***/ - {12000, 16000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {16000, 22000, {1, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {22000, 26000, {2, 1}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {26000, 30000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {30000, 34000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {34000, 38000, {4, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {38000, 44000, {5, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {44000, 52000, {6, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {52000, 60000, {8, 5}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {60000, 68000, {9, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {68000, 76000, {10, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 90000, {11, 7}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {90000, 112000, {11, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {112000, 132000, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {132000, 180000, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {180000, 288001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + /*** 44100hz 2ch SBR_AAC ***/ + {32000, 60000, {4, 4}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {9, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {11, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 529201, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 48000hz 1ch ***/ - {12000, 16000, {0, 0}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {16000, 22000, {1, 1}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {22000, 30000, {2, 3}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {30000, 36000, {4, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {36000, 40000, {5, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {40000, 48000, {6, 5}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {48000, 60000, {7, 6}, 1, {3, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {60000, 72000, {9, 6}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, - {72000, 88000, {10, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {88000, 160001, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {160001, 288001, {13, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + /*** 48000hz 1ch SBR_AAC ***/ + {24000, 36000, {4, 9}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 60000, {7, 10}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {72000, 100000, {11, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 288001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 48000hz 2ch ***/ - {12000, 16000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {16000, 22000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {22000, 26000, {1, 1}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {26000, 30000, {2, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {30000, 34000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {34000, 38000, {4, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {38000, 44000, {2, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {44000, 52000, {6, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {52000, 60000, {8, 5}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {60000, 68000, {9, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {68000, 76000, {10, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 90000, {11, 7}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {90000, 112000, {11, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {112000, 132000, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {132000, 180000, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {180000, 288001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + /*** 48000hz 2ch SBR_AAC ***/ + {32000, 60000, {4, 9}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 10}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {9, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {11, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 576001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}} }, From 1e660479c865ba2af3f86a4bf9ccd00289817243 Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 24 Aug 2025 13:31:40 +0700 Subject: [PATCH 28/28] fix sbr 2 --- encoder/ixheaace_sbr_rom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 0a739ed..bb52192 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -927,7 +927,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { { /*** 48000hz 2ch SBR_AAC ***/ {32000, 60000, {4, 9}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {60000, 80000, {7, 10}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 10}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {80000, 112000, {9, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {112000, 144000, {11, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {144000, 576001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT},