00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __REN_VIDEO_BUFFER_H__
00023 #define __REN_VIDEO_BUFFER_H__
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00035 typedef enum {
00036 REN_UNKNOWN,
00037 REN_NV12,
00038 REN_NV16,
00039 REN_RGB565,
00040 REN_RGB24,
00041 REN_BGR24,
00042 REN_RGB32,
00043 REN_ARGB32,
00044 } ren_vid_format_t;
00045
00046
00048 struct ren_vid_rect {
00049 int x;
00050 int y;
00051 int w;
00052 int h;
00053 };
00054
00056 struct ren_vid_surface {
00057 ren_vid_format_t format;
00058 int w;
00059 int h;
00060 int pitch;
00061 void *py;
00062 void *pc;
00063 void *pa;
00064 };
00065
00066 struct format_info {
00067 ren_vid_format_t fmt;
00068 int y_bpp;
00069 int c_bpp;
00070 int c_bpp_n;
00071 int c_bpp_d;
00072 int c_ss_horz;
00073 int c_ss_vert;
00074 };
00075
00076 static const struct format_info fmts[] = {
00077 { REN_UNKNOWN, 0, 0, 0, 1, 1, 1 },
00078 { REN_NV12, 1, 2, 1, 2, 2, 2 },
00079 { REN_NV16, 1, 2, 1, 1, 2, 1 },
00080 { REN_RGB565, 2, 0, 0, 1, 1, 1 },
00081 { REN_RGB24, 3, 0, 0, 1, 1, 1 },
00082 { REN_BGR24, 3, 0, 0, 1, 1, 1 },
00083 { REN_RGB32, 4, 0, 0, 1, 1, 1 },
00084 { REN_ARGB32, 4, 0, 0, 1, 1, 1 },
00085 };
00086
00087 static inline int is_ycbcr(ren_vid_format_t fmt)
00088 {
00089 if (fmt >= REN_NV12 && fmt <= REN_NV16)
00090 return 1;
00091 return 0;
00092 }
00093
00094 static inline int is_rgb(ren_vid_format_t fmt)
00095 {
00096 if (fmt >= REN_RGB565 && fmt <= REN_ARGB32)
00097 return 1;
00098 return 0;
00099 }
00100
00101 static inline int different_colorspace(ren_vid_format_t fmt1, ren_vid_format_t fmt2)
00102 {
00103 if ((is_rgb(fmt1) && is_ycbcr(fmt2))
00104 || (is_ycbcr(fmt1) && is_rgb(fmt2)))
00105 return 1;
00106 return 0;
00107 }
00108
00109 static inline size_t size_y(ren_vid_format_t format, int nr_pixels)
00110 {
00111 const struct format_info *fmt = &fmts[format];
00112 return (fmt->y_bpp * nr_pixels);
00113 }
00114
00115 static inline size_t size_c(ren_vid_format_t format, int nr_pixels)
00116 {
00117 const struct format_info *fmt = &fmts[format];
00118 return (fmt->c_bpp_n * nr_pixels) / fmt->c_bpp_d;
00119 }
00120
00121 static inline size_t size_a(ren_vid_format_t format, int nr_pixels)
00122 {
00123
00124 return nr_pixels;
00125 }
00126
00127 static inline size_t offset_y(ren_vid_format_t format, int w, int h, int pitch)
00128 {
00129 const struct format_info *fmt = &fmts[format];
00130 return (fmt->y_bpp * ((h * pitch) + w));
00131 }
00132
00133 static inline size_t offset_c(ren_vid_format_t format, int w, int h, int pitch)
00134 {
00135 const struct format_info *fmt = &fmts[format];
00136 return (fmt->c_bpp * (((h/fmt->c_ss_vert) * pitch/fmt->c_ss_horz) + w/fmt->c_ss_horz));
00137 }
00138
00139 static inline size_t offset_a(ren_vid_format_t format, int w, int h, int pitch)
00140 {
00141
00142 return ((h * pitch) + w);
00143 }
00144
00145 static int horz_increment(ren_vid_format_t format)
00146 {
00147
00148 return fmts[format].c_ss_horz;
00149 }
00150
00151 static int vert_increment(ren_vid_format_t format)
00152 {
00153
00154 return fmts[format].c_ss_vert;
00155 }
00156
00157
00158 static inline void get_sel_surface(
00159 struct ren_vid_surface *out,
00160 const struct ren_vid_surface *in,
00161 const struct ren_vid_rect *sel)
00162 {
00163 int x = sel->x & ~horz_increment(in->format);
00164 int y = sel->y & ~vert_increment(in->format);
00165
00166 *out = *in;
00167 out->w = sel->w & ~horz_increment(in->format);
00168 out->h = sel->h & ~vert_increment(in->format);
00169
00170 if (in->py) out->py += offset_y(in->format, x, y, in->pitch);
00171 if (in->pc) out->pc += offset_c(in->format, x, y, in->pitch);
00172 if (in->pa) out->pa += offset_a(in->format, x, y, in->pitch);
00173 }
00174
00175 #endif
00176
00177
00182 #ifndef __VEU_COLORSPACE_H__
00183 #define __VEU_COLORSPACE_H__
00184
00185
00187 typedef enum {
00188 SHVEU_NO_ROT=0,
00189 SHVEU_ROT_90,
00190 } shveu_rotation_t;
00191
00202 int
00203 shveu_setup(
00204 SHVEU *veu,
00205 const struct ren_vid_surface *src_surface,
00206 const struct ren_vid_surface *dst_surface,
00207 shveu_rotation_t rotate);
00208
00209
00215 void
00216 shveu_set_src(
00217 SHVEU *veu,
00218 void *src_py,
00219 void *src_pc);
00220
00226 void
00227 shveu_set_dst(
00228 SHVEU *veu,
00229 void *dst_py,
00230 void *dst_pc);
00231
00235 void
00236 shveu_start(
00237 SHVEU *veu);
00238
00243 void
00244 shveu_start_bundle(
00245 SHVEU *veu,
00246 int bundle_lines);
00247
00251 int
00252 shveu_wait(SHVEU *veu);
00253
00254
00264 int
00265 shveu_resize(
00266 SHVEU *veu,
00267 const struct ren_vid_surface *src_surface,
00268 const struct ren_vid_surface *dst_surface);
00269
00280 int
00281 shveu_rotate(
00282 SHVEU *veu,
00283 const struct ren_vid_surface *src_surface,
00284 const struct ren_vid_surface *dst_surface,
00285 shveu_rotation_t rotate);
00286
00287 #endif