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)
 

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; \
static uint8_t clampU8(int32_t v)
Definition: yuv_rgb.c:75
uint16_t Uint16
Definition: SDL_stdinc.h:169

Definition at line 12 of file yuv_rgb_std_func.h.

Referenced by STD_FUNCTION_NAME().

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.

References PACK_PIXEL, YUV2RGBParam::u_b_factor, YUV2RGBParam::u_g_factor, YUV2RGBParam::v_g_factor, YUV2RGBParam::v_r_factor, YUV2RGBParam::y_factor, YUV2RGBParam::y_shift, and YUV2RGB.

Referenced by SSE_FUNCTION_NAME().

77 {
78  const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]);
79 #if YUV_FORMAT == YUV_FORMAT_420
80  const int y_pixel_stride = 1;
81  const int uv_pixel_stride = 1;
82  const int uv_x_sample_interval = 2;
83  const int uv_y_sample_interval = 2;
84 #elif YUV_FORMAT == YUV_FORMAT_422
85  const int y_pixel_stride = 2;
86  const int uv_pixel_stride = 4;
87  const int uv_x_sample_interval = 2;
88  const int uv_y_sample_interval = 1;
89 #elif YUV_FORMAT == YUV_FORMAT_NV12
90  const int y_pixel_stride = 1;
91  const int uv_pixel_stride = 2;
92  const int uv_x_sample_interval = 2;
93  const int uv_y_sample_interval = 2;
94 #endif
95 
96  uint32_t x, y;
97  for(y=0; y<(height-(uv_y_sample_interval-1)); y+=uv_y_sample_interval)
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  *rgb_ptr2=RGB+(y+1)*RGB_stride;
106 
107  for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval)
108  {
109  // Compute U and V contributions, common to the four pixels
110 
111  int32_t u_tmp = ((*u_ptr)-128);
112  int32_t v_tmp = ((*v_ptr)-128);
113 
114  int32_t r_tmp = (v_tmp*param->v_r_factor);
115  int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
116  int32_t b_tmp = (u_tmp*param->u_b_factor);
117 
118  // Compute the Y contribution for each pixel
119 
120  int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
121  PACK_PIXEL(rgb_ptr1);
122 
123  y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
124  PACK_PIXEL(rgb_ptr1);
125 
126  if (uv_y_sample_interval > 1) {
127  y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
128  PACK_PIXEL(rgb_ptr2);
129 
130  y_tmp = ((y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor);
131  PACK_PIXEL(rgb_ptr2);
132  }
133 
134  y_ptr1+=2*y_pixel_stride;
135  y_ptr2+=2*y_pixel_stride;
136  u_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
137  v_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
138  }
139 
140  /* Catch the last pixel, if needed */
141  if (uv_x_sample_interval == 2 && x == (width-1))
142  {
143  // Compute U and V contributions, common to the four pixels
144 
145  int32_t u_tmp = ((*u_ptr)-128);
146  int32_t v_tmp = ((*v_ptr)-128);
147 
148  int32_t r_tmp = (v_tmp*param->v_r_factor);
149  int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
150  int32_t b_tmp = (u_tmp*param->u_b_factor);
151 
152  // Compute the Y contribution for each pixel
153 
154  int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
155  PACK_PIXEL(rgb_ptr1);
156 
157  if (uv_y_sample_interval > 1) {
158  y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
159  PACK_PIXEL(rgb_ptr2);
160  }
161  }
162  }
163 
164  /* Catch the last line, if needed */
165  if (uv_y_sample_interval == 2 && y == (height-1))
166  {
167  const uint8_t *y_ptr1=Y+y*Y_stride,
168  *u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
169  *v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
170 
171  uint8_t *rgb_ptr1=RGB+y*RGB_stride;
172 
173  for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval)
174  {
175  // Compute U and V contributions, common to the four pixels
176 
177  int32_t u_tmp = ((*u_ptr)-128);
178  int32_t v_tmp = ((*v_ptr)-128);
179 
180  int32_t r_tmp = (v_tmp*param->v_r_factor);
181  int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
182  int32_t b_tmp = (u_tmp*param->u_b_factor);
183 
184  // Compute the Y contribution for each pixel
185 
186  int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
187  PACK_PIXEL(rgb_ptr1);
188 
189  y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
190  PACK_PIXEL(rgb_ptr1);
191 
192  y_ptr1+=2*y_pixel_stride;
193  u_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
194  v_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
195  }
196 
197  /* Catch the last pixel, if needed */
198  if (uv_x_sample_interval == 2 && x == (width-1))
199  {
200  // Compute U and V contributions, common to the four pixels
201 
202  int32_t u_tmp = ((*u_ptr)-128);
203  int32_t v_tmp = ((*v_ptr)-128);
204 
205  int32_t r_tmp = (v_tmp*param->v_r_factor);
206  int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
207  int32_t b_tmp = (u_tmp*param->u_b_factor);
208 
209  // Compute the Y contribution for each pixel
210 
211  int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
212  PACK_PIXEL(rgb_ptr1);
213  }
214  }
215 }
Definition: edid.h:20
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
signed int int32_t
int16_t y_factor
Definition: yuv_rgb.c:25
int16_t v_g_factor
Definition: yuv_rgb.c:28
int16_t u_b_factor
Definition: yuv_rgb.c:29
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
static const YUV2RGBParam YUV2RGB[3]
Definition: yuv_rgb.c:42
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
int16_t u_g_factor
Definition: yuv_rgb.c:27
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 PACK_PIXEL(rgb_ptr)