After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 566717 - Small speed improvement for gegl-sampler-linear, clean-up of gegl-sampler-yafr, and addition of new resampler gegl-sampler-nohalo
Small speed improvement for gegl-sampler-linear, clean-up of gegl-sampler-yaf...
Status: RESOLVED FIXED
Product: GEGL
Classification: Other
Component: GeglBuffer
git master
Other All
: Normal enhancement
: ---
Assigned To: Default Gegl Component Owner
Default Gegl Component Owner
Depends on:
Blocks:
 
 
Reported: 2009-01-06 00:55 UTC by Nicolas Robidoux
Modified: 2009-01-14 12:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.* and gegl-buffer-access.c, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. (79.50 KB, patch)
2009-01-06 01:01 UTC, Nicolas Robidoux
none Details | Review
fixed patch which adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.* and gegl-buffer-access.c, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. (89.34 KB, patch)
2009-01-06 01:45 UTC, Nicolas Robidoux
none Details | Review
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. (89.89 KB, patch)
2009-01-06 03:32 UTC, Nicolas Robidoux
none Details | Review
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. (89.95 KB, patch)
2009-01-06 03:50 UTC, Nicolas Robidoux
none Details | Review
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. (91.06 KB, patch)
2009-01-06 19:56 UTC, Nicolas Robidoux
none Details | Review
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. (90.19 KB, patch)
2009-01-09 00:29 UTC, Nicolas Robidoux
none Details | Review
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. (91.68 KB, patch)
2009-01-11 03:09 UTC, Nicolas Robidoux
none Details | Review
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. (91.86 KB, patch)
2009-01-12 05:23 UTC, Nicolas Robidoux
none Details | Review
adds gegl-sampler-sharp.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and speeds up gegl-sampler-yafr.* and gegl-sampler-linear.c. (91.90 KB, patch)
2009-01-14 06:07 UTC, Nicolas Robidoux
none Details | Review

Description Nicolas Robidoux 2009-01-06 00:55:07 UTC
Add the nohalo method to the gegl family of resamplers, and apply patches to linear and yafr.
Comment 1 Nicolas Robidoux 2009-01-06 01:01:11 UTC
Created attachment 125813 [details] [review]
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.* and gegl-buffer-access.c, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. 

I'll triple check tonight that this does not introduce bugs and post and "all clear" message when I'm done.
Comment 2 Nicolas Robidoux 2009-01-06 01:36:16 UTC
I appear to have forgotten to apply the patch to gegl-sampler-linear.c (which, in its current version, actually runs more slowly than the brand new nohalo). Will fix ASAP.
Comment 3 Nicolas Robidoux 2009-01-06 01:45:14 UTC
Created attachment 125817 [details] [review]
fixed patch which adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.* and gegl-buffer-access.c, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c.
Comment 4 Nicolas Robidoux 2009-01-06 02:03:52 UTC
Quick and dirty timings (resizing four images through xml script):

Linear before patch:

7.266 + 8.947 + 0.969 + 44.793 = 61.975s

Linear after patch:

7.041 + 8.911 + 0.900 + 44.364 = 61.216s

For comparison:

With nohalo:

6.925 + 8.965 + 0.898 + 44.215 = 61.003s

With yafr:

8.103 + 10.061 + 1.003 + 49.839 = 69.006s

(Bicubic and Lanczos are even slower.)

The fact that nohalo is still the fastest suggests that I could still
speed linear up, because nohalo (even at this lowest quality level) is a considerably more complex method. But I have
other "cats to whip" (pardon my French) for now.

Nicolas Robidoux
Universite Laurentienne
Comment 5 Nicolas Robidoux 2009-01-06 02:05:32 UTC
Apparently, I did not add bugs, so this is a "go."

Nicolas Robidoux
Laurentian University
Comment 6 Nicolas Robidoux 2009-01-06 03:02:14 UTC
I need to double check again.

n
Comment 7 Nicolas Robidoux 2009-01-06 03:10:48 UTC
Ahrgh! Forgot to fix what creates the makefiles so it knows about nohalo!

Manana!
Comment 8 Nicolas Robidoux 2009-01-06 03:32:33 UTC
Created attachment 125820 [details] [review]
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. 

