Difference between revisions of "Hacking:Porting filters to GEGL"

From GIMP Developer Wiki
Jump to: navigation, search
(Unify table headers, fix typos, add hint on 'GEGL operation' column)
(File loaders/savers: strike unnecessary items, add gegl ops)
Line 339: Line 339:
 
{| class="wikitable sortable" style="text-align: left;"
 
{| class="wikitable sortable" style="text-align: left;"
 
! '''GIMP filter'''  
 
! '''GIMP filter'''  
 +
!style="text-align: center;"|[https://git.gnome.org/browse/gegl/log/operations '''GEGL operation''']
 
! [https://git.gnome.org/browse/gimp/log/plug-ins '''GEGL port''']
 
! [https://git.gnome.org/browse/gimp/log/plug-ins '''GEGL port''']
 
! style="text-align: center;"| '''Test result'''
 
! style="text-align: center;"| '''Test result'''
 
! '''Comment'''
 
! '''Comment'''
 
|-
 
|-
| file-aa || {{wip}} || {{unknown|untested}}||
+
| file-aa ||  {{unknown| }} || {{wip}} || {{unknown|untested}}||
 
|-
 
|-
| file-bmp || {{wip}} ||{{unknown|untested}}||
+
| file-bmp ||  {{unknown| }} || {{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-cel || {{wip}} ||{{unknown|untested}}||
+
| file-cel ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-csource || {{wip}} ||{{unknown|untested}}||
+
| file-csource ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-desktop-link || {{yes|doesn't need to be ported}} || {{yes|}}||
+
| <strike>file-desktop-link</strike>|| {{unknown| }} ||{{unknown| }}  || {{unknown| }} ||
 
|-
 
|-
| file-dicom || {{wip}} ||{{unknown|untested}}||
+
| file-dicom ||  {{unknown| }} || {{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-exr-load || {{wip}} ||{{unknown|untested}}||
+
| file-exr-load ||  {{wip|exr-load }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-exr-save || {{wip}} || {{unknown|untested}}||
+
| file-exr-save ||  {{wip|exr-save }} ||{{wip}} || {{unknown|untested}}||
 
|-
 
|-
| file-faxg3 || {{wip}} ||{{unknown|untested}}||
+
| file-faxg3 ||  {{unknown| }} || {{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-fits || {{wip}} ||{{unknown|untested}}||
+
| file-fits ||  {{unknown| }} || {{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-fli || {{wip}} ||{{unknown|untested}}||
+
| file-fli ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-gbr || {{wip}} ||{{unknown|untested}}||
+
| file-gbr ||  {{unknown| }} || {{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-gif-load || {{wip}} ||{{unknown|untested}}||
+
| file-gif-load ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-gif-save || {{wip}} ||{{unknown|untested}}||
+
| file-gif-save ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-gih || {{wip}} ||{{unknown|untested}}||
+
| file-gih ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-glob || {{no}} || {{unknown|untested}}||for file globbing -> is GEGL-port necessary?
+
| <strike>file-glob</strike> || {{unknown| }} ||{{unknown| }}  || {{unknown| }} ||
 
|-
 
|-
| file-header || {{wip}} ||{{unknown|untested}}||
+
| file-header ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-html-table || {{wip}} ||{{unknown|untested}}||
+
| file-html-table ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-ico || {{wip}} ||{{unknown|untested}}||
+
| file-ico ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-jp2-load || {{wip}} || {{unknown|untested}}||
+
| file-jp2-load ||  {{yes|jp2-load }} ||{{wip}} || {{unknown|untested}}||
 
|-
 
|-
| file-jpeg || {{yes}} || {{Yes|OK}}||
+
| file-jpeg ||  {{wip|jpg-load, jpg-save }} ||{{yes}} || {{Yes|OK}}||
 
|-
 
|-
| file-mng || {{wip}} ||{{unknown|untested}}||
+
| file-mng ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-pat || {{wip}} ||{{unknown|untested}}||
+
| file-pat ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-pcx || {{wip}} ||{{unknown|untested}}||
+
| file-pcx ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-pdf-load || {{no}} || {{unknown|untested}}||
+
| file-pdf-load ||  {{unknown| }} ||{{no}} || {{unknown|untested}}||
 
|-
 
|-
| file-pdf-save || {{wip}} ||{{unknown|untested}}||
+
| file-pdf-save ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-pix || {{wip}} ||{{unknown|untested}}||
+
| file-pix ||  {{unknown| }} || {{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-png || {{yes}} || {{Yes|OK}}||
+
| file-png ||  {{wip|png-load, png-save }} ||{{yes}} || {{Yes|OK}}||
 
|-
 
|-
| file-pnm || {{wip}} || {{unknown|untested}}||
+
| file-pnm ||  {{wip|ppm-load, ppm-save }} ||{{wip}} || {{unknown|untested}}||
 
|-
 
|-
| file-ps || {{wip}} || {{wip}}||
+
| file-ps ||  {{unknown| }} ||{{wip}} || {{wip}}||
 
|-
 
|-
| file-psd || {{no}} || {{unknown|untested}}||
+
| file-psd ||  {{unknown| }} ||{{no}} || {{unknown|untested}}||
 
|-
 
|-
| file-psp || {{wip}} ||{{unknown|untested}}||
+
| file-psp ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-raw || {{no}} || {{unknown|untested}}||see GEGL-op gegl:raw-load
+
| file-raw ||  {{unknown| }} || {{no}} || {{unknown|untested}}||see GEGL-op gegl:raw-load
 
|-
 
|-
| file-sgi || {{wip}} ||{{unknown|untested}}||
+
| file-sgi ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-sunras || {{no}} || {{unknown|untested}}||
+
| file-sunras ||  {{unknown| }} ||{{no}} || {{unknown|untested}}||
 
|-
 
|-
| file-svg || {{no}} || {{unknown|untested}}||extra GEGL-op gegl:svg-load exists for loading SVG and SVGZ format
+
| file-svg ||  {{wip|svg-load }} ||{{no}} || {{unknown|untested}}||extra GEGL-op gegl:svg-load exists for loading SVG and SVGZ format
 
|-
 
|-
| file-tga || {{wip}} ||{{unknown|untested}}||
+
| file-tga ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-tiff-load || {{wip}} ||{{No|Failing}}||GIMP doesn't respect layer order of multi-layer TIFFs.
+
| file-tiff-load ||  {{unknown| }} ||{{wip}} ||{{No|Failing}}||GIMP doesn't respect layer order of multi-layer TIFFs.
 
|-
 
|-
| file-tiff-save || {{wip}} ||{{No|Failing}}||GIMP flattens multi-layer TIFFs.
+
| file-tiff-save ||  {{unknown| }} ||{{wip}} ||{{No|Failing}}||GIMP flattens multi-layer TIFFs.
 
|-
 
|-
| file-wmf || {{no}} || {{unknown|untested}}||
+
| file-wmf ||  {{unknown| }} ||{{no}} || {{unknown|untested}}||
 
|-
 
|-
| file-xbm || {{wip}} ||{{unknown|untested}}||
+
| file-xbm ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-xmc || {{no}} || {{unknown|untested}}||
+
| file-xmc ||  {{unknown| }} ||{{no}} || {{unknown|untested}}||
 
|-
 
|-
| file-xpm || {{wip}} ||{{unknown|untested}}||
+
| file-xpm ||  {{unknown| }} ||{{wip}} ||{{unknown|untested}}||
 
|-
 
|-
| file-xwd || {{no}} || {{unknown|untested}}||
+
| file-xwd ||  {{unknown| }} ||{{no}} || {{unknown|untested}}||
 
|}
 
|}
  

Revision as of 21:43, 2 July 2013

Last updated: 27.05.2013

How to port

GEGL part

This is the general process to write a new GEGL operation:

  1. Gather information.
    1. Read the plugin you want to port, understand the algorithm hidden in it.
    2. Read carefully the GEGL website. There is lot of information here.
    3. Read the Babl website and understand the difference between color models.
    4. You may want to find a similar existing operation and get inspiration from it.
  2. Choose a base class. This is the general structure of your operation, the number of input/output, what kind of optimization GEGL can do.
  3. Create a new file for your operation. No need to register it in some Makefile, the build system will build every C file present in the operations directory. The exact directory where you should put your file is explained in the GEGL website.
  4. Copy another operation with the same base class and clean it to have your operation skeleton. GEGL use a macro system called GEGL chant, that avoid you to write all the GObject boilerplate, and register easily parameters for your op. Look other operation to see how it works.
  5. Use the prepare function to indicate what color model your op will operate, for each input/output.
  6. Create your op's parameter using the chant system. You can have integer, floats, string, color, curve, enum ... There is some predefined enum in the GEGL core, for instance GeglSamplerType. You can register your own, like in the ripple op.
  7. Write your operation in the process function. Some tips here:
    1. GEGL store data in tile, so it impose some restriction, especially for transform op. You usually need to write your algorithm backward, ie iterate over the output, compute where the data come from, use a sampler to get it and affect the output.
    2. ROI mean region of interest, it's the area your are currently working on.
    3. Sometimes you need to know the size of the full input, not just the roi. You can have it using gegl_operation_source_get_bounding_box.
    4. Rather than carry a lot of parameter in you different functions, you can register a custom structure in the chant system, like the WarpPrivate structure in the warp op.
    5. When you fetch data outside of the input buffer (in it's abyss) you get by default zeroed memory. The abyss policy allow you to chose what you want here, and in particular, you can choose to clamp to the border, loop in the buffer extent ... It allows to write more clever algorithm. For instance, see the ripple op. Setting the abyss policy to GEGL_ABYSS_LOOP add the tileability to the op for free.
  8. Test your operation. You can use the gegl binary to run an xml file, or use the GEGL tool in GIMP.

GIMP part

Alternative 1: Use a GeglBuffer to work on. For instance see /plug-ins/common/file-aa.c.

Alternative 2: In your program create a GEGL graph and let call gegl_node_process on it. See the column 'GEGL operation' below to see what has already been done in GEGL. For instance see /plug-ins/common/file-gegl.c.

For more inspiration see the other files that are already ported.

Porting matrix

Legend

Neither ported nor tested
Already (some) development work is done, but without succeeding unit test.
Port finished, unit test succeeds

You can sort the following tables by clicking the little arrow symbol in the column headers. If that doesn't work out of the box, please activate Javascript for this page.

GIMP core (Layer modes, Transformation and Color Adjustment Tools)

The GIMP core is already migrated to GEGL. See Michael Natterers blogposting and an article at libgregraphicsworld.org.

Processing, color grading and effects

GIMP filter GEGL operation GEGL port Test result OpenCL version Test result Comment
Alien Map No untested No untested
Align Visible Layers No untested No untested
Antialias No untested No untested
Apply Canvas No untested No untested
Apply Lens No untested No untested
Assign Color Profile No untested No untested
Autocrop Image No untested No untested
Autocrop Layer No untested No untested
Border Average No untested No untested
Bump Map bump-map No untested No untested
Cartoon cartoon No untested No untested It doesn't honor GeglOperationAreaFilter's area, among other things.
Channel Mixer No untested No untested
Checkerboard checker-board No untested No untested Missing Psychobilly Option
CML Explorer No untested No untested
Color Enhance No untested No untested
Color Exchange No untested No untested
Color to Alpha color-to-alpha No untested No untested
Colorcube Analysis No untested No untested
Compose No untested No untested
Convert to Color Profile No untested No untested
Convolution Matrix convolution-matrix No untested No untested
CSS stylesheet No untested No untested
Cubism cubism No untested No untested
Curve Bend No untested No untested
Decompose work in progress untested No untested Only RGB(A) decomposition currently
Deinterlace deinterlace No untested No untested
Depth Merge No untested No untested
Despeckle No untested No untested
Destripe No untested No untested
Difference of Gaussians difference-of-gaussians No untested No untested The port is missing Normalize and Invert options
Diffraction Patterns No untested No untested
Dilate No untested No untested
Displace No untested No untested
Drop Shadow dropshadow No untested No untested The GEGL port doesn't seem to work in the Mac build.
Edge... No untested No untested
Emboss emboss No untested No untested
Engrave No untested No untested
Erode No untested No untested
Filmstrip No untested No untested
Filterpack No untested No untested
Flame No untested No untested
Fractal Explorer fractal-explorer No untested No untested
Fractal Trace fractal-trace No untested No untested
From Webpage No untested No untested Probably doesn't need porting
Gaussian blur gaussian-blur No untested work in progress untested Needs abyss policy
Gfig No untested No untested Probably doesn't need porting
GIMPressionist No untested No untested
Glass Tile No untested No untested
Gradient Flare No untested No untested
Gradient Map No untested No untested
Grey grey No untested work in progress untested Similar to the Desaturation tool, but without its options
Grid grid No untested No untested Missing intersection option, is it needed ?
Hot No untested No untested
HSV Noise noise-hsv No untested No untested
Hurl noise-hurl No untested No untested
IFS Fractal work in progress untested No untested
Illusion No untested No untested
Image Map No untested No untested Probably doesn't need porting
Invert invert-gamma No untested work in progress untested
iWarp To be replaced with Warp Transform tool
Java map No untested No untested Probably doesn't need porting
Jigsaw No untested No untested
Laplace edge-laplace No untested No untested
Lens Distortion lens-distortion No untested No untested
Lens Flare No untested No untested
Lighting Effects No untested No untested
Make Seamless No untested No untested
Maximum RGB Will be removed without replacement
Maze No untested No untested
Mosaic No untested No untested
Motion Blur (circular) motion-blur-circular No untested No untested GIMP needs compat wrapper
Motion Blur (linear) motion-blur-linear No untested work in progress untested GIMP needs compat wrapper
Motion Blur (zoom) motion-blur-zoom No untested No untested GIMP needs compat wrapper
Neon No untested No untested
Newsprint No untested No untested
NL Filter No untested No untested
Normalize No untested No untested
Noise Spread noise-spread No untested No untested
Oilify oilify No untested work in progress untested
Optimize (Difference) No untested No untested
Optimize (for GIF) No untested No untested
Pagecurl No untested No untested
Palette Map No untested No untested
Paper Tile No untested No untested
Photocopy photocopy No untested No untested
Pick noise-pick No untested No untested
Pixelize pixelize No untested work in progress untested Needs abyss policy
Plasma plasma No untested No untested
Playback No untested No untested Probably doesn't have to be ported ?
Polar Coordinates polar-coordinates No untested No untested
Qbist No untested No untested
Recompose No untested No untested
Red Eye Removal red-eye-removal No untested No untested
Retinex No untested No untested
RGB Noise noise-rgb No untested No untested
Ripple ripple No untested No untested Complete in abyss branch
Rotate Colors color-rotate No untested No untested
Sample Colorize No untested No untested
Selective Gaussian Blur No untested No untested
Shift shift No untested No untested
Sinus No untested No untested
Slur noise-slur No untested No untested
Smooth Palette No untested No untested
Sobel edge-sobel No untested work in progress untested
Softglow softglow No untested No untested
Solid Noise No untested No untested
Sparkle No untested No untested
Sphere Designer No untested No untested
Spread noise-spread No untested No untested
Stretch Contrast stretch-contrast No untested No untested Not sure we need that with GEGL being the core of GIMP
Stretch HSV No untested No untested
Supernova No untested No untested
Tile tile No untested No untested
Unoptimize No untested No untested
Unsharp Mask unsharp-mask No untested No untested
Value Invert value-invert No untested work in progress untested
Value Propagate No untested No untested
Van Gogh (LIC) No untested No untested The filter has nothing to do with van-Gogh-style art and has no obvious function. We should remove it.
Video No untested No untested
Warp warp No untested No untested
Waves waves No untested No untested Missing reflective option that produce strange result, I suggest dropping that.
Whirl and Pinch whirl-pinch No untested No untested
Wind wind No untested No untested
Zealous Crop No untested No untested

Display filters

Display filter GEGL port Test result OpenCL version Test result Comment
Color deficient vision work in progress untested No untested
Color management work in progress untested No untested
Color proof work in progress untested No untested
Contrast work in progress untested No untested
Gamma work in progress untested No untested

File loaders/exporters

For porting to the GIO file access library see here.

GIMP filter GEGL operation GEGL port Test result Comment
file-aa work in progress untested
file-bmp work in progress untested
file-cel work in progress untested
file-csource work in progress untested
file-desktop-link
file-dicom work in progress untested
file-exr-load exr-load work in progress untested
file-exr-save exr-save work in progress untested
file-faxg3 work in progress untested
file-fits work in progress untested
file-fli work in progress untested
file-gbr work in progress untested
file-gif-load work in progress untested
file-gif-save work in progress untested
file-gih work in progress untested
file-glob
file-header work in progress untested
file-html-table work in progress untested
file-ico work in progress untested
file-jp2-load jp2-load work in progress untested
file-jpeg jpg-load, jpg-save Yes OK
file-mng work in progress untested
file-pat work in progress untested
file-pcx work in progress untested
file-pdf-load No untested
file-pdf-save work in progress untested
file-pix work in progress untested
file-png png-load, png-save Yes OK
file-pnm ppm-load, ppm-save work in progress untested
file-ps work in progress work in progress
file-psd No untested
file-psp work in progress untested
file-raw No untested see GEGL-op gegl:raw-load
file-sgi work in progress untested
file-sunras No untested
file-svg svg-load No untested extra GEGL-op gegl:svg-load exists for loading SVG and SVGZ format
file-tga work in progress untested
file-tiff-load work in progress Failing GIMP doesn't respect layer order of multi-layer TIFFs.
file-tiff-save work in progress Failing GIMP flattens multi-layer TIFFs.
file-wmf No untested
file-xbm work in progress untested
file-xmc No untested
file-xpm work in progress untested
file-xwd No untested

New File loaders/exporters

These file loaders/savers are implemented in GEGL, but not part of GIMP (yet). Currently they are listed here for completeness.

For porting to the GIO file access library see here.

GEGL filter GIMP filter Test result Comment
ff-load No untested FFmpeg video frame importer
ff-save No untested FFmpeg video frame output sink. GEGL op is work in progress.
rawbayer-load No untested RAWBAYER and RAWBAYERS format. GEGL op is work in progress
rgbe-load No untested for Radiance HDR format with extensions HDR and PIC
rgbe-save No untested for Radiance HDR format with extensions HDR and PIC
svg-load No untested for SVG and SVGZ format

Port of new GEGL ops to OpenCL

GEGL operation OpenCL version Test result Comment
Bilateral filter Yes untested
Box blur Yes untested
Box max No untested GEGL op is work in progress.
Box min No untested GEGL op is work in progress.
Box percentile No untested GEGL op is work in progress.
Brightness and Contrast Yes untested
Buffer cache No untested GEGL op is work in progress. Does this need an OpenCL port?
C2g Yes untested HDR related
Cielch Noise No untested
Color No untested
Color Reduction No untested
Color Temperature Yes untested
Contrast Curve No untested
Demosaic (bimedian) No untested GEGL op is work in progress.
Demosaic (simple) No untested GEGL op is work in progress.
Disc percentile No untested GEGL op is work in progress.
Display No untested Does this need an OpenCL port?
Ditto No untested GEGL op is work in progress. Test op - does this need an OpenCL port?
Dot No untested
Exp combine No untested HDR related
Exposure No untested HDR related
Fattal02 No untested HDR related
gluas No untested GEGL op is work in progress. Does this need an OpenCL port?
HStack No untested GEGL op is work in progress.
Image compare No untested
Introspect No untested Does this need an OpenCL port?
Kuwahara No untested GEGL op is work in progress.
Lens correction No untested GEGL op is work in progress.
Line profile No untested GEGL op is work in progress.
Linear gradient No untested GEGL op is work in progress.
Mandelbrot No untested GEGL op is work in progress.
Mantiuk06 No untested HDR related
Mirrors No untested
Mono mixer Yes untested
Noise No untested Perlin noise generator
Noise Reduction Yes untested
Over No untested Porter Duff operation over (d = cA + cB * (1 - aA))
Radial gradient No untested GEGL op is work in progress.
Reinhard05 Yes untested HDR related
Remap No untested
SNN (mean) Yes untested
SNN (percentile) No untested GEGL op is work in progress.
SVG Hue rotate No untested
SVG Luminance to Alpha No untested
SVG Matrix No untested
SVG Saturate No untested
Unpremul No untested GEGL op is work in progress.
Vignette Yes untested
Weighted Blend No untested