src/dct.js
function(N) {
  cosMap = cosMap || {};
  cosMap[N] = new Array(N*N);

  var PI_N = Math.PI / N;

  for (var k = 0; k < N; k++) {
    for (var n = 0; n < N; n++) {
      cosMap[N][n + (k * N)] = Math.cos(PI_N * (n + 0.5) * k);
    }
  }
}
function(N) {
  cosMap = cosMap || {};
  cosMap[N] = new Array(N*N);

  var PI_N = Math.PI / N;

  for (var k = 0; k < N; k++) {
    for (var n = 0; n < N; n++) {
      cosMap[N][n + (k * N)] = Math.cos(PI_N * (n + 0.5) * k);
    }
  }
}
function ( N ) { cosMap = cosMap || { } ; cosMap [ N ] = new Array ( N * N ) ; var PI_N = Math . PI / N ; for ( var k = 0 ; k < N ; k ++ ) { for ( var n = 0 ; n < N ; n ++ ) { cosMap [ N ] [ n + ( k * N ) ] = Math . cos ( PI_N * ( n + 0.5 ) * k ) ; } } }
Builds a cosine map for the given input size. This allows multiple input sizes to be memoized automagically if you want to run the DCT over and over.
Builds a cosine map for the given input size . This allows multiple input sizes to be memoized automagically if you want to run the DCT over and over .