示例#1
0
        public void Execute(bool keepProcessedFrames)
        {
            mStartTime = DateTime.Now;
            foreach (var frame in RawFrames)
            {
                // Encode the frame
                VideoCodec.EncodeFrame(frame, 1);
                var dvc = VideoCodec as JpegDiffVideoCodec;
                if (dvc != null)
                {
                    foreach (var block in dvc.EncodedBlocks)
                    {
                        if (block.BlockType == BlockType.Jpeg)
                        {
                            blocksAsJpeg++;
                            bytesAsJpeg += block.EncodedStream.Length;
                        }
                        else
                        {
                            blocksAsDelta++;
                            bytesAsDelta += block.EncodedStream.Length;
                        }
                    }
                }

                // Decode the frame
                bool moreChunks = true;
                var  buffer     = mVideoChunkPool.GetNext();
                while (moreChunks)
                {
                    buffer.Reset();
                    if (VideoCodec.GetNextChunk(buffer, out moreChunks))
                    {
                        EncodedSize += buffer.DataLength;
                        VideoCodec.DecodeChunk(buffer, 2);
                    }
                }
                mVideoChunkPool.Recycle(buffer);

                // Retrieve the frame
                var processedStream = VideoCodec.GetNextFrame();
                ProcessedFrames.Add(processedStream.ToArray());
            }
            Finish(keepProcessedFrames);
        }