MythTV  master
Macros | Functions
yuv2rgb.cpp File Reference

Contains various YUV, VUY and RGBA colorspace conversion routines. More...

#include <algorithm>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include "mythconfig.h"
#include "yuv2rgb.h"
Include dependency graph for yuv2rgb.cpp:

Go to the source code of this file.

Macros

#define movntq(src, dest)
 
#define SCALE_BITS   10
 
#define C_Y   (76309 >> (16 - SCALE_BITS))
 
#define C_RV   (117504 >> (16 - SCALE_BITS))
 
#define C_BU   (138453 >> (16 - SCALE_BITS))
 
#define C_GU   (13954 >> (16 - SCALE_BITS))
 
#define C_GV   (34903 >> (16 - SCALE_BITS))
 
#define RGBOUT(r, g, b, y1)
 
#define R_OI   2
 
#define G_OI   1
 
#define B_OI   0
 
#define A_OI   3
 
#define SCALEBITS   8
 
#define ONE_HALF   (1 << (SCALEBITS - 1))
 
#define FIX(x)   (lroundf((x) * (1L<<SCALEBITS)))
 
#define R_II   0
 
#define G_II   1
 
#define B_II   2
 
#define A_II   3
 

Functions

static void yuv420_argb32_non_mmx (unsigned char *image, unsigned char *py, unsigned char *pu, unsigned char *pv, int h_size, int v_size, int rgb_stride, int y_stride, int uv_stride, int alphaones)
 
yuv2rgb_fun yuv2rgb_init_mmxext (int bpp, int mode)
 This returns a yuv to rgba converter, using mmxext if MMX was compiled in. More...
 
yuv2rgb_fun yuv2rgb_init_mmx (int bpp, int mode)
 This returns a yuv to rgba converter, using mmx if MMX was compiled in. More...
 
void rgb32_to_yuv420p (unsigned char *lum, unsigned char *cb, unsigned char *cr, unsigned char *alpha, unsigned char *src, int width, int height, int srcwidth)
 Convert planar RGB to YUV420. More...
 
static void non_vec_i420_2vuy (uint8_t *image, int vuy_stride, const uint8_t *py, const uint8_t *pu, const uint8_t *pv, int y_stride, int u_stride, int v_stride, int h_size, int v_size)
 Plain C I420 to 2VUY conversion function. More...
 
conv_i420_2vuy_fun get_i420_2vuy_conv (void)
 Returns I420 to 2VUY conversion function. More...
 
static void non_vec_2vuy_i420 (uint8_t *py, uint8_t *pu, uint8_t *pv, int y_stride, int u_stride, int v_stride, const uint8_t *image, int vuy_stride, int h_size, int v_size)
 Plain C 2VUY to I420 conversion routine. More...
 
conv_2vuy_i420_fun get_2vuy_i420_conv (void)
 Returns 2VUY to I420 conversion function. More...
 

Detailed Description

Contains various YUV, VUY and RGBA colorspace conversion routines.

Definition in file yuv2rgb.cpp.

Macro Definition Documentation

◆ movntq

#define movntq (   src,
  dest 
)
Value:
do { \
if (cpu == CPU_MMXEXT) \
movntq_r2m (src, dest); \
else \
movq_r2m (src, dest); \
} while (0)

Definition at line 78 of file yuv2rgb.cpp.

◆ SCALE_BITS

#define SCALE_BITS   10

Definition at line 398 of file yuv2rgb.cpp.

◆ C_Y

#define C_Y   (76309 >> (16 - SCALE_BITS))

Definition at line 400 of file yuv2rgb.cpp.

◆ C_RV

#define C_RV   (117504 >> (16 - SCALE_BITS))

Definition at line 401 of file yuv2rgb.cpp.

◆ C_BU

#define C_BU   (138453 >> (16 - SCALE_BITS))

Definition at line 402 of file yuv2rgb.cpp.

◆ C_GU

#define C_GU   (13954 >> (16 - SCALE_BITS))

Definition at line 403 of file yuv2rgb.cpp.

◆ C_GV

#define C_GV   (34903 >> (16 - SCALE_BITS))

Definition at line 404 of file yuv2rgb.cpp.

◆ RGBOUT

#define RGBOUT (   r,
  g,
  b,
  y1 
)
Value:
{\
y = ((y1) - 16) * C_Y;\
(r) = std::min(UCHAR_MAX, std::max(0, (y + r_add) >> SCALE_BITS));\
(g) = std::min(UCHAR_MAX, std::max(0, (y + g_add) >> SCALE_BITS));\
(b) = std::min(UCHAR_MAX, std::max(0, (y + b_add) >> SCALE_BITS));\
}
unsigned char r
Definition: ParseText.cpp:329
unsigned char b
Definition: ParseText.cpp:329
#define SCALE_BITS
Definition: yuv2rgb.cpp:398
#define C_Y
Definition: yuv2rgb.cpp:400
unsigned char g
Definition: ParseText.cpp:329

Definition at line 417 of file yuv2rgb.cpp.

◆ R_OI

#define R_OI   2

◆ G_OI

#define G_OI   1

◆ B_OI

#define B_OI   0

◆ A_OI

#define A_OI   3

◆ SCALEBITS

