/// <summary>Marshals a FLAC LPC subframe</summary>
        /// <param name="frameHandle">Handle to unmanaged memory containing the frame</param>
        /// <param name="offset">Offset at which to begin reading this subframe</param>
        /// <returns>The marshaled LPC subframe</returns>
        private static LpcSubframe marshalLpcSubframe(IntPtr frameHandle, int offset)
        {
            LpcSubframe lpcSubframe = new LpcSubframe();

            lpcSubframe.EntropyCodingMethod = marshalEntropyCodingMethod(frameHandle, offset);
            lpcSubframe.Order = Marshal.ReadInt32(frameHandle, offset + 12);
            lpcSubframe.QlpCoefficientPrecision = Marshal.ReadInt32(frameHandle, offset + 16);
            lpcSubframe.QuantizationLevel       = Marshal.ReadInt32(frameHandle, offset + 20);

            offset += 24;

            // Marshal the array of QLP Coefficients
            lpcSubframe.QlpCoefficients = new int[Constants.MaximumLpcOrder];
            for (
                int index = 0; index < Constants.MaximumLpcOrder; ++index
                )
            {
                lpcSubframe.QlpCoefficients[index] = Marshal.ReadInt32(
                    frameHandle, offset + index * 4
                    );
            }

            offset += Constants.MaximumLpcOrder * 4;

            // Marshal the Warmup values for the LPC decoder
            lpcSubframe.Warmup = new int[Constants.MaximumLpcOrder];
            for (
                int index = 0; index < Constants.MaximumLpcOrder; ++index
                )
            {
                lpcSubframe.Warmup[index] = Marshal.ReadInt32(
                    frameHandle, offset + index * 4
                    );
            }

            offset += Constants.MaximumLpcOrder * 4;

            lpcSubframe.Residual = null;

            return(lpcSubframe);
        }
Ejemplo n.º 2
0
    /// <summary>Marshals a FLAC LPC subframe</summary>
    /// <param name="frameHandle">Handle to unmanaged memory containing the frame</param>
    /// <param name="offset">Offset at which to begin reading this subframe</param>
    /// <returns>The marshaled LPC subframe</returns>
    private static LpcSubframe marshalLpcSubframe(IntPtr frameHandle, int offset) {
      LpcSubframe lpcSubframe = new LpcSubframe();

      lpcSubframe.EntropyCodingMethod = marshalEntropyCodingMethod(frameHandle, offset);
      lpcSubframe.Order = Marshal.ReadInt32(frameHandle, offset + 12);
      lpcSubframe.QlpCoefficientPrecision = Marshal.ReadInt32(frameHandle, offset + 16);
      lpcSubframe.QuantizationLevel = Marshal.ReadInt32(frameHandle, offset + 20);

      offset += 24;

      // Marshal the array of QLP Coefficients
      lpcSubframe.QlpCoefficients = new int[Constants.MaximumLpcOrder];
      for(
        int index = 0; index < Constants.MaximumLpcOrder; ++index
      ) {
        lpcSubframe.QlpCoefficients[index] = Marshal.ReadInt32(
          frameHandle, offset + index * 4
        );
      }

      offset += Constants.MaximumLpcOrder * 4;

      // Marshal the Warmup values for the LPC decoder
      lpcSubframe.Warmup = new int[Constants.MaximumLpcOrder];
      for(
        int index = 0; index < Constants.MaximumLpcOrder; ++index
      ) {
        lpcSubframe.Warmup[index] = Marshal.ReadInt32(
          frameHandle, offset + index * 4
        );
      }

      offset += Constants.MaximumLpcOrder * 4;

      lpcSubframe.Residual = null;

      return lpcSubframe;
    }