• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C)2011, 2013 D. R. Commander.  All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * - Redistributions of source code must retain the above copyright notice,
8  *   this list of conditions and the following disclaimer.
9  * - Redistributions in binary form must reproduce the above copyright notice,
10  *   this list of conditions and the following disclaimer in the documentation
11  *   and/or other materials provided with the distribution.
12  * - Neither the name of the libjpeg-turbo Project nor the names of its
13  *   contributors may be used to endorse or promote products derived from this
14  *   software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 package org.libjpegturbo.turbojpeg;
30 
31 import java.awt.*;
32 import java.nio.*;
33 
34 /**
35  * Custom filter callback interface
36  */
37 public interface TJCustomFilter {
38 
39   /**
40    * A callback function that can be used to modify the DCT coefficients after
41    * they are losslessly transformed but before they are transcoded to a new
42    * JPEG image.  This allows for custom filters or other transformations to be
43    * applied in the frequency domain.
44    *
45    * @param coeffBuffer a buffer containing transformed DCT coefficients.
46    * (NOTE: this buffer is not guaranteed to be valid once the callback
47    * returns, so applications wishing to hand off the DCT coefficients to
48    * another function or library should make a copy of them within the body of
49    * the callback.)
50    *
51    * @param bufferRegion rectangle containing the width and height of
52    * <code>coeffBuffer</code> as well as its offset relative to the component
53    * plane.  TurboJPEG implementations may choose to split each component plane
54    * into multiple DCT coefficient buffers and call the callback function once
55    * for each buffer.
56    *
57    * @param planeRegion rectangle containing the width and height of the
58    * component plane to which <code>coeffBuffer</code> belongs
59    *
60    * @param componentID ID number of the component plane to which
61    * <code>coeffBuffer</code> belongs (Y, Cb, and Cr have, respectively, ID's
62    * of 0, 1, and 2 in typical JPEG images.)
63    *
64    * @param transformID ID number of the transformed image to which
65    * <code>coeffBuffer</code> belongs.  This is the same as the index of the
66    * transform in the <code>transforms</code> array that was passed to {@link
67    * TJTransformer#transform TJTransformer.transform()}.
68    *
69    * @param transform a {@link TJTransform} instance that specifies the
70    * parameters and/or cropping region for this transform
71    */
customFilter(ShortBuffer coeffBuffer, Rectangle bufferRegion, Rectangle planeRegion, int componentID, int transformID, TJTransform transform)72   void customFilter(ShortBuffer coeffBuffer, Rectangle bufferRegion,
73                     Rectangle planeRegion, int componentID, int transformID,
74                     TJTransform transform)
75     throws TJException;
76 }
77