Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16 bit clipping results in values being destroyed due to fe_test_invalid() check #11

Open
TomArrow opened this issue Nov 14, 2023 · 0 comments

Comments

@TomArrow
Copy link

This took me hours to debug and I'm not even sure what I'm looking at.

This code here destroys values at the start of a variable rate resample with small increments (11-12 samples).

static void RINT_CLIP(RINT_T * const dest, FLOATX const * const src,
    unsigned stride, size_t i, size_t const n, size_t * const clips SEED_ARG)
{
  COPY_SEED
  DITHER_VARS;
  for (; i < n; ++i) {
    FLOATD const d = src[i] DITHERING;
    RINT(dest[stride * i], d);
    if (fe_test_invalid()) {
      fe_clear_invalid();
      dest[stride * i] = d > 0? RINT_MAX : -RINT_MAX - 1;
      ++*clips;
    }
  }
  SAVE_SEED;
}

I am not sure what causes this to happen. The src[i] value is a perfectly fine float value but the fe_test_invalid() returns true for some reason and the code consequently destroys the values.

Sometimes it happens, sometimes it doesn't. It seems in particular small increments for resampling seem to cause it. My code uses variable rate but this happened in cases where it was just a fixed rate of 1.000 throughout. The IO values I did sox create with were 1,1 but I also tried 1,10 and 10,1 to make sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant