Log in

View Full Version : SSRC strangeness in dec 31 binary


Mug Funky
6th January 2004, 14:17
hi y'all.

first up, thanks HEAPS for including SSRC in avisynth. it rocks the house.

just one strangeness i've found though...

in certain cases SSRC cannot convert the sample rate. for example, i have a 44100 PAL source, slow it down to 24fps (samplerate now 42336 hz) and SSRC(44100) works fine. but if i assumefps(23.976, sync_audio=true), yielding 42294 hz, SSRC(44100) throws an error: could not resample between the 2 samplerates.

changing it to SSRC(44200) or SSRC(44000) yield working clips at 23.976

are there just some sample rates that SSRC cannot handle? my current workaround is to put this in my script:

SSRC(44200).SSRC(44100)

but i'd prefer not to chain 2 filters together as i'm sure speed and possibly quality (i have no idea what SSRC does internally :P) will suffer.

JohnMK
7th January 2004, 00:59
An invisible post by sh0dan?

sh0dan
7th January 2004, 10:33
Hey!?!? Where did my post go??? :confused: :confused:

Must have been deleted by the SQL-cleanup that was done yesterday (I posted just before it happened).

Anyway - SSRC has some internal limitations on which samplerates it can convert between. Naoki must have put this in for a reason.

Mug Funky
7th January 2004, 14:53
okay. that's fair enough.
*sobs*

:D nice work by the way. i've been consistently impressed by the fact that as soon as i think of something that would be great in avisynth, it gets included in the next binary. SSRC is awesome.

sh0dan
7th January 2004, 15:44
It's my job to read your mind! :D

BTW - new CVS binary up.

Wilbert
9th January 2004, 23:30
The invisible post by Sh0dan (the cases when resampling can be done), including two examples:


int CanResample(int sfrq,int dfrq)
{
if (sfrq==dfrq) return 1;
int frqgcd = gcd(sfrq,dfrq);

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;
}
}


example 1 (upsampling: 44100 -> 48000):

sfrq = 44100
dfrq = 48000

frqgcd = gcd(44100,48000) = 300 (the greatest common divisor)

fs1 = sfrq / frqgcd * dfrq = 7056000

fs1/dfrq = 147 which is not a multiple of 2
fs1/dfrq = 147 = 3*49 which is a multiple of 3

thus a 1 is returned, and the resampling is done.

example 2 (downsampling: 48000 -> 44100):

sfrq = 48000
dfrq = 44100

frqgcd = gcd(48000,44100) = 300 (the greatest common divisor)

fs1 = sfrq / frqgcd * dfrq = 7056000

dfrq/frqgcd = 160 which is a multiple of 2

thus a 1 is returned, and the resampling is done.

I hope the examples are clear :)