SDL  2.0
yuv_rgb_lsx_func.h File Reference
#include <lsxintrin.h>
+ Include dependency graph for yuv_rgb_lsx_func.h:

Go to the source code of this file.

Macros

#define READ_Y(y_ptr)   y = __lsx_vld(y_ptr, 0); \
 
#define READ_UV
 
#define PACK_RGBA_32(R1, R2, G1, G2, B1, B2, A1, A2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, RGB7, RGB8)
 
#define PACK_RGB24_32_STEP(R, G, B, RGB1, RGB2, RGB3)
 
#define PACK_RGB24_32(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6)
 
#define PACK_PIXEL
 
#define LSX_ST_UB2(in0, in1, pdst, stride)
 
#define SAVE_LINE1
 
#define SAVE_LINE2
 
#define UV2RGB_16(U, V, R1, G1, B1, R2, G2, B2)
 
#define ADD_Y2RGB_16(Y1, Y2, R1, G1, B1, R2, G2, B2)
 
#define CLIP(in0, in1, in2, in3, in4, in5)
 
#define YUV2RGB_32
 

Functions

void LSX_FUNCTION_NAME (uint32_t width, uint32_t height, const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, uint8_t *RGB, uint32_t RGB_stride, YCbCrType yuv_type)
 

Macro Definition Documentation

◆ ADD_Y2RGB_16

#define ADD_Y2RGB_16 (   Y1,
  Y2,
  R1,
  G1,
  B1,
  R2,
  G2,
  B2 
)
Value:
Y1 = __lsx_vsub_h(Y1, shift); \
Y2 = __lsx_vsub_h(Y2, shift); \
Y1 = __lsx_vmul_h(Y1, yf); \
Y2 = __lsx_vmul_h(Y2, yf); \
R1 = __lsx_vadd_h(R1, Y1); \
G1 = __lsx_vadd_h(G1, Y1); \
B1 = __lsx_vadd_h(B1, Y1); \
R2 = __lsx_vadd_h(R2, Y2); \
G2 = __lsx_vadd_h(G2, Y2); \
B2 = __lsx_vadd_h(B2, Y2); \
R1 = __lsx_vsrai_h(R1, PRECISION); \
G1 = __lsx_vsrai_h(G1, PRECISION); \
B1 = __lsx_vsrai_h(B1, PRECISION); \
R2 = __lsx_vsrai_h(R2, PRECISION); \
G2 = __lsx_vsrai_h(G2, PRECISION); \
B2 = __lsx_vsrai_h(B2, PRECISION); \
#define PRECISION
Definition: yuv_rgb.c:10

Definition at line 162 of file yuv_rgb_lsx_func.h.

◆ CLIP

#define CLIP (   in0,
  in1,
  in2,
  in3,
  in4,
  in5 
)
Value:
{ \
in0 = __lsx_vmaxi_h(in0, 0); \
in1 = __lsx_vmaxi_h(in1, 0); \
in2 = __lsx_vmaxi_h(in2, 0); \
in3 = __lsx_vmaxi_h(in3, 0); \
in4 = __lsx_vmaxi_h(in4, 0); \
in5 = __lsx_vmaxi_h(in5, 0); \
in0 = __lsx_vsat_hu(in0, 7); \
in1 = __lsx_vsat_hu(in1, 7); \
in2 = __lsx_vsat_hu(in2, 7); \
in3 = __lsx_vsat_hu(in3, 7); \
in4 = __lsx_vsat_hu(in4, 7); \
in5 = __lsx_vsat_hu(in5, 7); \
}

Definition at line 180 of file yuv_rgb_lsx_func.h.

◆ LSX_ST_UB2

#define LSX_ST_UB2 (   in0,
  in1,
  pdst,
  stride 
)
Value:
{ \
__lsx_vst(in0, pdst, 0); \
__lsx_vst(in1, pdst + stride, 0); \
}
GLsizei stride

Definition at line 111 of file yuv_rgb_lsx_func.h.

◆ PACK_PIXEL

#define PACK_PIXEL
Value:
__m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6; \
__m128i rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12; \
PACK_RGB24_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, \
rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6) \
PACK_RGB24_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, \
rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12) \

