mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
move whole logic to MF-grabber
This commit is contained in:
parent
0b75e90c54
commit
9cd21272c9
@ -31,7 +31,7 @@ public:
|
|||||||
PixelFormat pixelFormat, uint8_t* sharedData,
|
PixelFormat pixelFormat, uint8_t* sharedData,
|
||||||
int size, int width, int height, int lineLength,
|
int size, int width, int height, int lineLength,
|
||||||
int cropLeft, int cropTop, int cropBottom, int cropRight,
|
int cropLeft, int cropTop, int cropBottom, int cropRight,
|
||||||
VideoMode videoMode, bool bottomUp, FlipMode flipMode, int pixelDecimation);
|
VideoMode videoMode, FlipMode flipMode, int pixelDecimation);
|
||||||
|
|
||||||
void process();
|
void process();
|
||||||
|
|
||||||
@ -55,7 +55,6 @@ private:
|
|||||||
int _cropTop;
|
int _cropTop;
|
||||||
int _cropBottom;
|
int _cropBottom;
|
||||||
int _cropRight;
|
int _cropRight;
|
||||||
bool _bottomUp;
|
|
||||||
FlipMode _flipMode;
|
FlipMode _flipMode;
|
||||||
VideoMode _videoMode;
|
VideoMode _videoMode;
|
||||||
bool _doTransform;
|
bool _doTransform;
|
||||||
@ -96,14 +95,14 @@ public:
|
|||||||
PixelFormat pixelFormat, uint8_t* sharedData,
|
PixelFormat pixelFormat, uint8_t* sharedData,
|
||||||
int size, int width, int height, int lineLength,
|
int size, int width, int height, int lineLength,
|
||||||
int cropLeft, int cropTop, int cropBottom, int cropRight,
|
int cropLeft, int cropTop, int cropBottom, int cropRight,
|
||||||
VideoMode videoMode, bool bottomUp, FlipMode flipMode, int pixelDecimation)
|
VideoMode videoMode, FlipMode flipMode, int pixelDecimation)
|
||||||
{
|
{
|
||||||
auto encThread = qobject_cast<EncoderThread*>(_thread);
|
auto encThread = qobject_cast<EncoderThread*>(_thread);
|
||||||
if (encThread != nullptr)
|
if (encThread != nullptr)
|
||||||
encThread->setup(pixelFormat, sharedData,
|
encThread->setup(pixelFormat, sharedData,
|
||||||
size, width, height, lineLength,
|
size, width, height, lineLength,
|
||||||
cropLeft, cropTop, cropBottom, cropRight,
|
cropLeft, cropTop, cropBottom, cropRight,
|
||||||
videoMode, bottomUp, flipMode, pixelDecimation);
|
videoMode, flipMode, pixelDecimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isBusy()
|
bool isBusy()
|
||||||
|
@ -109,7 +109,6 @@ private:
|
|||||||
EncoderThreadManager* _threadManager;
|
EncoderThreadManager* _threadManager;
|
||||||
PixelFormat _pixelFormat,
|
PixelFormat _pixelFormat,
|
||||||
_pixelFormatConfig;
|
_pixelFormatConfig;
|
||||||
bool _bottomUp;
|
|
||||||
int _lineLength,
|
int _lineLength,
|
||||||
_frameByteSize,
|
_frameByteSize,
|
||||||
_noSignalCounterThreshold,
|
_noSignalCounterThreshold,
|
||||||
|
@ -15,7 +15,6 @@ public:
|
|||||||
void setVerticalPixelDecimation(int decimator) { _verticalDecimation = decimator; }
|
void setVerticalPixelDecimation(int decimator) { _verticalDecimation = decimator; }
|
||||||
void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
|
void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
|
||||||
void setVideoMode(VideoMode mode) { _videoMode = mode; }
|
void setVideoMode(VideoMode mode) { _videoMode = mode; }
|
||||||
void setBottomUp(bool isBottomUp) { _bottomUp = isBottomUp; }
|
|
||||||
void setFlipMode(FlipMode mode) { _flipMode = mode; }
|
void setFlipMode(FlipMode mode) { _flipMode = mode; }
|
||||||
void processImage(const uint8_t * data, int width, int height, int lineLength, PixelFormat pixelFormat, Image<ColorRgb> & outputImage) const;
|
void processImage(const uint8_t * data, int width, int height, int lineLength, PixelFormat pixelFormat, Image<ColorRgb> & outputImage) const;
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ private:
|
|||||||
int _cropTop;
|
int _cropTop;
|
||||||
int _cropBottom;
|
int _cropBottom;
|
||||||
VideoMode _videoMode;
|
VideoMode _videoMode;
|
||||||
bool _bottomUp;
|
|
||||||
FlipMode _flipMode;
|
FlipMode _flipMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -40,7 +40,7 @@ void EncoderThread::setup(
|
|||||||
PixelFormat pixelFormat, uint8_t* sharedData,
|
PixelFormat pixelFormat, uint8_t* sharedData,
|
||||||
int size, int width, int height, int lineLength,
|
int size, int width, int height, int lineLength,
|
||||||
int cropLeft, int cropTop, int cropBottom, int cropRight,
|
int cropLeft, int cropTop, int cropBottom, int cropRight,
|
||||||
VideoMode videoMode, bool bottomUp, FlipMode flipMode, int pixelDecimation)
|
VideoMode videoMode, FlipMode flipMode, int pixelDecimation)
|
||||||
{
|
{
|
||||||
_lineLength = lineLength;
|
_lineLength = lineLength;
|
||||||
_pixelFormat = pixelFormat;
|
_pixelFormat = pixelFormat;
|
||||||
@ -51,7 +51,6 @@ void EncoderThread::setup(
|
|||||||
_cropTop = cropTop;
|
_cropTop = cropTop;
|
||||||
_cropBottom = cropBottom;
|
_cropBottom = cropBottom;
|
||||||
_cropRight = cropRight;
|
_cropRight = cropRight;
|
||||||
_bottomUp = bottomUp;
|
|
||||||
_flipMode = flipMode;
|
_flipMode = flipMode;
|
||||||
_videoMode = videoMode;
|
_videoMode = videoMode;
|
||||||
_pixelDecimation = pixelDecimation;
|
_pixelDecimation = pixelDecimation;
|
||||||
@ -82,7 +81,6 @@ void EncoderThread::setup(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
_imageResampler.setVideoMode(_videoMode);
|
_imageResampler.setVideoMode(_videoMode);
|
||||||
_imageResampler.setBottomUp(_bottomUp);
|
|
||||||
_imageResampler.setFlipMode(_flipMode);
|
_imageResampler.setFlipMode(_flipMode);
|
||||||
_imageResampler.setCropping(_cropLeft, _cropRight, _cropTop, _cropBottom);
|
_imageResampler.setCropping(_cropLeft, _cropRight, _cropTop, _cropBottom);
|
||||||
_imageResampler.setHorizontalPixelDecimation(_pixelDecimation);
|
_imageResampler.setHorizontalPixelDecimation(_pixelDecimation);
|
||||||
|
@ -359,11 +359,22 @@ done:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_pixelFormat = props.pf;
|
_pixelFormat = props.pf;
|
||||||
_bottomUp = (props.defstride < 0);
|
|
||||||
_width = props.width;
|
_width = props.width;
|
||||||
_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
|
||||||
@ -550,7 +561,7 @@ void MFGrabber::process_image(const void *frameImageBuffer, int size)
|
|||||||
{
|
{
|
||||||
if (!_threadManager->_threads[i]->isBusy())
|
if (!_threadManager->_threads[i]->isBusy())
|
||||||
{
|
{
|
||||||
_threadManager->_threads[i]->setup(_pixelFormat, (uint8_t*)frameImageBuffer, size, _width, _height, _lineLength, _cropLeft, _cropTop, _cropBottom, _cropRight, _videoMode, _bottomUp, _flipMode, _pixelDecimation);
|
_threadManager->_threads[i]->setup(_pixelFormat, (uint8_t*)frameImageBuffer, size, _width, _height, _lineLength, _cropLeft, _cropTop, _cropBottom, _cropRight, _videoMode, _flipMode, _pixelDecimation);
|
||||||
_threadManager->_threads[i]->process();
|
_threadManager->_threads[i]->process();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1046,7 +1046,7 @@ bool V4L2Grabber::process_image(const void *p, int size)
|
|||||||
{
|
{
|
||||||
if (!_threadManager->_threads[i]->isBusy())
|
if (!_threadManager->_threads[i]->isBusy())
|
||||||
{
|
{
|
||||||
_threadManager->_threads[i]->setup(_pixelFormat, (uint8_t*)p, size, _width, _height, _lineLength, _cropLeft, _cropTop, _cropBottom, _cropRight, _videoMode, false, _flipMode, _pixelDecimation);
|
_threadManager->_threads[i]->setup(_pixelFormat, (uint8_t*)p, size, _width, _height, _lineLength, _cropLeft, _cropTop, _cropBottom, _cropRight, _videoMode, _flipMode, _pixelDecimation);
|
||||||
_threadManager->_threads[i]->process();
|
_threadManager->_threads[i]->process();
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
|
@ -10,7 +10,6 @@ ImageResampler::ImageResampler()
|
|||||||
, _cropTop(0)
|
, _cropTop(0)
|
||||||
, _cropBottom(0)
|
, _cropBottom(0)
|
||||||
, _videoMode(VideoMode::VIDEO_2D)
|
, _videoMode(VideoMode::VIDEO_2D)
|
||||||
, _bottomUp(false)
|
|
||||||
, _flipMode(FlipMode::NO_CHANGE)
|
, _flipMode(FlipMode::NO_CHANGE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -54,20 +53,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
|
|||||||
int xDestStart, xDestEnd;
|
int xDestStart, xDestEnd;
|
||||||
int yDestStart, yDestEnd;
|
int yDestStart, yDestEnd;
|
||||||
|
|
||||||
FlipMode flipMode = _flipMode;
|
switch (_flipMode)
|
||||||
if (_bottomUp)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (flipMode)
|
|
||||||
{
|
{
|
||||||
case FlipMode::NO_CHANGE:
|
case FlipMode::NO_CHANGE:
|
||||||
xDestStart = 0;
|
xDestStart = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user