#define SCALEBITS   8

Definition at line 491 of file yuv2rgb.cpp.

◆ ONE_HALF

#define ONE_HALF   (1 << (SCALEBITS - 1))

Definition at line 492 of file yuv2rgb.cpp.

◆ FIX

#define FIX (   x)    (lroundf((x) * (1L<<SCALEBITS)))

Definition at line 493 of file yuv2rgb.cpp.

◆ R_II

#define R_II   0

◆ G_II

#define G_II   1

◆ B_II

#define B_II   2

◆ A_II

#define A_II   3

Function Documentation

◆ yuv420_argb32_non_mmx()

static void yuv420_argb32_non_mmx ( unsigned char *  image,
unsigned char *  py,
unsigned char *  pu,
unsigned char *  pv,
int  h_size,
int  v_size,
int  rgb_stride,
int  y_stride,
int  uv_stride,
int  alphaones 
)
static

Definition at line 425 of file yuv2rgb.cpp.

Referenced by yuv2rgb_init_mmx().

◆ yuv2rgb_init_mmxext()

yuv2rgb_init_mmxext ( int  bpp,
int  mode 
)

This returns a yuv to rgba converter, using mmxext if MMX was compiled in.

Parameters
modemust be MODE_RGB
bppmust be 32
Returns
function pointer or nullptr if converter could not be found.

Definition at line 360 of file yuv2rgb.cpp.

◆ yuv2rgb_init_mmx()

yuv2rgb_init_mmx ( int  bpp,
int  mode 
)

This returns a yuv to rgba converter, using mmx if MMX was compiled in.

Parameters
modemust be MODE_RGB
bppmust be 32
Returns
function pointer or nullptr if converter could not be found.

Definition at line 384 of file yuv2rgb.cpp.

◆ rgb32_to_yuv420p()

void rgb32_to_yuv420p ( unsigned char *  lum,
unsigned char *  cb,
unsigned char *  cr,
unsigned char *  alpha,
unsigned char *  src,
int  width,
int  height,
int  srcwidth 
)

Convert planar RGB to YUV420.

Despite the name, this actually converts to i420

Definition at line 499 of file yuv2rgb.cpp.

◆ non_vec_i420_2vuy()

static void non_vec_i420_2vuy ( uint8_t *  image,
int  vuy_stride,
const uint8_t *  py,
const uint8_t *  pu,
const uint8_t *  pv,
int  y_stride,
int  u_stride,
int  v_stride,
int  h_size,
int  v_size 
)
static

Plain C I420 to 2VUY conversion function.

See http://developer.apple.com/quicktime/icefloe/dispatch019.html for a complete description of 2VUY and fourcc.org for YUV 4:2:0.

2vuy is a like a 8-bit per component YUV 4:2:2, but it's actually a Y'Cb'Cr sampling. 2vuy is packed with bytes [Cb, Y, Cr, Y] representing two pixels.

Returns
A pointer to a I420 to 2VUY conversion function, which uses Altivec or MMX when supported.

Definition at line 741 of file yuv2rgb.cpp.

Referenced by get_i420_2vuy_conv().

◆ get_i420_2vuy_conv()

conv_i420_2vuy_fun get_i420_2vuy_conv ( void  )

Returns I420 to 2VUY conversion function.

See http://developer.apple.com/quicktime/icefloe/dispatch019.html for a complete description of 2VUY and fourcc.org for YUV 4:2:0.

2vuy is a like a 8-bit per component YUV 4:2:2, but it's actually a Y'Cb'Cr sampling. 2vuy is packed with bytes [Cb, Y, Cr, Y] representing two pixels.

Returns
A pointer to a I420 to 2VUY conversion function, which uses Altivec or MMX when supported.

Definition at line 1017 of file yuv2rgb.cpp.

◆ non_vec_2vuy_i420()

static void non_vec_2vuy_i420 ( uint8_t *  py,
uint8_t *  pu,
uint8_t *  pv,
int  y_stride,
int  u_stride,
int  v_stride,
const uint8_t *  image,
int  vuy_stride,
int  h_size,
int  v_size 
)
static

Plain C 2VUY to I420 conversion routine.

See http://developer.apple.com/quicktime/icefloe/dispatch019.html for a complete description of 2VUY and fourcc.org for YUV 4:2:0.

2vuy is a like a 8-bit per component YUV 4:2:2, but it's actually a Y'Cb'Cr sampling. 2vuy is packed with bytes [Cb, Y, Cr, Y] representing two pixels.

Definition at line 1039 of file yuv2rgb.cpp.

Referenced by get_2vuy_i420_conv().

◆ get_2vuy_i420_conv()

get_2vuy_i420_conv ( void  )

Returns 2VUY to I420 conversion function.

See http://developer.apple.com/quicktime/icefloe/dispatch019.html for a complete description of 2VUY and fourcc.org for YUV 4:2:0.

2vuy is a like a 8-bit per component YUV 4:2:2, but it's actually a Y'Cb'Cr sampling. 2vuy is packed with bytes [Cb, Y, Cr, Y] representing two pixels.

Returns
A pointer to a 2VUY to I420 conversion function, which uses Altivec when supported.

Definition at line 1211 of file yuv2rgb.cpp.