/// <summary>Marshals a FLAC entropy coding method</summary> /// <param name="frameHandle"> /// Handle to unmanaged memory containing the entropy coding method /// </param> /// <param name="offset"> /// Offset at which to begin reading this entropy coding method /// </param> /// <returns>The marshaled entropy coding method</returns> private static EntropyCodingMethod marshalEntropyCodingMethod( IntPtr frameHandle, int offset ) { EntropyCodingMethod entropyCodingMethod = new EntropyCodingMethod(); entropyCodingMethod.Type = EntropyCodingMethodTypeFromInt( Marshal.ReadInt32(frameHandle, offset) ); switch (entropyCodingMethod.Type) { // Rice Partition Coding scheme 1 case EntropyCodingMethodType.PartitionedRice: { entropyCodingMethod.PartitionedRice.Order = Marshal.ReadInt32( frameHandle, offset + 4 ); IntPtr contentsAddress = Marshal.ReadIntPtr(frameHandle, offset + 8); entropyCodingMethod.PartitionedRice.Contents.Parameters = null; entropyCodingMethod.PartitionedRice.Contents.RawBits = null; entropyCodingMethod.PartitionedRice.Contents.CapacityByOrder = Marshal.ReadInt32( contentsAddress, 8 ); break; } // Rice Partition Coding scheme 2 case EntropyCodingMethodType.PartitionedRice2: { entropyCodingMethod.PartitionedRice.Order = Marshal.ReadInt32( frameHandle, offset + 4 ); IntPtr contentsAddress = Marshal.ReadIntPtr(frameHandle, offset + 8); entropyCodingMethod.PartitionedRice.Contents.Parameters = null; entropyCodingMethod.PartitionedRice.Contents.RawBits = null; entropyCodingMethod.PartitionedRice.Contents.CapacityByOrder = Marshal.ReadInt32( contentsAddress, 8 ); break; } } return(entropyCodingMethod); }
/// <summary>Marshals a FLAC entropy coding method</summary> /// <param name="frameHandle"> /// Handle to unmanaged memory containing the entropy coding method /// </param> /// <param name="offset"> /// Offset at which to begin reading this entropy coding method /// </param> /// <returns>The marshaled entropy coding method</returns> private static EntropyCodingMethod marshalEntropyCodingMethod( IntPtr frameHandle, int offset ) { EntropyCodingMethod entropyCodingMethod = new EntropyCodingMethod(); entropyCodingMethod.Type = EntropyCodingMethodTypeFromInt( Marshal.ReadInt32(frameHandle, offset) ); switch(entropyCodingMethod.Type) { // Rice Partition Coding scheme 1 case EntropyCodingMethodType.PartitionedRice: { entropyCodingMethod.PartitionedRice.Order = Marshal.ReadInt32( frameHandle, offset + 4 ); IntPtr contentsAddress = Marshal.ReadIntPtr(frameHandle, offset + 8); entropyCodingMethod.PartitionedRice.Contents.Parameters = null; entropyCodingMethod.PartitionedRice.Contents.RawBits = null; entropyCodingMethod.PartitionedRice.Contents.CapacityByOrder = Marshal.ReadInt32( contentsAddress, 8 ); break; } // Rice Partition Coding scheme 2 case EntropyCodingMethodType.PartitionedRice2: { entropyCodingMethod.PartitionedRice.Order = Marshal.ReadInt32( frameHandle, offset + 4 ); IntPtr contentsAddress = Marshal.ReadIntPtr(frameHandle, offset + 8); entropyCodingMethod.PartitionedRice.Contents.Parameters = null; entropyCodingMethod.PartitionedRice.Contents.RawBits = null; entropyCodingMethod.PartitionedRice.Contents.CapacityByOrder = Marshal.ReadInt32( contentsAddress, 8 ); break; } } return entropyCodingMethod; }