Skip to content

Commit

Permalink
Merge pull request #642 from argilo/fix-polar
Browse files Browse the repository at this point in the history
Add length checks to volk_8u_x2_encodeframepolar_8u
  • Loading branch information
jdemel authored Oct 22, 2023
2 parents 1f554ce + 6e79380 commit da574b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
12 changes: 2 additions & 10 deletions kernels/volk/volk_32f_8u_polarbutterfly_32f.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,7 @@ static inline void volk_32f_8u_polarbutterfly_32f_u_avx(float* llrs,
unsigned char* u_temp = u + 2 * frame_size;
memcpy(u_temp, u + u_num - stage_size, sizeof(unsigned char) * stage_size);

if (stage_size > 15) {
volk_8u_x2_encodeframepolar_8u_u_ssse3(u_target, u_temp, stage_size);
} else {
volk_8u_x2_encodeframepolar_8u_generic(u_target, u_temp, stage_size);
}
volk_8u_x2_encodeframepolar_8u_u_ssse3(u_target, u_temp, stage_size);

src_llr_ptr = llrs + (max_stage_depth + 1) * frame_size + row - stage_size;
dst_llr_ptr = llrs + max_stage_depth * frame_size + row;
Expand Down Expand Up @@ -331,11 +327,7 @@ static inline void volk_32f_8u_polarbutterfly_32f_u_avx2(float* llrs,
unsigned char* u_temp = u + 2 * frame_size;
memcpy(u_temp, u + u_num - stage_size, sizeof(unsigned char) * stage_size);

if (stage_size > 15) {
volk_8u_x2_encodeframepolar_8u_u_ssse3(u_target, u_temp, stage_size);
} else {
volk_8u_x2_encodeframepolar_8u_generic(u_target, u_temp, stage_size);
}
volk_8u_x2_encodeframepolar_8u_u_avx2(u_target, u_temp, stage_size);

src_llr_ptr = llrs + (max_stage_depth + 1) * frame_size + row - stage_size;
dst_llr_ptr = llrs + max_stage_depth * frame_size + row;
Expand Down
20 changes: 20 additions & 0 deletions kernels/volk/volk_8u_x2_encodeframepolar_8u.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ static inline void volk_8u_x2_encodeframepolar_8u_u_ssse3(unsigned char* frame,
unsigned char* temp,
unsigned int frame_size)
{
if (frame_size < 16) {
volk_8u_x2_encodeframepolar_8u_generic(frame, temp, frame_size);
return;
}

const unsigned int po2 = log2_of_power_of_2(frame_size);

unsigned int stage = po2;
Expand Down Expand Up @@ -256,6 +261,11 @@ static inline void volk_8u_x2_encodeframepolar_8u_u_avx2(unsigned char* frame,
unsigned char* temp,
unsigned int frame_size)
{
if (frame_size < 32) {
volk_8u_x2_encodeframepolar_8u_generic(frame, temp, frame_size);
return;
}

const unsigned int po2 = log2_of_power_of_2(frame_size);

unsigned int stage = po2;
Expand Down Expand Up @@ -612,6 +622,11 @@ static inline void volk_8u_x2_encodeframepolar_8u_a_ssse3(unsigned char* frame,
unsigned char* temp,
unsigned int frame_size)
{
if (frame_size < 16) {
volk_8u_x2_encodeframepolar_8u_generic(frame, temp, frame_size);
return;
}

const unsigned int po2 = log2_of_power_of_2(frame_size);

unsigned int stage = po2;
Expand Down Expand Up @@ -790,6 +805,11 @@ static inline void volk_8u_x2_encodeframepolar_8u_a_avx2(unsigned char* frame,
unsigned char* temp,
unsigned int frame_size)
{
if (frame_size < 32) {
volk_8u_x2_encodeframepolar_8u_generic(frame, temp, frame_size);
return;
}

const unsigned int po2 = log2_of_power_of_2(frame_size);

unsigned int stage = po2;
Expand Down

0 comments on commit da574b4

Please sign in to comment.