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

From GIMP Developer Wiki
Jump to: navigation, search
(GEGL part: review, fix grammatical errors, add hyperlinks)
(File loaders/exporters: update file-sunras, file-xmc)
Line 433: Line 433:
 
| file-sgi ||  {{unknown| }} || {{yes}} ||{{unknown|untested}}||
 
| file-sgi ||  {{unknown| }} || {{yes}} ||{{unknown|untested}}||
 
|-
 
|-
| file-sunras ||  {{unknown| }} ||{{no}} || {{unknown|untested}}||
+
| file-sunras ||  {{unknown| }} ||{{yes}} || {{unknown|untested}}||
 
|-
 
|-
 
| file-svg ||  {{wip|svg-load }} ||{{yes}} || {{unknown|untested}}||
 
| file-svg ||  {{wip|svg-load }} ||{{yes}} || {{unknown|untested}}||
Line 449: Line 449:
 
| file-xbm ||  {{unknown| }} ||{{yes}} ||{{unknown|untested}}||
 
| file-xbm ||  {{unknown| }} ||{{yes}} ||{{unknown|untested}}||
 
|-
 
|-
| file-xmc ||  {{unknown| }} ||{{no}} || {{unknown|untested}}||
+
| file-xmc ||  {{unknown| }} ||{{yes}} || {{unknown|untested}}||
 
|-
 
|-
 
| file-xpm ||  {{unknown| }} ||{{yes}} ||{{unknown|untested}}||
 
| file-xpm ||  {{unknown| }} ||{{yes}} ||{{unknown|untested}}||

Revision as of 14:00, 2 January 2014

