mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
V4L2: Fix error with frame size of RGB32
Former-commit-id: ab98c7b87acb7654c40a715ed21c0857c11a30ff
This commit is contained in:
parent
6be5652f8f
commit
ef6aa76409
@ -1 +1 @@
|
|||||||
0dd229e56d483fd0a75ae8a9d92fa142a6afa983
|
62843d7b04fbbe0a2ae994531100d2f3f3d73b11
|
@ -108,6 +108,7 @@ private:
|
|||||||
PixelFormat _pixelFormat;
|
PixelFormat _pixelFormat;
|
||||||
int _width;
|
int _width;
|
||||||
int _height;
|
int _height;
|
||||||
|
int _frameByteSize;
|
||||||
int _cropLeft;
|
int _cropLeft;
|
||||||
int _cropRight;
|
int _cropRight;
|
||||||
int _cropTop;
|
int _cropTop;
|
||||||
|
@ -52,6 +52,7 @@ V4L2Grabber::V4L2Grabber(const std::string & device,
|
|||||||
_pixelFormat(pixelFormat),
|
_pixelFormat(pixelFormat),
|
||||||
_width(width),
|
_width(width),
|
||||||
_height(height),
|
_height(height),
|
||||||
|
_frameByteSize(-1),
|
||||||
_cropLeft(0),
|
_cropLeft(0),
|
||||||
_cropRight(0),
|
_cropRight(0),
|
||||||
_cropTop(0),
|
_cropTop(0),
|
||||||
@ -426,25 +427,6 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
|
|||||||
throw_errno_exception("VIDIOC_G_FMT");
|
throw_errno_exception("VIDIOC_G_FMT");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check pixel format
|
|
||||||
switch (fmt.fmt.pix.pixelformat)
|
|
||||||
{
|
|
||||||
case V4L2_PIX_FMT_UYVY:
|
|
||||||
_pixelFormat = PIXELFORMAT_UYVY;
|
|
||||||
std::cout << "V4L2 pixel format=UYVY" << std::endl;
|
|
||||||
break;
|
|
||||||
case V4L2_PIX_FMT_YUYV:
|
|
||||||
_pixelFormat = PIXELFORMAT_YUYV;
|
|
||||||
std::cout << "V4L2 pixel format=YUYV" << std::endl;
|
|
||||||
break;
|
|
||||||
case V4L2_PIX_FMT_RGB32:
|
|
||||||
_pixelFormat = PIXELFORMAT_RGB32;
|
|
||||||
std::cout << "V4L2 pixel format=RGB32" << std::endl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw_exception("Only pixel formats UYVY, YUYV, and RGB32 are supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
// store width & height
|
// store width & height
|
||||||
_width = fmt.fmt.pix.width;
|
_width = fmt.fmt.pix.width;
|
||||||
_height = fmt.fmt.pix.height;
|
_height = fmt.fmt.pix.height;
|
||||||
@ -452,6 +434,28 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
|
|||||||
// print the eventually used width and height
|
// print the eventually used width and height
|
||||||
std::cout << "V4L2 width=" << _width << " height=" << _height << std::endl;
|
std::cout << "V4L2 width=" << _width << " height=" << _height << std::endl;
|
||||||
|
|
||||||
|
// check pixel format and frame size
|
||||||
|
switch (fmt.fmt.pix.pixelformat)
|
||||||
|
{
|
||||||
|
case V4L2_PIX_FMT_UYVY:
|
||||||
|
_pixelFormat = PIXELFORMAT_UYVY;
|
||||||
|
_frameByteSize = _width * _height * 2;
|
||||||
|
std::cout << "V4L2 pixel format=UYVY" << std::endl;
|
||||||
|
break;
|
||||||
|
case V4L2_PIX_FMT_YUYV:
|
||||||
|
_pixelFormat = PIXELFORMAT_YUYV;
|
||||||
|
_frameByteSize = _width * _height * 2;
|
||||||
|
std::cout << "V4L2 pixel format=YUYV" << std::endl;
|
||||||
|
break;
|
||||||
|
case V4L2_PIX_FMT_RGB32:
|
||||||
|
_pixelFormat = PIXELFORMAT_RGB32;
|
||||||
|
_frameByteSize = _width * _height * 4;
|
||||||
|
std::cout << "V4L2 pixel format=RGB32" << std::endl;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw_exception("Only pixel formats UYVY, YUYV, and RGB32 are supported");
|
||||||
|
}
|
||||||
|
|
||||||
switch (_ioMethod) {
|
switch (_ioMethod) {
|
||||||
case IO_METHOD_READ:
|
case IO_METHOD_READ:
|
||||||
init_read(fmt.fmt.pix.sizeimage);
|
init_read(fmt.fmt.pix.sizeimage);
|
||||||
@ -667,9 +671,9 @@ bool V4L2Grabber::process_image(const void *p, int size)
|
|||||||
{
|
{
|
||||||
// We do want a new frame...
|
// We do want a new frame...
|
||||||
|
|
||||||
if (size != 2*_width*_height)
|
if (size != _frameByteSize)
|
||||||
{
|
{
|
||||||
std::cout << "Frame too small: " << size << " != " << (2*_width*_height) << std::endl;
|
std::cout << "Frame too small: " << size << " != " << _frameByteSize << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user