Log in

View Full Version : SSRC: which is correct?


Chikuzen
16th February 2012, 12:12
I tried follow script,
ColorBars()
AssumeSampleRate(48000)
SSRC(40000, false)
and got error "SSRC: could not to resample between two samplerates." with both avs2.58 and avs2.60alpha3.

According to docs (http://avisynth.org/mediawiki/SSRC), these samplerates must be proper.

fs1 / dfrq = sfrq / frqgcd = 48000 / 8000 = 6
6 % 2 = 0 (also 6 % 3 = 0)

but code(SSRC.cpp) says as follows
if (dfrq>sfrq){
int fs1 = sfrq / frqgcd * dfrq;
if (fs1/dfrq == 1) return 1;
else if (fs1/dfrq % 2 == 0) return 1;
else if (fs1/dfrq % 3 == 0) return 1;
else return 0;
} else {
if (dfrq/frqgcd == 1) return 1;
else if (dfrq/frqgcd % 2 == 0) return 1;
else if (dfrq/frqgcd % 3 == 0) return 1;
else return 0;
}
Which is correct between docs and code :confused:

IanB
16th February 2012, 23:10
The documentation seem to be incomplete. That condition applies only for dest freq > source freq. i.e. for the class Upsampler case.

Your case is dest freq < source freq, and the reciprocal test needs to be applied. i.e. for the class Downsampler case.

40000 / 8000 = 5 and 5 is not mod 2 or mod 3.


You can work around the restriction by using ResampleAudio (http://avisynth.org/mediawiki/ResampleAudio) or doing it in 2 passes, i.e. ColorBars()
AssumeSampleRate(48000)
SSRC(80000, false)
SSRC(40000, false)SSRC typically uses a sinc window between 2 and 3 times more than ResampleAudio, which theoretically makes is more accurate. When SSRC was added to Avisynth (v2.5.4), ResampleAudio only worked with 16 bit samples, it has since (v2.5.6) been enhanced to support float samples. For 48000 <-> 44100 both filters far exceed the requirements of 16bit audio. Doing 2 conversions may negate any advantages SSRC has over ResampleAudio.

Chikuzen
17th February 2012, 09:27
i see, :thanks:

EDIT:
I fixed the descliption of the doc.
http://avisynth.org/mediawiki/SSRC