scanline.h

Go to the documentation of this file.
00001 #ifndef _SCANLINE_H_HEADER_INCLUDED
00002 #define _SCANLINE_H_HEADER_INCLUDED
00003 
00004 #include "asvisual.h"
00005 
00006 #ifdef __cplusplus
00007 extern "C" {
00008 #endif
00009 
00010 /****h* libAfterImage/scanline.h
00011  * NAME
00012  * scanline - Structures and functions for manipulation of image data 
00013  * in blocks of uncompressed scanlines. Each scanline has 4 32 bit channels.
00014  * Data in scanline could be both 8bit or 16 bit, with automated 
00015  * dithering of 16 bit data into standard 8-bit image.
00016  * SEE ALSO
00017  * Structures:
00018  *          ASScanline
00019  *
00020  * Functions :
00021  *   ASScanline handling:
00022  *          prepare_scanline(), free_scanline()
00023  *
00024  * Other libAfterImage modules :
00025  *          asvisual.h imencdec.h asimage.h blender.h
00026  * AUTHOR
00027  * Sasha Vasko <sasha at aftercode dot net>
00028  ******************/
00029 
00030 /****s* libAfterImage/ASScanline
00031  * NAME
00032  * ASScanline - structure to hold contents of the single scanline.
00033  * DESCRIPTION
00034  * ASScanline holds data for the single scanline, split into channels
00035  * with 32 bits per pixel per channel. All the memory is allocated at
00036  * once, and then split in between channels. There are three ways to
00037  * access channel data :
00038  * 1) using blue, green, red, alpha pointers.
00039  * 2) using channels[] array of pointers - convenient in loops
00040  * 4) using xc3, xc2, xc1 pointers. These are different from red, green,
00041  * blue in the way that xc3 will point to blue when BGR mode is specified
00042  * at the time of creation, otherwise it will point to red channel.
00043  * Likewise xc1 will point to red in BGR mode and blue otherwise.
00044  * xc2 always points to green channel's data. This is convenient while
00045  * writing XImages and when channels in source and destination has to be
00046  * reversed, while reading images from files.
00047  * Channel data is always aligned by 8 byte boundary allowing for
00048  * utilization of MMX, floating point and other 64bit registers for
00049  * transfer and processing.
00050  * SEE ALSO
00051  * ASImage
00052  * SOURCE
00053  */
00054 typedef struct ASScanline
00055 {
00056 #define SCL_DO_BLUE         (0x01<<ARGB32_BLUE_CHAN )
00057 #define SCL_DO_GREEN        (0x01<<ARGB32_GREEN_CHAN)
00058 #define SCL_DO_RED          (0x01<<ARGB32_RED_CHAN  )
00059 #define SCL_DO_ALPHA            (0x01<<ARGB32_ALPHA_CHAN)
00060 #define SCL_DO_COLOR            (SCL_DO_RED|SCL_DO_GREEN|SCL_DO_BLUE)
00061 #define SCL_DO_ALL                      (SCL_DO_RED|SCL_DO_GREEN|SCL_DO_BLUE| \
00062                              SCL_DO_ALPHA)
00063 #define SCL_RESERVED_MASK       0x0000FFFF
00064 #define SCL_CUSTOM_MASK         0xFFFF0000
00065 #define SCL_CUSTOM_OFFSET       16
00066                                                          
00067         CARD32             flags ;   /* combination of  the above values */
00068         CARD32        *buffer ;
00069         CARD32        *blue, *green, *red, *alpha ;
00070         CARD32        *channels[IC_NUM_CHANNELS];
00071         CARD32        *xc3, *xc2, *xc1; /* since some servers require
00072                                                                          * BGR mode here we store what
00073                                                                          * goes into what color component
00074                                                                          * in XImage */
00075         ARGB32         back_color;
00076         unsigned int   width, shift;
00077         unsigned int   offset_x ;
00078 }ASScanline;
00079 /*******************/
00080 
00081 #define ASIM_DEMOSAIC_DEFAULT_STRIP_SIZE        5
00082 
00083 typedef struct ASIMStrip
00084 {
00085 #define ASIM_SCL_InterpolatedH          (0x01<<SCL_CUSTOM_OFFSET)
00086 #define ASIM_SCL_InterpolatedV          (0x01<<(SCL_CUSTOM_OFFSET+ARGB32_CHANNELS))
00087 #define ASIM_SCL_InterpolatedAll        (ASIM_SCL_InterpolatedV|ASIM_SCL_InterpolatedH)
00088 
00089 #define ASIM_SCL_RGDiffCalculated       (0x01<<(SCL_CUSTOM_OFFSET+ARGB32_CHANNELS*2))
00090 #define ASIM_SCL_BGDiffCalculated       (0x01<<(SCL_CUSTOM_OFFSET+ARGB32_CHANNELS*2+1))
00091 
00092         int              size, width;
00093         ASScanline      **lines;
00094         int              start_line;
00095         
00096         void       **aux_data;
00097 
00098 #define ASIM_SCL_MissingValue   0xF0000000
00099 #define ASIM_IsMissingValue(v)          ((v)&0xF0000000)
00100 
00101 #define ASIM_IsStripLineLoaded(sptr,l)                  ((sptr)->lines[l]->flags & SCL_DO_COLOR)
00102 #define ASIM_IsStripLineInterpolated(sptr,l)    ((sptr)->lines[l]->flags & ASIM_SCL_Interpolated)
00103 }ASIMStrip;
00104 
00105 typedef void (*ASIMStripLoader)(ASScanline *scl, CARD8 *data, int data_size);
00106 
00107 
00108 
00109 /****f* libAfterImage/prepare_scanline()
00110  * NAME
00111  * prepare_scanline()
00112  * SYNOPSIS
00113  * ASScanline *prepare_scanline ( unsigned int width,
00114  *                                unsigned int shift,
00115  *                                ASScanline *reusable_memory,
00116  *                                Bool BGR_mode);
00117  * INPUTS
00118  * width           - width of the scanline.
00119  * shift           - format of contained data. 0 means - 32bit unshifted
00120  *                   8 means - 24.8bit ( 8 bit left shifted ).
00121  * reusable_memory - preallocated object.
00122  * BGR_mode        - if True will cause xc3 to point to Blue and xc1 to
00123  *                   point to red.
00124  * DESCRIPTION
00125  * This function allocates memory ( if reusable_memory is NULL ) for
00126  * the new ASScanline structure. Structures buffers gets allocated to
00127  * hold scanline data of at least width pixel wide. Buffers are adjusted
00128  * to start on 8 byte boundary.
00129  *********/
00130 /****f* libAfterImage/free_scanline()
00131  * NAME
00132  * free_scanline()
00133  * SYNOPSIS
00134  * void       free_scanline ( ASScanline *sl, Bool reusable );
00135  * INPUTS
00136  * sl       - pointer to previously allocated ASScanline structure to be
00137  *            deallocated.
00138  * reusable - if true then ASScanline object itself will not be
00139  *            deallocated.
00140  * DESCRIPTION
00141  * free_scanline() frees all the buffer memory allocated for ASScanline.
00142  * If reusable is false then object itself in not freed. That is usable
00143  * for declaring ASScanline on stack.
00144  *********/
00145 ASScanline* prepare_scanline( unsigned int width, unsigned int shift,
00146                                   ASScanline *reusable_memory, Bool BGR_mode);
00147 void       free_scanline( ASScanline *sl, Bool reusable );
00148 
00149 /* Scanline strips */
00150 void destroy_asim_strip (ASIMStrip **pstrip);
00151 ASIMStrip *create_asim_strip(unsigned int size, unsigned int width, int shift, int bgr);
00152 void advance_asim_strip (ASIMStrip *strip);
00153 
00154 /* demosaicing */
00155 /* returns number of lines processed from the data */
00156 int load_asim_strip (ASIMStrip *strip, CARD8 *data, int data_size, int data_start_line, int data_row_size, 
00157                                          ASIMStripLoader *line_loaders, int line_loaders_num);
00158 void decode_BG_12_be (ASScanline *scl, CARD8 *data, int data_size);
00159 void decode_GR_12_be (ASScanline *scl, CARD8 *data, int data_size);
00160 void decode_RG_12_be (ASScanline *scl, CARD8 *data, int data_size);
00161 void decode_GB_12_be (ASScanline *scl, CARD8 *data, int data_size);
00162 
00163 void interpolate_asim_strip_custom_rggb2 (ASIMStrip *strip, ASFlagType filter, Bool force_all);
00164 
00165 #ifdef __cplusplus
00166 }
00167 #endif
00168 
00169 #endif /* _SCANLINE_H_HEADER_INCLUDED */

Generated on Tue Jul 5 14:13:32 2011 for ROOT_528-00b_version by  doxygen 1.5.1