Had forgotten to fix gegl/gegl/buffer/Makefile.am so that nohalo compiles.
Comment 9 Nicolas Robidoux 2009-01-06 03:50:10 UTC
Created attachment 125822 [details] [review]
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. 

Eliminated a compilation warning.
Comment 10 Nicolas Robidoux 2009-01-06 03:59:40 UTC
Apologies:

Submitted my path too early.

Will make sure all is hunky dory.
Comment 11 Nicolas Robidoux 2009-01-06 19:56:38 UTC
Created attachment 125879 [details] [review]
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. 


Fixed Makefile.am (had missed one line).
Comment 12 Nicolas Robidoux 2009-01-06 20:54:33 UTC
Finally, it's a go: I'm pretty sure the patch is good this time.

-----

Fixed quick and dirty timings (resizing four images through xml script):

gegl-sampler-linear before patch:

7.266 + 8.947 + 0.969 + 44.793 = 61.975s

gegl-sampler-linear after patch:

7.041 + 8.911 + 0.900 + 44.364 = 61.216s

Other methods:

gegl-sampler-yafr:

8.103 + 10.061 + 1.003 + 49.839 = 69.006s

gegl-sampler-nohalo:

9.479 + 10.813 + 1.060 + 51.466 = 72.818s

gegl-sampler-cubic:

9.159 + 11.584 + 1.079 + 55.193 = 77.015

(gegl-sampler-lanczos is even slower.)

The fact that cubic is slower than yafr suggests that the code could be sped up considerably, given that yafr is a substantially more complex method (on the other hand, the current cubic actually implements a two parameter family of bicubic methods, which does account for some of the slowness).

Comment about future developments:

I may be enclined to remove yafr from gegl once higher quality level nohalos are programmed, because higher level nohalos should produce better results across the board than all of the other implemented methods. The current patch only implements the lowest level nohalo (quality level 1; think of quality level 0 as being bilinear).

Nicolas Robidoux
Universite Laurentienne
Comment 13 Nicolas Robidoux 2009-01-08 17:33:52 UTC
I just figured out a way of making the nohalo code both shorter and faster.

I'll implement this, and submit yet another patch.

Nicolas Robidoux
Laurentian University
Comment 14 Nicolas Robidoux 2009-01-09 00:29:47 UTC
Created attachment 126065 [details] [review]
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c.
Comment 15 Nicolas Robidoux 2009-01-09 00:40:19 UTC
This should be the final patch.

Final timings:

cubic:   9.277  + 11.506 + 1.133 + 55.170 = 77.086s (unchanged by this patch)

lanczos: 11.645 + 14.465 + 1.277 + 66.643 = 94.03s (unchanged by this patch)

linear:  7.139  + 8.891  + 0.944 + 44.693 = 61.667s (a little smaller than before)

nohalo:  8.109  + 10.249 + 1.014 + 50.664 = 70.036s (new method)
 
yafr:    8.209  + 10.256 + 1.008 + 50.656 = 70.129 (smaller than before)

Nicolas Robidoux
Laurentian University
Comment 16 Nicolas Robidoux 2009-01-09 00:57:25 UTC
Sorry: the nohalo line in the last comment was incorrect:

nohalo: 8.378 + 10.536 + 1.024 + 50.367 = 70.305s

Apologies,

n
Comment 17 Nicolas Robidoux 2009-01-09 16:01:25 UTC
Yet another speedup for nohalo is coming down the pipeline.

Apologies for the bandwidth.

Nicolas Robidoux
Laurentian University
Comment 18 Nicolas Robidoux 2009-01-11 03:09:54 UTC
Created attachment 126202 [details] [review]
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. 


Final ;-) revision.
78.266
Timings:

cubic:    9.179 + 11.656 + 1.082 + 56.349 = 78.266s

lanczos: 11.576 + 14.300 + 1.270 + 65.793 = 92.939s

linear:   6.988 +  8.840 + 0.910 + 44.009 = 60.747s

nohalo:   8.300 + 10.361 + 1.016 + 49.839 = 69.516s

yafr:     8.130 + 10.038 + 1.001 + 49.949 = 69.118s

