emotion: minor cleanup.

SVN revision: 64869
This commit is contained in:
Cedric BAIL 2011-11-07 15:45:24 +00:00
parent 191c19be96
commit ff41dfa5b5
4 changed files with 247 additions and 227 deletions

View File

@ -23,7 +23,9 @@ gstreamer_la_SOURCES = \
emotion_gstreamer.c \
emotion_sink.c \
emotion_alloc.c \
emotion_fakeeos.c
emotion_fakeeos.c \
emotion_convert.c
gstreamer_la_LIBADD = @ECORE_X_LIBS@ @GSTREAMER_LIBS@ @GSTREAMER_INTERFACE_LIBS@ $(top_builddir)/src/lib/libemotion.la
gstreamer_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
gstreamer_la_LIBTOOLFLAGS = --tag=disable-static

View File

@ -0,0 +1,216 @@
#include "emotion_gstreamer.h"
static inline void
_evas_video_bgrx_step(unsigned char *evas_data, const unsigned char *gst_data,
unsigned int w, unsigned int h __UNUSED__, unsigned int output_height, unsigned int step)
{
unsigned int x;
unsigned int y;
for (y = 0; y < output_height; ++y)
{
for (x = 0; x < w; x++)
{
evas_data[0] = gst_data[0];
evas_data[1] = gst_data[1];
evas_data[2] = gst_data[2];
evas_data[3] = 255;
gst_data += step;
evas_data += 4;
}
}
}
static void
_evas_video_bgr(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
{
_evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 3);
}
static void
_evas_video_bgrx(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
{
_evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 4);
}
static void
_evas_video_bgra(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
unsigned int x;
unsigned int y;
for (y = 0; y < output_height; ++y)
{
unsigned char alpha;
for (x = 0; x < w; ++x)
{
alpha = gst_data[3];
evas_data[0] = (gst_data[0] * alpha) / 255;
evas_data[1] = (gst_data[1] * alpha) / 255;
evas_data[2] = (gst_data[2] * alpha) / 255;
evas_data[3] = alpha;
gst_data += 4;
evas_data += 4;
}
}
}
static void
_evas_video_i420(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
const unsigned char **rows;
unsigned int i, j;
unsigned int rh;
rh = output_height;
rows = (const unsigned char **)evas_data;
for (i = 0; i < rh; i++)
rows[i] = &gst_data[i * w];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[h * w + j * (w / 2)];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[h * w + rh * (w / 4) + j * (w / 2)];
}
static void
_evas_video_yv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
const unsigned char **rows;
unsigned int i, j;
unsigned int rh;
rh = output_height;
rows = (const unsigned char **)evas_data;
for (i = 0; i < rh; i++)
rows[i] = &gst_data[i * w];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[h * w + rh * (w / 4) + j * (w / 2)];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[h * w + j * (w / 2)];
}
static void
_evas_video_yuy2(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
const unsigned char **rows;
unsigned int i;
rows = (const unsigned char **)evas_data;
for (i = 0; i < output_height; i++)
rows[i] = &gst_data[i * w * 2];
}
static void
_evas_video_nv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
const unsigned char **rows;
unsigned int i, j;
unsigned int rh;
rh = output_height;
rows = (const unsigned char **)evas_data;
for (i = 0; i < rh; i++)
rows[i] = &gst_data[i * w];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[rh * w + j * w];
}
static void
_evas_video_mt12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
{
const unsigned char **rows;
unsigned int i;
unsigned int j;
rows = (const unsigned char **)evas_data;
for (i = 0; i < (h / 32) / 2; i++)
rows[i] = &gst_data[i * w * 2 * 32];
if ((h / 32) % 2)
{
rows[i] = &gst_data[i * w * 2 * 32];
i++;
}
for (j = 0; j < ((h / 2) / 32) / 2; ++j, ++i)
rows[i] = &gst_data[h * w + j * (w / 2) * 2 * 16];
}
void
_evas_video_st12_multiplane(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
{
const GstMultiPlaneImageBuffer *mp_buf = (const GstMultiPlaneImageBuffer *) gst_data;
const unsigned char **rows;
unsigned int i;
unsigned int j;
rows = (const unsigned char **)evas_data;
for (i = 0; i < (h / 32) / 2; i++)
rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
if ((h / 32) % 2)
{
rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
i++;
}
for (j = 0; j < ((h / 2) / 16) / 2; j++, i++)
{
rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16 * 2;
}
if (((h / 2) / 16) % 2)
rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16 * 2;
}
void
_evas_video_st12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w __UNUSED__, unsigned int h, unsigned int output_height __UNUSED__)
{
const SCMN_IMGB *imgb = (const SCMN_IMGB *) gst_data;
const unsigned char **rows;
unsigned int i, j;
rows = (const unsigned char **)evas_data;
for (i = 0; i < (h / 32) / 2; i++)
rows[i] = imgb->uaddr[0] + i * imgb->stride[0] * 2 * 32;
if ((h / 32) % 2)
{
rows[i] = imgb->uaddr[0] + i * imgb->stride[0] * 2 * 32;
i++;
}
for (j = 0; j < (unsigned int) imgb->elevation[1] / 32 / 2; j++, i++)
rows[i] = imgb->uaddr[1] + j * imgb->stride[1] * 32 * 2;
if ((imgb->elevation[1] / 32) % 2)
rows[i++] = imgb->uaddr[1] + j * imgb->stride[1] * 32 * 2;
}
const ColorSpace_FourCC_Convertion colorspace_fourcc_convertion[] = {
{ "I420", GST_MAKE_FOURCC('I', '4', '2', '0'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_i420, EINA_TRUE },
{ "YV12", GST_MAKE_FOURCC('Y', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_yv12, EINA_TRUE },
{ "YUY2", GST_MAKE_FOURCC('Y', 'U', 'Y', '2'), EVAS_COLORSPACE_YCBCR422601_PL, _evas_video_yuy2, EINA_FALSE },
{ "NV12", GST_MAKE_FOURCC('N', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR420NV12601_PL, _evas_video_nv12, EINA_TRUE },
{ "TM12", GST_MAKE_FOURCC('T', 'M', '1', '2'), EVAS_COLORSPACE_YCBCR420TM12601_PL, _evas_video_mt12, EINA_TRUE },
{ NULL, 0, 0, NULL, 0 }
};
const ColorSpace_Format_Convertion colorspace_format_convertion[] = {
{ "BGR", GST_VIDEO_FORMAT_BGR, EVAS_COLORSPACE_ARGB8888, _evas_video_bgr },
{ "BGRx", GST_VIDEO_FORMAT_BGRx, EVAS_COLORSPACE_ARGB8888, _evas_video_bgrx },
{ "BGRA", GST_VIDEO_FORMAT_BGRA, EVAS_COLORSPACE_ARGB8888, _evas_video_bgra },
{ NULL, 0, 0, NULL }
};

View File

@ -260,6 +260,29 @@ Eina_Bool _emotion_gstreamer_video_pipeline_parse(Emotion_Gstreamer_Video *ev,
int em_shutdown(void *video);
typedef struct _ColorSpace_FourCC_Convertion ColorSpace_FourCC_Convertion;
typedef struct _ColorSpace_Format_Convertion ColorSpace_Format_Convertion;
struct _ColorSpace_FourCC_Convertion
{
const char *name;
guint32 fourcc;
Evas_Colorspace eformat;
Evas_Video_Convert_Cb func;
Eina_Bool force_height;
};
struct _ColorSpace_Format_Convertion
{
const char *name;
GstVideoFormat format;
Evas_Colorspace eformat;
Evas_Video_Convert_Cb func;
};
extern const ColorSpace_FourCC_Convertion colorspace_fourcc_convertion[];
extern const ColorSpace_Format_Convertion colorspace_format_convertion[];
/** Samsung specific infrastructure - do not touch, do not modify */
#define MPLANE_IMGB_MAX_COUNT 4
#define SCMN_IMGB_MAX_PLANE 4
@ -319,4 +342,7 @@ struct _SCMN_IMGB
int data[16];
};
void _evas_video_st12_multiplane(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__);
void _evas_video_st12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w __UNUSED__, unsigned int h, unsigned int output_height __UNUSED__);
#endif /* __EMOTION_GSTREAMER_H__ */

View File

@ -41,230 +41,6 @@ static void unlock_buffer_mutex(EvasVideoSinkPrivate* priv);
static void evas_video_sink_main_render(void *data);
static void evas_video_sink_samsung_main_render(void *data);
static void
_evas_video_bgrx_step(unsigned char *evas_data, const unsigned char *gst_data,
unsigned int w, unsigned int h __UNUSED__, unsigned int output_height, unsigned int step)
{
unsigned int x;
unsigned int y;
for (y = 0; y < output_height; ++y)
{
for (x = 0; x < w; x++)
{
evas_data[0] = gst_data[0];
evas_data[1] = gst_data[1];
evas_data[2] = gst_data[2];
evas_data[3] = 255;
gst_data += step;
evas_data += 4;
}
}
}
static void
_evas_video_bgr(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
{
_evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 3);
}
static void
_evas_video_bgrx(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height)
{
_evas_video_bgrx_step(evas_data, gst_data, w, h, output_height, 4);
}
static void
_evas_video_bgra(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
unsigned int x;
unsigned int y;
for (y = 0; y < output_height; ++y)
{
unsigned char alpha;
for (x = 0; x < w; ++x)
{
alpha = gst_data[3];
evas_data[0] = (gst_data[0] * alpha) / 255;
evas_data[1] = (gst_data[1] * alpha) / 255;
evas_data[2] = (gst_data[2] * alpha) / 255;
evas_data[3] = alpha;
gst_data += 4;
evas_data += 4;
}
}
}
static void
_evas_video_i420(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
const unsigned char **rows;
unsigned int i, j;
unsigned int rh;
rh = output_height;
rows = (const unsigned char **)evas_data;
for (i = 0; i < rh; i++)
rows[i] = &gst_data[i * w];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[h * w + j * (w / 2)];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[h * w + rh * (w / 4) + j * (w / 2)];
}
static void
_evas_video_yv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
const unsigned char **rows;
unsigned int i, j;
unsigned int rh;
rh = output_height;
rows = (const unsigned char **)evas_data;
for (i = 0; i < rh; i++)
rows[i] = &gst_data[i * w];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[h * w + rh * (w / 4) + j * (w / 2)];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[h * w + j * (w / 2)];
}
static void
_evas_video_yuy2(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
const unsigned char **rows;
unsigned int i;
rows = (const unsigned char **)evas_data;
for (i = 0; i < output_height; i++)
rows[i] = &gst_data[i * w * 2];
}
static void
_evas_video_nv12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h __UNUSED__, unsigned int output_height)
{
const unsigned char **rows;
unsigned int i, j;
unsigned int rh;
rh = output_height;
rows = (const unsigned char **)evas_data;
for (i = 0; i < rh; i++)
rows[i] = &gst_data[i * w];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &gst_data[rh * w + j * w];
}
static void
_evas_video_mt12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
{
const unsigned char **rows;
unsigned int i;
unsigned int j;
rows = (const unsigned char **)evas_data;
for (i = 0; i < (h / 32) / 2; i++)
rows[i] = &gst_data[i * w * 2 * 32];
if ((h / 32) % 2)
{
rows[i] = &gst_data[i * w * 2 * 32];
i++;
}
for (j = 0; j < ((h / 2) / 32) / 2; ++j, ++i)
rows[i] = &gst_data[h * w + j * (w / 2) * 2 * 16];
}
static void
_evas_video_st12_multiplane(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, unsigned int h, unsigned int output_height __UNUSED__)
{
const GstMultiPlaneImageBuffer *mp_buf = (const GstMultiPlaneImageBuffer *) gst_data;
const unsigned char **rows;
unsigned int i;
unsigned int j;
rows = (const unsigned char **)evas_data;
for (i = 0; i < (h / 32) / 2; i++)
rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
if ((h / 32) % 2)
{
rows[i] = mp_buf->uaddr[0] + i * w * 2 * 32;
i++;
}
for (j = 0; j < ((h / 2) / 16) / 2; j++, i++)
{
rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16 * 2;
}
if (((h / 2) / 16) % 2)
rows[i] = mp_buf->uaddr[1] + j * w * 2 * 16 * 2;
}
static void
_evas_video_st12(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w __UNUSED__, unsigned int h, unsigned int output_height __UNUSED__)
{
const SCMN_IMGB *imgb = (const SCMN_IMGB *) gst_data;
const unsigned char **rows;
unsigned int i, j;
rows = (const unsigned char **)evas_data;
for (i = 0; i < (h / 32) / 2; i++)
rows[i] = imgb->uaddr[0] + i * imgb->stride[0] * 2 * 32;
if ((h / 32) % 2)
{
rows[i] = imgb->uaddr[0] + i * imgb->stride[0] * 2 * 32;
i++;
}
for (j = 0; j < (unsigned int) imgb->elevation[1] / 32 / 2; j++, i++)
rows[i] = imgb->uaddr[1] + j * imgb->stride[1] * 32 * 2;
if ((imgb->elevation[1] / 32) % 2)
rows[i++] = imgb->uaddr[1] + j * imgb->stride[1] * 32 * 2;
}
static const struct {
const char *name;
guint32 fourcc;
Evas_Colorspace eformat;
Evas_Video_Convert_Cb func;
Eina_Bool force_height;
} colorspace_fourcc_convertion[] = {
{ "I420", GST_MAKE_FOURCC('I', '4', '2', '0'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_i420, EINA_TRUE },
{ "YV12", GST_MAKE_FOURCC('Y', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR422P601_PL, _evas_video_yv12, EINA_TRUE },
{ "YUY2", GST_MAKE_FOURCC('Y', 'U', 'Y', '2'), EVAS_COLORSPACE_YCBCR422601_PL, _evas_video_yuy2, EINA_FALSE },
{ "NV12", GST_MAKE_FOURCC('N', 'V', '1', '2'), EVAS_COLORSPACE_YCBCR420NV12601_PL, _evas_video_nv12, EINA_TRUE },
{ "TM12", GST_MAKE_FOURCC('T', 'M', '1', '2'), EVAS_COLORSPACE_YCBCR420TM12601_PL, _evas_video_mt12, EINA_TRUE }
};
static const struct {
const char *name;
GstVideoFormat format;
Evas_Colorspace eformat;
Evas_Video_Convert_Cb func;
} colorspace_format_convertion[] = {
{ "BGR", GST_VIDEO_FORMAT_BGR, EVAS_COLORSPACE_ARGB8888, _evas_video_bgr },
{ "BGRx", GST_VIDEO_FORMAT_BGRx, EVAS_COLORSPACE_ARGB8888, _evas_video_bgrx },
{ "BGRA", GST_VIDEO_FORMAT_BGRA, EVAS_COLORSPACE_ARGB8888, _evas_video_bgra }
};
static void
evas_video_sink_base_init(gpointer g_class)
{
@ -425,7 +201,7 @@ gboolean evas_video_sink_set_caps(GstBaseSink *bsink, GstCaps *caps)
{
priv->source_height = priv->height;
for (i = 0; i < sizeof (colorspace_fourcc_convertion) / sizeof (colorspace_fourcc_convertion[0]); ++i)
for (i = 0; colorspace_fourcc_convertion[i].name != NULL; ++i)
if (fourcc == colorspace_fourcc_convertion[i].fourcc)
{
fprintf(stderr, "Found '%s'\n", colorspace_fourcc_convertion[i].name);
@ -464,7 +240,7 @@ gboolean evas_video_sink_set_caps(GstBaseSink *bsink, GstCaps *caps)
priv->source_height = priv->height;
for (i = 0; i < sizeof (colorspace_format_convertion) / sizeof (colorspace_format_convertion[0]); ++i)
for (i = 0; colorspace_format_convertion[i].name != NULL; ++i)
if (format == colorspace_format_convertion[i].format)
{
fprintf(stderr, "Found '%s'\n", colorspace_format_convertion[i].name);