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