Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Apparent bug in SSRC (Read 9578 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Apparent bug in SSRC

There appears to be problems with SSRC when compiled using Microsofts compilers, compiling ssrc.exe in VC v6 (without modification) gives the bug, but ssrc compiled with gcc seems not to (atleast the supplied gcc already compiled ssrc). It appears to be a rounding error in data lengths, so not really a bug but something brought on through compiler differences.

To recreate (I am guessing SSRC downsampling in foobar might have the same problem), downsample this file (a strange part triangle wave, don't try to play it though speakers):

http://www.dbpoweramp.com/beta/SSRC-48khz-Source.wav

64KB

Down-sample it to 44100 HZ, then look at the resulting wave in a wave editor, around sample 5010 there are 22 bad samples ~ 57ms in.

So...my first question is has anyone seen this before?

Looking at the code, at the end of a down sample pass it is copying too many samples across from the end of buffer 2 down to the beginning of buffer 2:

Code: [Select]
  
int ds = (rp2-1)/(fs2/fs1);

if (ds > n1b2)
 ds = n1b2;
// <<<<<<<< BUG IS here somewhere  moving 35 sample from end of buffer even though only 34 samples, there is a NAN after that
for(ch = 0; ch < nch; ch++)
memmove(buf2[ch],buf2[ch]+ds,sizeof(REAL_SSRC)*(n2x+1+n1b2-ds));

rp2 -= ds*(fs2/fs1);

for(ch = 0; ch < nch; ch++)
  memcpy(buf2[ch]+n2x+1,buf1[ch]+n1b2,sizeof(REAL_SSRC)*n1b2);


My next question, what is the best way of debugging with gcc? in windows, if I can step that code in gcc it should be an easy fix.

Apparent bug in SSRC

Reply #1
Quote
My next question, what is the best way of debugging with gcc? in windows, if I can step that code in gcc it should be an easy fix.[a href="index.php?act=findpost&pid=300938"][{POST_SNAPBACK}][/a]

You can use gdb (GNU debugger), but it might take a while to get used to. I usually printf my debug information, FWIW.

Apparent bug in SSRC

Reply #2
Quote
There appears to be problems with SSRC when compiled using Microsofts compilers, compiling ssrc.exe in VC v6 (without modification) gives the bug...
[a href="index.php?act=findpost&pid=300938"][{POST_SNAPBACK}][/a]


Does that mean you have not applied any VC6 service packs?  If so, that's bad.

Apparent bug in SSRC

Reply #3
>compiling ssrc.exe in VC v6 (without modification) gives the bug...

Sorry I meant, ssrc code without modification (ie create a new project, drop in the ssrc source files, add the define BIGENDINESS and compile). My vc 6 is sp5.

Apparent bug in SSRC

Reply #4
Quote
You can use gdb (GNU debugger), but it might take a while to get used to. I usually printf my debug information, FWIW.
[a href="index.php?act=findpost&pid=300968"][{POST_SNAPBACK}][/a]


Can gcc output debug files that are intel compatible? (ie so I can debug in visual studio).

Apparent bug in SSRC

Reply #5
Quote
Can gcc output debug files that are intel compatible? (ie so I can debug in visual studio).
If it does I don't know about it, and googling didn't help either... gcc --help -v says this amongst many things:

Code: [Select]
-g                          Generate debug information in default format
-gcoff                      Generate debug information in COFF format
-gdwarf-2                   Generate debug information in DWARF v2 format
-ggdb                       Generate debug information in default extended
-gstabs                     Generate debug information in STABS format
-gstabs+                    Generate debug information in extended STABS
-gvms                       Generate debug information in VMS format
-gxcoff                     Generate debug information in XCOFF format
-gxcoff+                    Generate debug information in extended XCOFF

I forgot to mention, you might want to try Dev-C++, an IDE for MinGW. I think it integrates gdb quite nicely, although I haven't used it much.

Apparent bug in SSRC

Reply #6
>-gcoff                      Generate debug information in COFF format

Thanks, visual c++ can work with this AFAIK.

Apparent bug in SSRC

Reply #7
There are some other "real" bugs in ssrc to. It has a problem with dithering, which i reported a long time ago.  Ssrc also has some problems with very short files (i.e. 100 samples).

Apparent bug in SSRC

Reply #8
Still investigating, it is not down to compilers rather the difference between HighPrecission mode and non (16384 taps in the FIR filter and samples are not being moved correctly in buffers), with 65536 taps it works in that example but I suspect there will be combinations where that would fail also.

I will see if I can bug fix it. It will be worth the effort as many people seem to use SSRC.

What were the problems with the dither? (not that I use those routines).

as far short data samples missing data, I just put in an extra 10,000 or so samples and on the last block scale back to what it should be (calculated), seems to work.

Apparent bug in SSRC

Reply #9
Quote
Still investigating, it is not down to compilers rather the difference between HighPrecission mode and non (16384 taps in the FIR filter and samples are not being moved correctly in buffers), with 65536 taps it works in that example but I suspect there will be combinations where that would fail also.

I will see if I can bug fix it. It will be worth the effort as many people seem to use SSRC.

What were the problems with the dither? (not that I use those routines).

as far short data samples missing data, I just put in an extra 10,000 or so samples and on the last block scale back to what it should be (calculated), seems to work.
[{POST_SNAPBACK}][/a]

the dither problems are described in [a href="http://www.hydrogenaudio.org/forums/index.php?showtopic=25197&hl=]http://www.hydrogenaudio.org/forums/index....topic=25197&hl=[/url]

Im very interested in the bugs and how to solve them since i use ssrc myself, so please share the info when you know a little more about the bugs.

About adding 10000 samples, i dont know why that is necesary. I just use ssrc with my own input and output buffering and i have no problems, even with very short files. I dont need to add extra samples.

Apparent bug in SSRC

Reply #10
Bug fixed!!!

on line 1157 of ssrc:

    for(i=0;i<nch;i++) {
      buf2 = malloc(sizeof(REAL)*(n2x+1+n1b2));
      for(j=0;j<n2x+n1b2;j++) buf2[j] = 0;
    }

buf2 is not cleared to the last sample, and that sample is being used (later when running the filter the last sample is buf2[][]+=buf1[]  this bad sample is causing multiple samples later on to go > 1.

To fix clear to the last sample:

    for(i=0;i<nch;i++) {
      buf2 = malloc(sizeof(REAL)*(n2x+1+n1b2));
      for(j=0;j<n2x+n1b2+1;j++) buf2[j] = 0;
    }

a propper fix and not a fudge, so I am happy. It was hard to find because that cell was being added to later in the code not another sample moved, I was looking for a bug where moving samples was wrong.

About theo pushing blank samples, I found when upsampling (or might have been downsampling) say you had a very short audio file, say 800 bytes and you push it through ssrc I wasn't getting the right samples out (there were still some stuck in the fir delay line), so a simple fix was to push more than needed and remove those extra ones at the end (through simple maths you can tell how many real samples went in and how many should have come out).

Apparent bug in SSRC

Reply #11
Fix applied on my side, thanks for your report and contribution.
Microsoft Windows: We can't script here, this is bat country.

Apparent bug in SSRC

Reply #12
if this bug is against the vanilla ssrc codebase, perhaps a diff/patch can be offered for future usage?


later


Apparent bug in SSRC

Reply #14
Quote
I don't know if Mr Shibatch is active[a href="index.php?act=findpost&pid=304047"][{POST_SNAPBACK}][/a]


He isn't.