public void TestMemset() { var Pointer = CLib.malloc(8); CLib.memset(Pointer, 1, 4); CollectionAssert.AreEqual(new byte[] { 1, 1, 1, 1, 0, 0, 0, 0 }, Pointer.Data.ToArray()); }
private object Decode <TType>(byte[] Data, AVCodec AVCodec, Action <AVCodecContext, AVPacket, TType> Action) { var context = new AVCodecContext(); var packet = new AVPacket(); packet.data = Pointer <byte> .Create(new AllocatedMemory(Data)); packet.size = Data.Length; context.get_buffer = (AVCodecContext, AVFrame) => { var width = AVCodecContext.width; var height = AVCodecContext.height; AVFrame.linesize[0] = width * 4; AVFrame.data[0] = CLib.malloc(AVFrame.linesize[0] * height); return(0); }; context.release_buffer = (AVCodecContext, AVFrame) => { CLib.free(AVFrame.data[0]); }; AVCodec.init(context); try { object obj = null; if (AVCodec.decode(context, ref obj, packet) < 0) { throw(new Exception()); } Action(context, packet, (TType)obj); return(obj); } finally { AVCodec.close(context); } }