vdr-plugin-softhddevice-drm-gles 1.5.9-20e15de
grab.cpp File Reference

Grabing classes. More...

#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
#include <sys/mman.h>
#include <drm_fourcc.h>
#include "drmbuffer.h"
#include "grab.h"
#include "logger.h"
#include "videorender.h"

Go to the source code of this file.

Macros

#define OPAQUE   0xff
 
#define TRANSPARENT   0x00
 
#define UNMULTIPLY(color, alpha)   ((0xff * color) / alpha)
 
#define BLEND(back, front, alpha)   ((front * alpha) + (back * (255 - alpha))) / 255
 

Functions

enum AVPixelFormat DrmFormatToAVFormat (cDrmBuffer *buf)
 Convert a DRM format to a ffmpeg AV format.
 
static uint8_t * BufToRgb (cDrmBuffer *buf, int *size, int dstW, int dstH, enum AVPixelFormat dstPixFmt)
 Convert a DRM buffer to rgb format image.
 
static uint8_t * ScaleRgb24 (uint8_t *src, int *size, int srcW, int srcH, int dstW, int dstH)
 Scale an image.
 
static void AlphaBlend (uint8_t *result, uint8_t *front, uint8_t *back, const unsigned int width, const unsigned int height)
 Blend two images.
 
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.
 

Detailed Description

Grabing classes.

This file defines cGrabBuffer and cSoftHdGrab, which are used to handle grab requests.

Definition in file grab.cpp.

Macro Definition Documentation

◆ BLEND

#define BLEND (   back,
  front,
  alpha 
)    ((front * alpha) + (back * (255 - alpha))) / 255

Definition at line 43 of file grab.cpp.

◆ OPAQUE

#define OPAQUE   0xff

Definition at line 40 of file grab.cpp.

◆ TRANSPARENT

#define TRANSPARENT   0x00

Definition at line 41 of file grab.cpp.

◆ UNMULTIPLY

#define UNMULTIPLY (   color,
  alpha 
)    ((0xff * color) / alpha)

Definition at line 42 of file grab.cpp.

Function Documentation

◆ AlphaBlend()

static void AlphaBlend ( uint8_t *  result,
uint8_t *  front,
uint8_t *  back,
const unsigned int  width,
const unsigned int  height 
)
static

Blend two images.

Both, front and back image data have to be same size front is the OSD (ARGB) back is the video (RGB) result is RGB

Parameters
[out]resultpointer to the resulting image data
[in]frontpointer to the upper image data
[in]backpointer to the lower image data
[in]widthimage width
[in]heightimage height

Definition at line 207 of file grab.cpp.

References BLEND, OPAQUE, TRANSPARENT, and UNMULTIPLY.

Referenced by cSoftHdGrab::ProcessGrab().

◆ BlitVideo()

static int BlitVideo ( uint8_t *  dst,
uint8_t *  src,
int  dstW,
int  dstH,
int  dstX,
int  dstY,
int  srcW,
int  srcH 
)
static

Blit the video on black background.

Parameters
[in]dstpointer to the destination video
[in]srcpointer to the source video
[in]dstWdestination width of the image
[in]dstHdestination height of the image
[in]dstXx offset of the (already scaled) video on the image
[in]dstYy offset of the (already scaled) video on the image
[in]srcWsource video width
[in]srcHsource video height
Returns
0 on success, -1 on error

Definition at line 268 of file grab.cpp.

References L_GRAB, and LOGDEBUG2.

Referenced by cSoftHdGrab::ProcessGrab().

◆ BufToRgb()

static uint8_t * BufToRgb ( cDrmBuffer buf,
int *  size,
int  dstW,
int  dstH,
enum AVPixelFormat  dstPixFmt 
)
static

Convert a DRM buffer to rgb format image.

Conversion is done with ffmpegs swscale

Parameters
[in]bufpointer to the source drm buffer struct
[out]sizesize of the return data
[in]dstWwidth of the returned image
[in]dstHheight of the returned image
[in]dstPixFmtpixel format of the returned image
Returns
a pointer to the image data

Definition at line 78 of file grab.cpp.

References DrmFormatToAVFormat(), cDrmBuffer::Height(), L_GRAB, LOGDEBUG2, LOGERROR, cDrmBuffer::NumPlanes(), cDrmBuffer::Offset(), cDrmBuffer::Pitch(), cDrmBuffer::Plane(), cDrmBuffer::Size(), and cDrmBuffer::Width().

Referenced by cSoftHdGrab::GetGrab().

◆ CreateJpeg()

uint8_t * CreateJpeg ( uint8_t *  image,
int *  size,
int  quality,
int  width,
int  height 
)

Call rgb to jpeg for C Plugin.

Definition at line 431 of file grab.cpp.

Referenced by cSoftHdGrab::ProcessGrab().

◆ DrmFormatToAVFormat()

enum AVPixelFormat DrmFormatToAVFormat ( cDrmBuffer buf)

Convert a DRM format to a ffmpeg AV format.

Definition at line 48 of file grab.cpp.

References cDrmBuffer::PixFmt().

Referenced by BufToRgb().

◆ ScaleRgb24()

static uint8_t * ScaleRgb24 ( uint8_t *  src,
int *  size,
int  srcW,
int  srcH,
int  dstW,
int  dstH 
)
static

Scale an image.

Conversion is done with ffmpegs swscale

Parameters
[in]srcpointer to the source data
[out]sizesize of the return data
[in]srcWsource width
[in]srcHsource height
[in]dstWwidth of the returned image
[in]dstHheight of the returned image
Returns
a pointer to the converted image data

Definition at line 156 of file grab.cpp.

References L_GRAB, LOGDEBUG2, and LOGERROR.

Referenced by cSoftHdGrab::ProcessGrab().