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
00026 #ifndef __REN_VIDEO_BUFFER_H__
00027 #define __REN_VIDEO_BUFFER_H__
00028
00029 #include <stdint.h>
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00041 typedef enum {
00042 REN_UNKNOWN,
00043 REN_NV12,
00044 REN_NV16,
00045 REN_RGB565,
00046 REN_RGB24,
00047 REN_BGR24,
00048 REN_RGB32,
00049 REN_ARGB32,
00050 } ren_vid_format_t;
00051
00052
00054 struct ren_vid_rect {
00055 int x;
00056 int y;
00057 int w;
00058 int h;
00059 };
00060
00062 struct ren_vid_surface {
00063 ren_vid_format_t format;
00064 int w;
00065 int h;
00066 int pitch;
00067 void *py;
00068 void *pc;
00069 void *pa;
00070 };
00071
00072 struct format_info {
00073 ren_vid_format_t fmt;
00074 int y_bpp;
00075 int c_bpp;
00076 int c_bpp_n;
00077 int c_bpp_d;
00078 int c_ss_horz;
00079 int c_ss_vert;
00080 };
00081
00082 static const struct format_info fmts[] = {
00083 { REN_UNKNOWN, 0, 0, 0, 1, 1, 1 },
00084 { REN_NV12, 1, 2, 1, 2, 2, 2 },
00085 { REN_NV16, 1, 2, 1, 1, 2, 1 },
00086 { REN_RGB565, 2, 0, 0, 1, 1, 1 },
00087 { REN_RGB24, 3, 0, 0, 1, 1, 1 },
00088 { REN_BGR24, 3, 0, 0, 1, 1, 1 },
00089 { REN_RGB32, 4, 0, 0, 1, 1, 1 },
00090 { REN_ARGB32, 4, 0, 0, 1, 1, 1 },
00091 };
00092
00093 static inline int is_ycbcr(ren_vid_format_t fmt)
00094 {
00095 if (fmt >= REN_NV12 && fmt <= REN_NV16)
00096 return 1;
00097 return 0;
00098 }
00099
00100 static inline int is_rgb(ren_vid_format_t fmt)
00101 {
00102 if (fmt >= REN_RGB565 && fmt <= REN_ARGB32)
00103 return 1;
00104 return 0;
00105 }
00106
00107 static inline int different_colorspace(ren_vid_format_t fmt1, ren_vid_format_t fmt2)
00108 {
00109 if ((is_rgb(fmt1) && is_ycbcr(fmt2))
00110 || (is_ycbcr(fmt1) && is_rgb(fmt2)))
00111 return 1;
00112 return 0;
00113 }
00114
00115 static inline size_t size_y(ren_vid_format_t format, int nr_pixels)
00116 {
00117 const struct format_info *fmt = &fmts[format];
00118 return (fmt->y_bpp * nr_pixels);
00119 }
00120
00121 static inline size_t size_c(ren_vid_format_t format, int nr_pixels)
00122 {
00123 const struct format_info *fmt = &fmts[format];
00124 return (fmt->c_bpp_n * nr_pixels) / fmt->c_bpp_d;
00125 }
00126
00127 static inline size_t size_a(ren_vid_format_t format, int nr_pixels)
00128 {
00129
00130 return nr_pixels;
00131 }
00132
00133 static inline size_t offset_y(ren_vid_format_t format, int w, int h, int pitch)
00134 {
00135 const struct format_info *fmt = &fmts[format];
00136 return (fmt->y_bpp * ((h * pitch) + w));
00137 }
00138
00139 static inline size_t offset_c(ren_vid_format_t format, int w, int h, int pitch)
00140 {
00141 const struct format_info *fmt = &fmts[format];
00142 return (fmt->c_bpp * (((h/fmt->c_ss_vert) * pitch/fmt->c_ss_horz) + w/fmt->c_ss_horz));
00143 }
00144
00145 static inline size_t offset_a(ren_vid_format_t format, int w, int h, int pitch)
00146 {
00147
00148 return ((h * pitch) + w);
00149 }
00150
00151 static int horz_increment(ren_vid_format_t format)
00152 {
00153
00154 return fmts[format].c_ss_horz;
00155 }
00156
00157 static int vert_increment(ren_vid_format_t format)
00158 {
00159
00160 return fmts[format].c_ss_vert;
00161 }
00162
00163
00164 static inline void get_sel_surface(
00165 struct ren_vid_surface *out,
00166 const struct ren_vid_surface *in,
00167 const struct ren_vid_rect *sel)
00168 {
00169 int x = sel->x & ~horz_increment(in->format);
00170 int y = sel->y & ~vert_increment(in->format);
00171
00172 *out = *in;
00173 out->w = sel->w & ~horz_increment(in->format);
00174 out->h = sel->h & ~vert_increment(in->format);
00175
00176 if (in->py) out->py += offset_y(in->format, x, y, in->pitch);
00177 if (in->pc) out->pc += offset_c(in->format, x, y, in->pitch);
00178 if (in->pa) out->pa += offset_a(in->format, x, y, in->pitch);
00179 }
00180
00181 #endif
00182
00183
00188 #ifndef __VEU_COLORSPACE_H__
00189 #define __VEU_COLORSPACE_H__
00190
00191
00193 typedef enum {
00194 SHVEU_NO_ROT=0,
00195 SHVEU_ROT_90,
00196 } shveu_rotation_t;
00197
00208 int
00209 shveu_setup(
00210 SHVEU *veu,
00211 const struct ren_vid_surface *src_surface,
00212 const struct ren_vid_surface *dst_surface,
00213 shveu_rotation_t rotate);
00214
00215
00221 void
00222 shveu_set_src(
00223 SHVEU *veu,
00224 void *src_py,
00225 void *src_pc);
00226
00232 void
00233 shveu_set_dst(
00234 SHVEU *veu,
00235 void *dst_py,
00236 void *dst_pc);
00237
00243 void
00244 shveu_set_src_phys(
00245 SHVEU *veu,
00246 uint32_t src_py,
00247 uint32_t src_pc);
00248
00254 void
00255 shveu_set_dst_phys(
00256 SHVEU *veu,
00257 uint32_t dst_py,
00258 uint32_t dst_pc);
00259
00265 void
00266 shveu_set_color_conversion(
00267 SHVEU *veu,
00268 int bt709,
00269 int full_range);
00270
00274 void
00275 shveu_start(
00276 SHVEU *veu);
00277
00282 void
00283 shveu_start_bundle(
00284 SHVEU *veu,
00285 int bundle_lines);
00286
00290 int
00291 shveu_wait(SHVEU *veu);
00292
00293
00303 int
00304 shveu_resize(
00305 SHVEU *veu,
00306 const struct ren_vid_surface *src_surface,
00307 const struct ren_vid_surface *dst_surface);
00308
00319 int
00320 shveu_rotate(
00321 SHVEU *veu,
00322 const struct ren_vid_surface *src_surface,
00323 const struct ren_vid_surface *dst_surface,
00324 shveu_rotation_t rotate);
00325
00326 #endif