Buffer size issues in jbm_pcmdsp_apa_fx.c
Basic info
- Fixed point:
- Decoder (fixed): 4263280a
Bug description
As part of debugging non-BE case in !2289 (merged), it was noticed that there were problems existing in the BASOP time-scaling implementation for IVAS in jbm_pcmdsp_apa_fx.c already in main. MR !2289 (merged) does alleviate these a bit as a side effect but proper inspection and fixing should be done. At least two cases are were identified:
- The fix that reduces the buffer size caused a difference. Namely, this change
#ifdef JBM_MEMORY_OPT
#define APA_BUF_PER_CHANNEL ( IVAS_MAX_FRAME_SIZE * 2 ) /* == twice the max. frame length */
#define APA_MAX_NUM_CHANNELS ( 12 ) /* == MAX_TRANSPORT_CHANNELS */
#else
#define APA_BUF_PER_CHANNEL ( IVAS_MAX_FRAME_SIZE * 3 )
#define APA_MAX_NUM_CHANNELS 16
#define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS )
#endif
#define APA_BUF ( APA_BUF_PER_CHANNEL * APA_MAX_NUM_CHANNELS )
The old buffer size was 960*3*16 = 46080 and the new buffer size is 960*2*13 = 23040. The former is over Word16 limit and the latter is below so this is a possible cause for problems.
- UBSAN issue (normally suppressed)
lib_dec/jbm_pcmdsp_apa_fx.c:985:36: runtime error: implicit conversion from type 'UWord16' (aka 'unsigned short') of value 34560 (16-bit, unsigned) to type 'Word16' (aka 'short') changed the value to -30976 (16-bit, signed)
#0 0xebab28 in apa_exec_ivas_fx /home/ivasman/temp/debugtemp/ivas-basop/lib_dec/jbm_pcmdsp_apa_fx.c:985:36
#1 0x488fd9 in IVAS_DEC_GetSamplesDecoder /home/ivasman/temp/debugtemp/ivas-basop/lib_dec/lib_dec_fx.c:4006:17
#2 0x4a5070 in IVAS_DEC_VoIP_GetSamples /home/ivasman/temp/debugtemp/ivas-basop/lib_dec/lib_dec_fx.c:4925:21
#3 0x43a170 in decodeVoIP /home/ivasman/temp/debugtemp/ivas-basop/apps/decoder.c:3051:28
#4 0x42bbd3 in main /home/ivasman/temp/debugtemp/ivas-basop/apps/decoder.c:658:17
#5 0x7f8d34aaad8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#6 0x7f8d34aaae3f in __libc_start_main csu/../csu/libc-start.c:392:3
#7 0x4045e4 in _start (/home/ivasman/temp/debugtemp/ivas-basop/IVAS_dec_ref+0x4045e4)
SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change lib_dec/jbm_pcmdsp_apa_fx.c:985:36 in
This points to a code row
Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out
Ways to reproduce
Following command line was causing differences in !2289 (merged).
./IVAS_cod_flt -mc 7_1_4 256000 48 ./scripts/testv/stv714MC48c.wav test.bit
./scripts/tools/Linux/networkSimulator_g192 ./scripts/dly_error_profiles/dly_error_profile_5.dat test.bit test_netsimoutput.bit tracefile_sim 2 0
./IVAS_dec -no_delay_cmp -Tracefile tracefile_dec -VOIP 7_1_4 48 test_netsimoutput.bit test_out.wav