diff --git a/include/libyuv/row.h b/include/libyuv/row.h index 80c2837dd..7bc841f78 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -24,17 +24,13 @@ extern "C" { #ifdef __cplusplus #define align_buffer_64(var, size) \ - uint8* var; \ - uint8* var##_mem; \ - var##_mem = reinterpret_cast(malloc((size) + 63)); \ - var = reinterpret_cast \ - ((reinterpret_cast(var##_mem) + 63) & ~63) + uint8* var##_mem = reinterpret_cast(malloc((size) + 63)); \ + uint8* var = reinterpret_cast \ + ((reinterpret_cast(var##_mem) + 63) & ~63) #else #define align_buffer_64(var, size) \ - uint8* var; \ - uint8* var##_mem; \ - var##_mem = (uint8*)(malloc((size) + 63)); /* NOLINT */ \ - var = (uint8*) (((intptr_t)(var##_mem) + 63) & ~63) /* NOLINT */ + uint8* var##_mem = (uint8*)(malloc((size) + 63)); /* NOLINT */ \ + uint8* var = (uint8*)(((intptr_t)(var##_mem) + 63) & ~63) /* NOLINT */ #endif #define free_aligned_buffer_64(var) \ diff --git a/source/row_common.cc b/source/row_common.cc index 509b49e6d..87d877adc 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -71,7 +71,8 @@ static inline void WRITEWORD(uint8* p, uint32 v) { #endif void RGB24ToARGBRow_C(const uint8* src_rgb24, uint8* dst_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_rgb24[0]; uint8 g = src_rgb24[1]; uint8 r = src_rgb24[2]; @@ -85,7 +86,8 @@ void RGB24ToARGBRow_C(const uint8* src_rgb24, uint8* dst_argb, int width) { } void RAWToARGBRow_C(const uint8* src_raw, uint8* dst_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 r = src_raw[0]; uint8 g = src_raw[1]; uint8 b = src_raw[2]; @@ -99,7 +101,8 @@ void RAWToARGBRow_C(const uint8* src_raw, uint8* dst_argb, int width) { } void RGB565ToARGBRow_C(const uint8* src_rgb565, uint8* dst_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_rgb565[0] & 0x1f; uint8 g = (src_rgb565[0] >> 5) | ((src_rgb565[1] & 0x07) << 3); uint8 r = src_rgb565[1] >> 3; @@ -114,7 +117,8 @@ void RGB565ToARGBRow_C(const uint8* src_rgb565, uint8* dst_argb, int width) { void ARGB1555ToARGBRow_C(const uint8* src_argb1555, uint8* dst_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_argb1555[0] & 0x1f; uint8 g = (src_argb1555[0] >> 5) | ((src_argb1555[1] & 0x03) << 3); uint8 r = (src_argb1555[1] & 0x7c) >> 2; @@ -130,7 +134,8 @@ void ARGB1555ToARGBRow_C(const uint8* src_argb1555, uint8* dst_argb, void ARGB4444ToARGBRow_C(const uint8* src_argb4444, uint8* dst_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_argb4444[0] & 0x0f; uint8 g = src_argb4444[0] >> 4; uint8 r = src_argb4444[1] & 0x0f; @@ -145,7 +150,8 @@ void ARGB4444ToARGBRow_C(const uint8* src_argb4444, uint8* dst_argb, } void ARGBToRGB24Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_argb[0]; uint8 g = src_argb[1]; uint8 r = src_argb[2]; @@ -158,7 +164,8 @@ void ARGBToRGB24Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { } void ARGBToRAWRow_C(const uint8* src_argb, uint8* dst_rgb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_argb[0]; uint8 g = src_argb[1]; uint8 r = src_argb[2]; @@ -171,7 +178,8 @@ void ARGBToRAWRow_C(const uint8* src_argb, uint8* dst_rgb, int width) { } void ARGBToRGB565Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint8 b0 = src_argb[0] >> 3; uint8 g0 = src_argb[1] >> 2; uint8 r0 = src_argb[2] >> 3; @@ -192,7 +200,8 @@ void ARGBToRGB565Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { } void ARGBToARGB1555Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint8 b0 = src_argb[0] >> 3; uint8 g0 = src_argb[1] >> 3; uint8 r0 = src_argb[2] >> 3; @@ -218,7 +227,8 @@ void ARGBToARGB1555Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { } void ARGBToARGB4444Row_C(const uint8* src_argb, uint8* dst_rgb, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint8 b0 = src_argb[0] >> 4; uint8 g0 = src_argb[1] >> 4; uint8 r0 = src_argb[2] >> 4; @@ -256,7 +266,8 @@ static __inline int RGBToV(uint8 r, uint8 g, uint8 b) { #define MAKEROWY(NAME, R, G, B, BPP) \ void NAME ## ToYRow_C(const uint8* src_argb0, uint8* dst_y, int width) { \ - for (int x = 0; x < width; ++x) { \ + int x; \ + for (x = 0; x < width; ++x) { \ dst_y[0] = RGBToY(src_argb0[R], src_argb0[G], src_argb0[B]); \ src_argb0 += BPP; \ dst_y += 1; \ @@ -265,7 +276,8 @@ void NAME ## ToYRow_C(const uint8* src_argb0, uint8* dst_y, int width) { \ void NAME ## ToUVRow_C(const uint8* src_rgb0, int src_stride_rgb, \ uint8* dst_u, uint8* dst_v, int width) { \ const uint8* src_rgb1 = src_rgb0 + src_stride_rgb; \ - for (int x = 0; x < width - 1; x += 2) { \ + int x; \ + for (x = 0; x < width - 1; x += 2) { \ uint8 ab = (src_rgb0[B] + src_rgb0[B + BPP] + \ src_rgb1[B] + src_rgb1[B + BPP]) >> 2; \ uint8 ag = (src_rgb0[G] + src_rgb0[G + BPP] + \ @@ -336,7 +348,8 @@ static __inline int RGBToVJ(uint8 r, uint8 g, uint8 b) { #define MAKEROWYJ(NAME, R, G, B, BPP) \ void NAME ## ToYJRow_C(const uint8* src_argb0, uint8* dst_y, int width) { \ - for (int x = 0; x < width; ++x) { \ + int x; \ + for (x = 0; x < width; ++x) { \ dst_y[0] = RGBToYJ(src_argb0[R], src_argb0[G], src_argb0[B]); \ src_argb0 += BPP; \ dst_y += 1; \ @@ -345,7 +358,8 @@ void NAME ## ToYJRow_C(const uint8* src_argb0, uint8* dst_y, int width) { \ void NAME ## ToUVJRow_C(const uint8* src_rgb0, int src_stride_rgb, \ uint8* dst_u, uint8* dst_v, int width) { \ const uint8* src_rgb1 = src_rgb0 + src_stride_rgb; \ - for (int x = 0; x < width - 1; x += 2) { \ + int x; \ + for (x = 0; x < width - 1; x += 2) { \ uint8 ab = AVGB(AVGB(src_rgb0[B], src_rgb1[B]), \ AVGB(src_rgb0[B + BPP], src_rgb1[B + BPP])); \ uint8 ag = AVGB(AVGB(src_rgb0[G], src_rgb1[G]), \ @@ -372,7 +386,8 @@ MAKEROWYJ(ARGB, 2, 1, 0, 4) #undef MAKEROWYJ void RGB565ToYRow_C(const uint8* src_rgb565, uint8* dst_y, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_rgb565[0] & 0x1f; uint8 g = (src_rgb565[0] >> 5) | ((src_rgb565[1] & 0x07) << 3); uint8 r = src_rgb565[1] >> 3; @@ -386,7 +401,8 @@ void RGB565ToYRow_C(const uint8* src_rgb565, uint8* dst_y, int width) { } void ARGB1555ToYRow_C(const uint8* src_argb1555, uint8* dst_y, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_argb1555[0] & 0x1f; uint8 g = (src_argb1555[0] >> 5) | ((src_argb1555[1] & 0x03) << 3); uint8 r = (src_argb1555[1] & 0x7c) >> 2; @@ -400,7 +416,8 @@ void ARGB1555ToYRow_C(const uint8* src_argb1555, uint8* dst_y, int width) { } void ARGB4444ToYRow_C(const uint8* src_argb4444, uint8* dst_y, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 b = src_argb4444[0] & 0x0f; uint8 g = src_argb4444[0] >> 4; uint8 r = src_argb4444[1] & 0x0f; @@ -416,7 +433,8 @@ void ARGB4444ToYRow_C(const uint8* src_argb4444, uint8* dst_y, int width) { void RGB565ToUVRow_C(const uint8* src_rgb565, int src_stride_rgb565, uint8* dst_u, uint8* dst_v, int width) { const uint8* next_rgb565 = src_rgb565 + src_stride_rgb565; - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint8 b0 = src_rgb565[0] & 0x1f; uint8 g0 = (src_rgb565[0] >> 5) | ((src_rgb565[1] & 0x07) << 3); uint8 r0 = src_rgb565[1] >> 3; @@ -462,7 +480,8 @@ void RGB565ToUVRow_C(const uint8* src_rgb565, int src_stride_rgb565, void ARGB1555ToUVRow_C(const uint8* src_argb1555, int src_stride_argb1555, uint8* dst_u, uint8* dst_v, int width) { const uint8* next_argb1555 = src_argb1555 + src_stride_argb1555; - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint8 b0 = src_argb1555[0] & 0x1f; uint8 g0 = (src_argb1555[0] >> 5) | ((src_argb1555[1] & 0x03) << 3); uint8 r0 = (src_argb1555[1] & 0x7c) >> 2; @@ -509,7 +528,8 @@ void ARGB1555ToUVRow_C(const uint8* src_argb1555, int src_stride_argb1555, void ARGB4444ToUVRow_C(const uint8* src_argb4444, int src_stride_argb4444, uint8* dst_u, uint8* dst_v, int width) { const uint8* next_argb4444 = src_argb4444 + src_stride_argb4444; - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint8 b0 = src_argb4444[0] & 0x0f; uint8 g0 = src_argb4444[0] >> 4; uint8 r0 = src_argb4444[1] & 0x0f; @@ -555,7 +575,8 @@ void ARGB4444ToUVRow_C(const uint8* src_argb4444, int src_stride_argb4444, void ARGBToUV444Row_C(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 ab = src_argb[0]; uint8 ag = src_argb[1]; uint8 ar = src_argb[2]; @@ -569,7 +590,8 @@ void ARGBToUV444Row_C(const uint8* src_argb, void ARGBToUV422Row_C(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint8 ab = (src_argb[0] + src_argb[4]) >> 1; uint8 ag = (src_argb[1] + src_argb[5]) >> 1; uint8 ar = (src_argb[2] + src_argb[6]) >> 1; @@ -590,7 +612,8 @@ void ARGBToUV422Row_C(const uint8* src_argb, void ARGBToUV411Row_C(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width) { - for (int x = 0; x < width - 3; x += 4) { + int x; + for (x = 0; x < width - 3; x += 4) { uint8 ab = (src_argb[0] + src_argb[4] + src_argb[8] + src_argb[12]) >> 2; uint8 ag = (src_argb[1] + src_argb[5] + src_argb[9] + src_argb[13]) >> 2; uint8 ar = (src_argb[2] + src_argb[6] + src_argb[10] + src_argb[14]) >> 2; @@ -622,7 +645,8 @@ void ARGBToUV411Row_C(const uint8* src_argb, } void ARGBGrayRow_C(const uint8* src_argb, uint8* dst_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 y = RGBToYJ(src_argb[2], src_argb[1], src_argb[0]); dst_argb[2] = dst_argb[1] = dst_argb[0] = y; dst_argb[3] = src_argb[3]; @@ -633,7 +657,8 @@ void ARGBGrayRow_C(const uint8* src_argb, uint8* dst_argb, int width) { // Convert a row of image to Sepia tone. void ARGBSepiaRow_C(uint8* dst_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { int b = dst_argb[0]; int g = dst_argb[1]; int r = dst_argb[2]; @@ -652,7 +677,8 @@ void ARGBSepiaRow_C(uint8* dst_argb, int width) { // TODO(fbarchard): Consider adding rounding (+32). void ARGBColorMatrixRow_C(const uint8* src_argb, uint8* dst_argb, const int8* matrix_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { int b = src_argb[0]; int g = src_argb[1]; int r = src_argb[2]; @@ -676,7 +702,8 @@ void ARGBColorMatrixRow_C(const uint8* src_argb, uint8* dst_argb, // Apply color table to a row of image. void ARGBColorTableRow_C(uint8* dst_argb, const uint8* table_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { int b = dst_argb[0]; int g = dst_argb[1]; int r = dst_argb[2]; @@ -691,7 +718,8 @@ void ARGBColorTableRow_C(uint8* dst_argb, const uint8* table_argb, int width) { // Apply color table to a row of image. void RGBColorTableRow_C(uint8* dst_argb, const uint8* table_argb, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { int b = dst_argb[0]; int g = dst_argb[1]; int r = dst_argb[2]; @@ -704,7 +732,8 @@ void RGBColorTableRow_C(uint8* dst_argb, const uint8* table_argb, int width) { void ARGBQuantizeRow_C(uint8* dst_argb, int scale, int interval_size, int interval_offset, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { int b = dst_argb[0]; int g = dst_argb[1]; int r = dst_argb[2]; @@ -725,7 +754,8 @@ void ARGBShadeRow_C(const uint8* src_argb, uint8* dst_argb, int width, const uint32 r_scale = REPEAT8((value >> 16) & 0xff); const uint32 a_scale = REPEAT8(value >> 24); - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { const uint32 b = REPEAT8(src_argb[0]); const uint32 g = REPEAT8(src_argb[1]); const uint32 r = REPEAT8(src_argb[2]); @@ -746,7 +776,8 @@ void ARGBShadeRow_C(const uint8* src_argb, uint8* dst_argb, int width, void ARGBMultiplyRow_C(const uint8* src_argb0, const uint8* src_argb1, uint8* dst_argb, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { const uint32 b = REPEAT8(src_argb0[0]); const uint32 g = REPEAT8(src_argb0[1]); const uint32 r = REPEAT8(src_argb0[2]); @@ -771,7 +802,8 @@ void ARGBMultiplyRow_C(const uint8* src_argb0, const uint8* src_argb1, void ARGBAddRow_C(const uint8* src_argb0, const uint8* src_argb1, uint8* dst_argb, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { const int b = src_argb0[0]; const int g = src_argb0[1]; const int r = src_argb0[2]; @@ -795,7 +827,8 @@ void ARGBAddRow_C(const uint8* src_argb0, const uint8* src_argb1, void ARGBSubtractRow_C(const uint8* src_argb0, const uint8* src_argb1, uint8* dst_argb, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { const int b = src_argb0[0]; const int g = src_argb0[1]; const int r = src_argb0[2]; @@ -818,7 +851,8 @@ void ARGBSubtractRow_C(const uint8* src_argb0, const uint8* src_argb1, // Sobel functions which mimics SSSE3. void SobelXRow_C(const uint8* src_y0, const uint8* src_y1, const uint8* src_y2, uint8* dst_sobelx, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { int a = src_y0[i]; int b = src_y1[i]; int c = src_y2[i]; @@ -835,7 +869,8 @@ void SobelXRow_C(const uint8* src_y0, const uint8* src_y1, const uint8* src_y2, void SobelYRow_C(const uint8* src_y0, const uint8* src_y1, uint8* dst_sobely, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { int a = src_y0[i + 0]; int b = src_y0[i + 1]; int c = src_y0[i + 2]; @@ -852,7 +887,8 @@ void SobelYRow_C(const uint8* src_y0, const uint8* src_y1, void SobelRow_C(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { int r = src_sobelx[i]; int b = src_sobely[i]; int s = clamp255(r + b); @@ -866,7 +902,8 @@ void SobelRow_C(const uint8* src_sobelx, const uint8* src_sobely, void SobelToPlaneRow_C(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_y, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { int r = src_sobelx[i]; int b = src_sobely[i]; int s = clamp255(r + b); @@ -876,7 +913,8 @@ void SobelToPlaneRow_C(const uint8* src_sobelx, const uint8* src_sobely, void SobelXYRow_C(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { int r = src_sobelx[i]; int b = src_sobely[i]; int g = clamp255(r + b); @@ -890,7 +928,8 @@ void SobelXYRow_C(const uint8* src_sobelx, const uint8* src_sobely, void I400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) { // Copy a Y to RGB. - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { uint8 y = src_y[0]; dst_argb[2] = dst_argb[1] = dst_argb[0] = y; dst_argb[3] = 255u; @@ -933,7 +972,8 @@ void I444ToARGBRow_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint8 u = (src_u[0] + src_u[1] + 1) >> 1; uint8 v = (src_v[0] + src_v[1] + 1) >> 1; YuvPixel(src_y[0], u, v, rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); @@ -956,7 +996,8 @@ void I444ToARGBRow_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; @@ -973,7 +1014,8 @@ void I422ToARGBRow_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; @@ -997,7 +1039,8 @@ void I422ToRGB24Row_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); YuvPixel(src_y[1], src_u[0], src_v[0], @@ -1018,7 +1061,8 @@ void I422ToRAWRow_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); YuvPixel(src_y[1], src_u[0], src_v[0], @@ -1045,7 +1089,8 @@ void I422ToARGB4444Row_C(const uint8* src_y, uint8 b1; uint8 g1; uint8 r1; - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1); b0 = b0 >> 4; @@ -1082,7 +1127,8 @@ void I422ToARGB1555Row_C(const uint8* src_y, uint8 b1; uint8 g1; uint8 r1; - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1); b0 = b0 >> 3; @@ -1119,7 +1165,8 @@ void I422ToRGB565Row_C(const uint8* src_y, uint8 b1; uint8 g1; uint8 r1; - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], &b0, &g0, &r0); YuvPixel(src_y[1], src_u[0], src_v[0], &b1, &g1, &r1); b0 = b0 >> 3; @@ -1149,7 +1196,8 @@ void I411ToARGBRow_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 3; x += 4) { + int x; + for (x = 0; x < width - 3; x += 4) { YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; @@ -1188,7 +1236,8 @@ void NV12ToARGBRow_C(const uint8* src_y, const uint8* usrc_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], usrc_v[0], usrc_v[1], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; @@ -1210,7 +1259,8 @@ void NV21ToARGBRow_C(const uint8* src_y, const uint8* src_vu, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_vu[1], src_vu[0], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; @@ -1240,7 +1290,8 @@ void NV12ToRGB565Row_C(const uint8* src_y, uint8 b1; uint8 g1; uint8 r1; - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], usrc_v[0], usrc_v[1], &b0, &g0, &r0); YuvPixel(src_y[1], usrc_v[0], usrc_v[1], &b1, &g1, &r1); b0 = b0 >> 3; @@ -1274,7 +1325,8 @@ void NV21ToRGB565Row_C(const uint8* src_y, uint8 b1; uint8 g1; uint8 r1; - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], vsrc_u[1], vsrc_u[0], &b0, &g0, &r0); YuvPixel(src_y[1], vsrc_u[1], vsrc_u[0], &b1, &g1, &r1); b0 = b0 >> 3; @@ -1301,7 +1353,8 @@ void NV21ToRGB565Row_C(const uint8* src_y, void YUY2ToARGBRow_C(const uint8* src_yuy2, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_yuy2[0], src_yuy2[1], src_yuy2[3], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; @@ -1321,7 +1374,8 @@ void YUY2ToARGBRow_C(const uint8* src_yuy2, void UYVYToARGBRow_C(const uint8* src_uyvy, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_uyvy[1], src_uyvy[0], src_uyvy[2], rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; @@ -1343,7 +1397,8 @@ void I422ToBGRARow_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 3, rgb_buf + 2, rgb_buf + 1); rgb_buf[0] = 255; @@ -1367,7 +1422,8 @@ void I422ToABGRRow_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 2, rgb_buf + 1, rgb_buf + 0); rgb_buf[3] = 255; @@ -1391,7 +1447,8 @@ void I422ToRGBARow_C(const uint8* src_y, const uint8* src_v, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], src_u[0], src_v[0], rgb_buf + 1, rgb_buf + 2, rgb_buf + 3); rgb_buf[0] = 255; @@ -1411,7 +1468,8 @@ void I422ToRGBARow_C(const uint8* src_y, } void YToARGBRow_C(const uint8* src_y, uint8* rgb_buf, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { YuvPixel(src_y[0], 128, 128, rgb_buf + 0, rgb_buf + 1, rgb_buf + 2); rgb_buf[3] = 255; @@ -1429,8 +1487,9 @@ void YToARGBRow_C(const uint8* src_y, uint8* rgb_buf, int width) { } void MirrorRow_C(const uint8* src, uint8* dst, int width) { + int x; src += width - 1; - for (int x = 0; x < width - 1; x += 2) { + for (x = 0; x < width - 1; x += 2) { dst[x] = src[0]; dst[x + 1] = src[-1]; src -= 2; @@ -1441,8 +1500,9 @@ void MirrorRow_C(const uint8* src, uint8* dst, int width) { } void MirrorUVRow_C(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width) { + int x; src_uv += (width - 1) << 1; - for (int x = 0; x < width - 1; x += 2) { + for (x = 0; x < width - 1; x += 2) { dst_u[x] = src_uv[0]; dst_u[x + 1] = src_uv[-2]; dst_v[x] = src_uv[1]; @@ -1456,10 +1516,11 @@ void MirrorUVRow_C(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width) { } void ARGBMirrorRow_C(const uint8* src, uint8* dst, int width) { + int x; const uint32* src32 = (const uint32*)(src); uint32* dst32 = (uint32*)(dst); src32 += width - 1; - for (int x = 0; x < width - 1; x += 2) { + for (x = 0; x < width - 1; x += 2) { dst32[x] = src32[0]; dst32[x + 1] = src32[-1]; src32 -= 2; @@ -1470,7 +1531,8 @@ void ARGBMirrorRow_C(const uint8* src, uint8* dst, int width) { } void SplitUVRow_C(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { dst_u[x] = src_uv[0]; dst_u[x + 1] = src_uv[2]; dst_v[x] = src_uv[1]; @@ -1485,7 +1547,8 @@ void SplitUVRow_C(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width) { void MergeUVRow_C(const uint8* src_u, const uint8* src_v, uint8* dst_uv, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { dst_uv[0] = src_u[x]; dst_uv[1] = src_v[x]; dst_uv[2] = src_u[x + 1]; @@ -1505,7 +1568,8 @@ void CopyRow_C(const uint8* src, uint8* dst, int count) { void SetRow_C(uint8* dst, uint32 v8, int count) { #ifdef _MSC_VER // VC will generate rep stosb. - for (int x = 0; x < count; ++x) { + int x; + for (x = 0; x < count; ++x) { dst[x] = v8; } #else @@ -1515,9 +1579,11 @@ void SetRow_C(uint8* dst, uint32 v8, int count) { void ARGBSetRows_C(uint8* dst, uint32 v32, int width, int dst_stride, int height) { - for (int y = 0; y < height; ++y) { + int y; + for (y = 0; y < height; ++y) { uint32* d = (uint32*)(dst); - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { d[x] = v32; } dst += dst_stride; @@ -1528,7 +1594,8 @@ void ARGBSetRows_C(uint8* dst, uint32 v32, int width, void YUY2ToUVRow_C(const uint8* src_yuy2, int src_stride_yuy2, uint8* dst_u, uint8* dst_v, int width) { // Output a row of UV values, filtering 2 rows of YUY2. - for (int x = 0; x < width; x += 2) { + int x; + for (x = 0; x < width; x += 2) { dst_u[0] = (src_yuy2[1] + src_yuy2[src_stride_yuy2 + 1] + 1) >> 1; dst_v[0] = (src_yuy2[3] + src_yuy2[src_stride_yuy2 + 3] + 1) >> 1; src_yuy2 += 4; @@ -1541,7 +1608,8 @@ void YUY2ToUVRow_C(const uint8* src_yuy2, int src_stride_yuy2, void YUY2ToUV422Row_C(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, int width) { // Output a row of UV values. - for (int x = 0; x < width; x += 2) { + int x; + for (x = 0; x < width; x += 2) { dst_u[0] = src_yuy2[1]; dst_v[0] = src_yuy2[3]; src_yuy2 += 4; @@ -1553,7 +1621,8 @@ void YUY2ToUV422Row_C(const uint8* src_yuy2, // Copy row of YUY2 Y's (422) into Y (420/422). void YUY2ToYRow_C(const uint8* src_yuy2, uint8* dst_y, int width) { // Output a row of Y values. - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { dst_y[x] = src_yuy2[0]; dst_y[x + 1] = src_yuy2[2]; src_yuy2 += 4; @@ -1567,7 +1636,8 @@ void YUY2ToYRow_C(const uint8* src_yuy2, uint8* dst_y, int width) { void UYVYToUVRow_C(const uint8* src_uyvy, int src_stride_uyvy, uint8* dst_u, uint8* dst_v, int width) { // Output a row of UV values. - for (int x = 0; x < width; x += 2) { + int x; + for (x = 0; x < width; x += 2) { dst_u[0] = (src_uyvy[0] + src_uyvy[src_stride_uyvy + 0] + 1) >> 1; dst_v[0] = (src_uyvy[2] + src_uyvy[src_stride_uyvy + 2] + 1) >> 1; src_uyvy += 4; @@ -1580,7 +1650,8 @@ void UYVYToUVRow_C(const uint8* src_uyvy, int src_stride_uyvy, void UYVYToUV422Row_C(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width) { // Output a row of UV values. - for (int x = 0; x < width; x += 2) { + int x; + for (x = 0; x < width; x += 2) { dst_u[0] = src_uyvy[0]; dst_v[0] = src_uyvy[2]; src_uyvy += 4; @@ -1592,7 +1663,8 @@ void UYVYToUV422Row_C(const uint8* src_uyvy, // Copy row of UYVY Y's (422) into Y (420/422). void UYVYToYRow_C(const uint8* src_uyvy, uint8* dst_y, int width) { // Output a row of Y values. - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { dst_y[x] = src_uyvy[1]; dst_y[x + 1] = src_uyvy[3]; src_uyvy += 4; @@ -1609,7 +1681,8 @@ void UYVYToYRow_C(const uint8* src_uyvy, uint8* dst_y, int width) { // This code mimics the SSSE3 version for better testability. void ARGBBlendRow_C(const uint8* src_argb0, const uint8* src_argb1, uint8* dst_argb, int width) { - for (int x = 0; x < width - 1; x += 2) { + int x; + for (x = 0; x < width - 1; x += 2) { uint32 fb = src_argb0[0]; uint32 fg = src_argb0[1]; uint32 fr = src_argb0[2]; @@ -1658,7 +1731,8 @@ void ARGBBlendRow_C(const uint8* src_argb0, const uint8* src_argb1, // Multiply source RGB by alpha and store to destination. // This code mimics the SSSE3 version for better testability. void ARGBAttenuateRow_C(const uint8* src_argb, uint8* dst_argb, int width) { - for (int i = 0; i < width - 1; i += 2) { + int i; + for (i = 0; i < width - 1; i += 2) { uint32 b = src_argb[0]; uint32 g = src_argb[1]; uint32 r = src_argb[2]; @@ -1735,7 +1809,8 @@ const uint32 fixed_invtbl8[256] = { #undef T void ARGBUnattenuateRow_C(const uint8* src_argb, uint8* dst_argb, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { uint32 b = src_argb[0]; uint32 g = src_argb[1]; uint32 r = src_argb[2]; @@ -1757,7 +1832,8 @@ void ARGBUnattenuateRow_C(const uint8* src_argb, uint8* dst_argb, int width) { void ComputeCumulativeSumRow_C(const uint8* row, int32* cumsum, const int32* previous_cumsum, int width) { int32 row_sum[4] = {0, 0, 0, 0}; - for (int x = 0; x < width; ++x) { + int x; + for (x = 0; x < width; ++x) { row_sum[0] += row[x * 4 + 0]; row_sum[1] += row[x * 4 + 1]; row_sum[2] += row[x * 4 + 2]; @@ -1772,7 +1848,8 @@ void ComputeCumulativeSumRow_C(const uint8* row, int32* cumsum, void CumulativeSumToAverageRow_C(const int32* tl, const int32* bl, int w, int area, uint8* dst, int count) { float ooa = 1.0f / area; - for (int i = 0; i < count; ++i) { + int i; + for (i = 0; i < count; ++i) { dst[0] = (uint8)((bl[w + 0] + tl[0] - bl[0] - tl[w + 0]) * ooa); dst[1] = (uint8)((bl[w + 1] + tl[1] - bl[1] - tl[w + 1]) * ooa); dst[2] = (uint8)((bl[w + 2] + tl[2] - bl[2] - tl[w + 2]) * ooa); @@ -1787,11 +1864,12 @@ void CumulativeSumToAverageRow_C(const int32* tl, const int32* bl, LIBYUV_API void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride, uint8* dst_argb, const float* uv_dudv, int width) { + int i; // Render a row of pixels from source into a buffer. float uv[2]; uv[0] = uv_dudv[0]; uv[1] = uv_dudv[1]; - for (int i = 0; i < width; ++i) { + for (i = 0; i < width; ++i) { int x = (int)(uv[0]); int y = (int)(uv[1]); *(uint32*)(dst_argb) = @@ -1806,7 +1884,8 @@ void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride, // Blend 2 rows into 1 for conversions such as I422ToI420. void HalfRow_C(const uint8* src_uv, int src_uv_stride, uint8* dst_uv, int pix) { - for (int x = 0; x < pix; ++x) { + int x; + for (x = 0; x < pix; ++x) { dst_uv[x] = (src_uv[x] + src_uv[src_uv_stride + x] + 1) >> 1; } } @@ -1815,6 +1894,10 @@ void HalfRow_C(const uint8* src_uv, int src_uv_stride, void InterpolateRow_C(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride, int width, int source_y_fraction) { + int y1_fraction = source_y_fraction; + int y0_fraction = 256 - y1_fraction; + const uint8* src_ptr1 = src_ptr + src_stride; + int x; if (source_y_fraction == 0) { memcpy(dst_ptr, src_ptr, width); return; @@ -1823,11 +1906,7 @@ void InterpolateRow_C(uint8* dst_ptr, const uint8* src_ptr, HalfRow_C(src_ptr, (int)(src_stride), dst_ptr, width); return; } - int y1_fraction = source_y_fraction; - int y0_fraction = 256 - y1_fraction; - const uint8* src_ptr1 = src_ptr + src_stride; - - for (int x = 0; x < width - 1; x += 2) { + for (x = 0; x < width - 1; x += 2) { dst_ptr[0] = (src_ptr[0] * y0_fraction + src_ptr1[0] * y1_fraction) >> 8; dst_ptr[1] = (src_ptr[1] * y0_fraction + src_ptr1[1] * y1_fraction) >> 8; src_ptr += 2; @@ -1845,7 +1924,8 @@ void ARGBToBayerRow_C(const uint8* src_argb, int index0 = selector & 0xff; int index1 = (selector >> 8) & 0xff; // Copy a row of Bayer. - for (int x = 0; x < pix - 1; x += 2) { + int x; + for (x = 0; x < pix - 1; x += 2) { dst_bayer[0] = src_argb[index0]; dst_bayer[1] = src_argb[index1]; src_argb += 8; @@ -1860,7 +1940,8 @@ void ARGBToBayerRow_C(const uint8* src_argb, void ARGBToBayerGGRow_C(const uint8* src_argb, uint8* dst_bayer, uint32 selector, int pix) { // Copy a row of G. - for (int x = 0; x < pix - 1; x += 2) { + int x; + for (x = 0; x < pix - 1; x += 2) { dst_bayer[0] = src_argb[1]; dst_bayer[1] = src_argb[5]; src_argb += 8; @@ -1879,7 +1960,8 @@ void ARGBShuffleRow_C(const uint8* src_argb, uint8* dst_argb, int index2 = shuffler[2]; int index3 = shuffler[3]; // Shuffle a row of ARGB. - for (int x = 0; x < pix; ++x) { + int x; + for (x = 0; x < pix; ++x) { // To support in-place conversion. uint8 b = src_argb[index0]; uint8 g = src_argb[index1]; @@ -1898,44 +1980,46 @@ void I422ToYUY2Row_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_frame, int width) { - for (int x = 0; x < width - 1; x += 2) { - dst_frame[0] = src_y[0]; - dst_frame[1] = src_u[0]; - dst_frame[2] = src_y[1]; - dst_frame[3] = src_v[0]; - dst_frame += 4; - src_y += 2; - src_u += 1; - src_v += 1; - } - if (width & 1) { - dst_frame[0] = src_y[0]; - dst_frame[1] = src_u[0]; - dst_frame[2] = src_y[0]; // duplicate last y - dst_frame[3] = src_v[0]; - } + int x; + for (x = 0; x < width - 1; x += 2) { + dst_frame[0] = src_y[0]; + dst_frame[1] = src_u[0]; + dst_frame[2] = src_y[1]; + dst_frame[3] = src_v[0]; + dst_frame += 4; + src_y += 2; + src_u += 1; + src_v += 1; + } + if (width & 1) { + dst_frame[0] = src_y[0]; + dst_frame[1] = src_u[0]; + dst_frame[2] = src_y[0]; // duplicate last y + dst_frame[3] = src_v[0]; + } } void I422ToUYVYRow_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_frame, int width) { - for (int x = 0; x < width - 1; x += 2) { - dst_frame[0] = src_u[0]; - dst_frame[1] = src_y[0]; - dst_frame[2] = src_v[0]; - dst_frame[3] = src_y[1]; - dst_frame += 4; - src_y += 2; - src_u += 1; - src_v += 1; - } - if (width & 1) { - dst_frame[0] = src_u[0]; - dst_frame[1] = src_y[0]; - dst_frame[2] = src_v[0]; - dst_frame[3] = src_y[0]; // duplicate last y - } + int x; + for (x = 0; x < width - 1; x += 2) { + dst_frame[0] = src_u[0]; + dst_frame[1] = src_y[0]; + dst_frame[2] = src_v[0]; + dst_frame[3] = src_y[1]; + dst_frame += 4; + src_y += 2; + src_u += 1; + src_v += 1; + } + if (width & 1) { + dst_frame[0] = src_u[0]; + dst_frame[1] = src_y[0]; + dst_frame[2] = src_v[0]; + dst_frame[3] = src_y[0]; // duplicate last y + } } #if !defined(LIBYUV_DISABLE_X86) && defined(HAS_I422TOARGBROW_SSSE3) @@ -2059,7 +2143,8 @@ void UYVYToARGBRow_Unaligned_SSSE3(const uint8* src_uyvy, void ARGBPolynomialRow_C(const uint8* src_argb, uint8* dst_argb, const float* poly, int width) { - for (int i = 0; i < width; ++i) { + int i; + for (i = 0; i < width; ++i) { float b = (float)(src_argb[0]); float g = (float)(src_argb[1]); float r = (float)(src_argb[2]); @@ -2072,14 +2157,14 @@ void ARGBPolynomialRow_C(const uint8* src_argb, float dg = poly[1] + poly[5] * g; float dr = poly[2] + poly[6] * r; float da = poly[3] + poly[7] * a; - db += poly[8] * b2; - dg += poly[9] * g2; - dr += poly[10] * r2; - da += poly[11] * a2; float b3 = b2 * b; float g3 = g2 * g; float r3 = r2 * r; float a3 = a2 * a; + db += poly[8] * b2; + dg += poly[9] * g2; + dr += poly[10] * r2; + da += poly[11] * a2; db += poly[12] * b3; dg += poly[13] * g3; dr += poly[14] * r3; @@ -2095,21 +2180,23 @@ void ARGBPolynomialRow_C(const uint8* src_argb, } void ARGBLumaColorTableRow_C(const uint8* src_argb, uint8* dst_argb, int width, - const uint8* luma, const uint32 lumacoeff) { + const uint8* luma, uint32 lumacoeff) { uint32 bc = lumacoeff & 0xff; uint32 gc = (lumacoeff >> 8) & 0xff; uint32 rc = (lumacoeff >> 16) & 0xff; - for (int i = 0; i < width - 1; i += 2) { + int i; + for (i = 0; i < width - 1; i += 2) { // Luminance in rows, color values in columns. const uint8* luma0 = ((src_argb[0] * bc + src_argb[1] * gc + src_argb[2] * rc) & 0x7F00u) + luma; + const uint8* luma1; dst_argb[0] = luma0[src_argb[0]]; dst_argb[1] = luma0[src_argb[1]]; dst_argb[2] = luma0[src_argb[2]]; dst_argb[3] = src_argb[3]; - const uint8* luma1 = ((src_argb[4] * bc + src_argb[5] * gc + - src_argb[6] * rc) & 0x7F00u) + luma; + luma1 = ((src_argb[4] * bc + src_argb[5] * gc + + src_argb[6] * rc) & 0x7F00u) + luma; dst_argb[4] = luma1[src_argb[4]]; dst_argb[5] = luma1[src_argb[5]]; dst_argb[6] = luma1[src_argb[6]]; @@ -2129,7 +2216,8 @@ void ARGBLumaColorTableRow_C(const uint8* src_argb, uint8* dst_argb, int width, } void ARGBCopyAlphaRow_C(const uint8* src, uint8* dst, int width) { - for (int i = 0; i < width - 1; i += 2) { + int i; + for (i = 0; i < width - 1; i += 2) { dst[3] = src[3]; dst[7] = src[7]; dst += 8; @@ -2141,7 +2229,8 @@ void ARGBCopyAlphaRow_C(const uint8* src, uint8* dst, int width) { } void ARGBCopyYToAlphaRow_C(const uint8* src, uint8* dst, int width) { - for (int i = 0; i < width - 1; i += 2) { + int i; + for (i = 0; i < width - 1; i += 2) { dst[3] = src[0]; dst[7] = src[1]; dst += 8; diff --git a/source/scale_common.cc b/source/scale_common.cc index fee31ac17..6ed8bfaf9 100644 --- a/source/scale_common.cc +++ b/source/scale_common.cc @@ -30,7 +30,8 @@ static __inline int Abs(int v) { // CPU agnostic row functions void ScaleRowDown2_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width) { - for (int x = 0; x < dst_width - 1; x += 2) { + int x; + for (x = 0; x < dst_width - 1; x += 2) { dst[0] = src_ptr[1]; dst[1] = src_ptr[3]; dst += 2; @@ -44,7 +45,8 @@ void ScaleRowDown2_C(const uint8* src_ptr, ptrdiff_t src_stride, void ScaleRowDown2Linear_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width) { const uint8* s = src_ptr; - for (int x = 0; x < dst_width - 1; x += 2) { + int x; + for (x = 0; x < dst_width - 1; x += 2) { dst[0] = (s[0] + s[1] + 1) >> 1; dst[1] = (s[2] + s[3] + 1) >> 1; dst += 2; @@ -59,7 +61,8 @@ void ScaleRowDown2Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width) { const uint8* s = src_ptr; const uint8* t = src_ptr + src_stride; - for (int x = 0; x < dst_width - 1; x += 2) { + int x; + for (x = 0; x < dst_width - 1; x += 2) { dst[0] = (s[0] + s[1] + t[0] + t[1] + 2) >> 2; dst[1] = (s[2] + s[3] + t[2] + t[3] + 2) >> 2; dst += 2; @@ -73,7 +76,8 @@ void ScaleRowDown2Box_C(const uint8* src_ptr, ptrdiff_t src_stride, void ScaleRowDown4_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width) { - for (int x = 0; x < dst_width - 1; x += 2) { + int x; + for (x = 0; x < dst_width - 1; x += 2) { dst[0] = src_ptr[2]; dst[1] = src_ptr[6]; dst += 2; @@ -87,7 +91,8 @@ void ScaleRowDown4_C(const uint8* src_ptr, ptrdiff_t src_stride, void ScaleRowDown4Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width) { intptr_t stride = src_stride; - for (int x = 0; x < dst_width - 1; x += 2) { + int x; + for (x = 0; x < dst_width - 1; x += 2) { dst[0] = (src_ptr[0] + src_ptr[1] + src_ptr[2] + src_ptr[3] + src_ptr[stride + 0] + src_ptr[stride + 1] + src_ptr[stride + 2] + src_ptr[stride + 3] + @@ -121,8 +126,9 @@ void ScaleRowDown4Box_C(const uint8* src_ptr, ptrdiff_t src_stride, void ScaleRowDown34_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width) { + int x; assert((dst_width % 3 == 0) && (dst_width > 0)); - for (int x = 0; x < dst_width; x += 3) { + for (x = 0; x < dst_width; x += 3) { dst[0] = src_ptr[0]; dst[1] = src_ptr[1]; dst[2] = src_ptr[3]; @@ -134,10 +140,11 @@ void ScaleRowDown34_C(const uint8* src_ptr, ptrdiff_t src_stride, // Filter rows 0 and 1 together, 3 : 1 void ScaleRowDown34_0_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* d, int dst_width) { - assert((dst_width % 3 == 0) && (dst_width > 0)); const uint8* s = src_ptr; const uint8* t = src_ptr + src_stride; - for (int x = 0; x < dst_width; x += 3) { + int x; + assert((dst_width % 3 == 0) && (dst_width > 0)); + for (x = 0; x < dst_width; x += 3) { uint8 a0 = (s[0] * 3 + s[1] * 1 + 2) >> 2; uint8 a1 = (s[1] * 1 + s[2] * 1 + 1) >> 1; uint8 a2 = (s[2] * 1 + s[3] * 3 + 2) >> 2; @@ -156,10 +163,11 @@ void ScaleRowDown34_0_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, // Filter rows 1 and 2 together, 1 : 1 void ScaleRowDown34_1_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* d, int dst_width) { - assert((dst_width % 3 == 0) && (dst_width > 0)); const uint8* s = src_ptr; const uint8* t = src_ptr + src_stride; - for (int x = 0; x < dst_width; x += 3) { + int x; + assert((dst_width % 3 == 0) && (dst_width > 0)); + for (x = 0; x < dst_width; x += 3) { uint8 a0 = (s[0] * 3 + s[1] * 1 + 2) >> 2; uint8 a1 = (s[1] * 1 + s[2] * 1 + 1) >> 1; uint8 a2 = (s[2] * 1 + s[3] * 3 + 2) >> 2; @@ -178,7 +186,8 @@ void ScaleRowDown34_1_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, // Scales a single row of pixels using point sampling. void ScaleCols_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx) { - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { dst_ptr[0] = src_ptr[x >> 16]; x += dx; dst_ptr[1] = src_ptr[x >> 16]; @@ -193,7 +202,8 @@ void ScaleCols_C(uint8* dst_ptr, const uint8* src_ptr, // Scales a single row of pixels up by 2x using point sampling. void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx) { - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { dst_ptr[1] = dst_ptr[0] = src_ptr[0]; src_ptr += 1; dst_ptr += 2; @@ -209,7 +219,8 @@ void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr, void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx) { - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { int xi = x >> 16; int a = src_ptr[xi]; int b = src_ptr[xi + 1]; @@ -233,7 +244,8 @@ void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr, void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x32, int dx) { int64 x = (int64)(x32); - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { int64 xi = x >> 16; int a = src_ptr[xi]; int b = src_ptr[xi + 1]; @@ -257,8 +269,9 @@ void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr, void ScaleRowDown38_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width) { + int x; assert(dst_width % 3 == 0); - for (int x = 0; x < dst_width; x += 3) { + for (x = 0; x < dst_width; x += 3) { dst[0] = src_ptr[0]; dst[1] = src_ptr[3]; dst[2] = src_ptr[6]; @@ -271,9 +284,10 @@ void ScaleRowDown38_C(const uint8* src_ptr, ptrdiff_t src_stride, void ScaleRowDown38_3_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width) { - assert((dst_width % 3 == 0) && (dst_width > 0)); intptr_t stride = src_stride; - for (int i = 0; i < dst_width; i += 3) { + int i; + assert((dst_width % 3 == 0) && (dst_width > 0)); + for (i = 0; i < dst_width; i += 3) { dst_ptr[0] = (src_ptr[0] + src_ptr[1] + src_ptr[2] + src_ptr[stride + 0] + src_ptr[stride + 1] + src_ptr[stride + 2] + src_ptr[stride * 2 + 0] + @@ -296,9 +310,10 @@ void ScaleRowDown38_3_Box_C(const uint8* src_ptr, // 8x2 -> 3x1 void ScaleRowDown38_2_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width) { - assert((dst_width % 3 == 0) && (dst_width > 0)); intptr_t stride = src_stride; - for (int i = 0; i < dst_width; i += 3) { + int i; + assert((dst_width % 3 == 0) && (dst_width > 0)); + for (i = 0; i < dst_width; i += 3) { dst_ptr[0] = (src_ptr[0] + src_ptr[1] + src_ptr[2] + src_ptr[stride + 0] + src_ptr[stride + 1] + src_ptr[stride + 2]) * (65536 / 6) >> 16; @@ -315,12 +330,14 @@ void ScaleRowDown38_2_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, void ScaleAddRows_C(const uint8* src_ptr, ptrdiff_t src_stride, uint16* dst_ptr, int src_width, int src_height) { + int x; assert(src_width > 0); assert(src_height > 0); - for (int x = 0; x < src_width; ++x) { + for (x = 0; x < src_width; ++x) { const uint8* s = src_ptr + x; unsigned int sum = 0u; - for (int y = 0; y < src_height; ++y) { + int y; + for (y = 0; y < src_height; ++y) { sum += s[0]; s += src_stride; } @@ -335,7 +352,8 @@ void ScaleARGBRowDown2_C(const uint8* src_argb, const uint32* src = (const uint32*)(src_argb); uint32* dst = (uint32*)(dst_argb); - for (int x = 0; x < dst_width - 1; x += 2) { + int x; + for (x = 0; x < dst_width - 1; x += 2) { dst[0] = src[1]; dst[1] = src[3]; src += 4; @@ -349,7 +367,8 @@ void ScaleARGBRowDown2_C(const uint8* src_argb, void ScaleARGBRowDown2Linear_C(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width) { - for (int x = 0; x < dst_width; ++x) { + int x; + for (x = 0; x < dst_width; ++x) { dst_argb[0] = (src_argb[0] + src_argb[4] + 1) >> 1; dst_argb[1] = (src_argb[1] + src_argb[5] + 1) >> 1; dst_argb[2] = (src_argb[2] + src_argb[6] + 1) >> 1; @@ -361,7 +380,8 @@ void ScaleARGBRowDown2Linear_C(const uint8* src_argb, void ScaleARGBRowDown2Box_C(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width) { - for (int x = 0; x < dst_width; ++x) { + int x; + for (x = 0; x < dst_width; ++x) { dst_argb[0] = (src_argb[0] + src_argb[4] + src_argb[src_stride] + src_argb[src_stride + 4] + 2) >> 2; dst_argb[1] = (src_argb[1] + src_argb[5] + @@ -381,7 +401,8 @@ void ScaleARGBRowDownEven_C(const uint8* src_argb, ptrdiff_t src_stride, const uint32* src = (const uint32*)(src_argb); uint32* dst = (uint32*)(dst_argb); - for (int x = 0; x < dst_width - 1; x += 2) { + int x; + for (x = 0; x < dst_width - 1; x += 2) { dst[0] = src[0]; dst[1] = src[src_stepx]; src += src_stepx * 2; @@ -396,7 +417,8 @@ void ScaleARGBRowDownEvenBox_C(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width) { - for (int x = 0; x < dst_width; ++x) { + int x; + for (x = 0; x < dst_width; ++x) { dst_argb[0] = (src_argb[0] + src_argb[4] + src_argb[src_stride] + src_argb[src_stride + 4] + 2) >> 2; dst_argb[1] = (src_argb[1] + src_argb[5] + @@ -415,7 +437,8 @@ void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx) { const uint32* src = (const uint32*)(src_argb); uint32* dst = (uint32*)(dst_argb); - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { dst[0] = src[x >> 16]; x += dx; dst[1] = src[x >> 16]; @@ -432,7 +455,8 @@ void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb, int64 x = (int64)(x32); const uint32* src = (const uint32*)(src_argb); uint32* dst = (uint32*)(dst_argb); - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { dst[0] = src[x >> 16]; x += dx; dst[1] = src[x >> 16]; @@ -449,7 +473,8 @@ void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx) { const uint32* src = (const uint32*)(src_argb); uint32* dst = (uint32*)(dst_argb); - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { dst[1] = dst[0] = src[0]; src += 1; dst += 2; @@ -471,7 +496,8 @@ void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx) { const uint32* src = (const uint32*)(src_argb); uint32* dst = (uint32*)(dst_argb); - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { int xi = x >> 16; int xf = (x >> 9) & 0x7f; uint32 a = src[xi]; @@ -500,7 +526,8 @@ void ScaleARGBFilterCols64_C(uint8* dst_argb, const uint8* src_argb, int64 x = (int64)(x32); const uint32* src = (const uint32*)(src_argb); uint32* dst = (uint32*)(dst_argb); - for (int j = 0; j < dst_width - 1; j += 2) { + int j; + for (j = 0; j < dst_width - 1; j += 2) { int64 xi = x >> 16; int xf = (x >> 9) & 0x7f; uint32 a = src[xi]; @@ -535,15 +562,17 @@ void ScalePlaneVertical(int src_height, int x, int y, int dy, int bpp, enum FilterMode filtering) { // TODO(fbarchard): Allow higher bpp. + int dst_width_bytes = dst_width * bpp; + void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, + ptrdiff_t src_stride, int dst_width, int source_y_fraction) = + InterpolateRow_C; + const int max_y = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0; + int j; assert(bpp >= 1 && bpp <= 4); assert(src_height != 0); assert(dst_width > 0); assert(dst_height > 0); - int dst_width_bytes = dst_width * bpp; src_argb += (x >> 16) * bpp; - void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, - ptrdiff_t src_stride, int dst_width, int source_y_fraction) = - InterpolateRow_C; #if defined(HAS_INTERPOLATEROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && dst_width_bytes >= 16) { InterpolateRow = InterpolateRow_Any_SSE2; @@ -594,15 +623,16 @@ void ScalePlaneVertical(int src_height, } } #endif - const int max_y = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0; - for (int j = 0; j < dst_height; ++j) { + for (j = 0; j < dst_height; ++j) { + int yi; + int yf; if (y > max_y) { y = max_y; } - int yi = y >> 16; - int yf = filtering ? ((y >> 8) & 255) : 0; - const uint8* src = src_argb + yi * src_stride; - InterpolateRow(dst_argb, src, src_stride, dst_width_bytes, yf); + yi = y >> 16; + yf = filtering ? ((y >> 8) & 255) : 0; + InterpolateRow(dst_argb, src_argb + yi * src_stride, + src_stride, dst_width_bytes, yf); dst_argb += dst_stride; y += dy; }