Nicolas Robidoux
Comment 19 Nicolas Robidoux 2009-01-12 05:23:25 UTC
Created attachment 126250 [details] [review]
adds gegl-sampler-nohalo.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and patches gegl-sampler-yafr.* and gegl-sampler-linear.c. 


I don't quite know if I should put my name in the copyright for the changes of bilinear. I don't particularly care, but wonder if "licensing issues" make that mandatory.

n
Comment 20 Nicolas Robidoux 2009-01-12 12:32:07 UTC
(Apologies for the bandwidth.)

Following a discussion with my colleague Minglun Gong of Memorial University who
is putting together a (non GEGL, of course) GPU version of this scheme for video enlargement, I clicked on something, and consequently there will be yet another version of the patch.

Nicolas Robidoux
Laurentian University
Comment 21 Nicolas Robidoux 2009-01-14 06:07:52 UTC
Created attachment 126406 [details] [review]
adds gegl-sampler-sharp.* and inserts references in gegl-sampler.c, gegl-buffer.*, gegl-buffer-access.c and Makefile.am, and speeds up gegl-sampler-yafr.* and gegl-sampler-linear.c. 


Given that nohalo will actually be two families of schemes: nohalo-sharp (implemented here at its lowest quality level, unless one counts bilinear as level 0) and nohalo-smooth (future programming: it's quality level 0 will correspond to quadratic B-Spline pseudo-interpolation), I figured it may just be better to call the method "sharp" and call the future quality level 1 nohalo-smooth plain "smooth."

So, gegl-sampler-sharp is what I've been calling gegl-sampler-nohalo up to now.

I should be done for quite a bit.

Nicolas Robidoux
Universite Laurentienne
Comment 22 Øyvind Kolås (pippin) 2009-01-14 12:17:03 UTC
I've commited these changes, have you got plans for how decimation should be done for these resamplers, as the resampling framework in GEGL only handles interpolation...


2009-01-14  Øyvind Kolås  <pippin@gimp.org>

        Applied patch from Nicolas Robidoux that adds a new sampler
        (gegl-sampler-sharp) building on the existing YAFR resamplers.

        * gegl/buffer/Makefile.am:
        * gegl/buffer/gegl-buffer-access.c:
        * gegl/buffer/gegl-buffer.c:
        * gegl/buffer/gegl-buffer.h:
        * gegl/buffer/gegl-sampler-linear.c: (gegl_sampler_linear_init),
        (gegl_sampler_linear_get), (set_property), (get_property):
        * gegl/buffer/gegl-sampler-yafr.c: (gegl_sampler_yafr_init),
        (catrom_yafr), (gegl_sampler_yafr_get):
        * gegl/buffer/gegl-sampler.c:
        (gegl_buffer_interpolation_from_string),
        (gegl_sampler_type_from_interpolation):
Comment 23 Nicolas Robidoux 2009-01-14 12:43:48 UTC
Øyvind:

> I've commited these changes, have you got plans for how decimation should be
> done for these resamplers, as the resampling framework in GEGL only handles
> interpolation...

I am not sure that I understand your question.

Do you mean how downsampling should be done with these resamplers?

If so, downsampling with these resamplers will be done just like they are done with, say, bilinear, which means that it, like bilinear, bicubic, yafr and lanczos, will give results which resemble nearest neighbour when the transformation downsamples a lot.

If you remember an email exchange we had with Alex Prokoudine and Sven Neumann, my opinion is that either we should have a resampler which is custom made for
downsampling, or the resampler should use information about the local gradient of the transformation---possibly approximated with finite differences---to select whether an "scheme for upsampling" or a "scheme for downsampling" should be used near the pixel under consideration. This leads, for example, to a box filtering scheme with "radius" which depends on the gradient of the transformation (and which in my opinion should be smaller than the "exact area" one).

I am of course open to be corrected or improved on with respect to this vision, which unfortunately will not see my programming input soon (unless an angel swoops in with enough money to buy me a leave from my job, or to allow me to hire competent student programmers, at the price such programmers deserve).

I hope that I make sense, and that I answered your question.

------

Thank you for merging my patch.

Nicolas Robidoux
Universite Laurentienne