FFmpeg
Macros | Functions
colorspace.h File Reference

Go to the source code of this file.

Macros

#define SCALEBITS   10
 
#define ONE_HALF   (1 << (SCALEBITS - 1))
 
#define FIX(x)   ((int) ((x) * (1<<SCALEBITS) + 0.5))
 
#define YUV_TO_RGB1_CCIR(cb1, cr1)
 
#define YUV_TO_RGB1_CCIR_BT709(cb1, cr1)
 
#define YUV_TO_RGB2_CCIR(r, g, b, y1)
 
#define YUV_TO_RGB1(cb1, cr1)
 
#define YUV_TO_RGB2(r, g, b, y1)
 
#define Y_CCIR_TO_JPEG(y)   cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS]
 
#define Y_JPEG_TO_CCIR(y)   (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
 
#define C_CCIR_TO_JPEG(y)   cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS]
 
#define RGB_TO_Y_CCIR(r, g, b)
 
#define RGB_TO_U_CCIR(r1, g1, b1, shift)
 
#define RGB_TO_V_CCIR(r1, g1, b1, shift)
 
#define RGB_TO_Y_JPEG(r, g, b)
 
#define RGB_TO_U_JPEG(r1, g1, b1)
 
#define RGB_TO_V_JPEG(r1, g1, b1)
 
#define RGB_TO_Y_BT709(r, g, b)
 
#define RGB_TO_U_BT709(r1, g1, b1, shift)
 
#define RGB_TO_V_BT709(r1, g1, b1, shift)
 
#define RGB_TO_Y_BT709_FULL(r, g, b)
 
#define RGB_TO_U_BT709_FULL(r1, g1, b1)
 
#define RGB_TO_V_BT709_FULL(r1, g1, b1)
 

Functions

static int C_JPEG_TO_CCIR (int y)
 

Detailed Description

Various defines for YUV<->RGB conversion

Definition in file colorspace.h.

Macro Definition Documentation

◆ SCALEBITS

#define SCALEBITS   10

Definition at line 30 of file colorspace.h.

◆ ONE_HALF

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

Definition at line 31 of file colorspace.h.

◆ FIX

#define FIX (   x)    ((int) ((x) * (1<<SCALEBITS) + 0.5))

Definition at line 32 of file colorspace.h.

◆ YUV_TO_RGB1_CCIR

#define YUV_TO_RGB1_CCIR (   cb1,
  cr1 
)
Value:
{\
cb = (cb1) - 128;\
cr = (cr1) - 128;\
r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
ONE_HALF;\
b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
}

Definition at line 34 of file colorspace.h.

◆ YUV_TO_RGB1_CCIR_BT709

#define YUV_TO_RGB1_CCIR_BT709 (   cb1,
  cr1 
)
Value:
{ \
cb = (cb1) - 128; \
cr = (cr1) - 128; \
r_add = ONE_HALF + FIX(1.5747 * 255.0 / 224.0) * cr; \
g_add = ONE_HALF - FIX(0.1873 * 255.0 / 224.0) * cb - \
FIX(0.4682 * 255.0 / 224.0) * cr; \
b_add = ONE_HALF + FIX(1.8556 * 255.0 / 224.0) * cb; \
}

Definition at line 44 of file colorspace.h.

◆ YUV_TO_RGB2_CCIR

#define YUV_TO_RGB2_CCIR (   r,
  g,
  b,
  y1 
)
Value:
{\
y = ((y1) - 16) * FIX(255.0/219.0);\
r = cm[(y + r_add) >> SCALEBITS];\
g = cm[(y + g_add) >> SCALEBITS];\
b = cm[(y + b_add) >> SCALEBITS];\
}

Definition at line 55 of file colorspace.h.

◆ YUV_TO_RGB1

#define YUV_TO_RGB1 (   cb1,
  cr1 
)
Value:
{\
cb = (cb1) - 128;\
cr = (cr1) - 128;\
r_add = FIX(1.40200) * cr + ONE_HALF;\
g_add = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;\
b_add = FIX(1.77200) * cb + ONE_HALF;\
}

Definition at line 63 of file colorspace.h.

◆ YUV_TO_RGB2

#define YUV_TO_RGB2 (   r,
  g,
  b,
  y1 
)
Value:
{\
y = (y1) << SCALEBITS;\
r = cm[(y + r_add) >> SCALEBITS];\
g = cm[(y + g_add) >> SCALEBITS];\
b = cm[(y + b_add) >> SCALEBITS];\
}

Definition at line 72 of file colorspace.h.

◆ Y_CCIR_TO_JPEG

#define Y_CCIR_TO_JPEG (   y)    cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS]

Definition at line 80 of file colorspace.h.

◆ Y_JPEG_TO_CCIR

