Beispiel #1
0
 public static int a52_syncinfo(ReadOnlySpan <byte> span, out eFrameFlags flags, out int sampleRate, out int bitRate)
 {
     unsafe
     {
         fixed(byte *p = span)
         return(a52_syncinfo(p, out flags, out sampleRate, out bitRate));
     }
 }
Beispiel #2
0
        void iAudioDecoder.decodeFrame(ReadOnlySpan <byte> data, byte volume)
        {
            eFrameFlags flags = channelFlags;

            liba52.a52_frame(ac3, data, flags, volume);
            // Logger.logVerbose( "a52_frame" );

            // The decoder makes 6, but since we double the blocks tell player 3 are available.
            blocksLeft = 3;
        }
Beispiel #3
0
        public static void a52_frame(IntPtr state, ReadOnlySpan <byte> span, eFrameFlags flags, byte volume)
        {
            flags |= eFrameFlags.AdjustLevel;
            // Set the bias so the complete range maps to [ 383.0f .. 385.0f ] interval.
            // These particular magic numbers result in 16-bit samples in the lowest 16 bits of the float mantissa: https://www.h-schmidt.net/FloatConverter/IEEE754.html
            // This way we only need a few integer SIMD instructions to convert, very fast.
            // Specifically, AMD64 code uses _mm_sub_epi32 and _mm_packs_epi32, NEON version vsubq_s32, vqmovn_s32 and vcombine_s16.
            // Both _mm_packs_epi32 and vqmovn_s32 instructions use saturation to clip values into the range of int16_t, exactly what we need for PCM audio.
            float level = volume * (1.0f / 255.0f);
            float bias  = 384;

            unsafe
            {
                fixed(byte *p = span)
                if (0 != a52_frame(state, p, ref flags, &level, bias))
                {
                    throw new ApplicationException("liba52.a52_frame failed");
                }
            }
        }
Beispiel #4
0
 static unsafe extern int a52_frame(IntPtr state, byte *buffer, ref eFrameFlags flags, float *level, float bias);
Beispiel #5
0
 static unsafe extern int a52_syncinfo(byte *buffer, out eFrameFlags flags, out int sampleRate, out int bitRate);