FFmpeg
Macros | Functions | Variables
yuv2rgb.c File Reference
#include <stddef.h>
#include <stdint.h>
#include "libavutil/bswap.h"
#include "libavutil/mem.h"
#include "config.h"
#include "swscale.h"
#include "swscale_internal.h"
#include "libavutil/pixdesc.h"

Go to the source code of this file.

Macros

#define LOADCHROMA(l, i)
 
#define PUTRGB(l, i, abase)
 
#define PUTRGB24(l, i, abase)
 
#define PUTBGR24(l, i, abase)
 
#define PUTRGBA(l, i, abase)
 
#define PUTRGB48(l, i, abase)
 
#define PUTBGR48(l, i, abase)
 
#define PUTGBRP(l, i, abase)
 
#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes)
 
#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422, nb_dst_planes)
 
#define ENDYUV2RGBFUNC()
 
#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes)
 
#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes)
 
#define YUV420FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta)
 
#define YUV422FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta)
 
#define LOADDITHER16
 
#define PUTRGB16(l, i, o)
 
#define LOADDITHER15
 
#define PUTRGB15(l, i, o)
 
#define LOADDITHER12   const uint8_t *d16 = ff_dither_4x4_16[y & 3];
 
#define PUTRGB12(l, i, o)
 
#define LOADDITHER8
 
#define PUTRGB8(l, i, o)
 
#define LOADDITHER4D
 
#define PUTRGB4D(l, i, o)
 
#define LOADDITHER4DB
 
#define PUTRGB4DB(l, i, o)
 
#define PUTRGB1(out, src, i, o)
 
#define PUTRGB1_OR00(out, src, i, o)
 
#define ALLOC_YUV_TABLE(x)
 

Functions

const int * sws_getCoefficients (int colorspace)
 Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDetails(). More...
 
 PUTRGB1 (out_1, py_1, 0, 0)
 
 PUTRGB1 (out_2, py_2, 0, 0+8)
 
 PUTRGB1 (out_2, py_2, 1, 2+8)
 
 PUTRGB1 (out_1, py_1, 1, 2)
 
 PUTRGB1 (out_1, py_1, 2, 4)
 
 PUTRGB1 (out_2, py_2, 2, 4+8)
 
 PUTRGB1 (out_2, py_2, 3, 6+8)
 
 PUTRGB1 (out_1, py_1, 3, 6)
 
 if (c->dstW &7)
 

Variables

const int32_t ff_yuv2rgb_coeffs [11][4]
 
const uint8_t * d128 = ff_dither_8x8_220[yd & 7]
 
char out_1 = 0
 
char out_2 = 0
 
 g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM]
 
 dst_1 [0] = out_1
 
 dst_2 [0] = out_2
 
 py_1 = 8
 
 py_2 = 8
 

Macro Definition Documentation

◆ LOADCHROMA

#define LOADCHROMA (   l,
  i 
)
Value:
U = pu_##l[i]; \
V = pv_##l[i]; \
r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \
g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \
b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM];

Definition at line 68 of file yuv2rgb.c.

◆ PUTRGB

#define PUTRGB (   l,
  i,
  abase 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[2 * i] = r[Y] + g[Y] + b[Y]; \
Y = py_##l[2 * i + 1]; \
dst_##l[2 * i + 1] = r[Y] + g[Y] + b[Y];

Definition at line 75 of file yuv2rgb.c.

◆ PUTRGB24

#define PUTRGB24 (   l,
  i,
  abase 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[6 * i + 0] = r[Y]; \
dst_##l[6 * i + 1] = g[Y]; \
dst_##l[6 * i + 2] = b[Y]; \
Y = py_##l[2 * i + 1]; \
dst_##l[6 * i + 3] = r[Y]; \
dst_##l[6 * i + 4] = g[Y]; \
dst_##l[6 * i + 5] = b[Y];

Definition at line 81 of file yuv2rgb.c.

◆ PUTBGR24