#define Y_JPEG_TO_CCIR (   y)    (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)

Definition at line 83 of file colorspace.h.

◆ C_CCIR_TO_JPEG

#define C_CCIR_TO_JPEG (   y)    cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS]

Definition at line 86 of file colorspace.h.

◆ RGB_TO_Y_CCIR

#define RGB_TO_Y_CCIR (   r,
  g,
  b 
)
Value:
((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)

Definition at line 98 of file colorspace.h.

◆ RGB_TO_U_CCIR

#define RGB_TO_U_CCIR (   r1,
  g1,
  b1,
  shift 
)
Value:
(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)

Definition at line 102 of file colorspace.h.

◆ RGB_TO_V_CCIR

#define RGB_TO_V_CCIR (   r1,
  g1,
  b1,
  shift 
)
Value:
(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)

Definition at line 106 of file colorspace.h.

◆ RGB_TO_Y_JPEG

#define RGB_TO_Y_JPEG (   r,
  g,
  b 
)
Value:
(FFMIN((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
FIX(0.11400) * (b) + (ONE_HALF)) >> SCALEBITS, 255))

Definition at line 110 of file colorspace.h.

◆ RGB_TO_U_JPEG

#define RGB_TO_U_JPEG (   r1,
  g1,
  b1 
)
Value:
(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
FIX(0.50000) * b1 + (ONE_HALF) - 1) >> (SCALEBITS)) + 128)

Definition at line 114 of file colorspace.h.

◆ RGB_TO_V_JPEG

#define RGB_TO_V_JPEG (   r1,
  g1,
  b1 
)
Value:
(((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
FIX(0.08131) * b1 + (ONE_HALF) - 1) >> (SCALEBITS)) + 128)

Definition at line 118 of file colorspace.h.

◆ RGB_TO_Y_BT709

#define RGB_TO_Y_BT709 (   r,
  g,
  b 
)
Value:
((FIX(0.21260*219.0/255.0) * (r) + FIX(0.71520*219.0/255.0) * (g) + \
FIX(0.07220*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)

Definition at line 126 of file colorspace.h.

◆ RGB_TO_U_BT709

#define RGB_TO_U_BT709 (   r1,
  g1,
  b1,
  shift 
)
Value:
(((- FIX(0.11457*224.0/255.0) * r1 - FIX(0.38543*224.0/255.0) * g1 + \
FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)

Definition at line 130 of file colorspace.h.

◆ RGB_TO_V_BT709

#define RGB_TO_V_BT709 (   r1,
  g1,
  b1,
  shift 
)
Value:
(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.45415*224.0/255.0) * g1 - \
FIX(0.04585*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)

Definition at line 134 of file colorspace.h.

◆ RGB_TO_Y_BT709_FULL

#define RGB_TO_Y_BT709_FULL (   r,
  g,
  b 
)
Value:
(FFMIN((FIX(0.21260) * (r) + FIX(0.71520) * (g) + \
FIX(0.07220) * (b) + (ONE_HALF)) >> SCALEBITS, 255))

Definition at line 138 of file colorspace.h.

◆ RGB_TO_U_BT709_FULL

#define RGB_TO_U_BT709_FULL (   r1,
  g1,
  b1 
)
Value:
(((- FIX(0.11457) * r1 - FIX(0.38543) * g1 + \
FIX(0.50000) * b1 + (ONE_HALF) - 1) >> (SCALEBITS)) + 128)

Definition at line 142 of file colorspace.h.

◆ RGB_TO_V_BT709_FULL

#define RGB_TO_V_BT709_FULL (   r1,
  g1,
  b1 
)
Value:
(((FIX(0.50000) * r1 - FIX(0.45415) * g1 - \
FIX(0.04585) * b1 + (ONE_HALF) - 1) >> (SCALEBITS)) + 128)

Definition at line 146 of file colorspace.h.

Function Documentation

◆ C_JPEG_TO_CCIR()

static int C_JPEG_TO_CCIR ( int  y)
inlinestatic

Definition at line 90 of file colorspace.h.

r
const char * r
Definition: vf_curves.c:126
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:239
b
#define b
Definition: input.c:41
b1
static double b1(void *priv, double x, double y)
Definition: vf_xfade.c:1771
g
const char * g
Definition: vf_curves.c:127
FIX
#define FIX(x)
Definition: colorspace.h:32
shift
static int shift(int a, int b)
Definition: bonk.c:257
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
SCALEBITS
#define SCALEBITS
Definition: colorspace.h:30
cm
#define cm
Definition: dvbsubdec.c:39
cr
static double cr(void *priv, double x, double y)
Definition: vf_geq.c:240
ONE_HALF
#define ONE_HALF
Definition: colorspace.h:31