FFmpeg
Macros | Functions
yuv2rgb_template.c File Reference
#include <stdint.h>
#include "libavutil/x86/asm.h"
#include "libswscale/swscale_internal.h"

Go to the source code of this file.

Macros

#define MOVNTQ   "movq"
 
#define SFENCE   " # nop"
 
#define REG_BLUE   "0"
 
#define REG_RED   "1"
 
#define REG_GREEN   "2"
 
#define REG_ALPHA   "3"
 
#define YUV2RGB_LOOP(depth)
 
#define YUV2RGB_INITIAL_LOAD
 
#define YUV2RGB
 
#define RGB_PACK_INTERLEAVE
 
#define YUV2RGB_ENDLOOP(depth)
 
#define RGB_PACK24_B_OPERANDS
 
#define YUV2RGB_OPERANDS
 
#define YUV2RGB_OPERANDS_ALPHA
 
#define YUV2RGB_ENDFUNC
 
#define IF0(x)
 
#define IF1(x)   x
 
#define RGB_PACK16(gmask, is15)
 
#define DITHER_RGB
 
#define RGB_PACK24(blue, red)
 
#define RGB_PACK24_B
 
#define SET_EMPTY_ALPHA   "pcmpeqd %%mm"REG_ALPHA", %%mm"REG_ALPHA"\n\t" /* set alpha to 0xFF */ \
 
#define LOAD_ALPHA   "movq (%6, %0, 2), %%mm"REG_ALPHA"\n\t" \
 
#define RGB_PACK32(red, green, blue, alpha)
 

Functions

