dispmanx: fix grabber issues with certain widths and support cropping (#634)

* dispmanx: fix grabber issues with certain widths and support cropping

The dispmanx grabber will produce garbage output if the destination
pitch is not set to a multiple of 64 bytes (16 RGBA pixels).

It can also fail when retrieving only a part of the image
(eg in 3DSBS or TAB mode).

Handle these cases by capturing the full image into a separate
buffer with the pitch set to an appropriate value and manually
handle 3D SBS/TAB left/top half copying.

At this point supporting cropping like in the V4L2 grabber is
rather easy and added as well. This'll help handling overscan
setups (old TVs) and removing (possibly asymmetric) overscan
borders.

Cropping is disabled in video capture mode (when the
DISPMANX_SNAPSHOT_FILL flag is set).

Signed-off-by: Matthias Reichl <hias@horus.com>

* hyperion-dispmanx: add optional crop values and 3D mode options

Signed-off-by: Matthias Reichl <hias@horus.com>

* hyperiond: support cropping on the dispmanx grabber

Honor cropLeft, cropRight, cropTop and cropBottom settings in
the framegrabber section of the conf file to control cropping.

Signed-off-by: Matthias Reichl <hias@horus.com>

Former-commit-id: bbb55f6621b90384e417f37da4f2543d112ef57a
This commit is contained in:
Matthias Reichl
2016-05-18 11:26:25 +02:00
committed by brindosch
parent 4ccda40250
commit f584b05de5
8 changed files with 210 additions and 22 deletions

View File

@@ -2,10 +2,16 @@
// Hyperion-Dispmanx includes
#include "DispmanxWrapper.h"
DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight,
const VideoMode& videoMode,
const unsigned cropLeft, const unsigned cropRight,
const unsigned cropTop, const unsigned cropBottom,
const unsigned updateRate_Hz) :
_timer(this),
_grabber(grabWidth, grabHeight)
{
_grabber.setVideoMode(videoMode);
_grabber.setCropping(cropLeft, cropRight, cropTop, cropBottom);
_timer.setSingleShot(false);
_timer.setInterval(updateRate_Hz);

View File

@@ -9,7 +9,11 @@ class DispmanxWrapper : public QObject
{
Q_OBJECT
public:
DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight,
const VideoMode& videoMode,
const unsigned cropLeft, const unsigned cropRight,
const unsigned cropTop, const unsigned cropBottom,
const unsigned updateRate_Hz);
const Image<ColorRgb> & getScreenshot();

View File

@@ -46,6 +46,14 @@ int main(int argc, char ** argv)
SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
IntParameter & argCropLeft = parameters.add<IntParameter> (0x0, "crop-left", "pixels to remove on left after grabbing");
IntParameter & argCropRight = parameters.add<IntParameter> (0x0, "crop-right", "pixels to remove on right after grabbing");
IntParameter & argCropTop = parameters.add<IntParameter> (0x0, "crop-top", "pixels to remove on top after grabbing");
IntParameter & argCropBottom = parameters.add<IntParameter> (0x0, "crop-bottom", "pixels to remove on bottom after grabbing");
SwitchParameter<> & arg3DSBS = parameters.add<SwitchParameter<>> (0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
SwitchParameter<> & arg3DTAB = parameters.add<SwitchParameter<>> (0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
// set defaults
argFps.setDefault(10);
argWidth.setDefault(64);
@@ -53,9 +61,25 @@ int main(int argc, char ** argv)
argAddress.setDefault("127.0.0.1:19445");
argPriority.setDefault(800);
argCropLeft.setDefault(0);
argCropRight.setDefault(0);
argCropTop.setDefault(0);
argCropBottom.setDefault(0);
// parse all options
optionParser.parse(argc, const_cast<const char **>(argv));
VideoMode videoMode = VIDEO_2D;
if (arg3DSBS.isSet())
{
videoMode = VIDEO_3DSBS;
}
else if (arg3DTAB.isSet())
{
videoMode = VIDEO_3DTAB;
}
// check if we need to display the usage. exit if we do.
if (argHelp.isSet())
{
@@ -65,7 +89,13 @@ int main(int argc, char ** argv)
// Create the dispmanx grabbing stuff
int grabInterval = 1000 / argFps.getValue();
DispmanxWrapper dispmanxWrapper(argWidth.getValue(),argHeight.getValue(),grabInterval);
DispmanxWrapper dispmanxWrapper(argWidth.getValue(),argHeight.getValue(),
videoMode,
std::max(0, argCropLeft.getValue()),
std::max(0, argCropRight.getValue()),
std::max(0, argCropTop.getValue()),
std::max(0, argCropBottom.getValue()),
grabInterval);
if (argScreenshot.isSet())
{