Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions src/common/pa_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,22 @@
#define PA_MIN_( a, b ) ( ((a)<(b)) ? (a) : (b) )


/* greatest common divisor - PGCD in French */
/* greatest common divisor */
static unsigned long GCD( unsigned long a, unsigned long b )
{
return (b==0) ? a : GCD( b, a%b);
}

/* least common multiple - PPCM in French */
static unsigned long LCM( unsigned long a, unsigned long b )
{
return (a*b) / GCD(a,b);
}

#define PA_MAX_( a, b ) (((a) > (b)) ? (a) : (b))

static unsigned long CalculateFrameShift( unsigned long M, unsigned long N )
{
unsigned long result = 0;
unsigned long i;
unsigned long lcm;

assert( M > 0 );
assert( N > 0 );

lcm = LCM( M, N );
for( i = M; i < lcm; i += M )
result = PA_MAX_( result, i % N );

return result;
/*
The minimum required delay is calculated according to:
M. Rath & M. Geier, "Minimum required delay for realtime block size adaptation in digital audio signal processing",
Linux Audio Conference 2026; https://lac2026.sciencesconf.org/722511
*/
return N - GCD( M, N );
}


Expand Down
Loading