vdr-plugin-softhddevice-drm-gles 1.4.0
Macros | Functions
buf2rgb.cpp File Reference

Some helper functions to convert and blit buffers. More...

#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
#include <sys/mman.h>
#include <drm_fourcc.h>
#include "buf2rgb.h"
#include "logger.h"
#include "drmbuffer.h"
Include dependency graph for buf2rgb.cpp:

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

Detailed Description

Some helper functions to convert and blit buffers.

Definition in file buf2rgb.cpp.

Macro Definition Documentation

◆ BLEND

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

Definition at line 35 of file buf2rgb.cpp.

◆ OPAQUE

#define OPAQUE   0xff

Definition at line 32 of file buf2rgb.cpp.

◆ TRANSPARENT

#define TRANSPARENT   0x00

Definition at line 33 of file buf2rgb.cpp.

◆ UNMULTIPLY

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

Definition at line 34 of file buf2rgb.cpp.

Function Documentation

◆ AlphaBlend()

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

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 203 of file buf2rgb.cpp.

References BLEND, OPAQUE, TRANSPARENT, and UNMULTIPLY.

Referenced by cSoftHdDevice::GrabImage().

◆ BlitVideo()

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.

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 264 of file buf2rgb.cpp.

References L_GRAB, and LOGDEBUG2.

Referenced by cSoftHdDevice::GrabImage().

◆ BufToRgb()

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

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 74 of file buf2rgb.cpp.

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

Referenced by cVideoRender::ConvertOsdBufToRgb(), cVideoRender::ConvertPipBufToRgb(), and cVideoRender::ConvertVideoBufToRgb().

◆ DrmFormatToAVFormat()

enum AVPixelFormat DrmFormatToAVFormat ( cDrmBuffer buf)

Convert a DRM format to a ffmpeg AV format.

Definition at line 44 of file buf2rgb.cpp.

References cDrmBuffer::PixFmt().

Referenced by BufToRgb().

◆ PrintStreamData()

void PrintStreamData ( const uint8_t *  data,
int  size 
)

Print raw stream data.

Parameters
datapointer to stream data
sizedata size

Definition at line 288 of file buf2rgb.cpp.

References LOGDEBUG.

◆ ScaleRgb24()

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

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 152 of file buf2rgb.cpp.

References L_GRAB, LOGDEBUG2, and LOGERROR.

Referenced by cSoftHdDevice::GrabImage().