diff --git a/src/video/yuv2rgb/yuv_rgb.c b/src/video/yuv2rgb/yuv_rgb.c index c7415aa72..71bcde9c6 100644 --- a/src/video/yuv2rgb/yuv_rgb.c +++ b/src/video/yuv2rgb/yuv_rgb.c @@ -34,6 +34,11 @@ typedef struct // |G| = 1/PRECISION_FACTOR * |y_factor u_g_factor v_g_factor| * | U-128 | // |B| |y_factor u_b_factor 0 | | V-128 | +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 26451) +#endif + #define V(value) (int16_t)((value*PRECISION_FACTOR)+0.5) // for ITU-T T.871, values can be found in section 7 @@ -59,6 +64,10 @@ static const RGB2YUVParam RGB2YUV[3] = { {/*.y_shift=*/ 16, /*.matrix=*/ {{V(0.1826), V(0.6142), V(0.062)}, {-V(0.1006), -V(0.3386), V(0.4392)}, {V(0.4392), -V(0.3989), -V(0.0403)}}} }; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + /* The various layouts of YUV data we support */ #define YUV_FORMAT_420 1 #define YUV_FORMAT_422 2 @@ -76,7 +85,7 @@ static const RGB2YUVParam RGB2YUV[3] = { // input must be in the [-128*PRECISION_FACTOR:384*PRECISION_FACTOR] range static uint8_t clampU8(int32_t v) { - static const uint8_t lut[512] = + static const uint8_t lut[512] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46, @@ -186,52 +195,52 @@ static uint8_t clampU8(int32_t v) #include "yuv_rgb_std_func.h" void rgb24_yuv420_std( - uint32_t width, uint32_t height, - const uint8_t *RGB, uint32_t RGB_stride, - uint8_t *Y, uint8_t *U, uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, + uint32_t width, uint32_t height, + const uint8_t *RGB, uint32_t RGB_stride, + uint8_t *Y, uint8_t *U, uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, YCbCrType yuv_type) { const RGB2YUVParam *const param = &(RGB2YUV[yuv_type]); - + uint32_t x, y; for(y=0; y<(height-1); y+=2) { const uint8_t *rgb_ptr1=RGB+y*RGB_stride, *rgb_ptr2=RGB+(y+1)*RGB_stride; - + uint8_t *y_ptr1=Y+y*Y_stride, *y_ptr2=Y+(y+1)*Y_stride, *u_ptr=U+(y/2)*UV_stride, *v_ptr=V+(y/2)*UV_stride; - + for(x=0; x<(width-1); x+=2) { // compute yuv for the four pixels, u and v values are summed int32_t y_tmp, u_tmp, v_tmp; - + y_tmp = param->matrix[0][0]*rgb_ptr1[0] + param->matrix[0][1]*rgb_ptr1[1] + param->matrix[0][2]*rgb_ptr1[2]; u_tmp = param->matrix[1][0]*rgb_ptr1[0] + param->matrix[1][1]*rgb_ptr1[1] + param->matrix[1][2]*rgb_ptr1[2]; v_tmp = param->matrix[2][0]*rgb_ptr1[0] + param->matrix[2][1]*rgb_ptr1[1] + param->matrix[2][2]*rgb_ptr1[2]; y_ptr1[0]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr1[3] + param->matrix[0][1]*rgb_ptr1[4] + param->matrix[0][2]*rgb_ptr1[5]; u_tmp += param->matrix[1][0]*rgb_ptr1[3] + param->matrix[1][1]*rgb_ptr1[4] + param->matrix[1][2]*rgb_ptr1[5]; v_tmp += param->matrix[2][0]*rgb_ptr1[3] + param->matrix[2][1]*rgb_ptr1[4] + param->matrix[2][2]*rgb_ptr1[5]; y_ptr1[1]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr2[0] + param->matrix[0][1]*rgb_ptr2[1] + param->matrix[0][2]*rgb_ptr2[2]; u_tmp += param->matrix[1][0]*rgb_ptr2[0] + param->matrix[1][1]*rgb_ptr2[1] + param->matrix[1][2]*rgb_ptr2[2]; v_tmp += param->matrix[2][0]*rgb_ptr2[0] + param->matrix[2][1]*rgb_ptr2[1] + param->matrix[2][2]*rgb_ptr2[2]; y_ptr2[0]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr2[3] + param->matrix[0][1]*rgb_ptr2[4] + param->matrix[0][2]*rgb_ptr2[5]; u_tmp += param->matrix[1][0]*rgb_ptr2[3] + param->matrix[1][1]*rgb_ptr2[4] + param->matrix[1][2]*rgb_ptr2[5]; v_tmp += param->matrix[2][0]*rgb_ptr2[3] + param->matrix[2][1]*rgb_ptr2[4] + param->matrix[2][2]*rgb_ptr2[5]; y_ptr2[1]=clampU8(y_tmp+((param->y_shift)<matrix[2][0])), \ V = _mm_add_epi16(V, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[2][2]))); \ V = _mm_add_epi16(V, _mm_set1_epi16(128<v_r_factor); int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); int32_t b_tmp = (u_tmp*param->u_b_factor); - + // Compute the Y contribution for each pixel - + int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + #if uv_y_sample_interval > 1 y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr2); - + y_tmp = ((y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr2); #endif @@ -149,19 +154,19 @@ void STD_FUNCTION_NAME( if (uv_x_sample_interval == 2 && x == (width-1)) { // Compute U and V contributions, common to the four pixels - + int32_t u_tmp = ((*u_ptr)-128); int32_t v_tmp = ((*v_ptr)-128); - + int32_t r_tmp = (v_tmp*param->v_r_factor); int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); int32_t b_tmp = (u_tmp*param->u_b_factor); - + // Compute the Y contribution for each pixel - + int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + #if uv_y_sample_interval > 1 y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr2); @@ -175,28 +180,28 @@ void STD_FUNCTION_NAME( const uint8_t *y_ptr1=Y+y*Y_stride, *u_ptr=U+(y/uv_y_sample_interval)*UV_stride, *v_ptr=V+(y/uv_y_sample_interval)*UV_stride; - + uint8_t *rgb_ptr1=RGB+y*RGB_stride; - + for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval) { // Compute U and V contributions, common to the four pixels - + int32_t u_tmp = ((*u_ptr)-128); int32_t v_tmp = ((*v_ptr)-128); - + int32_t r_tmp = (v_tmp*param->v_r_factor); int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); int32_t b_tmp = (u_tmp*param->u_b_factor); - + // Compute the Y contribution for each pixel - + int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + y_ptr1+=2*y_pixel_stride; u_ptr+=2*uv_pixel_stride/uv_x_sample_interval; v_ptr+=2*uv_pixel_stride/uv_x_sample_interval; @@ -206,16 +211,16 @@ void STD_FUNCTION_NAME( if (uv_x_sample_interval == 2 && x == (width-1)) { // Compute U and V contributions, common to the four pixels - + int32_t u_tmp = ((*u_ptr)-128); int32_t v_tmp = ((*v_ptr)-128); - + int32_t r_tmp = (v_tmp*param->v_r_factor); int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); int32_t b_tmp = (u_tmp*param->u_b_factor); - + // Compute the Y contribution for each pixel - + int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); } @@ -227,6 +232,10 @@ void STD_FUNCTION_NAME( #undef uv_y_sample_interval } +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #undef STD_FUNCTION_NAME #undef YUV_FORMAT #undef RGB_FORMAT