Example #1
0
        void vbuf_add(vbuf_t v, int i_data, void *p_data)
        {
            if (i_data + v.i_data >= v.i_data_max)
            {
                v.i_data_max += i_data;
                v.p_data      = (byte *)Marshal.ReAllocHGlobal(new IntPtr(v.p_data), new IntPtr(v.i_data_max)).ToPointer();
            }

            memcpy(&v.p_data[v.i_data], p_data, (uint)i_data);

            v.i_data += i_data;
        }
Example #2
0
        void avi_write(avi_t a, vbuf_t v, int b_key)
        {
            int i = 0;

            if (!a.f.CanWrite)
            {
                return;
            }
            long i_pos = a.f.Position;

            /* chunk header */
            avi_write_fourcc(a, "00dc");
            avi_write_uint32(a, (uint)v.i_data);

            byte[] buffer = new byte[v.i_data * 1];
            Marshal.Copy(new IntPtr(v.p_data), buffer, 0, buffer.Length);
            a.f.Write(buffer, 0, buffer.Length);

            if ((v.i_data & 0x01) != 0)
            {
                /* pad */
                a.f.WriteByte(0);
            }

            /* Append idx chunk */
            if (a.i_idx_max <= a.i_frame)
            {
                a.i_idx_max += 1000;
                if (a.idx == null)
                {
                    a.idx = (uint *)Marshal.AllocHGlobal(a.i_idx_max * 16).ToPointer();
                }
                else
                {
                    a.idx = (uint *)Marshal.ReAllocHGlobal(new IntPtr(a.idx), new IntPtr(a.i_idx_max * 16)).ToPointer();
                }
            }

            IntPtr tmpPtr = Marshal.StringToHGlobalAnsi("00dc");

            memcpy(&a.idx[4 * a.i_frame + 0], tmpPtr.ToPointer(), 4);
            Marshal.FreeHGlobal(tmpPtr);
            avi_set_dw(&a.idx[4 * a.i_frame + 1], b_key != 0 ? (int)AVIIF_KEYFRAME : 0);
            avi_set_dw(&a.idx[4 * a.i_frame + 2], (int)i_pos);
            avi_set_dw(&a.idx[4 * a.i_frame + 3], v.i_data);

            a.i_frame++;
        }
Example #3
0
        public CAvcToAvi()
        {
            cfg       = new cfg_t();
            cfg.f_fps = 24;
            cfg.fcc   = "h264";

            /* Init data */
            b_eof   = 0;
            b_key   = 0;
            b_slice = 0;
            i_frame = 0;
            i_data  = 0;

            avi           = new avi_t();
            h264          = new h264_t();
            nal           = new nal_t();
            nal.p_payload = (byte *)Marshal.AllocHGlobal(DATA_MAX).ToPointer();
            vb            = new vbuf_t();

            data = (byte *)Marshal.AllocHGlobal(DATA_MAX).ToPointer();
        }
Example #4
0
 void vbuf_reset(vbuf_t v)
 {
     v.i_data = 0;
 }
Example #5
0
 void vbuf_init(vbuf_t v)
 {
     v.i_data     = 0;
     v.i_data_max = 10000;
     v.p_data     = (byte *)Marshal.AllocHGlobal(v.i_data_max).ToPointer();
 }