mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
MF-grabber: Add support for bottom-up image handling (#1752)
* prepare bottom-up image handling * add default stride handling, code cleaning * fix code * move whole logic to MF-grabber * minor fix --------- Co-authored-by: Thinner77 <none>
This commit is contained in:
parent
943f9e22f3
commit
7f90637a2d
@ -46,6 +46,7 @@ public:
|
|||||||
int numerator = 0;
|
int numerator = 0;
|
||||||
int denominator = 0;
|
int denominator = 0;
|
||||||
PixelFormat pf = PixelFormat::NO_CHANGE;
|
PixelFormat pf = PixelFormat::NO_CHANGE;
|
||||||
|
long defstride = 0;
|
||||||
GUID guid = GUID_NULL;
|
GUID guid = GUID_NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,10 +124,10 @@ inline QString pixelFormatToString(const PixelFormat& pixelFormat)
|
|||||||
|
|
||||||
enum class FlipMode
|
enum class FlipMode
|
||||||
{
|
{
|
||||||
|
NO_CHANGE,
|
||||||
HORIZONTAL,
|
HORIZONTAL,
|
||||||
VERTICAL,
|
VERTICAL,
|
||||||
BOTH,
|
BOTH
|
||||||
NO_CHANGE
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline FlipMode parseFlipMode(const QString& flipMode)
|
inline FlipMode parseFlipMode(const QString& flipMode)
|
||||||
|
@ -363,6 +363,18 @@ done:
|
|||||||
_height = props.height;
|
_height = props.height;
|
||||||
_frameByteSize = _width * _height * 3;
|
_frameByteSize = _width * _height * 3;
|
||||||
_lineLength = _width * 3;
|
_lineLength = _width * 3;
|
||||||
|
// adjust flipMode for bottom-up images
|
||||||
|
if (props.defstride < 0)
|
||||||
|
{
|
||||||
|
if (_flipMode == FlipMode::NO_CHANGE)
|
||||||
|
_flipMode = FlipMode::HORIZONTAL;
|
||||||
|
else if (_flipMode == FlipMode::HORIZONTAL)
|
||||||
|
_flipMode = FlipMode::NO_CHANGE;
|
||||||
|
else if (_flipMode == FlipMode::VERTICAL)
|
||||||
|
_flipMode = FlipMode::BOTH;
|
||||||
|
else if (_flipMode == FlipMode::BOTH)
|
||||||
|
_flipMode = FlipMode::VERTICAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
@ -436,6 +448,14 @@ void MFGrabber::enumVideoCaptureDevices()
|
|||||||
properties.denominator = denominator;
|
properties.denominator = denominator;
|
||||||
properties.pf = pixelformat;
|
properties.pf = pixelformat;
|
||||||
properties.guid = format;
|
properties.guid = format;
|
||||||
|
|
||||||
|
HRESULT hr = pType->GetUINT32(MF_MT_DEFAULT_STRIDE, (UINT32*)&properties.defstride);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
hr = MFGetStrideForBitmapInfoHeader(format.Data1, width, &properties.defstride);
|
||||||
|
if (FAILED(hr))
|
||||||
|
DebugIf (verbose, _log, "failed to get default stride");
|
||||||
|
}
|
||||||
devicePropertyList.append(properties);
|
devicePropertyList.append(properties);
|
||||||
|
|
||||||
DebugIf (verbose, _log, "%s %d x %d @ %d fps (%s)", QSTRING_CSTR(dev), properties.width, properties.height, properties.fps, QSTRING_CSTR(pixelFormatToString(properties.pf)));
|
DebugIf (verbose, _log, "%s %d x %d @ %d fps (%s)", QSTRING_CSTR(dev), properties.width, properties.height, properties.fps, QSTRING_CSTR(pixelFormatToString(properties.pf)));
|
||||||
@ -797,7 +817,7 @@ QJsonArray MFGrabber::discover(const QJsonObject& params)
|
|||||||
resolution_default["width"] = 640;
|
resolution_default["width"] = 640;
|
||||||
resolution_default["height"] = 480;
|
resolution_default["height"] = 480;
|
||||||
resolution_default["fps"] = 25;
|
resolution_default["fps"] = 25;
|
||||||
format_default["format"] = "bgr24";
|
format_default["format"] = "rgb24";
|
||||||
format_default["resolution"] = resolution_default;
|
format_default["resolution"] = resolution_default;
|
||||||
video_inputs_default["inputIdx"] = 0;
|
video_inputs_default["inputIdx"] = 0;
|
||||||
video_inputs_default["standards"] = "PAL";
|
video_inputs_default["standards"] = "PAL";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user