You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
1.8 KiB

#include "miniwebcam.h"
#include "video.h"
#include <stdio.h>
#include <stdlib.h>
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;
};