#define PUTBGR24 (   l,
  i,
  abase 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[6 * i + 0] = b[Y]; \
dst_##l[6 * i + 1] = g[Y]; \
dst_##l[6 * i + 2] = r[Y]; \
Y = py_##l[2 * i + 1]; \
dst_##l[6 * i + 3] = b[Y]; \
dst_##l[6 * i + 4] = g[Y]; \
dst_##l[6 * i + 5] = r[Y];

Definition at line 91 of file yuv2rgb.c.

◆ PUTRGBA

#define PUTRGBA (   l,
  i,
  abase 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[2 * i] = r[Y] + g[Y] + b[Y] + ((uint32_t)(pa_##l[2 * i]) << abase); \
Y = py_##l[2 * i + 1]; \
dst_##l[2 * i + 1] = r[Y] + g[Y] + b[Y] + ((uint32_t)(pa_##l[2 * i + 1]) << abase);

Definition at line 101 of file yuv2rgb.c.

◆ PUTRGB48

#define PUTRGB48 (   l,
  i,
  abase 
)
Value:
Y = py_##l[ 2 * i]; \
dst_##l[12 * i + 0] = dst_##l[12 * i + 1] = r[Y]; \
dst_##l[12 * i + 2] = dst_##l[12 * i + 3] = g[Y]; \
dst_##l[12 * i + 4] = dst_##l[12 * i + 5] = b[Y]; \
Y = py_##l[ 2 * i + 1]; \
dst_##l[12 * i + 6] = dst_##l[12 * i + 7] = r[Y]; \
dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \
dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = b[Y];

Definition at line 107 of file yuv2rgb.c.

◆ PUTBGR48

#define PUTBGR48 (   l,
  i,
  abase 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[12 * i + 0] = dst_##l[12 * i + 1] = b[Y]; \
dst_##l[12 * i + 2] = dst_##l[12 * i + 3] = g[Y]; \
dst_##l[12 * i + 4] = dst_##l[12 * i + 5] = r[Y]; \
Y = py_##l[2 * i + 1]; \
dst_##l[12 * i + 6] = dst_##l[12 * i + 7] = b[Y]; \
dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \
dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y];

Definition at line 117 of file yuv2rgb.c.

◆ PUTGBRP

#define PUTGBRP (   l,
  i,
  abase 
)
Value:
Y = py_##l[2 * i]; \
dst_##l [2 * i + 0] = g[Y]; \
dst1_##l[2 * i + 0] = b[Y]; \
dst2_##l[2 * i + 0] = r[Y]; \
Y = py_##l[2 * i + 1]; \
dst_##l [2 * i + 1] = g[Y]; \
dst1_##l[2 * i + 1] = b[Y]; \
dst2_##l[2 * i + 1] = r[Y];

Definition at line 127 of file yuv2rgb.c.

◆ YUV2RGBFUNC

#define YUV2RGBFUNC (   func_name,
  dst_type,
  alpha,
  yuv422,
  nb_dst_planes 
)

Definition at line 137 of file yuv2rgb.c.

◆ ENDYUV2RGBLINE

#define ENDYUV2RGBLINE (   dst_delta,
  ss,
  alpha,
  yuv422,
  nb_dst_planes 
)
Value:
pu_1 += 4 >> ss; \
pv_1 += 4 >> ss; \
if (yuv422) { \
pu_2 += 4 >> ss; \
pv_2 += 4 >> ss; \
} \
py_1 += 8 >> ss; \
py_2 += 8 >> ss; \
if (alpha) { \
pa_1 += 8 >> ss; \
pa_2 += 8 >> ss; \
} \
dst_1 += dst_delta >> ss; \
dst_2 += dst_delta >> ss; \
if (nb_dst_planes > 1) { \
dst1_1 += dst_delta >> ss; \
dst1_2 += dst_delta >> ss; \
dst2_1 += dst_delta >> ss; \
dst2_2 += dst_delta >> ss; \
} \
} \
if (c->dstW & (4 >> ss)) { \
int av_unused Y, U, V; \

Definition at line 176 of file yuv2rgb.c.

◆ ENDYUV2RGBFUNC

#define ENDYUV2RGBFUNC ( )
Value:
} \
} \
return srcSliceH; \
}

