<div class="gmail_quote"><div style="color:rgb(80, 0, 80);border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><div><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">To. Siarhei Siamashka</span></div>
<div><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><br>
</span></div>> Great. Surely contributions in this area would be definitely useful. But you<br>> may have started this work a bit too late ;) I have been looking into improving<br>> bilinear scaling performance for the last couple of weeks already and have just<br>
> submitted some initial SSE2 and ARM NEON optimizations for it (btw, testing is<br>> very much welcome). And there is still lots of work to do before all the<br>> bilinear scaling related performance bottlenecks are eliminated.</span><div>
<span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><br></span></div></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><font face="arial, sans-serif"><span style="border-collapse:collapse">I'm very glad to hear that you are already doing some work on it.</span></font></div>
<div style="color:rgb(80, 0, 80);border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="font-size:13px">> Well, in your original e-mail, you mentioned that you are interested in getting<br>> good performance on intel quad core. That's why without having any other<br>
> information, I suggested SSE2 as a solution for this problem :)</span></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div></div><div style="color:rgb(80, 0, 80);border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="font-size:13px">> I also tried to benchmark your change to the bilinear code and got something<br>> like 23% better scaling performance overall on Intel Core i7. I guess you have<br>
> benchmarked 2x performance improvement for that function alone but not for a<br>> full rendering pipeline, right?. It's a good improvement, but not even close to<br>> the performance effect of using SSE2 or NEON (or maybe even armv5te). So I<br>
> would consider looking at the supported instruction set on your target hardware<br>> first.</span></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="font-size:13px"><br>
</span></span></font></div></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">I'm sorry about that</span><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"> I did not give you enough information on my test.</span></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">I also tuned some codes of the function bits_image_fetch_bilinear_no_repeat_8888().</span></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">I made some fast path for the case where mask == NULL and ux_bottom == ux_top.</span></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">(But still using temporary source fetch buffer)</span></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<font face="arial, sans-serif"><span style="border-collapse:collapse">Anyway, majority of our target machines support NEON instructions.</span></font></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<font face="arial, sans-serif"><span style="border-collapse:collapse">Thus, your recent NEON patches are exactly what we are looking for.</span></font></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<font face="arial, sans-serif"><span style="border-collapse:collapse">I really appreciate what you've done for this :-)</span></font></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><font face="arial, sans-serif"><span style="border-collapse:collapse">At this point, my concern is about which cases have been (or will be) optimized using NEON and which are not.</span></font></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><font face="arial, sans-serif"><span style="border-collapse:collapse">There can be so many fast paths for combination of m</span></font><span style="border-collapse:collapse;font-family:arial, sans-serif">ask, rotation(including special angle), scale factors, pixel formats, operators and so on.</span></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif">As you mentioned it is boring job to make fast paths for all these cases.</span></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif">So we should focus at the cases most commonly used.</span></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif">I think most of the common operations are already optimized for both NEON and SSE2.</span></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><span style="border-collapse:collapse;font-family:arial, sans-serif">What do you think is the remaining parts?</span></div><div style="color:rgb(80, 0, 80);border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">To. Soeren Sandmann</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="font-size:13px">> If we decide to move away from bit-exact testing, we would need to<br>
> decide on an acceptable deviation from ideal, and then update the<br>> tests to verify that both the C and SIMD implementations are within<br>> that deviation.<br>><br>> For example there could be a reference implementation that computes<br>
> the bilinear filtering in double precision floating point, adds +/-<br>> x%, then converts that range into the target bitdepth and finally<br>> verifies that the output is within that range.</span></span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="font-size:13px"><br></span></span></font></div></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="font-size:13px">Here, we need reference implementation.</span></span></font></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="font-size:13px">In my opinion, it is overdoing that reference implementation should support arbitrary affine transformation, various pixel formats, operators and so on.</span></span></font></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><font face="arial, sans-serif"><span style="border-collapse:collapse">Because pixman is based on scanline approach, verifying bilinear filtered fetching from source with only scale transformation would be sufficient.</span></font></div>
<div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px"><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<font face="arial, sans-serif"><span style="border-collapse:collapse">Here's my simple test code. (bilinear_filter_test.c)</span></font></div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#include <cairo.h></span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#include <pixman.h></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#include <stdlib.h></span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#include <string.h></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#include <stdint.h></span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#include <stdio.h></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#include <assert.h></span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#include <math.h></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">//#define USE_DOUBLE_PRECISION</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">//#define USE_RANDOM_SOURCE</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define RED(x)<span style="white-space:pre-wrap">        </span> (((x)&0x00FF0000) >> 16)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define GREEN(x) (((x)&0x0000FF00) >> 8)</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define<span style="white-space:pre-wrap">        </span>BLUE(x)<span style="white-space:pre-wrap">        </span> ((x)&0x000000FF)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define ALPHA(x) (((x)&0xFF000000) >> 24)</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define RED_DOUBLE(x)<span style="white-space:pre-wrap">        </span>(((double)RED(x)) / 255.0)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define GREEN_DOUBLE(x)<span style="white-space:pre-wrap">        </span>(((double)GREEN(x)) / 255.0)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define BLUE_DOUBLE(x)<span style="white-space:pre-wrap">        </span>(((double)BLUE(x)) / 255.0)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define ALPHA_DOUBLE(x)<span style="white-space:pre-wrap">        </span>(((double)ALPHA(x)) / 255.0)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define ROUND_TO_INT(x)<span style="white-space:pre-wrap">        </span>((int)round(x))</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define FLOOR_TO_INT(x) ((int)floor(x))</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">static int inline</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">absolute(int val)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>if( val > 0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>return val;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>else</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>return -val;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">static uint32_t inline</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">bilinear_interpolation(uint32_t tl, uint32_t tr, uint32_t bl, uint32_t br, double distx, double disty)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#ifdef USE_DOUBLE_PRECISION</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>double r, g, b, a;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>double distxy, distixy, distxiy, distixiy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>uint32_t result;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>distxy = distx*disty;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>distixy = disty - distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>distxiy = distx - distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>distixiy = 1 - distx - disty + distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>r = RED_DOUBLE(tl)*distixiy + RED_DOUBLE(tr)*distxiy + RED_DOUBLE(bl)*distixy + RED_DOUBLE(br)*distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>g = GREEN_DOUBLE(tl)*distixiy + GREEN_DOUBLE(tr)*distxiy + GREEN_DOUBLE(bl)*distixy + GREEN_DOUBLE(br)*distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>b = BLUE_DOUBLE(tl)*distixiy + BLUE_DOUBLE(tr)*distxiy + BLUE_DOUBLE(bl)*distixy + BLUE_DOUBLE(br)*distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>a = ALPHA_DOUBLE(tl)*distixiy + ALPHA_DOUBLE(tr)*distxiy + ALPHA_DOUBLE(bl)*distixy + ALPHA_DOUBLE(br)*distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>result = (ROUND_TO_INT(a*255.0) << 24) | (ROUND_TO_INT(r*255.0) << 16) | (ROUND_TO_INT(g*255.0) << 8) | ROUND_TO_INT(b*255.0);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>return result;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#else // Emulation of pixman_fixed_t</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int distxy, distxiy, distixy, distixiy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>uint32_t f, r;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int dx, dy;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>dx = ((ROUND_TO_INT(distx*65536)) >> 8) & 0xFF;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>dy = ((ROUND_TO_INT(disty*65536)) >> 8) & 0xFF;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>distxy = dx * dy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>distxiy = (dx << 8) - distxy; /* distx * (256 - disty) */</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>distixy = (dy << 8) - distxy; /* disty * (256 - distx) */</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>distixiy =</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>256 * 256 - (dy << 8) - </span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>(dx << 8) + distxy; /* (256 - distx) * (256 - disty) */</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>/* Blue */</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>r = (tl & 0x000000ff) * distixiy + (tr & 0x000000ff) * distxiy</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>+ (bl & 0x000000ff) * distixy + (br & 0x000000ff) * distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>/* Green */</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>f = (tl & 0x0000ff00) * distixiy + (tr & 0x0000ff00) * distxiy</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>+ (bl & 0x0000ff00) * distixy + (br & 0x0000ff00) * distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>r |= f & 0xff000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>tl >>= 16;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>tr >>= 16;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>bl >>= 16;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>br >>= 16;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>r >>= 16;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>/* Red */</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>f = (tl & 0x000000ff) * distixiy + (tr & 0x000000ff) * distxiy</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>+ (bl & 0x000000ff) * distixy + (br & 0x000000ff) * distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>r |= f & 0x00ff0000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>/* Alpha */</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>f = (tl & 0x0000ff00) * distixiy + (tr & 0x0000ff00) * distxiy</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>+ (bl & 0x0000ff00) * distixy + (br & 0x0000ff00) * distxy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>r |= f & 0xff000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>return r;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#endif</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">static void</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">generate_reference_image_a8r8g8b8(void *src_buffer, int src_width, int src_height, int src_stride,</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>void *dst_buffer, int dst_width, int dst_height, int dst_stride)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int dx, dy, isx, isy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>double sx, sy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>double tl, tr, bl, br;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>double distx, disty;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>double xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>uint32_t *dst_row;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>uint32_t *src_top_row;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>uint32_t *src_bottom_row;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#ifdef USE_DOUBLE_PRECISION</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>xincr = (double)src_width/(double)dst_width;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#else</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>xincr = ((double)((src_width << 16) / dst_width)) / 65536.0;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#endif</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>for( dy=0; dy<dst_height; ++dy )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#ifdef USE_DOUBLE_PRECISION</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>sx = 0.5*(double)src_width/(double)dst_width - 0.5;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>sy = ((double)dy + 0.5)*(double)src_height/(double)dst_height - 0.5;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#else</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>sx = (0.5*((src_width << 16)/dst_width))/65536.0 - 0.5;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>sy = (((double)dy + 0.5)*((src_height << 16)/dst_height))/65536.0 - 0.5;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#endif</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>dst_row = (uint32_t*)((unsigned char*)dst_buffer + dst_stride*dy);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>assert( sx >= -1.0 );</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>assert( sy >= -1.0 && sy < src_height + 1 );</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>if( sy < 0.0 ) // No source top row</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>disty = sy - (double)FLOOR_TO_INT(sy);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>src_top_row = NULL;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>src_bottom_row = (uint32_t*)src_buffer;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>dx = 0;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < -1.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = 0x00000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Left edge</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < 0.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(0x00000000, 0x00000000, 0x00000000, src_bottom_row[isx + 1], distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Main part</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < src_width - 1.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(0x00000000, 0x00000000, src_bottom_row[isx], src_bottom_row[isx + 1], distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Right edge</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < src_width )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(0x00000000, 0x00000000, src_bottom_row[isx], 0x00000000, distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = 0x00000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>}</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>else if( sy > src_height ) // No source bottom row</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>disty = sy - (double)FLOOR_TO_INT(sy);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>src_top_row = (uint32_t*)((unsigned char*)src_buffer + src_stride*(src_height - 1));</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>src_bottom_row = NULL;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>dx = 0;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < -1.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = 0x00000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Left edge</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < 0.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(0x00000000, src_top_row[isx + 1], 0x00000000, 0x00000000, distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Main part</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < src_width - 1.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(src_top_row[isx], src_top_row[isx + 1], 0x00000000, 0x00000000, distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Right edge</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < src_width )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(src_top_row[isx], 0x00000000, 0x00000000, 0x00000000, distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = 0x00000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>}</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>else</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>{</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>isy = FLOOR_TO_INT(sy);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>disty = sy - (double)isy;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>src_top_row = (uint32_t*)((unsigned char*)src_buffer + src_stride*isy);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>src_bottom_row = (uint32_t*)((unsigned char*)src_buffer + src_stride*(isy + 1));</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>dx = 0;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < -1.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = 0x00000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Left edge</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < 0.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(0x00000000, src_top_row[isx + 1], 0x00000000, src_bottom_row[isx + 1], distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Main part</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < src_width - 1.0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(src_top_row[isx], src_top_row[isx + 1], src_bottom_row[isx], src_bottom_row[isx + 1], distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>// Right edge</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width && sx < src_width )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{ </span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>isx = FLOOR_TO_INT(sx);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>distx = sx - (double)isx;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = bilinear_interpolation(src_top_row[isx], 0x00000000, src_bottom_row[isx], 0x00000000, distx, disty);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>sx += xincr;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>while( dx < dst_width )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>*dst_row++ = 0x00000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>dx++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>}</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">}</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">static void</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">generate_test_image_a8r8g8b8(void *src_buffer, int src_width, int src_height, int src_stride,</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>void *dst_buffer, int dst_width, int dst_height, int dst_stride)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_image_t * src_img;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_image_t *<span style="white-space:pre-wrap">        </span>dst_img;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_transform_t transform;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>src_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, src_width, src_height, src_buffer, src_stride);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>dst_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, dst_width, dst_height, dst_buffer, dst_stride);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_transform_init_scale(&transform, (src_width << 16)/dst_width, (src_height << 16)/dst_height);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_image_set_transform(src_img, &transform);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_image_set_filter(src_img, PIXMAN_FILTER_BILINEAR, NULL, 0);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_image_composite(PIXMAN_OP_SRC, src_img, NULL, dst_img, 0, 0, 0, 0, 0, 0, dst_width, dst_height);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_image_unref(src_img);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>pixman_image_unref(dst_img);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">static int</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">compare_image_a8r8g8b8(void *buffer0, void *buffer1, int width, int height, int stride, int tolerance)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int x, y;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>uint32_t *row0;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>uint32_t *row1;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int <span style="white-space:pre-wrap">                </span> val0, val1;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>for( y=0; y<height; ++y )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>row0 = (uint32_t*)((unsigned char*)buffer0 + stride*y);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>row1 = (uint32_t*)((unsigned char*)buffer1 + stride*y);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>for( x=0; x<width; ++x )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>val0 = RED(*row0);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>val1 = RED(*row1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>if( absolute(val0 - val1) > tolerance )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>printf("RED : x=%d y=%d\n", x, y);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>return absolute(val0 - val1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>val0 = GREEN(*row0);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>val1 = GREEN(*row1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>if( absolute(val0 - val1) > tolerance )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>printf("GREEN : x=%d y=%d\n", x, y);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>return absolute(val0 - val1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>val0 = BLUE(*row0);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>val1 = BLUE(*row1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>if( absolute(val0 - val1) > tolerance )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>printf("BLUE : x=%d y=%d\n", x, y);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>return absolute(val0 - val1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>val0 = ALPHA(*row0);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>val1 = ALPHA(*row1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>if( absolute(val0 - val1) > tolerance )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>printf("ALPHA : x=%d y=%d\n", x, y);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>return absolute(val0 - val1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>row0++;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>row1++;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>}</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>return 0;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">static int</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">bilinear_filter_test_a8r8g8b8(void *src_buffer, int src_width, int src_height, int src_stride,</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>unsigned int scale_x, unsigned int scale_y, int tolerance)</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int dst_width;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int dst_height;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int dst_stride;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>void *ref_buffer;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>void *test_buffer;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>cairo_surface_t *dst0, *dst1, *src;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int result;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>dst_width = (src_width * scale_x) >> 8;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>dst_height = (src_height *scale_y) >> 8;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>printf("dw = %d dh = %d\n", dst_width, dst_height);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>dst_stride = dst_width * 4;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>ref_buffer = malloc(dst_stride*dst_height);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>test_buffer = malloc(dst_stride*dst_height);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>memset(ref_buffer, 0x00, dst_stride*dst_height);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>memset(test_buffer, 0x00, dst_stride*dst_height);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>generate_reference_image_a8r8g8b8(src_buffer, src_width, src_height, src_stride,</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>ref_buffer, dst_width, dst_height, dst_stride);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>generate_test_image_a8r8g8b8(src_buffer, src_width, src_height, src_stride,</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>test_buffer, dst_width, dst_height, dst_stride);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>src = cairo_image_surface_create_for_data((unsigned char*)src_buffer, CAIRO_FORMAT_ARGB32, src_width, src_height, src_stride);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>dst0 = cairo_image_surface_create_for_data((unsigned char*)ref_buffer, CAIRO_FORMAT_ARGB32, dst_width, dst_height, dst_stride);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>dst1 = cairo_image_surface_create_for_data((unsigned char*)test_buffer, CAIRO_FORMAT_ARGB32, dst_width, dst_height, dst_stride);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>cairo_surface_write_to_png(src, "src.png");</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>cairo_surface_write_to_png(dst0, "ref.png");</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>cairo_surface_write_to_png(dst1, "test.png");</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>cairo_surface_destroy(src);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>cairo_surface_destroy(dst0);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>cairo_surface_destroy(dst1);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>result = compare_image_a8r8g8b8(ref_buffer, test_buffer, dst_width, dst_height, dst_stride, tolerance);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>free(ref_buffer);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>free(test_buffer);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>return result;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define MAX_WIDTH 1024</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define MAX_HEIGHT 1024</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define MAX_SCALE_X 0x200</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#define MAX_SCALE_Y 0x200</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">int</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">main(int argc, const char *argv[])</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int seed;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>void *src_buffer;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int src_width, src_height;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int src_stride;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>unsigned int scale_x, scale_y;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int tolerance;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int i, j;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>int result;</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>if( argc != 3 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>printf("Usage : bilinear_test seed tolerance\n");</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>return 0;</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>seed = atoi(argv[1]);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>tolerance = atoi(argv[2]);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>srand(seed);</span></font></div><div>
<font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>src_width = rand()%MAX_WIDTH + 1;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>src_height = rand()%MAX_HEIGHT + 1;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>scale_x = rand()%MAX_SCALE_X;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>scale_y = rand()%MAX_SCALE_Y;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>src_stride = src_width * 4;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>src_buffer = malloc(src_stride*src_height);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">#ifdef USE_RANDOM_SOURCE // Random source image</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>for( i=0; i<src_stride*src_height; ++i )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>((unsigned char*)src_buffer)[i] = rand()%256;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#else // Check Board source image</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>for( i=0; i<src_height; ++i )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>for( j=0; j<src_width; ++j )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>if( (i%16 >= 0 && i%16 < 8))</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>if( (j%16 >= 0 && j%16 < 8) )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                        </span>((uint32_t*)src_buffer)[i*src_width + j] = 0xFF000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>else</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                        </span>((uint32_t*)src_buffer)[i*src_width + j] = 0xFFFFFFFF;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>else</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>{</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>if( (j%16 >= 0 && j%16 < 8) )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                        </span>((uint32_t*)src_buffer)[i*src_width + j] = 0xFFFFFFFF;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                </span>else</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                                        </span>((uint32_t*)src_buffer)[i*src_width + j] = 0xFF000000;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                        </span>}</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>}</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">#endif</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>printf("w=%d h=%d scale_x=%d scale_y=%d\n", src_width, src_height, scale_x, scale_y);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>if( (result = bilinear_filter_test_a8r8g8b8(src_buffer, src_width, src_height, src_stride, scale_x, scale_y, tolerance)) != 0 )</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>printf("Test Failed!!! Difference %d exceeds tolerance %d\n", result, tolerance);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>else</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">                </span>printf("Test Succeeded!!\n");</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>free(src_buffer);</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse"><span style="white-space:pre-wrap">        </span>return result;</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">}</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">The reference implementation is based on bits_image_fetch_bilinear_no_repeat_888() function in pixman-bits-image.c.</span></font></div>
</div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">I think this code can be a start point.</div><div style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">
<br></div>
</div><br><br clear="all"><br>-- <br>Best Regards,<div>Taekyun Kim</div><br>