示例#1
0
        private void PrepareFixedSubframe(int order, int subframeBitsPerSample)
        {
            int[] warmupSamples = new int[order];
            for (int i = 0; i < order; i++)
            {
                warmupSamples[i] = bitReader.ReadSignedBits(subframeBitsPerSample - this.wastedBitsPerSample);
            }

            IEnumerator <int> residual  = ReadResidualData(bitReader, BlockSize, order);
            IPredictor        predictor = PredictorFactory.CreateFixedPredictor(order, RemoveLastItem(warmupSamples));

            dataSource = GetPredictorSamples(BlockSize, warmupSamples, predictor, residual);
        }
        private FlacMethod FindBestFixedMethod(int[] channelSamples, int bitsPerSample, FlacEncodingPolicy policy)
        {
            if (!policy.FixedOrder.HasValue)
            {
                return(null);
            }

            int minFixedOrder = policy.FixedOrder.Value.MinValue;
            int maxFixedOrder = Math.Min(channelSamples.Length - 1,
                                         policy.FixedOrder.Value.MaxValue);

            FlacMethod[] methods = new FlacMethod[maxFixedOrder + 1];
            parallel.For(minFixedOrder, maxFixedOrder + 1, order =>
            {
                IPredictor predictor = PredictorFactory.CreateFixedPredictor(order, ArrayUtils.CutArray(channelSamples, 0, order - 1));
                FlacResidualCoefficeints residual = FindBestResidual(channelSamples, order, predictor, policy);

                FlacMethod method = new FlacFixedMethod(bitsPerSample, order, residual);
                methods[order]    = method;
            });

            return(FindBestMethod(methods));
        }
示例#3
0
 internal override IPredictor CreatePredictor(int[] samples)
 {
     return(PredictorFactory.CreateFixedPredictor(Order, samples));
 }