public void Decode(byte[] inbuf,int insize,byte[] outbuf) { int ret; xvid_dec_frame_t xvid_dec_frame=new xvid_dec_frame_t(); /* Set version */ xvid_dec_frame.version = XVID_VERSION; //xvid_dec_stats->version = XVID_VERSION; /* No general flags to set */ xvid_dec_frame.general = 0; /* fixed(void *inptr=inbuf,outptr=outbuf) { xvid_dec_frame.bitstream = inptr; xvid_dec_frame.length = insize; xvid_dec_frame.output.plane1 = outptr; xvid_dec_frame.output.stride1 = Width*3; xvid_dec_frame.output.csp = XVID_CSP_BGR; ret = xvid_decore(dec_handle, XVID_DEC_DECODE, ref xvid_dec_frame, IntPtr.Zero); } */ GCHandle h0 = GCHandle.Alloc(inbuf, GCHandleType.Pinned); GCHandle h1 = GCHandle.Alloc(outbuf, GCHandleType.Pinned); xvid_dec_frame.bitstream = h0.AddrOfPinnedObject(); xvid_dec_frame.length = insize; xvid_dec_frame.output.plane1 = h1.AddrOfPinnedObject(); xvid_dec_frame.output.stride1 = Width * 3; xvid_dec_frame.output.csp = XVID_CSP_BGR; ret = xvid_decore(dec_handle, XVID_DEC_DECODE, ref xvid_dec_frame, IntPtr.Zero); h0.Free(); h1.Free(); }
private static extern int xvid_decore(IntPtr handle, int opt, ref xvid_dec_frame_t param1, IntPtr param2);