diff --git a/convert.cc b/convert.cc index a29f08a..4575bac 100644 --- a/convert.cc +++ b/convert.cc @@ -27,8 +27,10 @@ uint32_t convert_pixelformats [] = { V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_SGRBG16, - V4L2_PIX_FMT_SGRBG8, V4L2_PIX_FMT_SRGGB10P, + V4L2_PIX_FMT_SBGGR10, + V4L2_PIX_FMT_SRGGB8, + V4L2_PIX_FMT_SGRBG8, 0 }; @@ -221,9 +223,9 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr case (V4L2_PIX_FMT_SRGGB10P): 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 - debayer_rggb10packet_bilinear ((uint16_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch); + debayer_rggb10packet_bilinear ((uint8_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch); break; 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); break; + case (V4L2_PIX_FMT_SRGGB8): case (V4L2_PIX_FMT_SGRBG8): if (debayer_mode == 0) debayer_grbg8_simple ((uint8_t *)ptrsrc, srcw, srch, ptrdst, srcw, srch); diff --git a/debayer.cc b/debayer.cc index 67a6d03..dab4cb3 100644 --- a/debayer.cc +++ b/debayer.cc @@ -365,7 +365,7 @@ void debayer_grbg8_bilinear (uint8_t * src, int src_w, int src_h, 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) { }; diff --git a/debayer.h b/debayer.h index 22c8ed6..3950f9d 100644 --- a/debayer.h +++ b/debayer.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, 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); void debayer_rggb10packet_bilinear (uint8_t * src, int src_w, int src_h, uint8_t * dst, int dst_w, int dst_h); diff --git a/main.cc b/main.cc index 5710185..8c211e7 100644 --- a/main.cc +++ b/main.cc @@ -46,7 +46,7 @@ int main(int argc, char **argv) { webserver.SetupSSL(config.ssl_key, config.ssl_cert); 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"); return 0; } diff --git a/video.cc b/video.cc index 183b84d..b3e7f47 100644 --- a/video.cc +++ b/video.cc @@ -21,6 +21,7 @@ VideoDevice_V4L2::VideoDevice_V4L2() { conf_width = 0; conf_videodev = ""; conf_iomode = 0; + conf_videofmt = 0; 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; if (fd != -1) { @@ -42,6 +43,7 @@ int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight) conf_videodev = newdevice; conf_width = nwidth; conf_height = nheight; + conf_videofmt = pixfmt; if (isrunning) { if (Start() == 0) return 0; @@ -73,7 +75,6 @@ int VideoDevice_V4L2::Open() { int i; struct v4l2_capability vcap; VideoDevCtrl vctl; - char txt[32]; debug ("Device: '%s'", conf_videodev.c_str()); if (fd != -1) return 0; @@ -151,7 +152,7 @@ int VideoDevice_V4L2::Open() { } // 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; if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt)) { debug ("VIDIOC_S_FMT : %s", strerror (errno)); @@ -170,11 +171,7 @@ int VideoDevice_V4L2::Open() { fmt.fmt.pix.sizeimage = min; conf_width = fmt.fmt.pix.width; conf_height = fmt.fmt.pix.height; - snprintf (txt, 32, "%c%c%c%c", ((char*)&fmt.fmt.pix.pixelformat)[0], - ((char*)&fmt.fmt.pix.pixelformat)[1], - ((char*)&fmt.fmt.pix.pixelformat)[2], - ((char*)&fmt.fmt.pix.pixelformat)[3]); - conf_videofmt = txt; + conf_videofmt = fmt.fmt.pix.pixelformat; PrintFmt (&fmt); // init buffers diff --git a/video.h b/video.h index 2170170..367c3a5 100644 --- a/video.h +++ b/video.h @@ -66,7 +66,7 @@ class VideoDevice { private: protected: std::string conf_videodev; - std::string conf_videofmt; + uint32_t conf_videofmt; int conf_width; int conf_height; int conf_iomode; @@ -75,7 +75,7 @@ class 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 Start() { return 0; }; virtual int Stop() { return 0; }; @@ -107,7 +107,7 @@ class VideoDevice_V4L2 : public VideoDevice { 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 Start(); int Stop();