예제 #1
0
        private byte[] MakeOldIndexChunk()
        {
            const uint AVIIF_KEYFRAME = 0x10;

            List <List <StreamChunkInfo> > cilList = new List <List <StreamChunkInfo> >();
            List <int>       cilIndex  = new List <int>();
            List <int>       cilLength = new List <int>();
            List <uint>      cilFourCC = new List <uint>();
            AVIOLDINDEXENTRY entry;

            byte[] buff;
            int    i, entryCount, buffPos, u;

            entryCount = 0;
            for (i = 0; i < _streamList.Count; i++)
            {
                AVIStream s = _streamList[i];

                if (s.ChunkList.Count > 0)
                {
                    cilList.Add(s.ChunkList);
                    cilIndex.Add(0);
                    cilLength.Add(s.ChunksInFirstMOVI);
                    cilFourCC.Add(s.FourCC);

                    entryCount += s.ChunksInFirstMOVI;
                }
            }

            buffPos = 0;
            buff    = new byte[entryCount * 16];
            while (entryCount > 0)
            {
                // Find the chunk with the lowest offset
                u = 0;
                for (i = 1; i < cilList.Count; i++)
                {
                    if (cilList[i][cilIndex[i]].Offset < cilList[u][cilIndex[u]].Offset)
                    {
                        u = i;
                    }
                }

                entry.dwChunkID = cilFourCC[u];
                entry.dwFlags   = cilList[u][cilIndex[u]].IsKeyFrame ? AVIIF_KEYFRAME : 0;
                entry.dwOffset  = (uint)(cilList[u][cilIndex[u]].Offset - (_moviOffset + 8));
                entry.dwSize    = cilList[u][cilIndex[u]].Size;

                BitConverterLE.WriteBytes(entry.dwChunkID, buff, buffPos);
                BitConverterLE.WriteBytes(entry.dwFlags, buff, buffPos + 4);
                BitConverterLE.WriteBytes(entry.dwOffset, buff, buffPos + 8);
                BitConverterLE.WriteBytes(entry.dwSize, buff, buffPos + 12);
                buffPos += 16;

                // If all the chunks from this stream have been written in the index,
                // stop checking this stream
                cilIndex[u]++;
                if (cilIndex[u] >= cilLength[u])
                {
                    cilList.RemoveAt(u);
                    cilIndex.RemoveAt(u);
                    cilLength.RemoveAt(u);
                    cilFourCC.RemoveAt(u);
                }

                entryCount--;
            }

            return(buff);
        }
예제 #2
0
 public static uint FourCC(string fourCC)
 {
     byte[] bytes = Encoding.ASCII.GetBytes(fourCC);
     return((bytes.Length == 4) ? BitConverterLE.ToUInt32(bytes, 0) : 0x20202020);
 }
예제 #3
0
 private byte[] MakeDMLHChunk(uint dwTotalFrames)
 {
     byte[] buff = new byte[248];
     BitConverterLE.WriteBytes(dwTotalFrames, buff, 0);
     return(buff);
 }