Skip to content

Commit f5456aa

Browse files
Merge pull request #7 from mloubout/master
Fix mulfac corner case
2 parents 3d686fe + 88c9cde commit f5456aa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

CvxCompress.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ float CvxCompress::Compress(
289289
compressed[5] = bz;
290290

291291
float glob_mulfac = global_rms != 0.0f ? 1.0f / (global_rms * scale) : 1.0f;
292+
// Some combinations of scale and global_rms lead to Inf when global_rms is very small
293+
// breaking decompression.
294+
glob_mulfac = !isfinite(glob_mulfac) ? 1.0f : glob_mulfac;
292295
compressed[6] = *((unsigned int*)&glob_mulfac);
293296
// printf("nx=%d, ny=%d, nz=%d, bx=%d, by=%d, bz=%d, mulfac=%e\n",nx,ny,nz,bx,by,bz,glob_mulfac);
294297

0 commit comments

Comments
 (0)