Skip to content

Commit

Permalink
refactor: make silk_LTP_vq_ptrs_Q7 static safe
Browse files Browse the repository at this point in the history
DCNick3 committed Jul 4, 2024
1 parent 42d0f33 commit 868e8f4
Showing 3 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/silk/decode_parameters.rs
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ pub unsafe fn silk_decode_parameters(
&mut (*psDecCtrl).pitchL[..psDec.nb_subfr as usize],
psDec.fs_kHz,
);
cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[psDec.indices.PERIndex as usize];
cbk_ptr_Q7 = &*(*silk_LTP_vq_ptrs_Q7[psDec.indices.PERIndex as usize].as_ptr()).as_ptr();
k = 0;
while k < psDec.nb_subfr {
Ix = psDec.indices.LTPIndex[k as usize] as i32;
4 changes: 2 additions & 2 deletions src/silk/quant_LTP_gains.rs
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ pub unsafe fn silk_quant_LTP_gains(
while k < 3 {
let gain_safety: i32 = (0.4f64 * ((1) << 7) as f64 + 0.5f64) as i32;
cl_ptr_Q5 = silk_LTP_gain_BITS_Q5_ptrs[k as usize].as_ptr();
cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[k as usize];
cbk_ptr_Q7 = &*(*silk_LTP_vq_ptrs_Q7[k as usize].as_ptr()).as_ptr();
cbk_gain_ptr_Q7 = silk_LTP_vq_gain_ptrs_Q7[k as usize];
cbk_size = silk_LTP_vq_sizes[k as usize] as i32;
XX_Q17_ptr = XX_Q17;
@@ -117,7 +117,7 @@ pub unsafe fn silk_quant_LTP_gains(
}
k += 1;
}
cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[*periodicity_index as usize];
cbk_ptr_Q7 = &*(*silk_LTP_vq_ptrs_Q7[*periodicity_index as usize].as_ptr()).as_ptr();
j = 0;
while j < nb_subfr {
k = 0;
15 changes: 5 additions & 10 deletions src/silk/tables_LTP.rs
Original file line number Diff line number Diff line change
@@ -87,16 +87,11 @@ static silk_LTP_gain_vq_2: [[i8; 5]; 32] = [
[81, 5, 11, 3, 7],
[2, 0, 9, 10, 88],
];
pub static mut silk_LTP_vq_ptrs_Q7: [*const i8; 3] = unsafe {
[
&*(*silk_LTP_gain_vq_0.as_ptr().offset(0)).as_ptr().offset(0) as *const i8 as *mut i8
as *const i8,
&*(*silk_LTP_gain_vq_1.as_ptr().offset(0)).as_ptr().offset(0) as *const i8 as *mut i8
as *const i8,
&*(*silk_LTP_gain_vq_2.as_ptr().offset(0)).as_ptr().offset(0) as *const i8 as *mut i8
as *const i8,
]
};
pub static silk_LTP_vq_ptrs_Q7: [&[[i8; 5]]; 3] = [
&silk_LTP_gain_vq_0,
&silk_LTP_gain_vq_1,
&silk_LTP_gain_vq_2,
];
static silk_LTP_gain_vq_0_gain: [u8; 8] = [46, 2, 90, 87, 93, 91, 82, 98];
static silk_LTP_gain_vq_1_gain: [u8; 16] = [
109, 120, 118, 12, 113, 115, 117, 119, 99, 59, 87, 111, 63, 111, 112, 80,

0 comments on commit 868e8f4

Please sign in to comment.