Skip to content

Commit

Permalink
Merge pull request #9 from awawa-dev/developing
Browse files Browse the repository at this point in the history
Developing
  • Loading branch information
awawa-dev committed Sep 16, 2020
2 parents a05e665 + 528ecaf commit 97b42b1
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 11 deletions.
2 changes: 2 additions & 0 deletions assets/webconfig/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@
"edt_conf_v4l2_hdrToneMappingMode_expl" : "Only MJPG: mode 1 for Fullscreen or mode 2 for faster Border Mode",
"edt_conf_v4l2_fpsSoftwareDecimation_title" : "Software frame skipping",
"edt_conf_v4l2_fpsSoftwareDecimation_expl" : "To save resources every n'th frame will be processed only. For ex. if grabber is set to 30FPS with this option set to 5 the final result will be around 6FPS (1 - disabled)",
"edt_conf_v4l2_v4l2Encoding_title" : "Force encoding format on grabber",
"edt_conf_v4l2_v4l2Encoding_expl" : "Force video encoding for multiformat capable grabbers (make sure that's correct)",
"edt_conf_v4l2_signalDetection_title" : "Signal detection",
"edt_conf_v4l2_signalDetection_expl" : "If enabled, usb capture will be temporarily disabled when no signal was found. This will happen when the picture fall below the threshold value for a period of 4 seconds.",
"edt_conf_v4l2_redSignalThreshold_title" : "Red signal threshold",
Expand Down
4 changes: 3 additions & 1 deletion config/hyperion.config.json.commented
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
/// * hdrToneMapping : enable HDR to SDR tone mapping using LUT table [default=0, on=1, border mode =2]
/// * hdrToneMappingMode : LUT effect apply mode [fullscreen=1, border mode =2]
/// * fpsSoftwareDecimation: process every n'th received frame [default=1]
/// * v4l2Encoding : force encoding: NONE, MJPEG, YUYV
"grabberV4L2" :
{
"device" : "auto",
Expand All @@ -144,7 +145,8 @@
"sDHOffsetMax" : 0.75,
"hdrToneMapping" : false,
"hdrToneMappingMode" : 1,
"fpsSoftwareDecimation": 1
"fpsSoftwareDecimation": 1,
"v4l2Encoding" : "NONE"
},

/// The configuration for the frame-grabber, contains the following items:
Expand Down
3 changes: 2 additions & 1 deletion config/hyperion.config.json.default
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"sDHOffsetMax" : 0.75,
"hdrToneMapping" : false,
"hdrToneMappingMode" : 1,
"fpsSoftwareDecimation" : 1
"fpsSoftwareDecimation" : 1,
"v4l2Encoding" : "NONE"
},

"framegrabber" :
Expand Down
4 changes: 4 additions & 0 deletions include/grabber/V4L2Grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class V4L2Grabber : public Grabber
/// @brief enable HDR to SDR tone mapping (v4l2)
///
void setHdrToneMappingEnabled(int mode);

void setEncoding(QString enc);

public slots:

Expand Down Expand Up @@ -315,6 +317,8 @@ private slots:
V4L2WorkerManager _V4L2WorkerManager;

void ResetCounter(uint64_t from);

QString _enc;
protected:
void enumFrameIntervals(QStringList &framerates, int fileDescriptor, int pixelformat, int width, int height);
};
2 changes: 2 additions & 0 deletions include/grabber/V4L2Wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public slots:
///
void setHdrToneMappingEnabled(int mode);

void setEncoding(QString enc);

private slots:
void newFrame(const Image<ColorRgb> & image);
void readError(const char* err);
Expand Down
14 changes: 7 additions & 7 deletions include/utils/PixelFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@ inline PixelFormat parsePixelFormat(const QString& pixelFormat)
// convert to lower case
QString format = pixelFormat.toLower();

