#include "miniwebcam.h" #include "video.h" #include #include VideoFrame::VideoFrame() { mem = NULL; width = 0; height = 0; mem_allocated = 0; }; VideoFrame::~VideoFrame() { FreeFrame(); }; void VideoFrame::FreeFrame() { if (mem != NULL) { free (mem); mem = NULL; width = 0; height = 0; mem_allocated = 0; } }; void VideoFrame::AllocateFrame() { printf ("VideoFrame::AllocateFrame()\n"); int memnewsize = width * height * 3; if (memnewsize >= mem_allocated) return; else if (memnewsize == 0) FreeFrame(); mem = (unsigned char *) realloc (mem, memnewsize); mem_allocated = memnewsize; if (mem == NULL) { debug ("Error on allocation new frame\n"); exit (1); } }; int VideoFrame::SetSize(int w, int h) { if (w < 0 && h < 0) return 0; width = w; height = h; AllocateFrame(); return 1; }; /*********************************************************************/ void VideoFrameFloat::AllocateFrame() { printf ("VideoFrameFloat::AllocateFrame()\n"); int memnewsize = width * height * 3 * sizeof(float); if (memnewsize >= mem_allocated) return; else if (memnewsize == 0) FreeFrame(); mem = (unsigned char *) realloc (mem, memnewsize); mem_allocated = memnewsize; if (mem == NULL) { debug ("Error on allocation new frame\n"); exit (1); } }; /*********************************************************************/ VideoDevice::VideoDevice() { videofd = 0; }; VideoDevice::~VideoDevice() { }; int VideoDevice::SetDevice() { return 0; }; int VideoDevice::Start(int w, int h) { return 0; }; int VideoDevice::Stop() { return 0; }; int VideoDevice::GetFrame(VideoFrame *destframe) { return 0; };