internal override FlacMethod FindBestMethod(int[] channelSamples, int bitsPerSample) { int i = 1; int firstSample = channelSamples[0]; while (i < channelSamples.Length && channelSamples[i] == firstSample) i++; if (i == channelSamples.Length) { // constant method will be better than other methods return new FlacConstantMethod(bitsPerSample); } FlacMethod verbatimMethod; verbatimMethod = new FlacVerbatimMethod( channelSamples.Length, bitsPerSample); FlacMethod fixedMethod = null, lpcMethod = null; parallel.Invoke( delegate { fixedMethod = FindBestFixedMethod(channelSamples, bitsPerSample, policy); }, delegate { lpcMethod = FindBestLpcMethod(channelSamples, bitsPerSample, policy); } ); return FindBestMethod(new FlacMethod[] { verbatimMethod, fixedMethod, lpcMethod }); }
internal override FlacMethod FindBestMethod(int[] channelSamples, int bitsPerSample) { int i = 1; int firstSample = channelSamples[0]; while (i < channelSamples.Length && channelSamples[i] == firstSample) { i++; } if (i == channelSamples.Length) { // constant method will be better than other methods return(new FlacConstantMethod(bitsPerSample)); } FlacMethod verbatimMethod; verbatimMethod = new FlacVerbatimMethod( channelSamples.Length, bitsPerSample); FlacMethod fixedMethod = null, lpcMethod = null; parallel.Invoke( delegate { fixedMethod = FindBestFixedMethod(channelSamples, bitsPerSample, policy); }, delegate { lpcMethod = FindBestLpcMethod(channelSamples, bitsPerSample, policy); } ); return(FindBestMethod(new FlacMethod[] { verbatimMethod, fixedMethod, lpcMethod })); }