Beispiel #1
0
        public void ReadSample(UInt32 index, byte[] buffer, int offset)
        {
            var    sampleEntry = SampleEntries[index];
            UInt32 seekInChunk = 0;

            for (uint i = 0; i < sampleEntry.IndexInChunk; i++)
            {
                seekInChunk += STSZ.SampleSize(index - i - 1);
            }
            uint dataIndex = STCO.Items[sampleEntry.ChunkIndex] + seekInChunk;

            Stream.Position = dataIndex;
            Stream.Read(buffer, offset, (int)STSZ.SampleSize(index));
        }
    private void WriteBytesSTSZ(MemoryStream ms)
    {
        byte [] tmp;
        STSZ    stsz = (STSZ)this.data;

        ms.Write(stsz.Dummy, 0, stsz.Dummy.Length);

        tmp = BitConverter.GetBytes(stsz.Table.Length);
        Utility.LeReverse(tmp);
        ms.Write(tmp, 0, tmp.Length);

        if (BitConverter.ToUInt32(stsz.Dummy, 4) == 0)
        {
            for (int i = 0; i < stsz.Table.Length; i++)
            {
                tmp = BitConverter.GetBytes(stsz.Table[i]);
                Utility.LeReverse(tmp);
                ms.Write(tmp, 0, tmp.Length);
            }
        }
    }
    private void ParseSTSZ(BinaryReader br)
    {
        byte [] tmp;
        STSZ    stsz = new STSZ();

        stsz.Dummy = br.ReadBytes(8);

        tmp        = br.ReadBytes(4); Utility.LeReverse(tmp);
        stsz.Table = new int[BitConverter.ToInt32(tmp, 0)];

        if (BitConverter.ToUInt32(stsz.Dummy, 4) == 0)
        {
            for (int i = 0; i < stsz.Table.Length; i++)
            {
                tmp           = br.ReadBytes(4); Utility.LeReverse(tmp);
                stsz.Table[i] = BitConverter.ToInt32(tmp, 0);
            }
        }

        this.data = stsz;
    }
    private void ParseSTSZ( BinaryReader br )
    {
        byte [] tmp;
        STSZ stsz = new STSZ();

        stsz.Dummy = br.ReadBytes( 8 );

        tmp = br.ReadBytes( 4 ); Utility.LeReverse( tmp );
        stsz.Table = new int[ BitConverter.ToInt32( tmp, 0 ) ];

        if( BitConverter.ToUInt32( stsz.Dummy, 4 ) == 0 )
        {
            for( int i = 0; i < stsz.Table.Length; i++ )
            {
                tmp = br.ReadBytes( 4 ); Utility.LeReverse( tmp );
                stsz.Table[ i ] = BitConverter.ToInt32( tmp, 0 );
            }
        }

        this.data = stsz;
    }