summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules/gstreamer/emotion_sink.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2011-11-07 15:45:24 +0000
committerCedric BAIL <cedric.bail@free.fr>2011-11-07 15:45:24 +0000
commitff41dfa5b5effbbd53023e0c803823d0e0c1f6e0 (patch)
treee696e4bb02315fb08cbf3722f2e8c4dc0e06b119 /legacy/emotion/src/modules/gstreamer/emotion_sink.c
parent191c19be9620007fdd6e283a78fa798991c41186 (diff)
emotion: minor cleanup.
SVN revision: 64869
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_sink.c228
1 files changed, 2 insertions, 226 deletions
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_sink.c b/legacy/emotion/src/modules/gstreamer/emotion_sink.c
index 81932bbc21..ae4b27ec63 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_sink.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_sink.c
@@ -42,230 +42,6 @@ static void evas_video_sink_main_render(void *data);
42static void evas_video_sink_samsung_main_render(void *data); 42static void evas_video_sink_samsung_main_render(void *data);
43 43
44static void 44static void
45_evas_video_bgrx_step(unsigned char *evas_data, const unsigned char *gst_data,
46 unsigned int w, unsigned int h __UNUSED__, unsigned int output_height, unsigned int step)
47{
48 unsigned int x;
49 unsigned int y;
50
51 for (y = 0; y < output_height; ++y)
52 {
53 for (x = 0; x < w; x++)
54 {
55 evas_data[0] = gst_data[0];
56 evas_data[1] = gst_data[1];
57 evas_data[2] = gst_data[2];
58 evas_data[3] = 255;
59 gst_data += step;
60 evas_data += 4;
61 }
62 }
63}
64
65static void
66_evas_video_bgr(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
67{
68 _evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 3);
69}
70
71static void
72_evas_video_bgrx(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
73{
74 _evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 4);
75}
76
77static void
78_evas_video_bgra(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
79{
80 unsigned int x;
81 unsigned int y;
82
83 for (y = 0; y < output_height; ++y)
84 {
85 unsigned char alpha;
86
87 for (x = 0; x < w; ++x)
88 {
89 alpha = gst_data[3];
90 evas_data[0] = (gst_data[0] * alpha) / 255;
91 evas_data[1] = (gst_data[1] * alpha) / 255;
92 evas_data[2] = (gst_data[2] * alpha) / 255;
93 evas_data[3] = alpha;
94 gst_data += 4;
95 evas_data += 4;
96 }
97 }
98}
99
100static void
101_evas_video_i420(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
102{
103 const unsigned char **rows;
104 unsigned int i, j;
105 unsigned int rh;
106
107 rh = output_height;
108
109 rows = (const unsigned char **)evas_data;
110
111 for (i = 0; i < rh; i++)
112 rows[i] = &gst_data[i * w];
113
114 for (j = 0; j < (rh / 2); j++, i++)
115 rows[i] = &gst_data[h * w + j * (w / 2)];
116
117 for (j = 0; j < (rh / 2); j++, i++)
118 rows[i] = &gst_data[h * w + rh * (w / 4) + j * (w / 2)];
119}
120
121static void
122_evas_video_yv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
123{
124 const unsigned char **rows;
125 unsigned int i, j;
126 unsigned int rh;
127
128 rh = output_height;
129
130 rows = (const unsigned char **)evas_data;
131
132 for (i = 0; i < rh; i++)
133 rows[i] = &gst_data[i * w];
134
135 for (j = 0; j < (rh / 2); j++, i++)
136 rows[i] = &gst_data[h * w + rh * (w / 4) + j * (w / 2)];
137
138 for (j = 0; j < (rh / 2); j++, i++)
139 rows[i] = &gst_data[h * w + j * (w / 2)];
140}
141
142static void
143_evas_video_yuy2(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
144{
145 const unsigned char **rows;
146 unsigned int i;
147
148 rows = (const unsigned char **)evas_data;
149
150 for (i = 0; i < output_height; i++)
151 rows[i] = &gst_data[i * w * 2];
152}
153
154static void
155_evas_video_nv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
156{
157 const unsigned char **rows;
158 unsigned int i, j;
159 unsigned int rh;
160
161 rh = output_height;
162
163 rows = (const unsigned char **)evas_data;
164
165 for (i = 0; i < rh; i++)
166 rows[i] = &gst_data[i * w];
167
168 for (j = 0; j < (rh / 2); j++, i++)
169 rows[i] = &gst_data[rh * w + j * w];
170}
171
172static void
173_evas_video_mt12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
174{
175 const unsigned char **rows;
176 unsigned int i;
177 unsigned int j;
178
179 rows = (const unsigned char **)evas_data;
180
181 for (i = 0; i < (h / 32) / 2; i++)
182 rows[i] = &gst_data[i * w * 2 * 32];
183
184 if ((h / 32) % 2)
185 {
186 rows[i] = &gst_data[i * w * 2 * 32];
187 i++;
188 }
189
190 for (j = 0; j < ((h / 2) / 32) / 2; ++j, ++i)
191 rows[i] = &gst_data[h * w + j * (w / 2) * 2 * 16];
192}
193
194static void
195_evas_video_st12_multiplane(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
196{
197 const GstMultiPlaneImageBuffer *mp_buf = (const GstMultiPlaneImageBuffer *) gst_data;
198 const unsigned char **rows;
199 unsigned int i;
200 unsigned int j;
201
202 rows = (const unsigned char **)evas_data;
203
204 for (i = 0; i < (h / 32) / 2; i++)
205 rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
206 if ((h / 32) % 2)
207 {
208 rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
209 i++;
210 }
211
212 for (j = 0; j < ((h / 2) / 16) / 2; j++, i++)
213 {
214 rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16 * 2;
215 }
216 if (((h / 2) / 16) % 2)
217 rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16 * 2;
218}
219
220static void
221_evas_video_st12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w __UNUSED__, unsigned int h, unsigned int output_height __UNUSED__)
222{
223 const SCMN_IMGB *imgb = (const SCMN_IMGB *) gst_data;
224 const unsigned char **rows;
225 unsigned int i, j;
226
227 rows = (const unsigned char **)evas_data;
228
229 for (i = 0; i < (h / 32) / 2; i++)
230 rows[i] = imgb->uaddr[0] + i * imgb->stride[0] * 2 * 32;
231 if ((h / 32) % 2)
232 {
233 rows[i] = imgb->uaddr[0] + i * imgb->stride[0] * 2 * 32;
234 i++;
235 }
236
237 for (j = 0; j < (unsigned int) imgb->elevation[1] / 32 / 2; j++, i++)
238 rows[i] = imgb->uaddr[1] + j * imgb->stride[1] * 32 * 2;
239 if ((imgb->elevation[1] / 32) % 2)
240 rows[i++] = imgb->uaddr[1] + j * imgb->stride[1] * 32 * 2;
241}
242
243static const struct {
244 const char *name;
245 guint32 fourcc;
246 Evas_Colorspace eformat;
247 Evas_Video_Convert_Cb func;
248 Eina_Bool force_height;
249} colorspace_fourcc_convertion[] = {
250 { "I420", GST_MAKE_FOURCC('I', '4', '2', '0'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_i420, EINA_TRUE },
251 { "YV12", GST_MAKE_FOURCC('Y', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_yv12, EINA_TRUE },
252 { "YUY2", GST_MAKE_FOURCC('Y', 'U', 'Y', '2'), EVAS_COLORSPACE_YCBCR422601_PL, _evas_video_yuy2, EINA_FALSE },
253 { "NV12", GST_MAKE_FOURCC('N', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR420NV12601_PL, _evas_video_nv12, EINA_TRUE },
254 { "TM12", GST_MAKE_FOURCC('T', 'M', '1', '2'), EVAS_COLORSPACE_YCBCR420TM12601_PL, _evas_video_mt12, EINA_TRUE }
255};
256
257static const struct {
258 const char *name;
259 GstVideoFormat format;
260 Evas_Colorspace eformat;
261 Evas_Video_Convert_Cb func;
262} colorspace_format_convertion[] = {
263 { "BGR", GST_VIDEO_FORMAT_BGR, EVAS_COLORSPACE_ARGB8888, _evas_video_bgr },
264 { "BGRx", GST_VIDEO_FORMAT_BGRx, EVAS_COLORSPACE_ARGB8888, _evas_video_bgrx },
265 { "BGRA", GST_VIDEO_FORMAT_BGRA, EVAS_COLORSPACE_ARGB8888, _evas_video_bgra }
266};
267
268static void
269evas_video_sink_base_init(gpointer g_class) 45evas_video_sink_base_init(gpointer g_class)
270{ 46{
271 GstElementClass* element_class; 47 GstElementClass* element_class;
@@ -425,7 +201,7 @@ gboolean evas_video_sink_set_caps(GstBaseSink *bsink, GstCaps *caps)
425 { 201 {
426 priv->source_height = priv->height; 202 priv->source_height = priv->height;
427 203
428 for (i = 0; i < sizeof (colorspace_fourcc_convertion) / sizeof (colorspace_fourcc_convertion[0]); ++i) 204 for (i = 0; colorspace_fourcc_convertion[i].name != NULL; ++i)
429 if (fourcc == colorspace_fourcc_convertion[i].fourcc) 205 if (fourcc == colorspace_fourcc_convertion[i].fourcc)
430 { 206 {
431 fprintf(stderr, "Found '%s'\n", colorspace_fourcc_convertion[i].name); 207 fprintf(stderr, "Found '%s'\n", colorspace_fourcc_convertion[i].name);
@@ -464,7 +240,7 @@ gboolean evas_video_sink_set_caps(GstBaseSink *bsink, GstCaps *caps)
464 240
465 priv->source_height = priv->height; 241 priv->source_height = priv->height;
466 242
467 for (i = 0; i < sizeof (colorspace_format_convertion) / sizeof (colorspace_format_convertion[0]); ++i) 243 for (i = 0; colorspace_format_convertion[i].name != NULL; ++i)
468 if (format == colorspace_format_convertion[i].format) 244 if (format == colorspace_format_convertion[i].format)
469 { 245 {
470 fprintf(stderr, "Found '%s'\n", colorspace_format_convertion[i].name); 246 fprintf(stderr, "Found '%s'\n", colorspace_format_convertion[i].name);