Exemplo n.º 1
0
 public AVIStream(AVIStreamType type, int streamID)
 {
     Type        = type;
     FourCC      = AVIHelper.StreamFourCC(streamID, AVIHelper.StreamTwoCC(type), false);
     FormatExtra = new byte[0];
     ChunkList   = new List <StreamChunkInfo>();
 }
Exemplo n.º 2
0
        private void MakeOpenDMLIndexes()
        {
            for (int iStream = 0; iStream < _streamList.Count; iStream++)
            {
                const byte AVI_INDEX_OF_INDEXES = 0x00;

                AVIStream stream = _streamList[iStream];
                List <StreamChunkInfo> chunkList = stream.ChunkList;

                AVISUPERINDEX      header = new AVISUPERINDEX();
                AVISUPERINDEXENTRY entry;
                int    entriesPerChunk, entryOffset, chunksLeft, buffPos;
                uint   indexChunkID = AVIHelper.StreamFourCC(AVIHelper.StreamID(stream.FourCC, false), "ix", true);
                byte[] buff;

                buffPos         = 0;
                buff            = new byte[OpenDMLSuperIndexSize(MaxOpenDMLSuperIndexEntries)];
                entriesPerChunk = (int)CalculateOpenDMLStandardIndexEntryCount(chunkList);
                entryOffset     = 0;
                chunksLeft      = chunkList.Count;

                header.wLongsPerEntry = 4;
                header.bIndexSubType  = 0;
                header.bIndexType     = AVI_INDEX_OF_INDEXES;
                header.nEntriesInUse  = (uint)((chunksLeft + (entriesPerChunk - 1)) / entriesPerChunk);
                header.dwChunkID      = stream.FourCC;

                if (header.nEntriesInUse > MaxOpenDMLSuperIndexEntries)
                {
                    throw new Exception("Too many super-index entries.");
                }

                buffPos += StructHelper <AVISUPERINDEX> .ToBytes(header, buff, buffPos, false);

                while (chunksLeft > 0)
                {
                    int    length = Math.Min(entriesPerChunk, chunksLeft);
                    byte[] tmp    = MakeOpenDMLStandardIndexChunk(chunkList, entryOffset, length,
                                                                  stream.FourCC);

                    CheckExtend((uint)tmp.Length);

                    entry.qwOffset   = (ulong)WriteChunk(indexChunkID, tmp);
                    entry.dwSize     = (uint)tmp.Length + 8;
                    entry.dwDuration = (stream.Type == AVIStreamType.Video) ? (uint)length :
                                       CalculateDuration(chunkList, entryOffset, length);

                    BitConverterLE.WriteBytes(entry.qwOffset, buff, buffPos);
                    BitConverterLE.WriteBytes(entry.dwSize, buff, buffPos + 8);
                    BitConverterLE.WriteBytes(entry.dwDuration, buff, buffPos + 12);
                    buffPos += 16;

                    entryOffset += length;
                    chunksLeft  -= length;
                }

                stream.OpenDMLSuperIndex = buff;
            }
        }
Exemplo n.º 3
0
 public void SetStreamTwoCC(int streamID, string twoCC)
 {
     _streamList[streamID].FourCC = AVIHelper.StreamFourCC(streamID, twoCC, false);
 }