Example #1
0
        bool ValidateCRC()
        {
            var crc = 0xFFFFU;

            // process the common bits...
            UpdateCRC(_syncBits, 16, ref crc);

            var apply = false;

            switch (Layer)
            {
            case MpegLayer.LayerI:
                apply = LayerIDecoder.GetCRC(this, ref crc);
                break;

            case MpegLayer.LayerII:
                apply = LayerIIDecoder.GetCRC(this, ref crc);
                break;

            case MpegLayer.LayerIII:
                apply = LayerIIIDecoder.GetCRC(this, ref crc);
                break;
            }

            if (apply)
            {
                var checkCrc = ReadByte(4) << 8 | ReadByte(5);
                return(checkCrc == crc);
            }

            return(true);
        }
Example #2
0
        protected IFrameDecoder retrieveDecoder(Header header, Bitstream stream, int layer)
        {
            IFrameDecoder decoder = null;

            // REVIEW: allow channel output selection type
            // (LEFT, RIGHT, BOTH, DOWNMIX)
            switch (layer)
            {
            case 3:
                if (l3decoder == null)
                {
                    l3decoder = new LayerIIIDecoder(stream,
                                                    header, filter1, filter2,
                                                    output, OutputChannels.Both);
                }

                decoder = l3decoder;
                break;

            case 2:
                if (l2decoder == null)
                {
                    l2decoder = new LayerIIDecoder();
                    l2decoder.create(stream,
                                     header, filter1, filter2,
                                     output, OutputChannels.Both);
                }
                decoder = l2decoder;
                break;

            case 1:
                if (l1decoder == null)
                {
                    l1decoder = new LayerIDecoder();
                    l1decoder.create(stream,
                                     header, filter1, filter2,
                                     output, OutputChannels.Both);
                }
                decoder = l1decoder;
                break;
            }

            if (decoder == null)
            {
                throw new DecoderException(Errors.UNSUPPORTED_LAYER);
            }

            return(decoder);
        }
Example #3
0
        protected internal virtual IFrameDecoder RetrieveDecoder(Header header, Bitstream stream, int layer)
        {
            IFrameDecoder decoder = null;

            // REVIEW: allow channel output selection type
            // (LEFT, RIGHT, BOTH, DOWNMIX)
            switch (layer)
            {
            case 3:
                if (m_L3Decoder == null)
                {
                    m_L3Decoder = new LayerIIIDecoder(stream, header, m_LeftChannelFilter, m_RightChannelFilter, m_Output,
                                                      (int)OutputChannelsEnum.BOTH_CHANNELS);
                }

                decoder = m_L3Decoder;
                break;

            case 2:
                if (m_L2Decoder == null)
                {
                    m_L2Decoder = new LayerIIDecoder();
                    m_L2Decoder.Create(stream, header, m_LeftChannelFilter, m_RightChannelFilter, m_Output,
                                       (int)OutputChannelsEnum.BOTH_CHANNELS);
                }
                decoder = m_L2Decoder;
                break;

            case 1:
                if (m_L1Decoder == null)
                {
                    m_L1Decoder = new LayerIDecoder();
                    m_L1Decoder.Create(stream, header, m_LeftChannelFilter, m_RightChannelFilter, m_Output,
                                       (int)OutputChannelsEnum.BOTH_CHANNELS);
                }
                decoder = m_L1Decoder;
                break;
            }

            if (decoder == null)
            {
                throw NewDecoderException(DecoderErrors.UNSUPPORTED_LAYER, null);
            }

            return(decoder);
        }
Example #4
0
        protected internal virtual FrameDecoder retrieveDecoder(Header header, Bitstream stream, int layer)
        {
            FrameDecoder decoder = null;

            // REVIEW: allow channel output selection type
            // (LEFT, RIGHT, BOTH, DOWNMIX)
            switch (layer)
            {
            case 3:
                if (l3decoder == null)
                {
                    l3decoder = new LayerIIIDecoder(stream, header, filter1, filter2, output, (int)OutputChannelsEnum.BOTH_CHANNELS);
                }

                decoder = l3decoder;
                break;

            case 2:
                if (l2decoder == null)
                {
                    l2decoder = new LayerIIDecoder();
                    l2decoder.create(stream, header, filter1, filter2, output, (int)OutputChannelsEnum.BOTH_CHANNELS);
                }
                decoder = l2decoder;
                break;

            case 1:
                if (l1decoder == null)
                {
                    l1decoder = new LayerIDecoder();
                    l1decoder.create(stream, header, filter1, filter2, output, (int)OutputChannelsEnum.BOTH_CHANNELS);
                }
                decoder = l1decoder;
                break;
            }

            if (decoder == null)
            {
                throw newDecoderException(javazoom.jl.decoder.DecoderErrors_Fields.UNSUPPORTED_LAYER, null);
            }

            return(decoder);
        }
Example #5
0
 private void InitBlock(LayerIIIDecoder enclosingInstance)
 {
     Enclosing_Instance = enclosingInstance;
 }
Example #6
0
 public ScaleFactorTable(LayerIIIDecoder enclosingInstance, int[] thel, int[] thes)
 {
     InitBlock(enclosingInstance);
     l = thel;
     s = thes;
 }
Example #7
0
 public ScaleFactorTable(LayerIIIDecoder enclosingInstance)
 {
     InitBlock(enclosingInstance);
     l = new int[5];
     s = new int[3];
 }
Example #8
0
 private void InitBlock(LayerIIIDecoder enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Example #9
0
 public ScaleFactorTable(LayerIIIDecoder enclosingInstance, int[] thel, int[] thes)
 {
     InitBlock(enclosingInstance);
     l = thel;
     s = thes;
 }
Example #10
0
 public ScaleFactorTable(LayerIIIDecoder enclosingInstance)
 {
     InitBlock(enclosingInstance);
     l = new int[5];
     s = new int[3];
 }
Example #11
0
 internal ScaleFactorTable(LayerIIIDecoder enclosingInstance, int[] thel, int[] thes)
 {
     InitBlock(enclosingInstance);
     L = thel;
     S = thes;
 }
Example #12
0
 internal ScaleFactorTable(LayerIIIDecoder enclosingInstance)
 {
     InitBlock(enclosingInstance);
     L = new int[5];
     S = new int[3];
 }