mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	speedup by unrolling loops
This commit is contained in:
		
							parent
							
								
									c22af89ef0
								
							
						
					
					
						commit
						42967dd1a6
					
				| 
						 | 
					@ -100,8 +100,8 @@ ImagingStretchHorizaontal(Imaging imIn, int xsize, int filter)
 | 
				
			||||||
    Imaging imOut;
 | 
					    Imaging imOut;
 | 
				
			||||||
    struct filter *filterp;
 | 
					    struct filter *filterp;
 | 
				
			||||||
    float support, scale, filterscale;
 | 
					    float support, scale, filterscale;
 | 
				
			||||||
    float center, ww, ss;
 | 
					    float center, ww, ss, ss4[4];
 | 
				
			||||||
    int xx, yy, x, b, kmax, xmin, xmax;
 | 
					    int xx, yy, x, kmax, xmin, xmax;
 | 
				
			||||||
    int *xbounds;
 | 
					    int *xbounds;
 | 
				
			||||||
    float *k, *kk;
 | 
					    float *k, *kk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -204,13 +204,27 @@ ImagingStretchHorizaontal(Imaging imIn, int xsize, int filter)
 | 
				
			||||||
                    xmin = xbounds[xx * 2 + 0];
 | 
					                    xmin = xbounds[xx * 2 + 0];
 | 
				
			||||||
                    xmax = xbounds[xx * 2 + 1];
 | 
					                    xmax = xbounds[xx * 2 + 1];
 | 
				
			||||||
                    k = &kk[xx * kmax];
 | 
					                    k = &kk[xx * kmax];
 | 
				
			||||||
                    for (b = 0; b < imIn->bands; b++) {
 | 
					                    if (imIn->bands == 3) {
 | 
				
			||||||
                        if (imIn->bands == 2 && b)
 | 
					                        ss4[0] = ss4[1] = ss4[2] = 0.5;
 | 
				
			||||||
                            b = 3; /* hack to deal with LA images */
 | 
					                        for (x = xmin; x < xmax; x++) {
 | 
				
			||||||
                        ss = 0.5;
 | 
					                            ss4[0] += (UINT8) imIn->image[yy][x*4 + 0] * k[x - xmin];
 | 
				
			||||||
                        for (x = xmin; x < xmax; x++)
 | 
					                            ss4[1] += (UINT8) imIn->image[yy][x*4 + 1] * k[x - xmin];
 | 
				
			||||||
                            ss = ss + (UINT8) imIn->image[yy][x*4+b] * k[x - xmin];
 | 
					                            ss4[2] += (UINT8) imIn->image[yy][x*4 + 2] * k[x - xmin];
 | 
				
			||||||
                        imOut->image[yy][xx*4+b] = clip8(ss);
 | 
					                        }
 | 
				
			||||||
 | 
					                        imOut->image32[yy][xx] =
 | 
				
			||||||
 | 
					                            clip8(ss4[0]) | clip8(ss4[1]) << 8 |
 | 
				
			||||||
 | 
					                            clip8(ss4[2]) << 16;
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        ss4[0] = ss4[1] = ss4[2] = ss4[3] = 0.5;
 | 
				
			||||||
 | 
					                        for (x = xmin; x < xmax; x++) {
 | 
				
			||||||
 | 
					                            ss4[0] += (UINT8) imIn->image[yy][x*4 + 0] * k[x - xmin];
 | 
				
			||||||
 | 
					                            ss4[1] += (UINT8) imIn->image[yy][x*4 + 1] * k[x - xmin];
 | 
				
			||||||
 | 
					                            ss4[2] += (UINT8) imIn->image[yy][x*4 + 2] * k[x - xmin];
 | 
				
			||||||
 | 
					                            ss4[3] += (UINT8) imIn->image[yy][x*4 + 3] * k[x - xmin];
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        imOut->image32[yy][xx] =
 | 
				
			||||||
 | 
					                            clip8(ss4[0]) | clip8(ss4[1]) << 8 |
 | 
				
			||||||
 | 
					                            clip8(ss4[2]) << 16 | clip8(ss4[3]) << 24;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user