preparing for new videoformats.

main
Steffen Pohle 3 months ago
parent 0d127bb882
commit f1eef750b9

@ -27,8 +27,10 @@ uint32_t convert_pixelformats [] = {
V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_BGR24,
V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_UYVY,
V4L2_PIX_FMT_SGRBG16, V4L2_PIX_FMT_SGRBG16,
V4L2_PIX_FMT_SGRBG8,
V4L2_PIX_FMT_SRGGB10P, V4L2_PIX_FMT_SRGGB10P,
V4L2_PIX_FMT_SBGGR10,
V4L2_PIX_FMT_SRGGB8,
V4L2_PIX_FMT_SGRBG8,
0 0
}; };
@ -221,9 +223,9 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
case (V4L2_PIX_FMT_SRGGB10P): case (V4L2_PIX_FMT_SRGGB10P):
if (debayer_mode == 0) if (debayer_mode == 0)
debayer_rggb10packed_simple ((uint16_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch); debayer_rggb10packet_simple ((uint8_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch);
else else
debayer_rggb10packet_bilinear ((uint16_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch); debayer_rggb10packet_bilinear ((uint8_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch);
break; break;
case (V4L2_PIX_FMT_SGRBG16): case (V4L2_PIX_FMT_SGRBG16):
@ -233,6 +235,7 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr
debayer_grbg16_bilinear ((uint16_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch); debayer_grbg16_bilinear ((uint16_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch);
break; break;
case (V4L2_PIX_FMT_SRGGB8):
case (V4L2_PIX_FMT_SGRBG8): case (V4L2_PIX_FMT_SGRBG8):
if (debayer_mode == 0) if (debayer_mode == 0)
debayer_grbg8_simple ((uint8_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch); debayer_grbg8_simple ((uint8_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch);

@ -365,7 +365,7 @@ void debayer_grbg8_bilinear (uint8_t * src, int src_w, int src_h,
STORE8; STORE8;
} }
void debayer_rggb10packet_simple (uint16_t * src, int src_w, int src_h, void debayer_rggb10packet_simple (uint8_t * src, int src_w, int src_h,
uint8_t * dst, int dst_w, int dst_h) { uint8_t * dst, int dst_w, int dst_h) {
}; };

@ -13,7 +13,7 @@ void debayer_grbg8_simple (uint8_t * src, int src_w, int src_h,
void debayer_grbg8_bilinear (uint8_t * src, int src_w, int src_h, void debayer_grbg8_bilinear (uint8_t * src, int src_w, int src_h,
uint8_t * dst, int dst_w, int dst_h); uint8_t * dst, int dst_w, int dst_h);
void debayer_rggb10packet_simple (uint16_t * src, int src_w, int src_h, void debayer_rggb10packet_simple (uint8_t * src, int src_w, int src_h,
uint8_t * dst, int dst_w, int dst_h); uint8_t * dst, int dst_w, int dst_h);
void debayer_rggb10packet_bilinear (uint8_t * src, int src_w, int src_h, void debayer_rggb10packet_bilinear (uint8_t * src, int src_w, int src_h,
uint8_t * dst, int dst_w, int dst_h); uint8_t * dst, int dst_w, int dst_h);

@ -46,7 +46,7 @@ int main(int argc, char **argv) {
webserver.SetupSSL(config.ssl_key, config.ssl_cert); webserver.SetupSSL(config.ssl_key, config.ssl_cert);
webserver.Start(); webserver.Start();
if (vdev.SetDevice (config.vdev_device, config.vdev_width, config.vdev_height) == 0) { if (vdev.SetDevice (config.vdev_device, config.vdev_width, config.vdev_height, convert_to_pixelformat(config.vdev_format)) == 0) {
debug ("could not setup device.\n"); debug ("could not setup device.\n");
return 0; return 0;
} }

@ -21,6 +21,7 @@ VideoDevice_V4L2::VideoDevice_V4L2() {
conf_width = 0; conf_width = 0;
conf_videodev = ""; conf_videodev = "";
conf_iomode = 0; conf_iomode = 0;
conf_videofmt = 0;
fd = -1; fd = -1;
}; };
@ -31,7 +32,7 @@ VideoDevice_V4L2::~VideoDevice_V4L2() {
int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight) { int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight, uint32_t pixfmt) {
int isrunning = 0; int isrunning = 0;
if (fd != -1) { if (fd != -1) {
@ -42,6 +43,7 @@ int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight)
conf_videodev = newdevice; conf_videodev = newdevice;
conf_width = nwidth; conf_width = nwidth;
conf_height = nheight; conf_height = nheight;
conf_videofmt = pixfmt;
if (isrunning) { if (isrunning) {
if (Start() == 0) return 0; if (Start() == 0) return 0;
@ -73,7 +75,6 @@ int VideoDevice_V4L2::Open() {
int i; int i;
struct v4l2_capability vcap; struct v4l2_capability vcap;
VideoDevCtrl vctl; VideoDevCtrl vctl;
char txt[32];
debug ("Device: '%s'", conf_videodev.c_str()); debug ("Device: '%s'", conf_videodev.c_str());
if (fd != -1) return 0; if (fd != -1) return 0;
@ -151,7 +152,7 @@ int VideoDevice_V4L2::Open() {
} }
// fixme: hardcoded video format????? // fixme: hardcoded video format?????
fmt.fmt.pix.pixelformat = convert_to_pixelformat(conf_videofmt); fmt.fmt.pix.pixelformat = conf_videofmt;
fmt.fmt.pix.field = V4L2_FIELD_NONE; fmt.fmt.pix.field = V4L2_FIELD_NONE;
if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt)) { if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt)) {
debug ("VIDIOC_S_FMT : %s", strerror (errno)); debug ("VIDIOC_S_FMT : %s", strerror (errno));
@ -170,11 +171,7 @@ int VideoDevice_V4L2::Open() {
fmt.fmt.pix.sizeimage = min; fmt.fmt.pix.sizeimage = min;
conf_width = fmt.fmt.pix.width; conf_width = fmt.fmt.pix.width;
conf_height = fmt.fmt.pix.height; conf_height = fmt.fmt.pix.height;
snprintf (txt, 32, "%c%c%c%c", ((char*)&fmt.fmt.pix.pixelformat)[0], conf_videofmt = fmt.fmt.pix.pixelformat;
((char*)&fmt.fmt.pix.pixelformat)[1],
((char*)&fmt.fmt.pix.pixelformat)[2],
((char*)&fmt.fmt.pix.pixelformat)[3]);
conf_videofmt = txt;
PrintFmt (&fmt); PrintFmt (&fmt);
// init buffers // init buffers

@ -66,7 +66,7 @@ class VideoDevice {
private: private:
protected: protected:
std::string conf_videodev; std::string conf_videodev;
std::string conf_videofmt; uint32_t conf_videofmt;
int conf_width; int conf_width;
int conf_height; int conf_height;
int conf_iomode; int conf_iomode;
@ -75,7 +75,7 @@ class VideoDevice {
VideoDevice(); VideoDevice();
~VideoDevice(); ~VideoDevice();
virtual int SetDevice(std::string newdevice, int nwidth, int nheight) { return 0; }; virtual int SetDevice(std::string newdevice, int nwidth, int nheight, uint32_t pixfmt) { return 0; };
virtual int SetIOMode(int newiomode) { return 0; }; virtual int SetIOMode(int newiomode) { return 0; };
virtual int Start() { return 0; }; virtual int Start() { return 0; };
virtual int Stop() { return 0; }; virtual int Stop() { return 0; };
@ -107,7 +107,7 @@ class VideoDevice_V4L2 : public VideoDevice {
VideoDevice_V4L2(); VideoDevice_V4L2();
~VideoDevice_V4L2(); ~VideoDevice_V4L2();
int SetDevice(std::string newdevice, int nwidth, int nheight); int SetDevice(std::string newdevice, int nwidth, int nheight, uint32_t pixfmt);
int SetIOMode(int newiomode); int SetIOMode(int newiomode);
int Start(); int Start();
int Stop(); int Stop();

Loading…
Cancel
Save