Răsfoiți Sursa

stb_image; optimize row computation in PR

Sean Barrett 6 ani în urmă
părinte
comite
e5d4d6fcce
1 a modificat fișierele cu 6 adăugiri și 6 ștergeri
  1. 6 6
      stb_image_write.h

+ 6 - 6
stb_image_write.h

@@ -1469,15 +1469,15 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
          for(x = 0; x < width; x += 8) {
          for(x = 0; x < width; x += 8) {
             float YDU[64], UDU[64], VDU[64];
             float YDU[64], UDU[64], VDU[64];
             for(row = y, pos = 0; row < y+8; ++row) {
             for(row = y, pos = 0; row < y+8; ++row) {
+               if(row < height) {
+                  p = (stbi__flip_vertically_on_write ? (height-1-row) : row)*width*comp;
+               } else {
+                  // row >= height => use last input row (=> first if flipping)
+                  p = stbi__flip_vertically_on_write ? 0 : ((height-1)*width*comp);
+               }
                for(col = x; col < x+8; ++col, ++pos) {
                for(col = x; col < x+8; ++col, ++pos) {
                   float r, g, b;
                   float r, g, b;
                   int p;
                   int p;
-                  if(row < height) {
-                     p = (stbi__flip_vertically_on_write ? (height-1-row) : row)*width*comp;
-                  } else {
-                     // row >= height => use last input row (=> first if flipping)
-                     p = stbi__flip_vertically_on_write ? 0 : ((height-1)*width*comp);
-                  }
                   // if col >= width => use pixel from last input column
                   // if col >= width => use pixel from last input column
                   p += ((col < width) ? col : (width-1))*comp;
                   p += ((col < width) ? col : (width-1))*comp;