if (format.compare("yuyv") )
if (format.compare("yuyv") == 0)
{
return PixelFormat::YUYV;
}
else if (format.compare("uyvy") )
else if (format.compare("uyvy") == 0)
{
return PixelFormat::UYVY;
}
else if (format.compare("bgr16") )
else if (format.compare("bgr16") == 0)
{
return PixelFormat::BGR16;
}
else if (format.compare("bgr24") )
else if (format.compare("bgr24") == 0)
{
return PixelFormat::BGR24;
}
else if (format.compare("rgb32") )
else if (format.compare("rgb32") == 0)
{
return PixelFormat::RGB32;
}
else if (format.compare("bgr32") )
else if (format.compare("bgr32") == 0)
{
return PixelFormat::BGR32;
}
#ifdef HAVE_JPEG_DECODER
else if (format.compare("mjpeg") )
else if (format.compare("mjpeg") == 0)
{
return PixelFormat::MJPEG;
}
Expand Down
27 changes: 26 additions & 1 deletion libsrc/grabber/v4l2/V4L2Grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ V4L2Grabber::V4L2Grabber(const QString & device
, _lutBufferInit(false)
, _currentFrame(0)
, _configurationPath(configurationPath)
, _enc("NONE")

{
getV4Ldevices();
Expand All @@ -79,7 +80,8 @@ V4L2Grabber::V4L2Grabber(const QString & device
setInput(input);
setWidthHeight(width, height);
setFramerate(fps);
setDeviceVideoStandard(device, videoStandard);
setDeviceVideoStandard(device, videoStandard);
Debug(_log,"Init pixel format: %i", static_cast<int>(_pixelFormat));
}

void V4L2Grabber::loadLutFile(const QString & color)
Expand Down Expand Up @@ -1353,3 +1355,26 @@ void V4L2Grabber::handleCecEvent(CECEvent event)
default: break;
}
}

void V4L2Grabber::setEncoding(QString enc)
{
bool active = _V4L2WorkerManager.isActive();

_enc = enc;
_pixelFormat = parsePixelFormat(_enc);
Debug(_log,"Force encoding (setEncoding): %s (%i)", QSTRING_CSTR(_enc), static_cast<int>(_pixelFormat));

if (_pixelFormat != PixelFormat::NO_CHANGE)
{

Debug(_log,"Restarting v4l2 grabber");
uninit();
init();

if (active)
{
start();
}
}
}

7 changes: 7 additions & 0 deletions libsrc/grabber/v4l2/V4L2Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ void V4L2Wrapper::setFpsSoftwareDecimation(int decimation)
_grabber.setFpsSoftwareDecimation(decimation);
}

void V4L2Wrapper::setEncoding(QString enc)
{
_grabber.setEncoding(enc);
}

void V4L2Wrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
{
if(type == settings::V4L2 && _grabberName.startsWith("V4L"))
Expand Down Expand Up @@ -172,5 +177,7 @@ void V4L2Wrapper::handleSettingsUpdate(settings::type type, const QJsonDocument&
_grabber.setDeviceVideoStandard(
obj["device"].toString("auto"),
parseVideoStandard(obj["standard"].toString("no-change")));

_grabber.setEncoding(obj["v4l2Encoding"].toString("NONE"));
}
}
9 changes: 9 additions & 0 deletions libsrc/hyperion/schema/schema-grabberV4L2.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@
"default" : 1,
"required" : true,
"propertyOrder" : 27
},
"v4l2Encoding" :
{
"type" : "string",
"title" : "edt_conf_v4l2_v4l2Encoding_title",
"enum" : ["NONE", "mjpeg", "yuyv", "bgr16", "bgr24", "rgb32", "bgr32", "uyvy"],
"default" : "NONE",
"required" : true,
"propertyOrder" : 28
}
},
"additionalProperties" : true
Expand Down
1 change: 1 addition & 0 deletions src/hyperiond/hyperiond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
Debug(_log, "V4L2 grabber created");
// software frame skipping
_v4l2Grabber->setFpsSoftwareDecimation(grabberConfig["fpsSoftwareDecimation"].toInt(1));
_v4l2Grabber->setEncoding(grabberConfig["v4l2Encoding"].toString("NONE"));

_v4l2Grabber->setSignalThreshold(
grabberConfig["redSignalThreshold"].toDouble(0.0) / 100.0,
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.2.0.8A
8.2.0.8A

0 comments on commit 97b42b1

Please sign in to comment.