Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

yuv2rgb.h

Go to the documentation of this file.
00001 
00002 #ifndef HAVE_YUV2RGB_H
00003 #define HAVE_YUV2RGB_h
00004 
00005 #ifdef HAVE_MLIB
00006 #include <mlib_video.h>
00007 #endif
00008 
00009 #include <inttypes.h>
00010 
00011 typedef struct yuv2rgb_s yuv2rgb_t;
00012 
00013 typedef struct yuv2rgb_factory_s yuv2rgb_factory_t;
00014 
00015 /*
00016  * function types for functions which can be replaced
00017  * by hardware-accelerated versions
00018  */
00019 
00020 /* internal function use to scale yuv data */
00021 typedef void (*scale_line_func_t) (uint8_t *source, uint8_t *dest, int width, int step);
00022 
00023 typedef void (*yuv2rgb_fun_t) (yuv2rgb_t *this, uint8_t * image, uint8_t * py, uint8_t * pu, uint8_t * pv) ;
00024 
00025 typedef void (*yuy22rgb_fun_t) (yuv2rgb_t *this, uint8_t * image, uint8_t * p);
00026 
00027 typedef uint32_t (*yuv2rgb_single_pixel_fun_t) (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v);
00028 
00029 /*
00030  * modes supported - feel free to implement yours
00031  */
00032 
00033 #define MODE_8_RGB    1
00034 #define MODE_8_BGR    2
00035 #define MODE_15_RGB   3
00036 #define MODE_15_BGR   4
00037 #define MODE_16_RGB   5
00038 #define MODE_16_BGR   6
00039 #define MODE_24_RGB   7
00040 #define MODE_24_BGR   8
00041 #define MODE_32_RGB   9
00042 #define MODE_32_BGR  10
00043 #define MODE_8_GRAY  11
00044 #define MODE_PALETTE 12
00045 
00046 struct yuv2rgb_s {
00047   /*
00048    * configure converter for scaling factors
00049    */
00050   int (*configure) (yuv2rgb_t *this,
00051                     int source_width, int source_height,
00052                     int y_stride, int uv_stride,
00053                     int dest_width, int dest_height,
00054                     int rgb_stride);
00055 
00056   /*
00057    * start a new field or frame if dest is NULL
00058    */
00059   int (*next_slice) (yuv2rgb_t *this, uint8_t **dest);
00060 
00061   /*
00062    * free resources
00063    */
00064   void (*dispose) (yuv2rgb_t *this);
00065 
00066   /*
00067    * this is the function to call for the yuv2rgb and scaling process
00068    */
00069   yuv2rgb_fun_t     yuv2rgb_fun;
00070 
00071   /*
00072    * this is the function to call for the yuy2->rgb and scaling process
00073    */
00074   yuy22rgb_fun_t    yuy22rgb_fun;
00075 
00076   /*
00077    * this is the function to call for the yuv2rgb for a single pixel
00078    * (used for converting clut colors)
00079    */
00080 
00081   yuv2rgb_single_pixel_fun_t yuv2rgb_single_pixel_fun;
00082 
00083   /* private stuff below */
00084 
00085   int               source_width, source_height;
00086   int               y_stride, uv_stride;
00087   int               dest_width, dest_height;
00088   int               rgb_stride;
00089   int               slice_height, slice_offset;
00090   int               step_dx, step_dy;
00091   int               do_scale, swapped;
00092 
00093   uint8_t          *y_buffer;
00094   uint8_t          *u_buffer;
00095   uint8_t          *v_buffer;
00096   void             *y_chunk;
00097   void             *u_chunk;
00098   void             *v_chunk;
00099 
00100 #ifdef HAVE_MLIB
00101   uint8_t          *mlib_buffer;
00102   uint8_t          *mlib_resize_buffer;
00103   void             *mlib_chunk;
00104   void             *mlib_resize_chunk;
00105   mlib_filter      mlib_filter_type;
00106 #endif
00107 
00108   void            **table_rV;
00109   void            **table_gU;
00110   int              *table_gV;
00111   void            **table_bU;
00112   void             *table_mmx;
00113 
00114   uint8_t          *cmap;
00115   scale_line_func_t scale_line;  
00116 } ;
00117 
00118 /*
00119  * convenience class to easily create a lot of converters
00120  */
00121 
00122 struct yuv2rgb_factory_s {
00123   yuv2rgb_t* (*create_converter) (yuv2rgb_factory_t *this);
00124 
00125   /* 
00126    * set color space conversion levels
00127    * for all converters produced by this factory
00128    */
00129   void (*set_csc_levels) (yuv2rgb_factory_t *this,
00130                           int brightness, int contrast, int saturation);
00131 
00132   /*
00133    * free resources
00134    */
00135   void (*dispose) (yuv2rgb_factory_t *this);
00136 
00137   /* private data */
00138 
00139   int      mode;
00140   int      swapped;
00141   uint8_t *cmap;
00142 
00143   uint32_t matrix_coefficients;
00144 
00145   void    *table_base;
00146   void    *table_rV[256];
00147   void    *table_gU[256];
00148   int      table_gV[256];
00149   void    *table_bU[256];
00150   void    *table_mmx_base;
00151   void    *table_mmx;
00152 
00153   /* preselected functions for mode/swap/hardware */
00154   yuv2rgb_fun_t               yuv2rgb_fun;
00155   yuy22rgb_fun_t              yuy22rgb_fun;
00156   yuv2rgb_single_pixel_fun_t  yuv2rgb_single_pixel_fun;
00157 };
00158 
00159 yuv2rgb_factory_t *yuv2rgb_factory_init (int mode, int swapped, uint8_t *colormap);
00160 
00161                    
00162 /*
00163  * internal stuff below this line
00164  */
00165 
00166 void mmx_yuv2rgb_set_csc_levels(yuv2rgb_factory_t *this,
00167                                 int brightness, int contrast, int saturation);
00168 void yuv2rgb_init_mmxext (yuv2rgb_factory_t *this);
00169 void yuv2rgb_init_mmx (yuv2rgb_factory_t *this);
00170 void yuv2rgb_init_mlib (yuv2rgb_factory_t *this);
00171 
00172 #endif

Generated on Sat Nov 5 16:17:33 2005 for OPIE by  doxygen 1.4.2