Menu

Bug in dithering

dofu
2023-01-16
2024-08-15
  • dofu

    dofu - 2023-01-16

    In system that 'unsigned long' is 32-bit(i.e. Windows, 32-bit Linux), dithering is not working as expected.

    In those systems, dithering has pattern of every 16 samples. Later 8 samples are always ±0.

     0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
     0  1  0  0 -1  0  0 -1  0  0  0  0  0  0  0  0
     0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
    -1  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0
     0  1  0  0  0  0  0 -1  0  0  0  0  0  0  0  0
     0  0  0  1  0  0  1  1  0  0  0  0  0  0  0  0
     0 -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0
     0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0
     0 -1  0  0  1  0  0  0  0  0  0  0  0  0  0  0
     0  0  0 -1  0  0  0  1  0  0  0  0  0  0  0  0
     0  0  1  0  0 -1  0  0  0  0  0  0  0  0  0  0
    -1  0  0 -1  0  0  0  0  0  0  0  0  0  0  0  0
     0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
     0  0  1  1  0  0  0  1  0  0  0  0  0  0  0  0
     0  0  0  0  0  0 -1  0  0  0  0  0  0  0  0  0
     0  0  0  0  0  1 -1  1  0  0  0  0  0  0  0  0
    ...
    

    Random variable used in dithering is unsigned long.
    And it should have 56+ bits. 32-bit is not sufficient and it cause fixed 0 output.

    Attachment is fix for this bug. Note that it's not intensively tested.

     
  • dofu

    dofu - 2024-08-15

    Now this patch is being intensively used by Python-SoXR and seems like working fine.

    I'm maintaing libsoxr in my personal repository. https://github.com/dofuuz/soxr/

     

Log in to post a comment.