SDL  2.0
yuv_rgb_std_func.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PACK_PIXEL(rgb_ptr)
 
#define y_pixel_stride   1
 
#define uv_pixel_stride   1
 
#define uv_x_sample_interval   2
 
#define uv_y_sample_interval   2
 

Functions

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)
 

Macro Definition Documentation

◆ PACK_PIXEL

#define PACK_PIXEL (   rgb_ptr)
Value:
*(Uint16 *)rgb_ptr = \
((((Uint16)clampU8(y_tmp+r_tmp)) << 8 ) & 0xF800) | \
((((Uint16)clampU8(y_tmp+g_tmp)) << 3) & 0x07E0) | \
(((Uint16)clampU8(y_tmp+b_tmp)) >> 3); \
rgb_ptr += 2; \

Definition at line 12 of file yuv_rgb_std_func.h.

◆ uv_pixel_stride

#define uv_pixel_stride   1

◆ uv_x_sample_interval

#define uv_x_sample_interval   2

◆ uv_y_sample_interval

#define uv_y_sample_interval   2

◆ y_pixel_stride

#define y_pixel_stride   1

Function Documentation

◆ STD_FUNCTION_NAME()

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 
)

Definition at line 72 of file yuv_rgb_std_func.h.

77 {
78  const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]);
79 #if YUV_FORMAT == YUV_FORMAT_420
80  #define y_pixel_stride 1
81  #define uv_pixel_stride 1
82  #define uv_x_sample_interval 2
83  #define uv_y_sample_interval 2
84 #elif YUV_FORMAT == YUV_FORMAT_422
85  #define y_pixel_stride 2
86  #define uv_pixel_stride 4
87  #define uv_x_sample_interval 2
88  #define uv_y_sample_interval 1
89 #elif YUV_FORMAT == YUV_FORMAT_NV12
90  #define y_pixel_stride 1
91  #define uv_pixel_stride 2
92  #define uv_x_sample_interval 2
93  #define uv_y_sample_interval 2
94 #endif
95 
96  uint32_t x, y;
98  {
99  const uint8_t *y_ptr1=Y+y*Y_stride,
100  *y_ptr2=Y+(y+1)*Y_stride,
101  *u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
102  *v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
103 
104  uint8_t *rgb_ptr1=RGB+y*RGB_stride;
105 
106  #if uv_y_sample_interval > 1
107  uint8_t *rgb_ptr2=RGB+(y+1)*RGB_stride;
108  #endif
109 
111  {
112  // Compute U and V contributions, common to the four pixels
113 
114  int32_t u_tmp = ((*u_ptr)-128);
115  int32_t v_tmp = ((*v_ptr)-128);
116 
117  int32_t r_tmp = (v_tmp*param->v_r_factor);
118  int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
119  int32_t b_tmp = (u_tmp*param->u_b_factor);
120 
121  // Compute the Y contribution for each pixel
122 
123  int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
124  PACK_PIXEL(rgb_ptr1);
125 
126  y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
127  PACK_PIXEL(rgb_ptr1);
128 
129  #if uv_y_sample_interval > 1
130  y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
131  PACK_PIXEL(rgb_ptr2);
132 
133  y_tmp = ((y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor);
134  PACK_PIXEL(rgb_ptr2);
135  #endif
136 
137  y_ptr1+=2*y_pixel_stride;
138  y_ptr2+=2*y_pixel_stride;
141  }
142 
143  /* Catch the last pixel, if needed */
144  if (uv_x_sample_interval == 2 && x == (width-1))
145  {
146  // Compute U and V contributions, common to the four pixels
147 
148  int32_t u_tmp = ((*u_ptr)-128);
149  int32_t v_tmp = ((*v_ptr)-128);
150 
151  int32_t r_tmp = (v_tmp*param->v_r_factor);
152  int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
153  int32_t b_tmp = (u_tmp*param->u_b_factor);
154 
155  // Compute the Y contribution for each pixel
156 
157  int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
158  PACK_PIXEL(rgb_ptr1);
159 
160  #if uv_y_sample_interval > 1
161  y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
162  PACK_PIXEL(rgb_ptr2);
163  #endif
164  }
165  }
166 
167  /* Catch the last line, if needed */
168  if (uv_y_sample_interval == 2 && y == (height-1))
169  {
170  const uint8_t *y_ptr1=Y+y*Y_stride,
171  *u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
172  *v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
173 
174  uint8_t *rgb_ptr1=RGB+y*RGB_stride;
175 
177  {
178  // Compute U and V contributions, common to the four pixels
179 
180  int32_t u_tmp = ((*u_ptr)-128);
181  int32_t v_tmp = ((*v_ptr)-128);
182 
183  int32_t r_tmp = (v_tmp*param->v_r_factor);
184  int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
185  int32_t b_tmp = (u_tmp*param->u_b_factor);
186 
187  // Compute the Y contribution for each pixel
188 
189  int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
190  PACK_PIXEL(rgb_ptr1);
191 
192  y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
193  PACK_PIXEL(rgb_ptr1);
194 
195  y_ptr1+=2*y_pixel_stride;
198  }
199 
200  /* Catch the last pixel, if needed */
201  if (uv_x_sample_interval == 2 && x == (width-1))
202  {
203  // Compute U and V contributions, common to the four pixels
204 
205  int32_t u_tmp = ((*u_ptr)-128);
206  int32_t v_tmp = ((*v_ptr)-128);
207 
208  int32_t r_tmp = (v_tmp*param->v_r_factor);
209  int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
210  int32_t b_tmp = (u_tmp*param->u_b_factor);
211 
212  // Compute the Y contribution for each pixel
213 
214  int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
215  PACK_PIXEL(rgb_ptr1);
216  }
217  }
218 
219  #undef y_pixel_stride
220  #undef uv_pixel_stride
221  #undef uv_x_sample_interval
222  #undef uv_y_sample_interval
223 }

References PACK_PIXEL, RGB, uv_pixel_stride, uv_x_sample_interval, uv_y_sample_interval, V, y_pixel_stride, and YUV2RGB.

Referenced by SSE_FUNCTION_NAME().

y_pixel_stride
#define y_pixel_stride
YUV2RGB
static const YUV2RGBParam YUV2RGB[3]
Definition: yuv_rgb.c:42
YUV2RGBParam
Definition: yuv_rgb.c:22
PACK_PIXEL
#define PACK_PIXEL(rgb_ptr)
Definition: yuv_rgb_std_func.h:12
clampU8
static uint8_t clampU8(int32_t v)
Definition: yuv_rgb.c:75
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
RGB
@ RGB
Definition: edid.h:20
V
#define V(value)
Definition: yuv_rgb.c:35
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
int32_t
signed int int32_t
Definition: SDL_config_windows.h:62
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
Uint16
uint16_t Uint16
Definition: SDL_stdinc.h:191
param
GLfloat param
Definition: SDL_opengl_glext.h:370
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
uint32_t
unsigned int uint32_t
Definition: SDL_config_windows.h:63
uint8_t
unsigned char uint8_t
Definition: SDL_config_windows.h:59
uv_y_sample_interval
#define uv_y_sample_interval
uv_pixel_stride
#define uv_pixel_stride
uv_x_sample_interval
#define uv_x_sample_interval