[MOVED FROM BAD 06/68] gst-indent

Original commit message from CVS:
gst-indent
This commit is contained in:
Thomas Vander Stichele 2004-03-14 22:34:33 +00:00 committed by Wim Taymans
parent 243acdb0a4
commit f20bede182
4 changed files with 651 additions and 653 deletions

View file

@ -28,84 +28,80 @@
static GstColorspaceFormat gst_colorspace_formats[] = { static GstColorspaceFormat gst_colorspace_formats[] = {
{ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420")) }, {GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))},
{ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("YV12")) }, {GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YV12"))},
{ GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB) }, {GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB)},
{ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB) }, {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)},
{ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16) }, {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16)},
}; };
static GstColorspaceConverter gst_colorspace_converters[] = { static GstColorspaceConverter gst_colorspace_converters[] = {
{ GST_COLORSPACE_I420, GST_COLORSPACE_RGB32, gst_colorspace_I420_to_rgb32 }, {GST_COLORSPACE_I420, GST_COLORSPACE_RGB32, gst_colorspace_I420_to_rgb32},
{ GST_COLORSPACE_YV12, GST_COLORSPACE_RGB32, gst_colorspace_YV12_to_rgb32 }, {GST_COLORSPACE_YV12, GST_COLORSPACE_RGB32, gst_colorspace_YV12_to_rgb32},
{ GST_COLORSPACE_I420, GST_COLORSPACE_RGB24, gst_colorspace_I420_to_rgb24 }, {GST_COLORSPACE_I420, GST_COLORSPACE_RGB24, gst_colorspace_I420_to_rgb24},
{ GST_COLORSPACE_YV12, GST_COLORSPACE_RGB24, gst_colorspace_YV12_to_rgb24 }, {GST_COLORSPACE_YV12, GST_COLORSPACE_RGB24, gst_colorspace_YV12_to_rgb24},
{ GST_COLORSPACE_I420, GST_COLORSPACE_RGB16, gst_colorspace_I420_to_rgb16 }, {GST_COLORSPACE_I420, GST_COLORSPACE_RGB16, gst_colorspace_I420_to_rgb16},
{ GST_COLORSPACE_YV12, GST_COLORSPACE_RGB16, gst_colorspace_YV12_to_rgb16 }, {GST_COLORSPACE_YV12, GST_COLORSPACE_RGB16, gst_colorspace_YV12_to_rgb16},
}; };
static GstElementDetails colorspace_details = GST_ELEMENT_DETAILS ( static GstElementDetails colorspace_details =
"Colorspace converter", GST_ELEMENT_DETAILS ("Colorspace converter",
"Filter/Converter/Video", "Filter/Converter/Video",
"Converts video from one colorspace to another", "Converts video from one colorspace to another",
"Wim Taymans <wim.taymans@chello.be>" "Wim Taymans <wim.taymans@chello.be>");
);
static GstStaticPadTemplate gst_colorspace_sink_template = static GstStaticPadTemplate gst_colorspace_sink_template =
GST_STATIC_PAD_TEMPLATE ( GST_STATIC_PAD_TEMPLATE ("sink",
"sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YV12 }")) GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YV12 }"))
); );
static GstStaticPadTemplate gst_colorspace_src_template = static GstStaticPadTemplate gst_colorspace_src_template =
GST_STATIC_PAD_TEMPLATE ( GST_STATIC_PAD_TEMPLATE ("src",
"src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ( GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB "; "
GST_VIDEO_CAPS_xRGB "; " GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_RGB "; " GST_VIDEO_CAPS_RGB_16)
GST_VIDEO_CAPS_BGRx "; " );
GST_VIDEO_CAPS_RGB "; "
GST_VIDEO_CAPS_RGB_16
)
);
/* Stereo signals and args */ /* Stereo signals and args */
enum { enum
{
/* FILL ME */ /* FILL ME */
LAST_SIGNAL LAST_SIGNAL
}; };
enum { enum
{
ARG_0, ARG_0,
ARG_SOURCE, ARG_SOURCE,
ARG_DEST, ARG_DEST,
}; };
static void gst_colorspace_base_init (gpointer g_class); static void gst_colorspace_base_init (gpointer g_class);
static void gst_colorspace_class_init (GstColorspaceClass *klass); static void gst_colorspace_class_init (GstColorspaceClass * klass);
static void gst_colorspace_init (GstColorspace *space); static void gst_colorspace_init (GstColorspace * space);
static void gst_colorspace_set_property (GObject *object, guint prop_id, static void gst_colorspace_set_property (GObject * object, guint prop_id,
const GValue *value, GParamSpec *pspec); const GValue * value, GParamSpec * pspec);
static void gst_colorspace_get_property (GObject *object, guint prop_id, static void gst_colorspace_get_property (GObject * object, guint prop_id,
GValue *value, GParamSpec *pspec); GValue * value, GParamSpec * pspec);
static GstPadLinkReturn static GstPadLinkReturn
gst_colorspace_link (GstPad *pad, const GstCaps *caps); gst_colorspace_link (GstPad * pad, const GstCaps * caps);
static void gst_colorspace_chain (GstPad *pad, GstData *_data); static void gst_colorspace_chain (GstPad * pad, GstData * _data);
static GstElementStateReturn static GstElementStateReturn gst_colorspace_change_state (GstElement * element);
gst_colorspace_change_state (GstElement *element);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
/*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */ /*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */
#if 0 #if 0
static gboolean static gboolean
colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *to_caps) colorspace_setup_converter (GstColorspace * space, GstCaps * from_caps,
GstCaps * to_caps)
{ {
guint32 from_space, to_space; guint32 from_space, to_space;
GstStructure *from_struct; GstStructure *from_struct;
@ -117,138 +113,142 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t
from_struct = gst_caps_get_structure (from_caps, 0); from_struct = gst_caps_get_structure (from_caps, 0);
to_struct = gst_caps_get_structure (to_caps, 0); to_struct = gst_caps_get_structure (to_caps, 0);
from_space = GST_MAKE_FOURCC ('R','G','B',' '); from_space = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_fourcc (from_struct, "format", &from_space); gst_structure_get_fourcc (from_struct, "format", &from_space);
to_space = GST_MAKE_FOURCC ('R','G','B',' '); to_space = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_fourcc (to_struct, "format", &to_space); gst_structure_get_fourcc (to_struct, "format", &to_space);
GST_INFO ("set up converter for " GST_FOURCC_FORMAT GST_INFO ("set up converter for " GST_FOURCC_FORMAT
" (%08x) to " GST_FOURCC_FORMAT " (%08x)", " (%08x) to " GST_FOURCC_FORMAT " (%08x)",
GST_FOURCC_ARGS (from_space), from_space, GST_FOURCC_ARGS (from_space), from_space,
GST_FOURCC_ARGS (to_space), to_space); GST_FOURCC_ARGS (to_space), to_space);
switch (from_space) { switch (from_space) {
case GST_MAKE_FOURCC ('R','G','B',' '): case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
{ {
gint from_bpp; gint from_bpp;
gst_structure_get_int (from_struct, "bpp", &from_bpp); gst_structure_get_int (from_struct, "bpp", &from_bpp);
switch (to_space) { switch (to_space) {
case GST_MAKE_FOURCC ('R','G','B',' '): case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
#ifdef HAVE_HERMES #ifdef HAVE_HERMES
{ {
gint to_bpp; gint to_bpp;
gst_structure_get_int (to_struct, "bpp", &to_bpp);
gst_structure_get_int (from_struct, "red_mask", &space->source.r); gst_structure_get_int (to_struct, "bpp", &to_bpp);
gst_structure_get_int (from_struct, "red_mask", &space->source.r);
gst_structure_get_int (from_struct, "green_mask", &space->source.g); gst_structure_get_int (from_struct, "green_mask", &space->source.g);
gst_structure_get_int (from_struct, "blue_mask", &space->source.b); gst_structure_get_int (from_struct, "blue_mask", &space->source.b);
space->source.a = 0; space->source.a = 0;
space->srcbpp = space->source.bits = from_bpp; space->srcbpp = space->source.bits = from_bpp;
space->source.indexed = 0; space->source.indexed = 0;
space->source.has_colorkey = 0; space->source.has_colorkey = 0;
GST_INFO ( "source red mask %08x", space->source.r); GST_INFO ("source red mask %08x", space->source.r);
GST_INFO ( "source green mask %08x", space->source.g); GST_INFO ("source green mask %08x", space->source.g);
GST_INFO ( "source blue mask %08x", space->source.b); GST_INFO ("source blue mask %08x", space->source.b);
GST_INFO ( "source bpp %08x", space->srcbpp); GST_INFO ("source bpp %08x", space->srcbpp);
gst_structure_get_int (to_struct, "red_mask", &space->dest.r); gst_structure_get_int (to_struct, "red_mask", &space->dest.r);
gst_structure_get_int (to_struct, "green_mask", &space->dest.g); gst_structure_get_int (to_struct, "green_mask", &space->dest.g);
gst_structure_get_int (to_struct, "blue_mask", &space->dest.b); gst_structure_get_int (to_struct, "blue_mask", &space->dest.b);
space->dest.a = 0; space->dest.a = 0;
space->destbpp = space->dest.bits = to_bpp; space->destbpp = space->dest.bits = to_bpp;
space->dest.indexed = 0; space->dest.indexed = 0;
space->dest.has_colorkey = 0; space->dest.has_colorkey = 0;
GST_INFO ( "dest red mask %08x", space->dest.r); GST_INFO ("dest red mask %08x", space->dest.r);
GST_INFO ( "dest green mask %08x", space->dest.g); GST_INFO ("dest green mask %08x", space->dest.g);
GST_INFO ( "dest blue mask %08x", space->dest.b); GST_INFO ("dest blue mask %08x", space->dest.b);
GST_INFO ( "dest bpp %08x", space->destbpp); GST_INFO ("dest bpp %08x", space->destbpp);
if (!Hermes_ConverterRequest (space->h_handle, &space->source, &space->dest)) { if (!Hermes_ConverterRequest (space->h_handle, &space->source,
&space->dest)) {
g_warning ("Hermes: could not get converter\n"); g_warning ("Hermes: could not get converter\n");
return FALSE; return FALSE;
} }
GST_INFO ( "converter set up"); GST_INFO ("converter set up");
space->type = GST_COLORSPACE_HERMES; space->type = GST_COLORSPACE_HERMES;
return TRUE; return TRUE;
} }
#else #else
g_warning ("colorspace: compiled without hermes!"); g_warning ("colorspace: compiled without hermes!");
return FALSE; return FALSE;
#endif #endif
case GST_MAKE_FOURCC ('Y','V','1','2'): case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
if (from_bpp == 32) { if (from_bpp == 32) {
space->type = GST_COLORSPACE_RGB32_YV12; space->type = GST_COLORSPACE_RGB32_YV12;
space->destbpp = 12; space->destbpp = 12;
return TRUE; return TRUE;
} }
case GST_MAKE_FOURCC ('I','4','2','0'): case GST_MAKE_FOURCC ('I', '4', '2', '0'):
if (from_bpp == 32) { if (from_bpp == 32) {
space->type = GST_COLORSPACE_RGB32_I420; space->type = GST_COLORSPACE_RGB32_I420;
space->destbpp = 12; space->destbpp = 12;
return TRUE; return TRUE;
} }
case GST_MAKE_FOURCC ('Y','U','Y','2'): case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
GST_INFO ( "colorspace: RGB to YUV with bpp %d not implemented!!", from_bpp); GST_INFO ("colorspace: RGB to YUV with bpp %d not implemented!!",
from_bpp);
return FALSE; return FALSE;
} }
break; break;
} }
case GST_MAKE_FOURCC ('I','4','2','0'): case GST_MAKE_FOURCC ('I', '4', '2', '0'):
switch (to_space) { switch (to_space) {
case GST_MAKE_FOURCC ('R','G','B',' '): case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
GST_INFO ( "colorspace: YUV to RGB"); GST_INFO ("colorspace: YUV to RGB");
gst_structure_get_int (to_struct, "bpp", &space->destbpp); gst_structure_get_int (to_struct, "bpp", &space->destbpp);
space->converter = gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps); space->converter =
space->type = GST_COLORSPACE_YUV_RGB; gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
space->type = GST_COLORSPACE_YUV_RGB;
return TRUE; return TRUE;
case GST_MAKE_FOURCC ('I','4','2','0'): case GST_MAKE_FOURCC ('I', '4', '2', '0'):
space->type = GST_COLORSPACE_NONE; space->type = GST_COLORSPACE_NONE;
space->destbpp = 12; space->destbpp = 12;
return TRUE; return TRUE;
case GST_MAKE_FOURCC ('Y','V','1','2'): case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
space->type = GST_COLORSPACE_420_SWAP; space->type = GST_COLORSPACE_420_SWAP;
space->destbpp = 12; space->destbpp = 12;
return TRUE; return TRUE;
} }
break; break;
case GST_MAKE_FOURCC ('Y','U','Y','2'): case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
switch (to_space) { switch (to_space) {
case GST_MAKE_FOURCC ('I','4','2','0'): case GST_MAKE_FOURCC ('I', '4', '2', '0'):
space->type = GST_COLORSPACE_YUY2_I420; space->type = GST_COLORSPACE_YUY2_I420;
space->destbpp = 12; space->destbpp = 12;
return TRUE; return TRUE;
case GST_MAKE_FOURCC ('Y','U','Y','2'): case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
space->type = GST_COLORSPACE_NONE; space->type = GST_COLORSPACE_NONE;
space->destbpp = 16; space->destbpp = 16;
return TRUE; return TRUE;
case GST_MAKE_FOURCC ('R','G','B',' '): case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
GST_INFO ( "colorspace: YUY2 to RGB not implemented!!"); GST_INFO ("colorspace: YUY2 to RGB not implemented!!");
return FALSE; return FALSE;
} }
break; break;
case GST_MAKE_FOURCC ('Y','V','1','2'): case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
switch (to_space) { switch (to_space) {
case GST_MAKE_FOURCC ('R','G','B',' '): case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
GST_INFO ( "colorspace: YV12 to RGB"); GST_INFO ("colorspace: YV12 to RGB");
gst_structure_get_int (to_struct, "bpp", &space->destbpp); gst_structure_get_int (to_struct, "bpp", &space->destbpp);
space->converter = gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps); space->converter =
space->type = GST_COLORSPACE_YUV_RGB; gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
space->type = GST_COLORSPACE_YUV_RGB;
return TRUE; return TRUE;
case GST_MAKE_FOURCC ('I','4','2','0'): case GST_MAKE_FOURCC ('I', '4', '2', '0'):
space->type = GST_COLORSPACE_420_SWAP; space->type = GST_COLORSPACE_420_SWAP;
space->destbpp = 12; space->destbpp = 12;
return TRUE; return TRUE;
case GST_MAKE_FOURCC ('Y','V','1','2'): case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
space->type = GST_COLORSPACE_NONE; space->type = GST_COLORSPACE_NONE;
space->destbpp = 12; space->destbpp = 12;
return TRUE; return TRUE;
} }
@ -259,13 +259,13 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t
#endif #endif
static GstCaps * static GstCaps *
gst_colorspace_caps_remove_format_info (GstCaps *caps, const char *media_type) gst_colorspace_caps_remove_format_info (GstCaps * caps, const char *media_type)
{ {
int i; int i;
GstStructure *structure; GstStructure *structure;
GstCaps *rgbcaps; GstCaps *rgbcaps;
for (i=0; i<gst_caps_get_size (caps); i++) { for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i); structure = gst_caps_get_structure (caps, i);
gst_structure_set_name (structure, media_type); gst_structure_set_name (structure, media_type);
@ -284,14 +284,14 @@ gst_colorspace_caps_remove_format_info (GstCaps *caps, const char *media_type)
return rgbcaps; return rgbcaps;
} }
static GstCaps* static GstCaps *
gst_colorspace_getcaps (GstPad *pad) gst_colorspace_getcaps (GstPad * pad)
{ {
GstColorspace *space; GstColorspace *space;
GstPad *otherpad; GstPad *otherpad;
GstCaps *othercaps; GstCaps *othercaps;
GstCaps *caps; GstCaps *caps;
space = GST_COLORSPACE (gst_pad_get_parent (pad)); space = GST_COLORSPACE (gst_pad_get_parent (pad));
otherpad = (pad == space->srcpad) ? space->sinkpad : space->srcpad; otherpad = (pad == space->srcpad) ? space->sinkpad : space->srcpad;
@ -308,16 +308,16 @@ gst_colorspace_getcaps (GstPad *pad)
} }
static GstColorSpaceFormatType static GstColorSpaceFormatType
gst_colorspace_get_format (const GstCaps *caps) gst_colorspace_get_format (const GstCaps * caps)
{ {
int i; int i;
for(i=0; i<G_N_ELEMENTS (gst_colorspace_formats); i++) { for (i = 0; i < G_N_ELEMENTS (gst_colorspace_formats); i++) {
GstCaps *icaps; GstCaps *icaps;
GstCaps *fcaps; GstCaps *fcaps;
fcaps = gst_caps_copy (gst_static_caps_get ( fcaps =
&gst_colorspace_formats[i].caps)); gst_caps_copy (gst_static_caps_get (&gst_colorspace_formats[i].caps));
icaps = gst_caps_intersect (caps, fcaps); icaps = gst_caps_intersect (caps, fcaps);
if (!gst_caps_is_empty (icaps)) { if (!gst_caps_is_empty (icaps)) {
@ -327,7 +327,7 @@ gst_colorspace_get_format (const GstCaps *caps)
gst_caps_free (icaps); gst_caps_free (icaps);
} }
g_assert_not_reached(); g_assert_not_reached ();
return -1; return -1;
} }
@ -336,7 +336,7 @@ gst_colorspace_get_format (const GstCaps *caps)
#define ROUND_UP_8(x) (((x)+7)&~7) #define ROUND_UP_8(x) (((x)+7)&~7)
static int static int
gst_colorspace_format_get_size(GstColorSpaceFormatType index, int width, gst_colorspace_format_get_size (GstColorSpaceFormatType index, int width,
int height) int height)
{ {
int size; int size;
@ -345,22 +345,22 @@ gst_colorspace_format_get_size(GstColorSpaceFormatType index, int width,
case GST_COLORSPACE_I420: case GST_COLORSPACE_I420:
case GST_COLORSPACE_YV12: case GST_COLORSPACE_YV12:
size = ROUND_UP_4 (width) * ROUND_UP_2 (height); size = ROUND_UP_4 (width) * ROUND_UP_2 (height);
size += ROUND_UP_8 (width)/2 * ROUND_UP_2 (height)/2; size += ROUND_UP_8 (width) / 2 * ROUND_UP_2 (height) / 2;
size += ROUND_UP_8 (width)/2 * ROUND_UP_2 (height)/2; size += ROUND_UP_8 (width) / 2 * ROUND_UP_2 (height) / 2;
return size; return size;
break; break;
case GST_COLORSPACE_RGB32: case GST_COLORSPACE_RGB32:
return width*height*4; return width * height * 4;
break; break;
case GST_COLORSPACE_RGB24: case GST_COLORSPACE_RGB24:
return ROUND_UP_4 (width*3) * height; return ROUND_UP_4 (width * 3) * height;
break; break;
case GST_COLORSPACE_RGB16: case GST_COLORSPACE_RGB16:
return ROUND_UP_4 (width*2) * height; return ROUND_UP_4 (width * 2) * height;
break; break;
} }
g_assert_not_reached(); g_assert_not_reached ();
return 0; return 0;
} }
@ -370,18 +370,19 @@ gst_colorspace_get_converter (GstColorSpaceFormatType from,
{ {
int i; int i;
for (i=0; i<G_N_ELEMENTS (gst_colorspace_converters); i++) { for (i = 0; i < G_N_ELEMENTS (gst_colorspace_converters); i++) {
GstColorspaceConverter *converter = gst_colorspace_converters + i; GstColorspaceConverter *converter = gst_colorspace_converters + i;
if (from == converter->from && to == converter->to) { if (from == converter->from && to == converter->to) {
return i; return i;
} }
} }
g_assert_not_reached(); g_assert_not_reached ();
return -1; return -1;
} }
static GstPadLinkReturn static GstPadLinkReturn
gst_colorspace_link (GstPad *pad, const GstCaps *caps) gst_colorspace_link (GstPad * pad, const GstCaps * caps)
{ {
GstColorspace *space; GstColorspace *space;
GstPad *otherpad; GstPad *otherpad;
@ -402,23 +403,22 @@ gst_colorspace_link (GstPad *pad, const GstCaps *caps)
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
format_index = gst_colorspace_get_format (caps); format_index = gst_colorspace_get_format (caps);
g_print("format index is %d\n", format_index); g_print ("format index is %d\n", format_index);
gst_structure_get_int (structure, "width", &width); gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "height", &height); gst_structure_get_int (structure, "height", &height);
gst_structure_get_double (structure, "framerate", &fps); gst_structure_get_double (structure, "framerate", &fps);
GST_INFO ( "size: %dx%d", space->width, space->height); GST_INFO ("size: %dx%d", space->width, space->height);
if (gst_pad_is_negotiated (otherpad)) { if (gst_pad_is_negotiated (otherpad)) {
GstCaps *othercaps; GstCaps *othercaps;
othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad)); othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad));
gst_caps_set_simple (othercaps, gst_caps_set_simple (othercaps,
"width", G_TYPE_INT, width, "width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, "height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
"framerate", G_TYPE_DOUBLE, fps, NULL);
link_ret = gst_pad_try_set_caps (otherpad, othercaps); link_ret = gst_pad_try_set_caps (otherpad, othercaps);
if (link_ret != GST_PAD_LINK_OK) { if (link_ret != GST_PAD_LINK_OK) {
@ -433,20 +433,20 @@ gst_colorspace_link (GstPad *pad, const GstCaps *caps)
} }
if (gst_pad_is_negotiated (otherpad)) { if (gst_pad_is_negotiated (otherpad)) {
space->converter_index = gst_colorspace_get_converter ( space->converter_index =
space->sink_format_index, space->src_format_index); gst_colorspace_get_converter (space->sink_format_index,
space->src_format_index);
g_print("using index %d\n", space->converter_index); g_print ("using index %d\n", space->converter_index);
space->sink_size = gst_colorspace_format_get_size(space->sink_format_index, space->sink_size = gst_colorspace_format_get_size (space->sink_format_index,
width,height); width, height);
space->src_size = gst_colorspace_format_get_size(space->src_format_index, space->src_size = gst_colorspace_format_get_size (space->src_format_index,
width,height); width, height);
space->width = width; space->width = width;
space->height = height; space->height = height;
space->fps = fps; space->fps = fps;
} }
#if 0 #if 0
if (gst_pad_is_negotiated (otherpad)) { if (gst_pad_is_negotiated (otherpad)) {
g_warning ("could not get converter\n"); g_warning ("could not get converter\n");
@ -464,17 +464,19 @@ gst_colorspace_get_type (void)
if (!colorspace_type) { if (!colorspace_type) {
static const GTypeInfo colorspace_info = { static const GTypeInfo colorspace_info = {
sizeof(GstColorspaceClass), sizeof (GstColorspaceClass),
gst_colorspace_base_init, gst_colorspace_base_init,
NULL, NULL,
(GClassInitFunc)gst_colorspace_class_init, (GClassInitFunc) gst_colorspace_class_init,
NULL, NULL,
NULL, NULL,
sizeof(GstColorspace), sizeof (GstColorspace),
0, 0,
(GInstanceInitFunc)gst_colorspace_init, (GInstanceInitFunc) gst_colorspace_init,
}; };
colorspace_type = g_type_register_static(GST_TYPE_ELEMENT, "GstColorspace", &colorspace_info, 0); colorspace_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstColorspace",
&colorspace_info, 0);
} }
return colorspace_type; return colorspace_type;
} }
@ -483,54 +485,54 @@ static void
gst_colorspace_base_init (gpointer g_class) gst_colorspace_base_init (gpointer g_class)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_colorspace_src_template)); gst_static_pad_template_get (&gst_colorspace_src_template));
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_colorspace_sink_template)); gst_static_pad_template_get (&gst_colorspace_sink_template));
gst_element_class_set_details (element_class, &colorspace_details); gst_element_class_set_details (element_class, &colorspace_details);
} }
static void static void
gst_colorspace_class_init (GstColorspaceClass *klass) gst_colorspace_class_init (GstColorspaceClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass*)klass; gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_colorspace_set_property; gobject_class->set_property = gst_colorspace_set_property;
gobject_class->get_property = gst_colorspace_get_property; gobject_class->get_property = gst_colorspace_get_property;
gstelement_class->change_state = gst_colorspace_change_state; gstelement_class->change_state = gst_colorspace_change_state;
gst_colorspace_table_init(NULL); gst_colorspace_table_init (NULL);
} }
static void static void
gst_colorspace_init (GstColorspace *space) gst_colorspace_init (GstColorspace * space)
{ {
space->sinkpad = gst_pad_new_from_template ( space->sinkpad =
gst_static_pad_template_get (&gst_colorspace_sink_template), gst_pad_new_from_template (gst_static_pad_template_get
"sink"); (&gst_colorspace_sink_template), "sink");
gst_pad_set_link_function (space->sinkpad, gst_colorspace_link); gst_pad_set_link_function (space->sinkpad, gst_colorspace_link);
gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps); gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps);
gst_pad_set_chain_function(space->sinkpad,gst_colorspace_chain); gst_pad_set_chain_function (space->sinkpad, gst_colorspace_chain);
gst_element_add_pad(GST_ELEMENT(space),space->sinkpad); gst_element_add_pad (GST_ELEMENT (space), space->sinkpad);
space->srcpad = gst_pad_new_from_template ( space->srcpad =
gst_static_pad_template_get (&gst_colorspace_src_template), gst_pad_new_from_template (gst_static_pad_template_get
"src"); (&gst_colorspace_src_template), "src");
gst_element_add_pad(GST_ELEMENT(space),space->srcpad); gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
gst_pad_set_link_function (space->srcpad, gst_colorspace_link); gst_pad_set_link_function (space->srcpad, gst_colorspace_link);
} }
static void static void
gst_colorspace_chain (GstPad *pad,GstData *_data) gst_colorspace_chain (GstPad * pad, GstData * _data)
{ {
GstBuffer *buf = GST_BUFFER (_data); GstBuffer *buf = GST_BUFFER (_data);
GstColorspace *space; GstColorspace *space;
@ -542,7 +544,7 @@ gst_colorspace_chain (GstPad *pad,GstData *_data)
g_return_if_fail (buf != NULL); g_return_if_fail (buf != NULL);
space = GST_COLORSPACE (gst_pad_get_parent (pad)); space = GST_COLORSPACE (gst_pad_get_parent (pad));
g_return_if_fail (space != NULL); g_return_if_fail (space != NULL);
g_return_if_fail (GST_IS_COLORSPACE (space)); g_return_if_fail (GST_IS_COLORSPACE (space));
@ -552,10 +554,9 @@ gst_colorspace_chain (GstPad *pad,GstData *_data)
outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE, outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE,
space->src_size); space->src_size);
converter = gst_colorspace_converters + space->converter_index; converter = gst_colorspace_converters + space->converter_index;
converter->convert (space, GST_BUFFER_DATA (outbuf), converter->convert (space, GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf));
GST_BUFFER_DATA (buf));
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf); GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
@ -565,7 +566,7 @@ gst_colorspace_chain (GstPad *pad,GstData *_data)
} }
static GstElementStateReturn static GstElementStateReturn
gst_colorspace_change_state (GstElement *element) gst_colorspace_change_state (GstElement * element)
{ {
GstColorspace *space; GstColorspace *space;
@ -584,13 +585,14 @@ gst_colorspace_change_state (GstElement *element)
} }
static void static void
gst_colorspace_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_colorspace_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{ {
GstColorspace *space; GstColorspace *space;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_COLORSPACE(object)); g_return_if_fail (GST_IS_COLORSPACE (object));
space = GST_COLORSPACE(object); space = GST_COLORSPACE (object);
switch (prop_id) { switch (prop_id) {
default: default:
@ -599,13 +601,14 @@ gst_colorspace_set_property (GObject *object, guint prop_id, const GValue *value
} }
static void static void
gst_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) gst_colorspace_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{ {
GstColorspace *space; GstColorspace *space;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_COLORSPACE(object)); g_return_if_fail (GST_IS_COLORSPACE (object));
space = GST_COLORSPACE(object); space = GST_COLORSPACE (object);
switch (prop_id) { switch (prop_id) {
default: default:
@ -615,22 +618,17 @@ gst_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GPar
} }
static gboolean static gboolean
plugin_init (GstPlugin *plugin) plugin_init (GstPlugin * plugin)
{ {
if (!gst_element_register (plugin, "colorspace", GST_RANK_PRIMARY, if (!gst_element_register (plugin, "colorspace", GST_RANK_PRIMARY,
GST_TYPE_COLORSPACE)) GST_TYPE_COLORSPACE))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
GST_PLUGIN_DEFINE ( GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MAJOR, GST_VERSION_MINOR,
GST_VERSION_MINOR, "colorspace",
"colorspace", "internal colorspace converter",
"internal colorspace converter", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN)

View file

@ -23,7 +23,6 @@
#include <gst/gst.h> #include <gst/gst.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define GST_TYPE_COLORSPACE \ #define GST_TYPE_COLORSPACE \
(gst_colorspace_get_type()) (gst_colorspace_get_type())
#define GST_COLORSPACE(obj) \ #define GST_COLORSPACE(obj) \
@ -34,11 +33,11 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COLORSPACE)) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COLORSPACE))
#define GST_IS_COLORSPACE_CLASS(obj) \ #define GST_IS_COLORSPACE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COLORSPACE)) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COLORSPACE))
typedef struct _GstColorspace GstColorspace; typedef struct _GstColorspace GstColorspace;
typedef struct _GstColorspaceClass GstColorspaceClass; typedef struct _GstColorspaceClass GstColorspaceClass;
typedef enum { typedef enum
{
GST_COLORSPACE_NONE, GST_COLORSPACE_NONE,
GST_COLORSPACE_HERMES, GST_COLORSPACE_HERMES,
GST_COLORSPACE_YUV_RGB, GST_COLORSPACE_YUV_RGB,
@ -48,10 +47,11 @@ typedef enum {
GST_COLORSPACE_420_SWAP, GST_COLORSPACE_420_SWAP,
} GstColorSpaceConverterType; } GstColorSpaceConverterType;
struct _GstColorspace { struct _GstColorspace
{
GstElement element; GstElement element;
GstPad *sinkpad,*srcpad; GstPad *sinkpad, *srcpad;
int converter_index; int converter_index;
@ -60,7 +60,7 @@ struct _GstColorspace {
int src_size; int src_size;
int sink_size; int sink_size;
int src_stride; int src_stride;
int sink_stride; int sink_stride;
@ -68,18 +68,21 @@ struct _GstColorspace {
gdouble fps; gdouble fps;
}; };
struct _GstColorspaceClass { struct _GstColorspaceClass
{
GstElementClass parent_class; GstElementClass parent_class;
}; };
GType gst_colorspace_get_type(void); GType gst_colorspace_get_type (void);
typedef struct _GstColorspaceFormat { typedef struct _GstColorspaceFormat
{
GstStaticCaps caps; GstStaticCaps caps;
} GstColorspaceFormat; } GstColorspaceFormat;
typedef enum { typedef enum
{
GST_COLORSPACE_I420, GST_COLORSPACE_I420,
GST_COLORSPACE_YV12, GST_COLORSPACE_YV12,
GST_COLORSPACE_RGB32, GST_COLORSPACE_RGB32,
@ -87,13 +90,13 @@ typedef enum {
GST_COLORSPACE_RGB16, GST_COLORSPACE_RGB16,
} GstColorSpaceFormatType; } GstColorSpaceFormatType;
typedef struct _GstColorspaceConverter { typedef struct _GstColorspaceConverter
{
GstColorSpaceFormatType from; GstColorSpaceFormatType from;
GstColorSpaceFormatType to; GstColorSpaceFormatType to;
void (*convert) (GstColorspace *colorspace, unsigned char *dest, unsigned char *src); void (*convert) (GstColorspace * colorspace, unsigned char *dest,
unsigned char *src);
} GstColorspaceConverter; } GstColorspaceConverter;
G_END_DECLS G_END_DECLS
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -26,11 +26,11 @@
#include <gstcolorspace.h> #include <gstcolorspace.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#if 0 #if 0
typedef struct _GstColorspaceYUVTables GstColorspaceYUVTables; typedef struct _GstColorspaceYUVTables GstColorspaceYUVTables;
struct _GstColorspaceYUVTables { struct _GstColorspaceYUVTables
{
int gammaCorrectFlag; int gammaCorrectFlag;
double gammaCorrect; double gammaCorrect;
int chromaCorrectFlag; int chromaCorrectFlag;
@ -50,9 +50,11 @@ struct _GstColorspaceYUVTables {
typedef struct _GstColorspaceConverter GstColorspaceConverter; typedef struct _GstColorspaceConverter GstColorspaceConverter;
typedef void (*GstColorspaceConvertFunction) (GstColorspaceConverter *space, guchar *src, guchar *dest); typedef void (*GstColorspaceConvertFunction) (GstColorspaceConverter * space,
guchar * src, guchar * dest);
struct _GstColorspaceConverter { struct _GstColorspaceConverter
{
guint width; guint width;
guint height; guint height;
guint insize; guint insize;
@ -63,35 +65,34 @@ struct _GstColorspaceConverter {
}; };
#endif #endif
void gst_colorspace_table_init (GstColorspace *space); void gst_colorspace_table_init (GstColorspace * space);
void gst_colorspace_I420_to_rgb32(GstColorspace *space, void gst_colorspace_I420_to_rgb32 (GstColorspace * space,
unsigned char *src, unsigned char *dest); unsigned char *src, unsigned char *dest);
void gst_colorspace_I420_to_rgb24(GstColorspace *space, void gst_colorspace_I420_to_rgb24 (GstColorspace * space,
unsigned char *src, unsigned char *dest); unsigned char *src, unsigned char *dest);
void gst_colorspace_I420_to_rgb16(GstColorspace *space, void gst_colorspace_I420_to_rgb16 (GstColorspace * space,
unsigned char *src, unsigned char *dest); unsigned char *src, unsigned char *dest);
void gst_colorspace_YV12_to_rgb32(GstColorspace *space, void gst_colorspace_YV12_to_rgb32 (GstColorspace * space,
unsigned char *src, unsigned char *dest); unsigned char *src, unsigned char *dest);
void gst_colorspace_YV12_to_rgb24(GstColorspace *space, void gst_colorspace_YV12_to_rgb24 (GstColorspace * space,
unsigned char *src, unsigned char *dest); unsigned char *src, unsigned char *dest);
void gst_colorspace_YV12_to_rgb16(GstColorspace *space, void gst_colorspace_YV12_to_rgb16 (GstColorspace * space,
unsigned char *src, unsigned char *dest); unsigned char *src, unsigned char *dest);
#if 0 #if 0
GstColorspaceYUVTables * gst_colorspace_init_yuv(long depth, GstColorspaceYUVTables *gst_colorspace_init_yuv (long depth,
long red_mask, long green_mask, long blue_mask); long red_mask, long green_mask, long blue_mask);
#endif #endif
#if 0 #if 0
GstColorspaceConverter* gst_colorspace_yuv2rgb_get_converter (const GstCaps *from, const GstCaps *to); GstColorspaceConverter *gst_colorspace_yuv2rgb_get_converter (const GstCaps *
from, const GstCaps * to);
#define gst_colorspace_convert(converter, src, dest) \ #define gst_colorspace_convert(converter, src, dest) \
(converter)->convert((converter), (src), (dest)) (converter)->convert((converter), (src), (dest))
void gst_colorspace_converter_destroy (GstColorspaceConverter *space); void gst_colorspace_converter_destroy (GstColorspaceConverter * space);
#endif #endif
G_END_DECLS G_END_DECLS
#endif #endif