Ejemplo n.º 1
0
        private void DecodeAviStream(RiffParser rp, int length)
        {
            var ba = new byte[length];

            if (rp.ReadData(ba, 0, length) != length)
            {
                throw new RiffParserException("Problem reading AVI header.");
            }

            var aviStreamHeader = new AviStreamHeader
            {
                FccType    = GetInt(ba, 0),
                FccHandler = GetInt(ba, 4),
                Scale      = GetInt(ba, 20),
                Rate       = GetInt(ba, 24),
                Start      = GetInt(ba, 28),
                Length     = GetInt(ba, 32),
                SampleSize = GetInt(ba, 44),
            };

            if (AviRiffData.StreamTypeVideo == aviStreamHeader.FccType)
            {
                _vidHandler = RiffParser.FromFourCc(aviStreamHeader.FccHandler);
                if (aviStreamHeader.Scale > 0)
                {
                    _vidDataRate = (double)aviStreamHeader.Rate / aviStreamHeader.Scale;
                }
                else
                {
                    _vidDataRate = 0.0;
                }
            }
            else if (AviRiffData.StreamTypeAudio == aviStreamHeader.FccType)
            {
                if (AviRiffData.Mp3 == aviStreamHeader.FccHandler)
                {
                    _audHandler = "MP3";
                }
                else
                {
                    _audHandler = RiffParser.FromFourCc(aviStreamHeader.FccHandler);
                }
                if (aviStreamHeader.Scale > 0)
                {
                    _audDataRate = 8.0 * aviStreamHeader.Rate / aviStreamHeader.Scale;
                    if (aviStreamHeader.SampleSize > 0)
                    {
                        _audDataRate /= aviStreamHeader.SampleSize;
                    }
                }
                else
                {
                    _audDataRate = 0.0;
                }
            }
        }
Ejemplo n.º 2
0
        private void DecodeAviStream(RiffParser rp, int length)
        {
            var ba = new byte[length];

            if (rp.ReadData(ba, 0, length) != length)
            {
                throw new RiffParserException("Problem reading AVI header.");
            }

            var aviStreamHeader = new AVISTREAMHEADER
            {
                fccType      = GetInt(ba, 0),
                fccHandler   = GetInt(ba, 4),
                dwScale      = GetInt(ba, 20),
                dwRate       = GetInt(ba, 24),
                dwStart      = GetInt(ba, 28),
                dwLength     = GetInt(ba, 32),
                dwSampleSize = GetInt(ba, 44),
            };

            if (AviRiffData.streamtypeVIDEO == aviStreamHeader.fccType)
            {
                _vidHandler = RiffParser.FromFourCc(aviStreamHeader.fccHandler);
                if (aviStreamHeader.dwScale > 0)
                {
                    _vidDataRate = (double)aviStreamHeader.dwRate / aviStreamHeader.dwScale;
                }
                else
                {
                    _vidDataRate = 0.0;
                }
            }
            else if (AviRiffData.streamtypeAUDIO == aviStreamHeader.fccType)
            {
                if (AviRiffData.ckidMP3 == aviStreamHeader.fccHandler)
                {
                    _audHandler = "MP3";
                }
                else
                {
                    _audHandler = RiffParser.FromFourCc(aviStreamHeader.fccHandler);
                }
                if (aviStreamHeader.dwScale > 0)
                {
                    _audDataRate = 8.0 * aviStreamHeader.dwRate / aviStreamHeader.dwScale;
                    if (aviStreamHeader.dwSampleSize > 0)
                    {
                        _audDataRate /= aviStreamHeader.dwSampleSize;
                    }
                }
                else
                {
                    _audDataRate = 0.0;
                }
            }
        }