Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of G722 Codec State for a
        /// new encode or decode session
        /// </summary>
        /// <param name="rate">Bitrate (typically 64000)</param>
        /// <param name="options">Special options</param>
        public G722CodecState(int rate, G722Flags options)
        {
            this.Band = new Band[2] {
                new Band()
                {
                    det = 32
                }, new Band()
                {
                    det = 8
                }
            };
            this.QmfSignalHistory = new int[24];
            this.ItuTestMode      = false;

            if (rate == 48000)
            {
                this.BitsPerSample = 6;
            }
            else if (rate == 56000)
            {
                this.BitsPerSample = 7;
            }
            else if (rate == 64000)
            {
                this.BitsPerSample = 8;
            }
            else
            {
                throw new System.ArgumentException("Invalid rate, should be 48000, 56000 or 64000");
            }
            if ((options & G722Flags.SampleRate8000) == G722Flags.SampleRate8000)
            {
                this.EncodeFrom8000Hz = true;
            }
            if (((options & G722Flags.Packed) == G722Flags.Packed) && this.BitsPerSample != 8)
            {
                this.Packed = true;
            }
            else
            {
                this.Packed = false;
            }
            //this.Band[0].det = 32;
            //this.Band[1].det = 8;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new instance of G722 Codec State for a 
        /// new encode or decode session
        /// </summary>
        /// <param name="rate">Bitrate (typically 64000)</param>
        /// <param name="options">Special options</param>
        public G722CodecState(int rate, G722Flags options)
        {
            this.Band = new Band[2] { new Band(), new Band() };
            this.QmfSignalHistory = new int[24];
            this.ItuTestMode = false;

            if (rate == 48000)
                this.BitsPerSample = 6;
            else if (rate == 56000)
                this.BitsPerSample = 7;
            else if (rate == 64000)
                this.BitsPerSample = 8;
            else
                throw new ArgumentException("Invalid rate, should be 48000, 56000 or 64000");
            if ((options & G722Flags.SampleRate8000) == G722Flags.SampleRate8000)
                this.EncodeFrom8000Hz = true;
            if (((options & G722Flags.Packed) == G722Flags.Packed) && this.BitsPerSample != 8)
                this.Packed = true;
            else
                this.Packed = false;
            this.Band[0].det = 32;
            this.Band[1].det = 8;
        }