Commit 0c8e76d2 authored by emerit's avatar emerit
Browse files

Merge branch 'orange/fixpoint_crend_hrtf_file_format' of...

Merge branch 'orange/fixpoint_crend_hrtf_file_format' of https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec into orange/fixpoint_crend_hrtf_file_format
parents 0c7eac65 482d031e
Loading
Loading
Loading
Loading
Loading
+24 −19
Original line number Diff line number Diff line
@@ -79,56 +79,61 @@ end
%% Generate C-code tables for RENDERER_BINAURAL_FASTCONV (SHD)
if generateCustomBinaryFile
    disp('Processing HRIRs (FOA) for FastConv renderer...');
    FastConv_SHD_IR_FOA = SHD_2_ROM(hrir_file, 1, -1);
    FastConv_SHD_IR_FOA_float = SHD_2_ROM(hrir_file, 1, -1);
    
    disp('Processing HRIRs (HOA2) for FastConv renderer...');
    FastConv_SHD_IR_HOA2 = SHD_2_ROM(hrir_file, 2, -1);
    FastConv_SHD_IR_HOA2_float = SHD_2_ROM(hrir_file, 2, -1);
    
    disp('Processing HRIRs (HOA3) for FastConv renderer...');
    FastConv_SHD_IR_HOA3 = SHD_2_ROM(hrir_file, 3, -1);
    FastConv_SHD_IR_HOA3_float = SHD_2_ROM(hrir_file, 3, -1);
else
    disp('Processing HRIRs (FOA) for FastConv renderer...');
    FastConv_SHD_IR_FOA = SHD_2_ROM(hrir_file, 1, 128);
    FastConv_SHD_IR_FOA_float = SHD_2_ROM(hrir_file, 1, 128);
    
    disp('Processing HRIRs (HOA2) for FastConv renderer...');
    FastConv_SHD_IR_HOA2 = SHD_2_ROM(hrir_file, 2, 128);
    FastConv_SHD_IR_HOA2_float = SHD_2_ROM(hrir_file, 2, 128);
    
    disp('Processing HRIRs (HOA3) for FastConv renderer...');
    FastConv_SHD_IR_HOA3 = SHD_2_ROM(hrir_file, 3, 128);
    FastConv_SHD_IR_HOA3_float = SHD_2_ROM(hrir_file, 3, 128);
end

%% Generate C-code tables for RENDERER_BINAURAL_FASTCONV (SD)
disp('Processing HRIRs (SD) for FastConv renderer...');
FastConv_SD_IR = SD_2_ROM(hrir_file);
FastConv_SD_IR_float = SD_2_ROM(hrir_file);

%% Generate C-code tables for RENDERER_BINAURAL_FASTCONV_ROOM (SD)
disp('Processing BRIRs (SD) for FastConv renderer...');
FastConv_SD_BRIR = generate_BRIR_CLDFB_FASTCONV(brir_file);
FastConv_SD_BRIR_float = generate_BRIR_CLDFB_FASTCONV(brir_file);
if generateCustomBinaryFile == true
    FastConv_SD_BRIR.rev_param.rt60 = FastConv_SD_BRIR.rev_param.rt60 * 2;
    FastConv_SD_BRIR.rev_param.nrgLr = FastConv_SD_BRIR.rev_param.nrgLr * 2;
    FastConv_SD_BRIR_float.rev_param.rt60 = FastConv_SD_BRIR_float.rev_param.rt60 * 2;
    FastConv_SD_BRIR_float.rev_param.nrgLr = FastConv_SD_BRIR_float.rev_param.nrgLr * 2;
end