Definition at line 201 of file yuv2rgb.c.

◆ YUV420FUNC

#define YUV420FUNC (   func_name,
  dst_type,
  alpha,
  abase,
  PUTFUNC,
  dst_delta,
  nb_dst_planes 
)
Value:
YUV2RGBFUNC(func_name, dst_type, alpha, 0, nb_dst_planes) \
LOADCHROMA(1, 0); \
PUTFUNC(1, 0, abase); \
PUTFUNC(2, 0, abase); \
LOADCHROMA(1, 1); \
PUTFUNC(2, 1, abase); \
PUTFUNC(1, 1, abase); \
LOADCHROMA(1, 2); \
PUTFUNC(1, 2, abase); \
PUTFUNC(2, 2, abase); \
LOADCHROMA(1, 3); \
PUTFUNC(2, 3, abase); \
PUTFUNC(1, 3, abase); \
ENDYUV2RGBLINE(dst_delta, 0, alpha, 0, nb_dst_planes) \
LOADCHROMA(1, 0); \
PUTFUNC(1, 0, abase); \
PUTFUNC(2, 0, abase); \
LOADCHROMA(1, 1); \
PUTFUNC(2, 1, abase); \
PUTFUNC(1, 1, abase); \
ENDYUV2RGBLINE(dst_delta, 1, alpha, 0, nb_dst_planes) \
LOADCHROMA(1, 0); \
PUTFUNC(1, 0, abase); \
PUTFUNC(2, 0, abase); \
ENDYUV2RGBFUNC()

Definition at line 207 of file yuv2rgb.c.

◆ YUV422FUNC

#define YUV422FUNC (   func_name,
  dst_type,
  alpha,
  abase,
  PUTFUNC,
  dst_delta,
  nb_dst_planes 
)

Definition at line 238 of file yuv2rgb.c.

◆ YUV420FUNC_DITHER

#define YUV420FUNC_DITHER (   func_name,
  dst_type,
  LOADDITHER,
  PUTFUNC,
  dst_delta 
)

Definition at line 283 of file yuv2rgb.c.

◆ YUV422FUNC_DITHER

#define YUV422FUNC_DITHER (   func_name,
  dst_type,
  LOADDITHER,
  PUTFUNC,
  dst_delta 
)

Definition at line 320 of file yuv2rgb.c.

◆ LOADDITHER16

#define LOADDITHER16
Value:
const uint8_t *d16 = ff_dither_2x2_8[y & 1]; \
const uint8_t *e16 = ff_dither_2x2_4[y & 1]; \
const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1];

Definition at line 371 of file yuv2rgb.c.

◆ PUTRGB16

#define PUTRGB16 (   l,
  i,
 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[2 * i] = r[Y + d16[0 + o]] + \
g[Y + e16[0 + o]] + \
b[Y + f16[0 + o]]; \
Y = py_##l[2 * i + 1]; \
dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \
g[Y + e16[1 + o]] + \
b[Y + f16[1 + o]];

Definition at line 376 of file yuv2rgb.c.

◆ LOADDITHER15

#define LOADDITHER15
Value:
const uint8_t *d16 = ff_dither_2x2_8[y & 1]; \
const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1];

Definition at line 386 of file yuv2rgb.c.

◆ PUTRGB15

#define PUTRGB15 (   l,
  i,
 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[2 * i] = r[Y + d16[0 + o]] + \
g[Y + d16[1 + o]] + \
b[Y + e16[0 + o]]; \
Y = py_##l[2 * i + 1]; \
dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \
g[Y + d16[0 + o]] + \
b[Y + e16[1 + o]];

Definition at line 390 of file yuv2rgb.c.

◆ LOADDITHER12

#define LOADDITHER12   const uint8_t *d16 = ff_dither_4x4_16[y & 3];