Last updated: see tab 'history'

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 it implements.
    2. Read the GEGL website carefully. There is lot of information.
    3. Read the babl website. Understand the differences 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. There's no need to register it in a particular Makefile, because GEGL's build system will build every C file present in the operations directory. The exact directory where you should put your file into is explained at GEGL's website.
  4. Copy another operation with the same base class and clean it to have your operation skeleton. GEGL uses a macro system called GEGL chant. It makes it unnecessary for you to write all the GObject boilerplate and eases your work registering parameters for your op. Look at other operations to see how it works.
  5. Use the prepare function to indicate what color model your op will operate with for each input/output.
  6. Create your op's parameters using the chant system. You can have integer, floats, string, color, curve, enum ... There are some predefined enums 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 hints here:
    1. GEGL stores data in tiles. This imposes some restrictions, especially for transform op's. You usually need to write your algorithm backwards, i.e. iterate over the output, compute where the data come from, use a sampler to get it and affect the output.
    2. ROI means 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 carrying a lot of parameters in your various functions, you can register a custom aggregate structure in the chant system, like the WarpPrivate structure in the Warp op.
    5. If you fetch data from outside of the input buffer (in it's abyss) you get zeroed memory by default. The abyss policy allows you to chose what you want here. In particular you can choose to clamp to the border, loop in the buffer extent ... It enables you to implement a more intelligent algorithm. For instance see the Ripple op. Setting the abyss policy to GEGL_ABYSS_LOOP adds 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

Columns 'GEGL port', 'OpenCL version':

completely unimplemented yet
implementation unfinished
implementation finished, no matter of the test results
doesn't need porting


Columns 'Test result':

tests failed (please also describe the failure shortly

in the comment field or link to a Bugzilla bug report)

tests unfinished
tests ok
not tested at all yet


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 alien-map Yes untested Yes untested
Align Visible Layers Doesn't need porting
Antialias antialias Yes untested No untested
Apply Canvas texturize-canvas work in progress untested No untested texturize-canvas should be more generic and allow any input texture instead of the hard-coded one only. The GIMP compat wrapper is missing
Apply Lens No untested No untested
Assign Color Profile No untested No untested
Autocrop Image Yes untested No untested Done in core
Autocrop Layer Yes untested No untested Done in core
Border Average Yes untested No untested
Bump Map bump-map work in progress untested No untested
Cartoon cartoon work in progress untested No untested It doesn't honor GeglOperationAreaFilter's area, among other things.
Channel Mixer channel-mixer Yes untested No untested
Checkerboard checker-board work in progress 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 work in progress untested Yes untested The pdb wrapper needs some more love (see comment in there)
Colorcube Analysis No untested No untested
Compose Yes untested No untested Compatibility with 2.8 is currently not maintained : An image decomposed in 2.8 won't be recomposed correctly in 2.10. Also it's inconsistent with gimp's gamma policy. Nobody know who is right currently.
Convert to Color Profile No untested No untested
Convolution Matrix convolution-matrix No untested No untested Not sure the wip GEGL operation is the right approach for that op. Shouldn't that matrix be given as an aux input, instead of the chant property ?
CSS stylesheet No untested No untested
Cubism cubism work in progress untested No untested It doesn't honnor the GeglOperationAreaFilter class properly
Curve Bend No untested No untested
Decompose Yes untested No untested inconsistent with gimp's gamma policy currently. Nobody know who is right currently. See also Compose
Deinterlace deinterlace work in progress untested No untested The current GEGL implementation is wrong (just try it on a black/white 1px grid), and not sure what the parameter size is for...
Depth Merge No untested No untested
Despeckle No untested No untested
Destripe No untested No untested
Difference of Gaussians difference-of-gaussians work in progress 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 work in progress untested No untested Shadow effect only seen in transparent areas inside the layer bounds.
Edge... No untested No untested
Emboss emboss work in progress 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 work in progress untested No untested
Fractal Trace fractal-trace work in progress untested No untested
From Webpage untested Doesn't need porting
Gaussian blur gaussian-blur work in progress untested work in progress untested Needs abyss policy. GIMP and GEGL parameters differ (Radius vs. Size, Algorithm RLE vs. FIR). OpenCL version only supports FIR.
Gfig Doesn't need porting
GIMPressionist No untested No untested
Glass Tile No untested No untested
Gradient Flare No untested No untested
Gradient Map Yes untested No untested
Grey grey No untested Yes untested Similar to the Desaturation tool, but without its options
Grid grid work in progress untested No untested Missing intersection option, is it needed ?
Hot No untested No untested
HSV Noise noise-hsv Yes untested No untested The GEGL implementation is not strictly identical to the legacy one, but similar enough...
Hurl noise-hurl Yes Yes Yes Yes
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 Yes untested The pdb documentation needs to be updated. Apart from that it's done.
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 Yes untested No untested
Lens Distortion lens-distortion Yes untested No untested
Lens Flare No untested No untested
Lighting Effects No untested No untested
Make Seamless tile-seamless Yes untested No untested
Maximum RGB Will be removed without replacement
Maze No untested No untested
Mosaic mosaic Yes untested No untested The GEGL op tries to allocate the whole input.
Motion Blur (circular) motion-blur-circular Yes untested No untested Is allocating the whole input
Motion Blur (linear) motion-blur-linear Yes untested Yes untested Is allocating the whole input
Motion Blur (zoom) motion-blur-zoom Yes untested No untested Is allocating the whole input
Neon No untested No untested
Newsprint No untested No untested
NL Filter No untested No untested
Normalize No untested No untested
Oilify oilify work in progress untested Yes untested
Optimize (Difference) No untested No untested
Optimize (for GIF) No untested No untested
Pagecurl No untested No untested
Palette Map Yes untested No untested
Paper Tile No untested No untested
Photocopy photocopy work in progress untested No untested
Pick noise-pick Yes untested No untested
Pixelize pixelize Yes untested Yes untested
Plasma plasma Yes untested No untested
Playback Yes untested No untested
Polar Coordinates polar-coordinates work in progress untested No untested
Qbist No untested No untested
Rearrange Colormap Yes untested No untested Not to be confused with GEGL's 'remap' operation.
Recompose Yes untested No untested See compose
Red Eye Removal red-eye-removal work in progress untested Yes untested
Retinex No untested No untested
RGB Noise noise-rgb work in progress untested No untested
Ripple ripple work in progress 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
Set Colormap Yes untested No untested Not to be confused with GEGL's 'remap' operation.
Shift shift Yes Yes No untested
Sinus No untested No untested
Slur noise-slur Yes untested No untested
Smooth Palette No untested No untested
Sobel edge-sobel work in progress untested Yes untested
Softglow softglow Yes untested No untested Also it uses a different intensity function (Y' instead of (max(R', G', B') + min (R', G', B')) / 2). I suggest the new behaviour is better.
Solid Noise No untested No untested
Sparkle No untested No untested
Sphere Designer No untested No untested
Spread noise-spread work in progress untested No untested
Stretch Contrast stretch-contrast Yes Yes Yes Yes
Stretch HSV stretch-contrast-hsv Yes Yes No untested
Supernova No untested No untested
Tile tile No untested No untested
Unoptimize No untested No untested
Unsharp Mask unsharp-mask work in progress untested No untested
Value Invert value-invert work in progress untested Yes 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
Waves waves work in progress untested No untested Missing reflective option that produce strange result, I suggest dropping that.
Whirl and Pinch whirl-pinch work in progress untested No untested
Wind wind work in progress untested No untested GEGL op parameters differ from GIMP filter.
Zealous Crop N/A No untested No untested Zealous Crop can't be performed as a GEGL operation because get_bounding_box depends on the image content. It should be ported as a gimp plugin instead.

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 Yes untested
file-bmp Yes untested
file-cel Yes untested
file-compressor doesn't need porting
file-csource Yes untested
file-desktop-link doesn't need porting
file-dicom Yes untested
file-exr-load exr-load Yes untested
file-exr-save exr-save Yes untested
file-faxg3 Yes untested
file-fits Yes untested
file-fli Yes untested
file-gbr Yes untested
file-gif-load Yes untested
file-gif-save Yes untested
file-gih Yes untested
file-glob doesn't need porting
file-header Yes untested
file-html-table Yes untested
file-ico Yes untested
file-jp2-load jp2-load Yes untested
file-jpeg jpg-load, jpg-save Yes OK
file-mng Yes untested
file-pat Yes untested
file-pcx Yes untested
file-pdf-load Yes untested
file-pdf-save Yes untested
file-pix Yes untested
file-png png-load, png-save Yes OK
file-pnm ppm-load, ppm-save Yes untested
file-ps Yes untested
file-psd No untested
file-psp Yes untested
file-raw-data Yes untested Unrelated to raw camera files
file-sgi Yes untested
file-sunras Yes untested
file-svg svg-load Yes untested
file-tga Yes 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-uri doesn't need porting
file-wmf Yes untested
file-xbm Yes untested
file-xmc Yes untested
file-xpm Yes untested
file-xwd Yes untested

New File loaders/exporters

These file loaders/savers are implemented in GEGL, but may not be 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.
npy-save No untested Numerical Python (NumPy) file saver.
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
webp-load work in progress untested for WebP image format
webp-save work in progress untested for WebP image 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 Yes untested GEGL op is work in progress.
Box min Yes 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 work in progress 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?
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 Yes untested