51#include <libavutil/imgutils.h>
52#include <libswscale/swscale.h>
57#include <drm_fourcc.h>
73#define TRANSPARENT 0x00
74#define UNMULTIPLY(color, alpha) ((0xff * color) / alpha)
75#define BLEND(back, front, alpha) ((front * alpha) + (back * (255 - alpha))) / 255
84 unsigned int w,
unsigned int h)
99 const unsigned int w3 = w &
mask;
100 const unsigned int w2 = w - (
w1 +
w3);
122 unsigned int w,
unsigned int h)
124 const unsigned int x1 = (w / 3) * 4;
125 const unsigned int xrem1 = w - (
x1 >> 2) * 3;
142 *
d++ = (
p3 >> 10) & 0x3ff;
143 *
d++ = (
p3 >> 20) & 0x3ff;
145 if (((x += 4) &
mask) == 0)
154 *
d++ = (
p3 >> 10) & 0x3ff;
166 unsigned int w,
unsigned int h)
168 const unsigned int x1 = (w / 3) * 8;
169 const unsigned int xrem1 = w - (
x1 >> 3) * 3;
189 *
dv++ = (
p3a >> 10) & 0x3ff;
190 *
du++ = (
p3a >> 20) & 0x3ff;
192 *
du++ = (
p3b >> 10) & 0x3ff;
193 *
dv++ = (
p3b >> 20) & 0x3ff;
195 if (((x += 8) &
mask) == 0)
204 *
dv++ = (
p3a >> 10) & 0x3ff;
206 *
du++ = (
p3a >> 20) & 0x3ff;
302 for (
unsigned long index = 0; index < width * height; index++) {
306 for (
int i = 0;
i < 3;
i++) {
316 for (
int i = 0;
i < 3;
i++) {
372 for (
int y = 0; y <
srcH; y++) {
383 int width,
int height)
418 for (
int i = 0;
i < 4;
i++) {
445 if (
src->GetScreenRect().IsEmpty())
452 if (!
src->Plane(0)) {
453 for (
int object = 0;
object <
src->NumObjects();
object++) {
466 LOGERROR(
"%s: %s: cannot map buffer size %d prime_fd %d (%d): %m",
476 if (
src->ObjectIndex(
plane) ==
object)
498 for (
int i = 0;
i <
src->NumPlanes();
i++) {
506 LOGDEBUG2(
L_GRAB,
"%s: %s: Set input buffer: %dx%d pixFmt %d modifier %d num planes %d with %dx%d at %d|%d",
507 m_identifier,
__FUNCTION__,
m_width,
m_height,
m_pixFmt,
m_modifier,
m_numPlanes,
m_outputRect.Width(),
m_outputRect.Height(),
m_outputRect.X(),
m_outputRect.Y());
509 LOGDEBUG2(
L_GRAB,
"%s: %s: Copied plane %d address %p pitch %d offset %d size %d",
738 if (!
grab->IsSet()) {
740 grab->SetOutputSize(0);
752 *size =
grab->GetOutputSize();
754 *width =
grab->GetOutputWidth();
756 *height =
grab->GetOutputHeight();
758 *x =
grab->GetOutputX();
760 *y =
grab->GetOutputY();
762 return grab->GetOutputData();
int m_outputSize
size of grabbed data
const char * m_identifier
void Clear(void)
Clear the grab buffer (input and output data)
uint8_t * m_pOutputData
pointer to grabbed image
void Set(cDrmBuffer *)
Set the grab buffer and the dimensions how it is presented on the screen.
void FreeInput(void)
Free the grab input buffer.
cRect m_outputRect
rect of the grabbed data
uint8_t * ConvertToRgb(int *)
Convert a grabbed buffer to rgb format image.
int GetOutputHeight(void)
int m_screenWidth
pixel screenwidth
uint8_t * GetGrabbedOsdData(int *, int *, int *, int *, int *)
int m_quality
quality of the jpeg image
uint8_t * m_grabbedImage
pointer to the finished grabbed image
std::atomic< bool > m_active
true, if a grab process is currently running
int m_grabbedWidth
pixel width of the grabbed image
int m_screenHeight
pixel screenheight
uint8_t * GetGrabbedData(int *, int *, int *, int *, int *, cGrabBuffer *)
Convert the cloned drm buffer data to RGB(void, pip) or ARGB (osd) and return a pointer to the raw da...
bool Start(bool, int, int, int, int, int)
Start a grab in the video renderer.
uint8_t * GetGrabbedVideoData(int *, int *, int *, int *, int *)
uint8_t * GetGrabbedPipData(int *, int *, int *, int *, int *)
int m_grabbedSize
data size of the grabbed image
bool m_isJpeg
true, if a jpeg image was requested
bool ProcessGrab(void)
Start the conversion.
int m_grabbedHeight
pixel height of the grabbed image
cVideoRender * m_pRender
pointer to cVideoRender object
void Finish(void)
Clean up.
cGrabBuffer * GetGrabbedPipBuffer(void)
cGrabBuffer * GetGrabbedVideoBuffer(void)
cGrabBuffer * GetGrabbedOsdBuffer(void)
int TriggerGrab(void)
Trigger a screen grab.
void ClearGrabBuffers(void)
Clear the grab drm buffers.
Grabbing Interface Header File.
#define UNMULTIPLY(color, alpha)
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
static void Sand30ToPlanarC16(uint8_t *dstU, const unsigned int dstStrideU, uint8_t *dstV, const unsigned int dstStrideV, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int w, unsigned int h)
Convert the chroma (UV plane) from SAND to linear buffer (10bit)
#define BLEND(back, front, alpha)
#define LOGERROR
log to LOG_ERR
static uint8_t * ScaleRgb24(uint8_t *src, int *size, int srcW, int srcH, int dstW, int dstH)
Scale an image.
void Sand128ToPlanarY8(uint8_t *dst, const unsigned int dstStride, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int w, unsigned int h)
Convert the luma (Y plane) from SAND to linear buffer (8bit)
static void Sand30ToPlanarY16(uint8_t *dst, const unsigned int dstStride, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int w, unsigned int h)
Convert the luma (Y plane) from SAND to linear buffer (10bit)
static int BlitVideo(uint8_t *dst, uint8_t *src, int dstW, int dstH, int dstX, int dstY, int srcW, int srcH)
Blit the video on black background.
uint8_t * CreateJpeg(uint8_t *image, int *size, int quality, int width, int height)
Call rgb to jpeg for C Plugin.
enum AVPixelFormat DrmFormatToAVFormat(uint32_t pixFmt)
Convert a DRM format to a ffmpeg AV format.
static void AlphaBlend(uint8_t *result, uint8_t *front, uint8_t *back, const unsigned int width, const unsigned int height)
Blend two images.
Video Renderer (Display) Header File.