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(pu, pv, i)
 
#define PUTRGB(dst, src, asrc, i, abase)
 
#define PUTRGB24(dst, src, asrc, i, abase)
 
#define PUTBGR24(dst, src, asrc, i, abase)
 
#define PUTRGBA(dst, ysrc, asrc, i, abase)
 
#define PUTRGB48(dst, src, asrc, i, abase)
 
#define PUTBGR48(dst, src, asrc, i, abase)
 
#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422)
 
#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422)
 
#define ENDYUV2RGBFUNC()
 
#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta)
 
#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta)
 
#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(dst, src, i, o)
 
#define LOADDITHER15
 
#define PUTRGB15(dst, src, i, o)
 
#define LOADDITHER12   const uint8_t *d16 = ff_dither_4x4_16[y & 3];
 
#define PUTRGB12(dst, src, i, o)
 
#define LOADDITHER8
 
#define PUTRGB8(dst, src, i, o)
 
#define LOADDITHER4D
 
#define PUTRGB4D(dst, src, i, o)
 
#define LOADDITHER4DB
 
#define PUTRGB4DB(dst, src, i, o)
 
#define PUTRGB1(out, src, i, o)
 
#define PUTRGB1_OR00(out, src, i, o)
 
#define ALLOC_YUV_TABLE(x)
 

Functions

const intsws_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 (   pu,
  pv,
  i 
)
Value:
U = pu[i]; \
V = pv[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 (   dst,
  src,
  asrc,
  i,
  abase 
)
Value:
Y = src[2 * i]; \
dst[2 * i] = r[Y] + g[Y] + b[Y]; \
Y = src[2 * i + 1]; \
dst[2 * i + 1] = r[Y] + g[Y] + b[Y];

Definition at line 75 of file yuv2rgb.c.

◆ PUTRGB24

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

Definition at line 81 of file yuv2rgb.c.

◆ PUTBGR24

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

Definition at line 91 of file yuv2rgb.c.

◆ PUTRGBA

#define PUTRGBA (   dst,
  ysrc,
  asrc,
  i,
  abase 
)
Value:
Y = ysrc[2 * i]; \
dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << abase); \
Y = ysrc[2 * i + 1]; \
dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << abase);

Definition at line 101 of file yuv2rgb.c.

◆ PUTRGB48

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

Definition at line 107 of file yuv2rgb.c.

◆ PUTBGR48

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

Definition at line 117 of file yuv2rgb.c.

◆ YUV2RGBFUNC