Definition at line 400 of file yuv2rgb.c.

◆ PUTRGB12

#define PUTRGB12 (   l,
  i,
 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[2 * i] = r[Y + d16[0 + o]] + \
g[Y + d16[0 + o]] + \
b[Y + d16[0 + o]]; \
Y = py_##l[2 * i + 1]; \
dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \
g[Y + d16[1 + o]] + \
b[Y + d16[1 + o]];

Definition at line 403 of file yuv2rgb.c.

◆ LOADDITHER8

#define LOADDITHER8
Value:
const uint8_t *d32 = ff_dither_8x8_32[yd & 7]; \
const uint8_t *d64 = ff_dither_8x8_73[yd & 7];

Definition at line 413 of file yuv2rgb.c.

◆ PUTRGB8

#define PUTRGB8 (   l,
  i,
 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[2 * i] = r[Y + d32[0 + o]] + \
g[Y + d32[0 + o]] + \
b[Y + d64[0 + o]]; \
Y = py_##l[2 * i + 1]; \
dst_##l[2 * i + 1] = r[Y + d32[1 + o]] + \
g[Y + d32[1 + o]] + \
b[Y + d64[1 + o]];

Definition at line 417 of file yuv2rgb.c.

◆ LOADDITHER4D

#define LOADDITHER4D
Value:
const uint8_t * d64 = ff_dither_8x8_73[yd & 7]; \
const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; \
int acc;

Definition at line 427 of file yuv2rgb.c.

◆ PUTRGB4D

#define PUTRGB4D (   l,
  i,
 
)
Value:
Y = py_##l[2 * i]; \
acc = r[Y + d128[0 + o]] + \
g[Y + d64[0 + o]] + \
b[Y + d128[0 + o]]; \
Y = py_##l[2 * i + 1]; \
acc |= (r[Y + d128[1 + o]] + \
g[Y + d64[1 + o]] + \
b[Y + d128[1 + o]]) << 4; \
dst_##l[i] = acc;

Definition at line 432 of file yuv2rgb.c.

◆ LOADDITHER4DB

#define LOADDITHER4DB
Value:
const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; \
const uint8_t *d128 = ff_dither_8x8_220[yd & 7];

Definition at line 443 of file yuv2rgb.c.

◆ PUTRGB4DB

#define PUTRGB4DB (   l,
  i,
 
)
Value:
Y = py_##l[2 * i]; \
dst_##l[2 * i] = r[Y + d128[0 + o]] + \
g[Y + d64[0 + o]] + \
b[Y + d128[0 + o]]; \
Y = py_##l[2 * i + 1]; \
dst_##l[2 * i + 1] = r[Y + d128[1 + o]] + \
g[Y + d64[1 + o]] + \
b[Y + d128[1 + o]];

Definition at line 447 of file yuv2rgb.c.

◆ PUTRGB1

#define PUTRGB1 (   out,
  src,
  i,
 
)
Value:
Y = src[2 * i]; \
out += out + g[Y + d128[0 + o]]; \
Y = src[2 * i + 1]; \
out += out + g[Y + d128[1 + o]];

Definition at line 462 of file yuv2rgb.c.

◆ PUTRGB1_OR00

#define PUTRGB1_OR00 (   out,
  src,
  i,
 
)
Value:
if (pixels_left) { \
PUTRGB1(out, src, i, o) \
pixels_left--; \
} else { \
out <<= 2; \
}

◆ ALLOC_YUV_TABLE

#define ALLOC_YUV_TABLE (   x)
Value:
c->yuvTable = av_malloc(x); \
if (!c->yuvTable) \
return AVERROR(ENOMEM);

Function Documentation

◆ PUTRGB1() [1/8]

PUTRGB1 ( out_1  ,
py_1  ,
,
 
)

◆ PUTRGB1() [2/8]

PUTRGB1 ( out_2  ,
py_2  ,
,
0+  8 
)

◆ PUTRGB1() [3/8]