%% compute scaling factor and set floating point precision to word16
if generate_BE == false
    [FastConv_SHD_IR_FOA.IR, FastConv_SHD_IR_FOA.factorQ] = make_be_with_fx(FastConv_SHD_IR_FOA.IR,15);
    [FastConv_SHD_IR_HOA2.IR, FastConv_SHD_IR_HOA2.factorQ] = make_be_with_fx(FastConv_SHD_IR_HOA2.IR,15);
    [FastConv_SHD_IR_HOA3.IR, FastConv_SHD_IR_HOA3.factorQ] = make_be_with_fx(FastConv_SHD_IR_HOA3.IR,15);
    [FastConv_SD_IR.IR, FastConv_SD_IR.factorQ] = make_be_with_fx(FastConv_SD_IR.IR,15);
    [FastConv_SD_BRIR.IR, FastConv_SD_BRIR.factorQ] = make_be_with_fx(FastConv_SD_BRIR.IR,15);
    [FastConv_SD_BRIR.rev_param.rt60, FastConv_SD_BRIR.factorQ_rt60] = make_be_with_fx(FastConv_SD_BRIR.rev_param.rt60,15);
    [FastConv_SD_BRIR.rev_param.nrgLr, FastConv_SD_BRIR.factorQ_nrgLr] = make_be_with_fx(FastConv_SD_BRIR.rev_param.nrgLr,15);
    FastConv_SHD_IR_FOA = FastConv_SHD_IR_FOA_float;
    FastConv_SHD_IR_HOA2 = FastConv_SHD_IR_HOA2_float;
    FastConv_SHD_IR_HOA3 = FastConv_SHD_IR_HOA3_float;
    FastConv_SD_IR = FastConv_SD_IR_float;
    FastConv_SD_BRIR = FastConv_SD_BRIR_float;
    [FastConv_SHD_IR_FOA.IR, FastConv_SHD_IR_FOA.factorQ] = make_be_with_fx(FastConv_SHD_IR_FOA_float.IR,15);
    [FastConv_SHD_IR_HOA2.IR, FastConv_SHD_IR_HOA2.factorQ] = make_be_with_fx(FastConv_SHD_IR_HOA2_float.IR,15);
    [FastConv_SHD_IR_HOA3.IR, FastConv_SHD_IR_HOA3.factorQ] = make_be_with_fx(FastConv_SHD_IR_HOA3_float.IR,15);
    [FastConv_SD_IR.IR, FastConv_SD_IR.factorQ] = make_be_with_fx(FastConv_SD_IR_float.IR,15);
    [FastConv_SD_BRIR.IR, FastConv_SD_BRIR.factorQ] = make_be_with_fx(FastConv_SD_BRIR_float.IR,15);
    [FastConv_SD_BRIR.rev_param.rt60, FastConv_SD_BRIR.factorQ_rt60] = make_be_with_fx(FastConv_SD_BRIR_float.rev_param.rt60,15);
    [FastConv_SD_BRIR.rev_param.nrgLr, FastConv_SD_BRIR.factorQ_nrgLr] = make_be_with_fx(FastConv_SD_BRIR_float.rev_param.nrgLr,15);
    if writeRomFileOutput
        write_fastconv_rom_table(rom_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR);
    end
else
    if writeRomFileOutput
        write_fastconv_rom_table_BE(rom_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR);
        write_fastconv_rom_table_BE(rom_file, FastConv_SHD_IR_FOA_float, FastConv_SHD_IR_HOA2_float, FastConv_SHD_IR_HOA3_float, FastConv_SD_IR_float, FastConv_SD_BRIR_float);
    end
end

if writeBinaryOutput
    write_fastconv_binary_data(ivas_path, bin_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR);
    write_fastconv_binary_data(ivas_path, bin_file, FastConv_SHD_IR_FOA_float, FastConv_SHD_IR_HOA2_float, FastConv_SHD_IR_HOA3_float, FastConv_SD_IR_float, FastConv_SD_BRIR_float);
    if generateBinaryFile_fx
        write_fastconv_binary_data_fx(ivas_path, bin_file, FastConv_SHD_IR_FOA, FastConv_SHD_IR_HOA2, FastConv_SHD_IR_HOA3, FastConv_SD_IR, FastConv_SD_BRIR);
    end