Definition at line 55 of file yuv_rgb_lsx_func.h.

Referenced by LSX_FUNCTION_NAME().

◆ PACK_RGB24_32

#define PACK_RGB24_32 (   R1,
  R2,
  G1,
  G2,
  B1,
  B2,
  RGB1,
  RGB2,
  RGB3,
  RGB4,
  RGB5,
  RGB6 
)
Value:
PACK_RGB24_32_STEP(R1, G1, B1, RGB1, RGB2, RGB3); \
PACK_RGB24_32_STEP(R2, G2, B2, RGB4, RGB5, RGB6); \
#define PACK_RGB24_32_STEP(R, G, B, RGB1, RGB2, RGB3)

Definition at line 49 of file yuv_rgb_lsx_func.h.

◆ PACK_RGB24_32_STEP

#define PACK_RGB24_32_STEP (   R,
  G,
  B,
  RGB1,
  RGB2,
  RGB3 
)
Value:
RGB1 = __lsx_vilvl_b(G, R); \
RGB1 = __lsx_vshuf_b(B, RGB1, mask1); \
RGB2 = __lsx_vshuf_b(B, G, mask2); \
RGB2 = __lsx_vshuf_b(R, RGB2, mask3); \
RGB3 = __lsx_vshuf_b(R, B, mask4); \
RGB3 = __lsx_vshuf_b(G, RGB3, mask5); \
#define G(x, y, z)
Definition: SDL_test_md5.c:74

Definition at line 41 of file yuv_rgb_lsx_func.h.

◆ PACK_RGBA_32

#define PACK_RGBA_32 (   R1,
  R2,
  G1,
  G2,
  B1,
  B2,
  A1,
  A2,
  RGB1,
  RGB2,
  RGB3,
  RGB4,
  RGB5,
  RGB6,
  RGB7,
  RGB8 
)
Value:
{ \
__m128i ab_l, ab_h, gr_l, gr_h; \
ab_l = __lsx_vilvl_b(B1, A1); \
ab_h = __lsx_vilvh_b(B1, A1); \
gr_l = __lsx_vilvl_b(R1, G1); \
gr_h = __lsx_vilvh_b(R1, G1); \
RGB1 = __lsx_vilvl_h(gr_l, ab_l); \
RGB2 = __lsx_vilvh_h(gr_l, ab_l); \
RGB3 = __lsx_vilvl_h(gr_h, ab_h); \
RGB4 = __lsx_vilvh_h(gr_h, ab_h); \
ab_l = __lsx_vilvl_b(B2, A2); \
ab_h = __lsx_vilvh_b(B2, A2); \
gr_l = __lsx_vilvl_b(R2, G2); \
gr_h = __lsx_vilvh_b(R2, G2); \
RGB5 = __lsx_vilvl_h(gr_l, ab_l); \
RGB6 = __lsx_vilvh_h(gr_l, ab_l); \
RGB7 = __lsx_vilvl_h(gr_h, ab_h); \
RGB8 = __lsx_vilvh_h(gr_h, ab_h); \
}

Definition at line 19 of file yuv_rgb_lsx_func.h.

◆ READ_UV

#define READ_UV
Value:
u_temp = __lsx_vld(u_ptr, 0); \
v_temp = __lsx_vld(v_ptr, 0); \

Definition at line 11 of file yuv_rgb_lsx_func.h.

◆ READ_Y

#define READ_Y (   y_ptr)    y = __lsx_vld(y_ptr, 0); \

Definition at line 8 of file yuv_rgb_lsx_func.h.

◆ SAVE_LINE1

#define SAVE_LINE1
Value:
LSX_ST_UB2(rgb_1, rgb_2, rgb_ptr1, 16); \
LSX_ST_UB2(rgb_3, rgb_4, rgb_ptr1 + 32, 16); \
LSX_ST_UB2(rgb_5, rgb_6, rgb_ptr1 + 64, 16); \
#define LSX_ST_UB2(in0, in1, pdst, stride)

Definition at line 119 of file yuv_rgb_lsx_func.h.

