00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __REN_VIDEO_BUFFER_H__
00022 #define __REN_VIDEO_BUFFER_H__
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00034 typedef enum {
00035 REN_UNKNOWN,
00036 REN_NV12,
00037 REN_NV16,
00038 REN_RGB565,
00039 REN_RGB24,
00040 REN_BGR24,
00041 REN_RGB32,
00042 REN_ARGB32,
00043 } ren_vid_format_t;
00044
00045
00047 struct ren_vid_rect {
00048 int x;
00049 int y;
00050 int w;
00051 int h;
00052 };
00053
00055 struct ren_vid_surface {
00056 ren_vid_format_t format;
00057 int w;
00058 int h;
00059 int pitch;
00060 void *py;
00061 void *pc;
00062 void *pa;
00063 };
00064
00065 struct format_info {
00066 ren_vid_format_t fmt;
00067 int y_bpp;
00068 int c_bpp;
00069 int c_bpp_n;
00070 int c_bpp_d;
00071 int c_ss_horz;
00072 int c_ss_vert;
00073 };
00074
00075 static const struct format_info fmts[] = {
00076 { REN_UNKNOWN, 0, 0, 0, 1, 1, 1 },
00077 { REN_NV12, 1, 2, 1, 2, 2, 2 },
00078 { REN_NV16, 1, 2, 1, 1, 2, 1 },
00079 { REN_RGB565, 2, 0, 0, 1, 1, 1 },
00080 { REN_RGB24, 3, 0, 0, 1, 1, 1 },
00081 { REN_BGR24, 3, 0, 0, 1, 1, 1 },
00082 { REN_RGB32, 4, 0, 0, 1, 1, 1 },
00083 { REN_ARGB32, 4, 0, 0, 1, 1, 1 },
00084 };
00085
00086 static inline int is_ycbcr(ren_vid_format_t fmt)
00087 {
00088 if (fmt >= REN_NV12 && fmt <= REN_NV16)
00089 return 1;
00090 return 0;
00091 }
00092
00093 static inline int is_rgb(ren_vid_format_t fmt)
00094 {
00095 if (fmt >= REN_RGB565 && fmt <= REN_ARGB32)
00096 return 1;
00097 return 0;
00098 }
00099
00100 static inline int different_colorspace(ren_vid_format_t fmt1, ren_vid_format_t fmt2)
00101 {
00102 if ((is_rgb(fmt1) && is_ycbcr(fmt2))
00103 || (is_ycbcr(fmt1) && is_rgb(fmt2)))
00104 return 1;
00105 return 0;
00106 }
00107
00108 static inline size_t size_y(ren_vid_format_t format, int nr_pixels)
00109 {
00110 const struct format_info *fmt = &fmts[format];
00111 return (fmt->y_bpp * nr_pixels);
00112 }
00113
00114 static inline size_t size_c(ren_vid_format_t format, int nr_pixels)
00115 {
00116 const struct format_info *fmt = &fmts[format];
00117 return (fmt->c_bpp_n * nr_pixels) / fmt->c_bpp_d;
00118 }
00119
00120 static inline size_t size_a(ren_vid_format_t format, int nr_pixels)
00121 {
00122
00123 return nr_pixels;
00124 }
00125
00126 static inline size_t offset_y(ren_vid_format_t format, int w, int h, int pitch)
00127 {
00128 const struct format_info *fmt = &fmts[format];
00129 return (fmt->y_bpp * ((h * pitch) + w));
00130 }
00131
00132 static inline size_t offset_c(ren_vid_format_t format, int w, int h, int pitch)
00133 {
00134 const struct format_info *fmt = &fmts[format];
00135 return (fmt->c_bpp * (((h/fmt->c_ss_vert) * pitch/fmt->c_ss_horz) + w/fmt->c_ss_horz));
00136 }
00137
00138 static inline size_t offset_a(ren_vid_format_t format, int w, int h, int pitch)
00139 {
00140
00141 return ((h * pitch) + w);
00142 }
00143
00144 static int horz_increment(ren_vid_format_t format)
00145 {
00146
00147 return fmts[format].c_ss_horz;
00148 }
00149
00150 static int vert_increment(ren_vid_format_t format)
00151 {
00152
00153 return fmts[format].c_ss_vert;
00154 }
00155
00156
00157 static inline void get_sel_surface(
00158 struct ren_vid_surface *out,
00159 const struct ren_vid_surface *in,
00160 const struct ren_vid_rect *sel)
00161 {
00162 int x = sel->x & ~horz_increment(in->format);
00163 int y = sel->y & ~vert_increment(in->format);
00164
00165 *out = *in;
00166 out->w = sel->w & ~horz_increment(in->format);
00167 out->h = sel->h & ~vert_increment(in->format);
00168
00169 if (in->py) out->py += offset_y(in->format, x, y, in->pitch);
00170 if (in->pc) out->pc += offset_c(in->format, x, y, in->pitch);
00171 if (in->pa) out->pa += offset_a(in->format, x, y, in->pitch);
00172 }
00173
00174 #endif
00175
00176
00177 #ifndef __SHBEU_H__
00178 #define __SHBEU_H__
00179
00180 #ifdef __cplusplus
00181 extern "C" {
00182 #endif
00183
00266 struct SHBEU;
00267 typedef struct SHBEU SHBEU;
00268
00272 struct shbeu_surface {
00273 struct ren_vid_surface s;
00274 unsigned char alpha;
00275 int x;
00276 int y;
00277 };
00278
00279
00284 SHBEU *shbeu_open(void);
00285
00290 void shbeu_close(SHBEU *beu);
00291
00301 int
00302 shbeu_start_blend(
00303 SHBEU *beu,
00304 const struct shbeu_surface *src1,
00305 const struct shbeu_surface *src2,
00306 const struct shbeu_surface *src3,
00307 const struct shbeu_surface *dest);
00308
00312 void
00313 shbeu_wait(SHBEU *beu);
00314
00318 int
00319 shbeu_blend(
00320 SHBEU *beu,
00321 const struct shbeu_surface *src1,
00322 const struct shbeu_surface *src2,
00323 const struct shbeu_surface *src3,
00324 const struct shbeu_surface *dest);
00325
00326 #ifdef __cplusplus
00327 }
00328 #endif
00329
00330 #endif
00331