summaryrefslogtreecommitdiff
path: root/src/modules/emotion/gstreamer/emotion_convert.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 03:43:32 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 03:43:32 +0000
commitdfb84c1657bfb14a5236b881193b81f4c0b8a69b (patch)
treeb51b210fc88a21eec8e5907b8bbfe12ebc669f90 /src/modules/emotion/gstreamer/emotion_convert.c
parent532284dbbe4259a9f2291f44d3eff376849e8031 (diff)
efl: merge emotion.
this one was quite a huge work, but hopefully it's correct. NOTES: * removed vlc generic module, it should go into a separate package. * gstreamer is enabled by default (see --disable-gstreamer) * xine is disabled by default (see --enable-gstreamer) * generic is always built statically if supported * gstreamer and xine can't be configured as static (just lacks command line options, build system supports it) * v4l2 is enabled by default on linux if eeze is built (see --disable-v4l2) * emotion_test moved to src/tests/emotion and depends on EFL_ENABLE_TESTS (--with-tests), but is still installed if enabled. TODO (need your help!): * fix warnings with gstreamer and xine engine * call engine shutdown functions if building as static * remove direct usage of PACKAGE_*_DIR and use eina_prefix * add eina_prefix checkme file as evas and others * add support for $EFL_RUN_IN_TREE * create separate package for emotion_generic_modules * check docs hierarchy (doxygen is segv'in here) SVN revision: 82501
Diffstat (limited to 'src/modules/emotion/gstreamer/emotion_convert.c')
-rw-r--r--src/modules/emotion/gstreamer/emotion_convert.c251
1 files changed, 251 insertions, 0 deletions
diff --git a/src/modules/emotion/gstreamer/emotion_convert.c b/src/modules/emotion/gstreamer/emotion_convert.c
new file mode 100644
index 0000000000..2664d28be6
--- /dev/null
+++ b/src/modules/emotion/gstreamer/emotion_convert.c
@@ -0,0 +1,251 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Eina.h>
6#include <Evas.h>
7
8#include <glib.h>
9#include <gst/gst.h>
10#include <gst/video/video.h>
11#include <gst/video/gstvideosink.h>
12
13#ifdef HAVE_ECORE_X
14# include <Ecore_X.h>
15# ifdef HAVE_XOVERLAY_H
16# include <gst/interfaces/xoverlay.h>
17# endif
18#endif
19
20#include "Emotion.h"
21#include "emotion_gstreamer.h"
22
23static inline void
24_evas_video_bgrx_step(unsigned char *evas_data, const unsigned char *gst_data,
25 unsigned int w, unsigned int h EINA_UNUSED, unsigned int output_height, unsigned int step)
26{
27 unsigned int x;
28 unsigned int y;
29
30 for (y = 0; y < output_height; ++y)
31 {
32 for (x = 0; x < w; x++)
33 {
34 evas_data[0] = gst_data[0];
35 evas_data[1] = gst_data[1];
36 evas_data[2] = gst_data[2];
37 evas_data[3] = 255;
38 gst_data += step;
39 evas_data += 4;
40 }
41 }
42}
43
44static void
45_evas_video_bgr(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
46{
47 _evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 3);
48}
49
50static void
51_evas_video_bgrx(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
52{
53 _evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 4);
54}
55
56static void
57_evas_video_bgra(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h EINA_UNUSED, unsigned int output_height)
58{
59 unsigned int x;
60 unsigned int y;
61
62 for (y = 0; y < output_height; ++y)
63 {
64 unsigned char alpha;
65
66 for (x = 0; x < w; ++x)
67 {
68 alpha = gst_data[3];
69 evas_data[0] = (gst_data[0] * alpha) / 255;
70 evas_data[1] = (gst_data[1] * alpha) / 255;
71 evas_data[2] = (gst_data[2] * alpha) / 255;
72 evas_data[3] = alpha;
73 gst_data += 4;
74 evas_data += 4;
75 }
76 }
77}
78
79static void
80_evas_video_i420(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
81{
82 const unsigned char **rows;
83 unsigned int i, j;
84 unsigned int rh;
85 unsigned int stride_y, stride_uv;
86
87 rh = output_height;
88
89 rows = (const unsigned char **)evas_data;
90
91 stride_y = GST_ROUND_UP_4(w);
92 stride_uv = GST_ROUND_UP_8(w) / 2;
93
94 for (i = 0; i < rh; i++)
95 rows[i] = &gst_data[i * stride_y];
96
97 for (j = 0; j < (rh / 2); j++, i++)
98 rows[i] = &gst_data[h * stride_y + j * stride_uv];
99
100 for (j = 0; j < (rh / 2); j++, i++)
101 rows[i] = &gst_data[h * stride_y +
102 (rh / 2) * stride_uv +
103 j * stride_uv];
104}
105
106static void
107_evas_video_yv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
108{
109 const unsigned char **rows;
110 unsigned int i, j;
111 unsigned int rh;
112 unsigned int stride_y, stride_uv;
113
114 rh = output_height;
115
116 rows = (const unsigned char **)evas_data;
117
118 stride_y = GST_ROUND_UP_4(w);
119 stride_uv = GST_ROUND_UP_8(w) / 2;
120
121 for (i = 0; i < rh; i++)
122 rows[i] = &gst_data[i * stride_y];
123
124 for (j = 0; j < (rh / 2); j++, i++)
125 rows[i] = &gst_data[h * stride_y +
126 (rh / 2) * stride_uv +
127 j * stride_uv];
128
129 for (j = 0; j < (rh / 2); j++, i++)
130 rows[i] = &gst_data[h * stride_y + j * stride_uv];
131}
132
133static void
134_evas_video_yuy2(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h EINA_UNUSED, unsigned int output_height)
135{
136 const unsigned char **rows;
137 unsigned int i;
138 unsigned int stride;
139
140 rows = (const unsigned char **)evas_data;
141
142 stride = GST_ROUND_UP_4(w * 2);
143
144 for (i = 0; i < output_height; i++)
145 rows[i] = &gst_data[i * stride];
146}
147
148static void
149_evas_video_nv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h EINA_UNUSED, unsigned int output_height)
150{
151 const unsigned char **rows;
152 unsigned int i, j;
153 unsigned int rh;
154
155 rh = output_height;
156
157 rows = (const unsigned char **)evas_data;
158
159 for (i = 0; i < rh; i++)
160 rows[i] = &gst_data[i * w];
161
162 for (j = 0; j < (rh / 2); j++, i++)
163 rows[i] = &gst_data[rh * w + j * w];
164}
165
166static void
167_evas_video_mt12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height EINA_UNUSED)
168{
169 const unsigned char **rows;
170 unsigned int i;
171 unsigned int j;
172
173 rows = (const unsigned char **)evas_data;
174
175 for (i = 0; i < (h / 32) / 2; i++)
176 rows[i] = &gst_data[i * w * 2 * 32];
177
178 if ((h / 32) % 2)
179 {
180 rows[i] = &gst_data[i * w * 2 * 32];
181 i++;
182 }
183
184 for (j = 0; j < ((h / 2) / 32) / 2; ++j, ++i)
185 rows[i] = &gst_data[h * w + j * (w / 2) * 2 * 16];
186}
187
188void
189_evas_video_st12_multiplane(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height EINA_UNUSED)
190{
191 const GstMultiPlaneImageBuffer *mp_buf = (const GstMultiPlaneImageBuffer *) gst_data;
192 const unsigned char **rows;
193 unsigned int i;
194 unsigned int j;
195
196 rows = (const unsigned char **)evas_data;
197
198 for (i = 0; i < (h / 32) / 2; i++)
199 rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
200 if ((h / 32) % 2)
201 {
202 rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
203 i++;
204 }
205
206 for (j = 0; j < ((h / 2) / 16) / 2; j++, i++)
207 {
208 rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16 * 2;
209 }
210 if (((h / 2) / 16) % 2)
211 rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16 * 2;
212}
213
214void
215_evas_video_st12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w EINA_UNUSED, unsigned int h, unsigned int output_height EINA_UNUSED)
216{
217 const SCMN_IMGB *imgb = (const SCMN_IMGB *) gst_data;
218 const unsigned char **rows;
219 unsigned int i, j;
220
221 rows = (const unsigned char **)evas_data;
222
223 for (i = 0; i < (h / 32) / 2; i++)
224 rows[i] = imgb->uaddr[0] + i * imgb->stride[0] * 2 * 32;
225 if ((h / 32) % 2)
226 {
227 rows[i] = imgb->uaddr[0] + i * imgb->stride[0] * 2 * 32;
228 i++;
229 }
230
231 for (j = 0; j < (unsigned int) imgb->elevation[1] / 32 / 2; j++, i++)
232 rows[i] = imgb->uaddr[1] + j * imgb->stride[1] * 32 * 2;
233 if ((imgb->elevation[1] / 32) % 2)
234 rows[i++] = imgb->uaddr[1] + j * imgb->stride[1] * 32 * 2;
235}
236
237const ColorSpace_FourCC_Convertion colorspace_fourcc_convertion[] = {
238 { "I420", GST_MAKE_FOURCC('I', '4', '2', '0'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_i420, EINA_TRUE },
239 { "YV12", GST_MAKE_FOURCC('Y', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_yv12, EINA_TRUE },
240 { "YUY2", GST_MAKE_FOURCC('Y', 'U', 'Y', '2'), EVAS_COLORSPACE_YCBCR422601_PL, _evas_video_yuy2, EINA_FALSE },
241 { "NV12", GST_MAKE_FOURCC('N', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR420NV12601_PL, _evas_video_nv12, EINA_TRUE },
242 { "TM12", GST_MAKE_FOURCC('T', 'M', '1', '2'), EVAS_COLORSPACE_YCBCR420TM12601_PL, _evas_video_mt12, EINA_TRUE },
243 { NULL, 0, 0, NULL, 0 }
244};
245
246const ColorSpace_Format_Convertion colorspace_format_convertion[] = {
247 { "BGR", GST_VIDEO_FORMAT_BGR, EVAS_COLORSPACE_ARGB8888, _evas_video_bgr },
248 { "BGRx", GST_VIDEO_FORMAT_BGRx, EVAS_COLORSPACE_ARGB8888, _evas_video_bgrx },
249 { "BGRA", GST_VIDEO_FORMAT_BGRA, EVAS_COLORSPACE_ARGB8888, _evas_video_bgra },
250 { NULL, 0, 0, NULL }
251};