Referenced by LSX_FUNCTION_NAME().

◆ SAVE_LINE2

#define SAVE_LINE2
Value:
LSX_ST_UB2(rgb_7, rgb_8, rgb_ptr2, 16); \
LSX_ST_UB2(rgb_9, rgb_10, rgb_ptr2 + 32, 16); \
LSX_ST_UB2(rgb_11, rgb_12, rgb_ptr2 + 64, 16); \
#define LSX_ST_UB2(in0, in1, pdst, stride)

Definition at line 124 of file yuv_rgb_lsx_func.h.

Referenced by LSX_FUNCTION_NAME().

◆ UV2RGB_16

#define UV2RGB_16 (   U,
  V,
  R1,
  G1,
  B1,
  R2,
  G2,
  B2 
)
Value:
r_temp = __lsx_vmul_h(V, v2r); \
g_temp = __lsx_vmul_h(U, u2g); \
g_temp = __lsx_vmadd_h(g_temp, V, v2g); \
b_temp = __lsx_vmul_h(U, u2b); \
R1 = __lsx_vilvl_h(r_temp, r_temp); \
G1 = __lsx_vilvl_h(g_temp, g_temp); \
B1 = __lsx_vilvl_h(b_temp, b_temp); \
R2 = __lsx_vilvh_h(r_temp, r_temp); \
G2 = __lsx_vilvh_h(g_temp, g_temp); \
B2 = __lsx_vilvh_h(b_temp, b_temp); \
#define V(value)
Definition: yuv_rgb.c:35

Definition at line 149 of file yuv_rgb_lsx_func.h.

◆ YUV2RGB_32

#define YUV2RGB_32

Definition at line 196 of file yuv_rgb_lsx_func.h.

Referenced by LSX_FUNCTION_NAME().

Function Documentation

◆ LSX_FUNCTION_NAME()

void LSX_FUNCTION_NAME ( uint32_t  width,
uint32_t  height,
const uint8_t Y,
const uint8_t U,
const uint8_t V,
uint32_t  Y_stride,
uint32_t  UV_stride,
uint8_t RGB,
uint32_t  RGB_stride,
YCbCrType  yuv_type 
)

Definition at line 268 of file yuv_rgb_lsx_func.h.

References PACK_PIXEL, SAVE_LINE1, SAVE_LINE2, STD_FUNCTION_NAME(), YUV2RGBParam::u_b_factor, YUV2RGBParam::u_g_factor, uv_pixel_stride, uv_x_sample_interval, uv_y_sample_interval, YUV2RGBParam::v_g_factor, YUV2RGBParam::v_r_factor, YUV2RGBParam::y_factor, y_pixel_stride, YUV2RGBParam::y_shift, YUV2RGB, YUV2RGB_32, and zero.