static int yuv420_rgb15_TMPL (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
 
static int yuv420_rgb16_TMPL (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
 
static int yuv420_rgb24_TMPL (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
 
static int yuv420_bgr24_TMPL (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
 
static int yuv420_rgb32_TMPL (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
 
static int yuv420_bgr32_TMPL (SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
 

Macro Definition Documentation

◆ MOVNTQ

#define MOVNTQ   "movq"

Definition at line 37 of file yuv2rgb_template.c.

◆ SFENCE

#define SFENCE   " # nop"

Definition at line 38 of file yuv2rgb_template.c.

◆ REG_BLUE

#define REG_BLUE   "0"

Definition at line 41 of file yuv2rgb_template.c.

◆ REG_RED

#define REG_RED   "1"

Definition at line 42 of file yuv2rgb_template.c.

◆ REG_GREEN

#define REG_GREEN   "2"

Definition at line 43 of file yuv2rgb_template.c.

◆ REG_ALPHA

#define REG_ALPHA   "3"

Definition at line 44 of file yuv2rgb_template.c.

◆ YUV2RGB_LOOP

#define YUV2RGB_LOOP (   depth)
Value:
h_size = (c->dstW + 7) & ~7; \
if (h_size * depth > FFABS(dstStride[0])) \
h_size -= 8; \
\
vshift = c->srcFormat != AV_PIX_FMT_YUV422P; \
\
__asm__ volatile ("pxor %mm4, %mm4\n\t"); \
for (y = 0; y < srcSliceH; y++) { \
uint8_t *image = dst[0] + (y + srcSliceY) * dstStride[0]; \
const uint8_t *py = src[0] + y * srcStride[0]; \
const uint8_t *pu = src[1] + (y >> vshift) * srcStride[1]; \
const uint8_t *pv = src[2] + (y >> vshift) * srcStride[2]; \
x86_reg index = -h_size / 2; \

Definition at line 46 of file yuv2rgb_template.c.

◆ YUV2RGB_INITIAL_LOAD

#define YUV2RGB_INITIAL_LOAD
Value:
__asm__ volatile ( \
"movq (%5, %0, 2), %%mm6\n\t" \
"movd (%2, %0), %%mm0\n\t" \
"movd (%3, %0), %%mm1\n\t" \
"1: \n\t" \

Definition at line 61 of file yuv2rgb_template.c.

◆ YUV2RGB

#define YUV2RGB

Definition at line 84 of file yuv2rgb_template.c.

◆ RGB_PACK_INTERLEAVE

#define RGB_PACK_INTERLEAVE
Value:
/* pack and interleave even/odd pixels */ \
"packuswb %%mm1, %%mm0\n\t" \
"packuswb %%mm5, %%mm3\n\t" \
"packuswb %%mm2, %%mm2\n\t" \
"movq %%mm0, %%mm1\n\n" \
"packuswb %%mm7, %%mm7\n\t" \
"punpcklbw %%mm3, %%mm0\n\t" \
"punpckhbw %%mm3, %%mm1\n\t" \
"punpcklbw %%mm7, %%mm2\n\t" \

Definition at line 123 of file yuv2rgb_template.c.

◆ YUV2RGB_ENDLOOP

#define YUV2RGB_ENDLOOP (   depth)
Value:
"movq 8 (%5, %0, 2), %%mm6\n\t" \
"movd 4 (%3, %0), %%mm1\n\t" \
"movd 4 (%2, %0), %%mm0\n\t" \
"add $"AV_STRINGIFY(depth * 8)", %1\n\t" \
"add $4, %0\n\t" \
"js 1b\n\t" \

Definition at line 134 of file yuv2rgb_template.c.

◆ RGB_PACK24_B_OPERANDS

#define RGB_PACK24_B_OPERANDS

Definition at line 147 of file yuv2rgb_template.c.

◆ YUV2RGB_OPERANDS

#define YUV2RGB_OPERANDS
Value:
: "+r" (index), "+r" (image) \
: "r" (pu - index), "r" (pv - index), "r"(&c->redDither), \
"r" (py - 2*index) \
NAMED_CONSTRAINTS_ADD(mmx_00ffw,pb_03,pb_07,mmx_redmask,pb_e0) \
RGB_PACK24_B_OPERANDS \
: "memory" \
); \
} \

Definition at line 150 of file yuv2rgb_template.c.

◆ YUV2RGB_OPERANDS_ALPHA

#define YUV2RGB_OPERANDS_ALPHA
Value:
: "+r" (index), "+r" (image) \
: "r" (pu - index), "r" (pv - index), "r"(&c->redDither), \
"r" (py - 2*index), "r" (pa - 2*index) \
NAMED_CONSTRAINTS_ADD(mmx_00ffw) \
: "memory" \
); \
} \

Definition at line 160 of file yuv2rgb_template.c.

◆ YUV2RGB_ENDFUNC

#define YUV2RGB_ENDFUNC
Value:
__asm__ volatile (SFENCE"\n\t" \
"emms \n\t"); \
return srcSliceH; \

Definition at line 169 of file yuv2rgb_template.c.

◆ IF0

#define IF0 (   x)

Definition at line 174 of file yuv2rgb_template.c.

◆ IF1

#define IF1 (   x)    x

Definition at line 175 of file yuv2rgb_template.c.

◆ RGB_PACK16

#define RGB_PACK16 (   gmask,
  is15 
)
Value:
"pand "MANGLE(mmx_redmask)", %%mm0\n\t" \
"pand "MANGLE(mmx_redmask)", %%mm1\n\t" \
"movq %%mm2, %%mm3\n\t" \
"psllw $"AV_STRINGIFY(3-is15)", %%mm2\n\t" \
"psrlw $"AV_STRINGIFY(5+is15)", %%mm3\n\t" \
"psrlw $3, %%mm0\n\t" \
IF##is15("psrlw $1, %%mm1\n\t") \
"pand "MANGLE(pb_e0)", %%mm2\n\t" \
"pand "MANGLE(gmask)", %%mm3\n\t" \
"por %%mm2, %%mm0\n\t" \
"por %%mm3, %%mm1\n\t" \
"movq %%mm0, %%mm2\n\t" \
"punpcklbw %%mm1, %%mm0\n\t" \
"punpckhbw %%mm1, %%mm2\n\t" \
MOVNTQ " %%mm0, (%1)\n\t" \
MOVNTQ " %%mm2, 8(%1)\n\t" \

Definition at line 177 of file yuv2rgb_template.c.

◆ DITHER_RGB

#define DITHER_RGB
Value:
"paddusb "BLUE_DITHER"(%4), %%mm0\n\t" \
"paddusb "GREEN_DITHER"(%4), %%mm2\n\t" \
"paddusb "RED_DITHER"(%4), %%mm1\n\t" \

Definition at line 195 of file yuv2rgb_template.c.

◆ RGB_PACK24

#define RGB_PACK24 (   blue,
  red 
)
Value:
"packuswb %%mm3, %%mm0 \n" /* R0 R2 R4 R6 R1 R3 R5 R7 */\
"packuswb %%mm5, %%mm1 \n" /* B0 B2 B4 B6 B1 B3 B5 B7 */\
"packuswb %%mm7, %%mm2 \n" /* G0 G2 G4 G6 G1 G3 G5 G7 */\
"movq %%mm"red", %%mm3 \n"\
"movq %%mm"blue", %%mm6 \n"\
"psrlq $32, %%mm"red" \n" /* R1 R3 R5 R7 */\
"punpcklbw %%mm2, %%mm3 \n" /* R0 G0 R2 G2 R4 G4 R6 G6 */\
"punpcklbw %%mm"red", %%mm6 \n" /* B0 R1 B2 R3 B4 R5 B6 R7 */\
"movq %%mm3, %%mm5 \n"\
"punpckhbw %%mm"blue", %%mm2 \n" /* G1 B1 G3 B3 G5 B5 G7 B7 */\
"punpcklwd %%mm6, %%mm3 \n" /* R0 G0 B0 R1 R2 G2 B2 R3 */\
"punpckhwd %%mm6, %%mm5 \n" /* R4 G4 B4 R5 R6 G6 B6 R7 */\
RGB_PACK24_B

Definition at line 258 of file yuv2rgb_template.c.

◆ RGB_PACK24_B

#define RGB_PACK24_B
Value:
"movd %%mm3, (%1) \n" /* R0 G0 B0 R1 */\
"movd %%mm2, 4(%1) \n" /* G1 B1 */\
"psrlq $32, %%mm3 \n"\
"psrlq $16, %%mm2 \n"\
"movd %%mm3, 6(%1) \n" /* R2 G2 B2 R3 */\
"movd %%mm2, 10(%1) \n" /* G3 B3 */\
"psrlq $16, %%mm2 \n"\
"movd %%mm5, 12(%1) \n" /* R4 G4 B4 R5 */\
"movd %%mm2, 16(%1) \n" /* G5 B5 */\
"psrlq $32, %%mm5 \n"\
"movd %%mm2, 20(%1) \n" /* -- -- G7 B7 */\
"movd %%mm5, 18(%1) \n" /* R6 G6 B6 R7 */\

Definition at line 303 of file yuv2rgb_template.c.

◆ SET_EMPTY_ALPHA

#define SET_EMPTY_ALPHA   "pcmpeqd %%mm"REG_ALPHA", %%mm"REG_ALPHA"\n\t" /* set alpha to 0xFF */ \

Definition at line 356 of file yuv2rgb_template.c.

◆ LOAD_ALPHA

#define LOAD_ALPHA   "movq (%6, %0, 2), %%mm"REG_ALPHA"\n\t" \

Definition at line 359 of file yuv2rgb_template.c.

◆ RGB_PACK32

#define RGB_PACK32 (   red,
  green,
  blue,
  alpha 
)
Value:
"movq %%mm"blue", %%mm5\n\t" \
"movq %%mm"red", %%mm6\n\t" \
"punpckhbw %%mm"green", %%mm5\n\t" \
"punpcklbw %%mm"green", %%mm"blue"\n\t" \
"punpckhbw %%mm"alpha", %%mm6\n\t" \
"punpcklbw %%mm"alpha", %%mm"red"\n\t" \
"movq %%mm"blue", %%mm"green"\n\t" \
"movq %%mm5, %%mm"alpha"\n\t" \
"punpcklwd %%mm"red", %%mm"blue"\n\t" \
"punpckhwd %%mm"red", %%mm"green"\n\t" \
"punpcklwd %%mm6, %%mm5\n\t" \
"punpckhwd %%mm6, %%mm"alpha"\n\t" \
MOVNTQ " %%mm"blue", 0(%1)\n\t" \
MOVNTQ " %%mm"green", 8(%1)\n\t" \
MOVNTQ " %%mm5, 16(%1)\n\t" \
MOVNTQ " %%mm"alpha", 24(%1)\n\t" \

Definition at line 362 of file yuv2rgb_template.c.

Function Documentation

◆ yuv420_rgb15_TMPL()

static int yuv420_rgb15_TMPL ( SwsContext c,
const uint8_t src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t dst[],
int  dstStride[] 
)
inlinestatic

Definition at line 201 of file yuv2rgb_template.c.

◆ yuv420_rgb16_TMPL()

static int yuv420_rgb16_TMPL ( SwsContext c,
const uint8_t src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t dst[],
int  dstStride[] 
)
inlinestatic

Definition at line 229 of file yuv2rgb_template.c.

◆ yuv420_rgb24_TMPL()

static int yuv420_rgb24_TMPL ( SwsContext c,
const uint8_t src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t dst[],
int  dstStride[] 
)
inlinestatic

Definition at line 319 of file yuv2rgb_template.c.

◆ yuv420_bgr24_TMPL()

static int yuv420_bgr24_TMPL ( SwsContext c,
const uint8_t src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t dst[],
int  dstStride[] 
)
inlinestatic

Definition at line 337 of file yuv2rgb_template.c.

◆ yuv420_rgb32_TMPL()

static int yuv420_rgb32_TMPL ( SwsContext c,
const uint8_t src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t dst[],
int  dstStride[] 
)
inlinestatic

Definition at line 381 of file yuv2rgb_template.c.

◆ yuv420_bgr32_TMPL()

static int yuv420_bgr32_TMPL ( SwsContext c,
const uint8_t src[],
int  srcStride[],
int  srcSliceY,
int  srcSliceH,
uint8_t dst[],
int  dstStride[] 
)
inlinestatic

Definition at line 424 of file yuv2rgb_template.c.

NAMED_CONSTRAINTS_ADD
#define NAMED_CONSTRAINTS_ADD(...)
Definition: asm.h:145
src
#define src
Definition: vp8dsp.c:254
SFENCE
#define SFENCE
Definition: yuv2rgb_template.c:38
BLUE_DITHER
#define BLUE_DITHER
Definition: swscale_internal.h:442
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
GREEN_DITHER
#define GREEN_DITHER
Definition: swscale_internal.h:441
index
int index
Definition: gxfenc.c:89
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
RED_DITHER
#define RED_DITHER
Definition: swscale_internal.h:440
AV_STRINGIFY
#define AV_STRINGIFY(s)
Definition: macros.h:36
uint8_t
uint8_t
Definition: audio_convert.c:194
pv
#define pv
Definition: regdef.h:60
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
MANGLE
#define MANGLE(a)
Definition: asm.h:127
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55