|
|
@ -6,6 +6,7 @@
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "simpleskycam.h"
|
|
|
|
#include "convert.h"
|
|
|
|
#include "convert.h"
|
|
|
|
#include "gui.h"
|
|
|
|
#include "gui.h"
|
|
|
|
#include "video.h"
|
|
|
|
#include "video.h"
|
|
|
@ -225,21 +226,11 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
|
|
|
|
if (dest == NULL || ptrsrc == NULL)
|
|
|
|
if (dest == NULL || ptrsrc == NULL)
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
|
|
|
|
|
|
|
if (dest->data != NULL && dest->w != srcw && dest->h != srch) {
|
|
|
|
|
|
|
|
free (dest->data);
|
|
|
|
|
|
|
|
dest->data = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dest->data == NULL) {
|
|
|
|
|
|
|
|
dest->w = srcw;
|
|
|
|
|
|
|
|
dest->h = srch;
|
|
|
|
|
|
|
|
dest->size = srcw * srch * 3;
|
|
|
|
|
|
|
|
dest->data = (unsigned char*) malloc (dest->size);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ptrdst = dest->data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (pixelformat) {
|
|
|
|
switch (pixelformat) {
|
|
|
|
case (V4L2_PIX_FMT_RGB32):
|
|
|
|
case (V4L2_PIX_FMT_RGB32):
|
|
|
|
|
|
|
|
dest->SetSize(srcw, srch);
|
|
|
|
|
|
|
|
dest->SetPixelSize(3); // 8 bits per pixel
|
|
|
|
|
|
|
|
ptrdst = (unsigned char *)dest->GetData();
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
/* read the pixel */
|
|
|
|
/* read the pixel */
|
|
|
@ -267,6 +258,9 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case (V4L2_PIX_FMT_BGR32):
|
|
|
|
case (V4L2_PIX_FMT_BGR32):
|
|
|
|
|
|
|
|
dest->SetSize(srcw, srch);
|
|
|
|
|
|
|
|
dest->SetPixelSize(3); // 8 bits per pixel
|
|
|
|
|
|
|
|
ptrdst = (unsigned char *)dest->GetData();
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
/* read the pixel */
|
|
|
|
/* read the pixel */
|
|
|
@ -293,6 +287,9 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case (V4L2_PIX_FMT_RGB24):
|
|
|
|
case (V4L2_PIX_FMT_RGB24):
|
|
|
|
|
|
|
|
dest->SetSize(srcw, srch);
|
|
|
|
|
|
|
|
dest->SetPixelSize(3); // 8 bits per pixel
|
|
|
|
|
|
|
|
ptrdst = (unsigned char *)dest->GetData();
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
/* read the pixel */
|
|
|
|
/* read the pixel */
|
|
|
@ -319,6 +316,10 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case (V4L2_PIX_FMT_BGR24):
|
|
|
|
case (V4L2_PIX_FMT_BGR24):
|
|
|
|
|
|
|
|
dest->SetSize(srcw, srch);
|
|
|
|
|
|
|
|
dest->SetPixelSize(3); // 8 bits per pixel
|
|
|
|
|
|
|
|
ptrdst = (unsigned char *)dest->GetData();
|
|
|
|
|
|
|
|
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
/* read the pixel */
|
|
|
|
/* read the pixel */
|
|
|
@ -345,6 +346,10 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case (V4L2_PIX_FMT_UYVY):
|
|
|
|
case (V4L2_PIX_FMT_UYVY):
|
|
|
|
|
|
|
|
dest->SetSize(srcw, srch);
|
|
|
|
|
|
|
|
dest->SetPixelSize(3); // 8 bits per pixel
|
|
|
|
|
|
|
|
ptrdst = (unsigned char *)dest->GetData();
|
|
|
|
|
|
|
|
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
/* read the pixel */
|
|
|
|
/* read the pixel */
|
|
|
@ -380,6 +385,10 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case (V4L2_PIX_FMT_YUYV):
|
|
|
|
case (V4L2_PIX_FMT_YUYV):
|
|
|
|
|
|
|
|
dest->SetSize(srcw, srch);
|
|
|
|
|
|
|
|
dest->SetPixelSize(3); // 8 bits per pixel
|
|
|
|
|
|
|
|
ptrdst = (unsigned char *)dest->GetData();
|
|
|
|
|
|
|
|
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
for (ys = 0, yd = 0; ys < (signed int)srch; ys++) {
|
|
|
|
if (yd < dest->h) {
|
|
|
|
if (yd < dest->h) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
|
for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) {
|
|
|
@ -416,6 +425,10 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case (V4L2_PIX_FMT_MJPEG):
|
|
|
|
case (V4L2_PIX_FMT_MJPEG):
|
|
|
|
|
|
|
|
dest->SetSize(srcw, srch);
|
|
|
|
|
|
|
|
dest->SetPixelSize(3); // 8 bits per pixel
|
|
|
|
|
|
|
|
ptrdst = (unsigned char *)dest->GetData();
|
|
|
|
|
|
|
|
|
|
|
|
cdata->cinfo.err = jpeg_std_error(&jerr.pub);
|
|
|
|
cdata->cinfo.err = jpeg_std_error(&jerr.pub);
|
|
|
|
jerr.pub.error_exit = jpg_error_exit;
|
|
|
|
jerr.pub.error_exit = jpg_error_exit;
|
|
|
|
if (setjmp(jerr.setjmp_buffer)) {
|
|
|
|
if (setjmp(jerr.setjmp_buffer)) {
|
|
|
@ -437,8 +450,7 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
printf ("%s:%d Error no default possible, need to finish\n", __FILE__, __LINE__);
|
|
|
|
errorexit ((char*)"%s:%d Error no default possible, need to finish\n", __FILE__, __LINE__);
|
|
|
|
exit (-1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|