272 {
273  const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]);
274 #if YUV_FORMAT == YUV_FORMAT_420
275  const int y_pixel_stride = 1;
276  const int uv_pixel_stride = 1;
277  const int uv_x_sample_interval = 2;
278  const int uv_y_sample_interval = 2;
279 #endif
280 #if RGB_FORMAT == RGB_FORMAT_RGB565
281  const int rgb_pixel_stride = 2;
282 #elif RGB_FORMAT == RGB_FORMAT_RGB24
283  const int rgb_pixel_stride = 3;
284  __m128i mask1 = {0x0504110302100100, 0x0A14090813070612};
285  __m128i mask2 = {0x1808170716061505, 0x00000000000A1909};
286  __m128i mask3 = {0x0504170302160100, 0x0A1A090819070618};
287  __m128i mask4 = {0x1E0D1D0C1C0B1B0A, 0x00000000000F1F0E};
288  __m128i mask5 = {0x05041C03021B0100, 0x0A1F09081E07061D};
289 #elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT_BGRA || \
290  RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT_ABGR
291  const int rgb_pixel_stride = 4;
292 #else
293 #error Unknown RGB pixel size
294 #endif
295 
296  uint32_t xpos, ypos;
297  __m128i v2r = __lsx_vreplgr2vr_h(param->v_r_factor);
298  __m128i v2g = __lsx_vreplgr2vr_h(param->v_g_factor);
299  __m128i u2g = __lsx_vreplgr2vr_h(param->u_g_factor);
300  __m128i u2b = __lsx_vreplgr2vr_h(param->u_b_factor);
301  __m128i bias = __lsx_vreplgr2vr_h(128);
302  __m128i shift = __lsx_vreplgr2vr_h(param->y_shift);
303  __m128i yf = __lsx_vreplgr2vr_h(param->y_factor);
304  __m128i zero = __lsx_vldi(0);
305 
306  if (width >= 32) {
307  for (ypos = 0; ypos < (height - (uv_y_sample_interval - 1)); ypos += uv_y_sample_interval) {
308  const uint8_t *y_ptr1 = Y + ypos * Y_stride,
309  *y_ptr2 = Y + (ypos + 1) * Y_stride,
310  *u_ptr = U + (ypos/uv_y_sample_interval) * UV_stride,
311  *v_ptr = V + (ypos/uv_y_sample_interval) * UV_stride;
312  uint8_t *rgb_ptr1 = RGB + ypos * RGB_stride,
313  *rgb_ptr2 = RGB + (ypos + 1) * RGB_stride;
314 
315  for (xpos = 0; xpos < (width - 31); xpos += 32){
316  YUV2RGB_32
317  {
318  PACK_PIXEL
319  SAVE_LINE1
320  if (uv_y_sample_interval > 1)
321  {
322  SAVE_LINE2
323  }
324  }
325  y_ptr1 += 32 * y_pixel_stride;
326  y_ptr2 += 32 * y_pixel_stride;
327  u_ptr += 32 * uv_pixel_stride/uv_x_sample_interval;
328  v_ptr += 32 * uv_pixel_stride/uv_x_sample_interval;
329  rgb_ptr1 += 32 * rgb_pixel_stride;
330  rgb_ptr2 += 32 * rgb_pixel_stride;
331  }
332  }
333  if (uv_y_sample_interval == 2 && ypos == (height - 1)) {
334  const uint8_t *y_ptr = Y + ypos * Y_stride,
335  *u_ptr = U + (ypos/uv_y_sample_interval) * UV_stride,
336  *v_ptr = V + (ypos/uv_y_sample_interval) * UV_stride;
337  uint8_t *rgb_ptr = RGB + ypos * RGB_stride;
338  STD_FUNCTION_NAME(width, 1, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type);
339  }
340  }
341  {
342  int converted = (width & ~31);
343  if (converted != width)
344  {
345  const uint8_t *y_ptr = Y + converted * y_pixel_stride,
346  *u_ptr = U + converted * uv_pixel_stride / uv_x_sample_interval,
347  *v_ptr = V + converted * uv_pixel_stride / uv_x_sample_interval;
348  uint8_t *rgb_ptr = RGB + converted * rgb_pixel_stride;
349 
350  STD_FUNCTION_NAME(width-converted, height, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type);
351  }
352  }
353 }
Definition: edid.h:20
#define SAVE_LINE1
int16_t y_factor
Definition: yuv_rgb.c:25
#define uv_x_sample_interval
#define PACK_PIXEL
int16_t v_g_factor
Definition: yuv_rgb.c:28
#define y_pixel_stride
int16_t u_b_factor
Definition: yuv_rgb.c:29
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
static const double zero
Definition: e_atan2.c:44
void STD_FUNCTION_NAME(uint32_t width, uint32_t height, const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, uint8_t *RGB, uint32_t RGB_stride, YCbCrType yuv_type)
#define YUV2RGB_32
static const YUV2RGBParam YUV2RGB[3]
Definition: yuv_rgb.c:42
int16_t u_g_factor
Definition: yuv_rgb.c:27
#define SAVE_LINE2
#define uv_pixel_stride
unsigned char uint8_t
unsigned int uint32_t
uint8_t y_shift
Definition: yuv_rgb.c:24
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
int16_t v_r_factor
Definition: yuv_rgb.c:26
#define V(value)
Definition: yuv_rgb.c:35
GLfloat param
#define uv_y_sample_interval
GLfloat bias