add default stride handling, code cleaning

This commit is contained in:
unknown 2024-06-04 19:56:58 +02:00
parent ac9aaf4037
commit 382cc13650
3 changed files with 19 additions and 13 deletions

View File

@ -46,6 +46,7 @@ public:
int numerator = 0;
int denominator = 0;
PixelFormat pf = PixelFormat::NO_CHANGE;
long defstride = 0;
GUID guid = GUID_NULL;
};
@ -108,6 +109,7 @@ private:
EncoderThreadManager* _threadManager;
PixelFormat _pixelFormat,
_pixelFormatConfig;
bool _bottomUp;
int _lineLength,
_frameByteSize,
_noSignalCounterThreshold,

View File

@ -359,6 +359,7 @@ done:
else
{
_pixelFormat = props.pf;
_bottomUp = (props.defstride < 0);
_width = props.width;
_height = props.height;
_frameByteSize = _width * _height * 3;
@ -436,6 +437,14 @@ void MFGrabber::enumVideoCaptureDevices()
properties.denominator = denominator;
properties.pf = pixelformat;
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);
DebugIf (verbose, _log, "%s %d x %d @ %d fps (%s)", QSTRING_CSTR(dev), properties.width, properties.height, properties.fps, QSTRING_CSTR(pixelFormatToString(properties.pf)));
@ -541,7 +550,7 @@ void MFGrabber::process_image(const void *frameImageBuffer, int size)
{
if (!_threadManager->_threads[i]->isBusy())
{
_threadManager->_threads[i]->setup(_pixelFormat, (uint8_t*)frameImageBuffer, size, _width, _height, _lineLength, _cropLeft, _cropTop, _cropBottom, _cropRight, _videoMode, (_pixelFormat == PixelFormat::BGR24), _flipMode, _pixelDecimation);
_threadManager->_threads[i]->setup(_pixelFormat, (uint8_t*)frameImageBuffer, size, _width, _height, _lineLength, _cropLeft, _cropTop, _cropBottom, _cropRight, _videoMode, _bottomUp, _flipMode, _pixelDecimation);
_threadManager->_threads[i]->process();
break;
}
@ -797,7 +806,7 @@ QJsonArray MFGrabber::discover(const QJsonObject& params)
resolution_default["width"] = 640;
resolution_default["height"] = 480;
resolution_default["fps"] = 25;
format_default["format"] = "bgr24";
format_default["format"] = "rgb24";
format_default["resolution"] = resolution_default;
video_inputs_default["inputIdx"] = 0;
video_inputs_default["standards"] = "PAL";

View File

@ -54,24 +54,19 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
int xDestStart, xDestEnd;
int yDestStart, yDestEnd;
FlipMode flipMode;
if (!_bottomUp)
{
flipMode = _flipMode;
}
else
if (bottomUp)
{
if (_flipMode == FlipMode::NO_CHANGE)
flipMode = FlipMode::HORIZONTAL;
_flipMode = FlipMode::HORIZONTAL;
else if (_flipMode == FlipMode::HORIZONTAL)
flipMode = FlipMode::NO_CHANGE;
_flipMode = FlipMode::NO_CHANGE;
else if (_flipMode == FlipMode::VERTICAL)
flipMode = FlipMode::BOTH;
_flipMode = FlipMode::BOTH;
else if (_flipMode == FlipMode::BOTH)
flipMode = FlipMode::VERTICAL;
_flipMode = FlipMode::VERTICAL;
}
switch (flipMode)
switch (_flipMode)
{
case FlipMode::NO_CHANGE:
xDestStart = 0;