PUTRGB1 ( out_2  ,
py_2  ,
,
2+  8 
)

◆ PUTRGB1() [4/8]

PUTRGB1 ( out_1  ,
py_1  ,
,
 
)

◆ PUTRGB1() [5/8]

PUTRGB1 ( out_1  ,
py_1  ,
,
 
)

◆ PUTRGB1() [6/8]

PUTRGB1 ( out_2  ,
py_2  ,
,
4+  8 
)

◆ PUTRGB1() [7/8]

PUTRGB1 ( out_2  ,
py_2  ,
,
6+  8 
)

◆ PUTRGB1() [8/8]

PUTRGB1 ( out_1  ,
py_1  ,
,
 
)

◆ if()

if ( c->dstW &  7)

Definition at line 488 of file yuv2rgb.c.

Variable Documentation

◆ ff_yuv2rgb_coeffs

const int32_t ff_yuv2rgb_coeffs[11][4]
Initial value:
= {
{ 104597, 132201, 25675, 53279 },
{ 117489, 138438, 13975, 34925 },
{ 104597, 132201, 25675, 53279 },
{ 104597, 132201, 25675, 53279 },
{ 104448, 132798, 24759, 53109 },
{ 104597, 132201, 25675, 53279 },
{ 104597, 132201, 25675, 53279 },
{ 117579, 136230, 16907, 35559 },
{ 0 },
{ 110013, 140363, 12277, 42626 },
{ 110013, 140363, 12277, 42626 },
}

Definition at line 47 of file yuv2rgb.c.

Referenced by sws_getCoefficients(), and sws_init_single_context().

◆ d128

const uint8_t* d128 = ff_dither_8x8_220[yd & 7]

◆ out_1

char out_1 = 0

Definition at line 459 of file yuv2rgb.c.

Referenced by if().

◆ out_2

char out_2 = 0

Definition at line 459 of file yuv2rgb.c.

Referenced by if().

◆ g

g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM]

Definition at line 460 of file yuv2rgb.c.

Referenced by if().

◆ dst_1

dst_1 = out_1

Definition at line 480 of file yuv2rgb.c.

Referenced by if().

◆ dst_2

dst_2 = out_2

Definition at line 481 of file yuv2rgb.c.

Referenced by if().

◆ py_1

py_1 = 8

Definition at line 483 of file yuv2rgb.c.

Referenced by if().

◆ py_2

py_2 = 8

Definition at line 484 of file yuv2rgb.c.

Referenced by if().

r
const char * r
Definition: vf_curves.c:127
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
out
FILE * out
Definition: movenc.c:55
ff_dither_8x8_32
const uint8_t ff_dither_8x8_32[][8]
Definition: output.c:59
av_unused
#define av_unused
Definition: attributes.h:131
b
#define b
Definition: input.c:41
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
ss
#define ss(width, name, subs,...)
Definition: cbs_vp9.c:202
YUVRGB_TABLE_HEADROOM
#define YUVRGB_TABLE_HEADROOM
Definition: swscale_internal.h:45
ff_dither_2x2_4
const uint8_t ff_dither_2x2_4[][8]
Definition: output.c:39
ff_dither_8x8_220
const uint8_t ff_dither_8x8_220[][8]
Definition: output.c:84
V
#define V
Definition: avdct.c:31
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
g
g
Definition: yuv2rgb.c:460
ff_dither_8x8_73
const uint8_t ff_dither_8x8_73[][8]
Definition: output.c:71
Y
#define Y
Definition: boxblur.h:37
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
LOADCHROMA
#define LOADCHROMA(l, i)
Definition: yuv2rgb.c:68
YUV2RGBFUNC
#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes)
Definition: yuv2rgb.c:137
U
#define U(x)
Definition: vpx_arith.h:37
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
d128
const uint8_t * d128
Definition: yuv2rgb.c:458
src
#define src
Definition: vp8dsp.c:248
ff_dither_2x2_8
const uint8_t ff_dither_2x2_8[][8]
Definition: output.c:45