#define YUV2RGBFUNC (   func_name,
  dst_type,
  alpha,
  yuv422 
)
Value:
static int func_name(SwsContext *c, const uint8_t *src[], \
int srcStride[], int srcSliceY, int srcSliceH, \
uint8_t *dst[], int dstStride[]) \
{ \
int y; \
for (y = 0; y < srcSliceH; y += 2) { \
int yd = y + srcSliceY; \
dst_type *dst_1 = \
(dst_type *)(dst[0] + (yd) * dstStride[0]); \
dst_type *dst_2 = \
(dst_type *)(dst[0] + (yd + 1) * dstStride[0]); \
dst_type av_unused *r, *g, *b; \
const uint8_t *py_1 = src[0] + y * srcStride[0]; \
const uint8_t *py_2 = py_1 + srcStride[0]; \
const uint8_t av_unused *pu_1 = src[1] + (y >> !yuv422) * srcStride[1]; \
const uint8_t av_unused *pv_1 = src[2] + (y >> !yuv422) * srcStride[2]; \
const uint8_t av_unused *pu_2, *pv_2; \
const uint8_t av_unused *pa_1, *pa_2; \
unsigned int h_size = c->dstW >> 3; \
if (yuv422) { \
pu_2 = pu_1 + srcStride[1]; \
pv_2 = pv_1 + srcStride[2]; \
} \
if (alpha) { \
pa_1 = src[3] + y * srcStride[3]; \
pa_2 = pa_1 + srcStride[3]; \
} \
while (h_size--) { \
int av_unused U, V, Y; \

Definition at line 127 of file yuv2rgb.c.

◆ ENDYUV2RGBLINE

#define ENDYUV2RGBLINE (   dst_delta,
  ss,
  alpha,
  yuv422 
)
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 (c->dstW & (4 >> ss)) { \
int av_unused Y, U, V; \

Definition at line 159 of file yuv2rgb.c.

◆ ENDYUV2RGBFUNC

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

Definition at line 178 of file yuv2rgb.c.

◆ YUV420FUNC

#define YUV420FUNC (   func_name,
  dst_type,
  alpha,
  abase,
  PUTFUNC,
  dst_delta 
)
Value:
YUV2RGBFUNC(func_name, dst_type, alpha, 0) \
LOADCHROMA(pu_1, pv_1, 0); \
PUTFUNC(dst_1, py_1, pa_1, 0, abase); \
PUTFUNC(dst_2, py_2, pa_2, 0, abase); \
LOADCHROMA(pu_1, pv_1, 1); \
PUTFUNC(dst_2, py_2, pa_2, 1, abase); \
PUTFUNC(dst_1, py_1, pa_1, 1, abase); \
LOADCHROMA(pu_1, pv_1, 2); \
PUTFUNC(dst_1, py_1, pa_1, 2, abase); \
PUTFUNC(dst_2, py_2, pa_2, 2, abase); \
LOADCHROMA(pu_1, pv_1, 3); \
PUTFUNC(dst_2, py_2, pa_2, 3, abase); \
PUTFUNC(dst_1, py_1, pa_1, 3, abase); \
ENDYUV2RGBLINE(dst_delta, 0, alpha, 0) \
LOADCHROMA(pu_1, pv_1, 0); \
PUTFUNC(dst_1, py_1, pa_1, 0, abase); \
PUTFUNC(dst_2, py_2, pa_2, 0, abase); \
LOADCHROMA(pu_1, pv_1, 1); \
PUTFUNC(dst_2, py_2, pa_2, 1, abase); \
PUTFUNC(dst_1, py_1, pa_1, 1, abase); \
ENDYUV2RGBLINE(dst_delta, 1, alpha, 0) \
LOADCHROMA(pu_1, pv_1, 0); \
PUTFUNC(dst_1, py_1, pa_1, 0, abase); \
PUTFUNC(dst_2, py_2, pa_2, 0, abase); \
ENDYUV2RGBFUNC()

Definition at line 184 of file yuv2rgb.c.

◆ YUV422FUNC

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

Definition at line 215 of file yuv2rgb.c.

◆ YUV420FUNC_DITHER

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

Definition at line 260 of file yuv2rgb.c.

◆ YUV422FUNC_DITHER

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

Definition at line 297 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 348 of file yuv2rgb.c.

◆ PUTRGB16

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

Definition at line 353 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 363 of file yuv2rgb.c.

◆ PUTRGB15

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

Definition at line 367 of file yuv2rgb.c.

◆ LOADDITHER12

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

Definition at line 377 of file yuv2rgb.c.

◆ PUTRGB12

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

Definition at line 380 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 390 of file yuv2rgb.c.

◆ PUTRGB8

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

Definition at line 394 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 404 of file yuv2rgb.c.

◆ PUTRGB4D

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

Definition at line 409 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 420 of file yuv2rgb.c.

◆ PUTRGB4DB

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

Definition at line 424 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 439 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 465 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 436 of file yuv2rgb.c.

Referenced by if().

◆ out_2

char out_2 = 0

Definition at line 436 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 437 of file yuv2rgb.c.

Referenced by if().

◆ dst_1

dst_1 = out_1

Definition at line 457 of file yuv2rgb.c.

Referenced by if().

◆ dst_2

dst_2 = out_2

Definition at line 458 of file yuv2rgb.c.

Referenced by if().

◆ py_1

py_1 = 8

Definition at line 460 of file yuv2rgb.c.

Referenced by if().

◆ py_2

py_2 = 8

Definition at line 461 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:44
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
LOADCHROMA
#define LOADCHROMA(pu, pv, i)
Definition: yuv2rgb.c:68
V
#define V
Definition: avdct.c:31
dst_2
dst_2[0]
Definition: yuv2rgb.c:458
py_1
py_1
Definition: yuv2rgb.c:460
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
YUV2RGBFUNC
#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422)
Definition: yuv2rgb.c:127
g
g
Definition: yuv2rgb.c:437
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
srcSliceH
return srcSliceH
Definition: yuv2rgb_template.c:87
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
py_2
py_2
Definition: yuv2rgb.c:461
U
#define U(x)
Definition: vpx_arith.h:37
dst_1
dst_1[0]
Definition: yuv2rgb.c:457
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
d128
const uint8_t * d128
Definition: yuv2rgb.c:435
SwsContext
Definition: swscale_internal.h:301
ff_dither_2x2_8
const uint8_t ff_dither_2x2_8[][8]
Definition: output.c:45