summaryrefslogtreecommitdiffstats
path: root/gst/flx
diff options
context:
space:
mode:
Diffstat (limited to 'gst/flx')
-rw-r--r--gst/flx/flx_color.c58
-rw-r--r--gst/flx/flx_color.h28
-rw-r--r--gst/flx/flx_fmt.h197
-rw-r--r--gst/flx/gstflxdec.c565
-rw-r--r--gst/flx/gstflxdec.h60
5 files changed, 454 insertions, 454 deletions
diff --git a/gst/flx/flx_color.c b/gst/flx/flx_color.c
index b64c90c4..73846845 100644
--- a/gst/flx/flx_color.c
+++ b/gst/flx/flx_color.c
@@ -27,40 +27,41 @@
#include "flx_color.h"
FlxColorSpaceConverter *
-flx_colorspace_converter_new(gint width, gint height)
+flx_colorspace_converter_new (gint width, gint height)
{
- FlxColorSpaceConverter *new = g_malloc(sizeof(FlxColorSpaceConverter));
+ FlxColorSpaceConverter *new = g_malloc (sizeof (FlxColorSpaceConverter));
new->width = width;
new->height = height;
- memset(new->palvec, 0, sizeof(new->palvec));
+ memset (new->palvec, 0, sizeof (new->palvec));
return new;
}
void
-flx_colorspace_converter_destroy(FlxColorSpaceConverter *flxpal)
+flx_colorspace_converter_destroy (FlxColorSpaceConverter * flxpal)
{
- g_return_if_fail(flxpal != NULL);
+ g_return_if_fail (flxpal != NULL);
- g_free(flxpal);
+ g_free (flxpal);
}
void
-flx_colorspace_convert(FlxColorSpaceConverter *flxpal, guchar *src, guchar *dest)
+flx_colorspace_convert (FlxColorSpaceConverter * flxpal, guchar * src,
+ guchar * dest)
{
guint size, col;
- g_return_if_fail(flxpal != NULL);
- g_return_if_fail(src != dest);
+ g_return_if_fail (flxpal != NULL);
+ g_return_if_fail (src != dest);
size = flxpal->width * flxpal->height;
- while(size--) {
- col = (*src++ * 3);
- *dest++ = flxpal->palvec[col+2];
- *dest++ = flxpal->palvec[col+1];
+ while (size--) {
+ col = (*src++ * 3);
+ *dest++ = flxpal->palvec[col + 2];
+ *dest++ = flxpal->palvec[col + 1];
*dest++ = flxpal->palvec[col];
*dest++ = 0;
}
@@ -68,13 +69,14 @@ flx_colorspace_convert(FlxColorSpaceConverter *flxpal, guchar *src, guchar *dest
}
-void
-flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num, guchar *newpal, gint scale)
+void
+flx_set_palette_vector (FlxColorSpaceConverter * flxpal, guint start, guint num,
+ guchar * newpal, gint scale)
{
- guint grab;
-
- g_return_if_fail(flxpal != NULL);
- g_return_if_fail(start < 0x100);
+ guint grab;
+
+ g_return_if_fail (flxpal != NULL);
+ g_return_if_fail (start < 0x100);
grab = ((start + num) > 0x100 ? 0x100 - start : num);
@@ -88,23 +90,21 @@ flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num, g
flxpal->palvec[start++] = newpal[i++] << scale;
grab--;
}
- }
- else {
- memcpy(&flxpal->palvec[start * 3], newpal, grab * 3);
+ } else {
+ memcpy (&flxpal->palvec[start * 3], newpal, grab * 3);
}
}
void
-flx_set_color(FlxColorSpaceConverter *flxpal, guint colr, guint red, guint green, guint blue, gint scale)
+flx_set_color (FlxColorSpaceConverter * flxpal, guint colr, guint red,
+ guint green, guint blue, gint scale)
{
-
- g_return_if_fail(flxpal != NULL);
- g_return_if_fail(colr < 0x100);
- flxpal->palvec[(colr * 3)] = red << scale;
+ g_return_if_fail (flxpal != NULL);
+ g_return_if_fail (colr < 0x100);
+
+ flxpal->palvec[(colr * 3)] = red << scale;
flxpal->palvec[(colr * 3) + 1] = green << scale;
flxpal->palvec[(colr * 3) + 2] = blue << scale;
}
-
-
diff --git a/gst/flx/flx_color.h b/gst/flx/flx_color.h
index d423ab87..2ad852fa 100644
--- a/gst/flx/flx_color.h
+++ b/gst/flx/flx_color.h
@@ -17,7 +17,8 @@
* Boston, MA 02111-1307, USA.
*/
-typedef enum {
+typedef enum
+{
FLX_COLORSPACE_RGB8,
FLX_COLORSPACE_RGB32,
} FlxColorSpaceType;
@@ -25,19 +26,20 @@ typedef enum {
typedef struct _FlxColorSpaceConverter FlxColorSpaceConverter;
-struct _FlxColorSpaceConverter {
- guint width;
- guint height;
- guchar palvec[768];
+struct _FlxColorSpaceConverter
+{
+ guint width;
+ guint height;
+ guchar palvec[768];
};
-void flx_colorspace_converter_destroy(FlxColorSpaceConverter *flxpal);
-void flx_colorspace_convert(FlxColorSpaceConverter *flxpal, guchar *src, guchar *dest);
-FlxColorSpaceConverter * flx_colorspace_converter_new(gint width, gint height);
-
-void flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num,
- guchar *newpal, gint scale);
-void flx_set_color(FlxColorSpaceConverter *flxpal, guint colr, guint red, guint green,
- guint blue, gint scale);
+void flx_colorspace_converter_destroy (FlxColorSpaceConverter * flxpal);
+void flx_colorspace_convert (FlxColorSpaceConverter * flxpal, guchar * src,
+ guchar * dest);
+FlxColorSpaceConverter *flx_colorspace_converter_new (gint width, gint height);
+void flx_set_palette_vector (FlxColorSpaceConverter * flxpal, guint start,
+ guint num, guchar * newpal, gint scale);
+void flx_set_color (FlxColorSpaceConverter * flxpal, guint colr, guint red,
+ guint green, guint blue, gint scale);
diff --git a/gst/flx/flx_fmt.h b/gst/flx/flx_fmt.h
index ac2062ed..1457551a 100644
--- a/gst/flx/flx_fmt.h
+++ b/gst/flx/flx_fmt.h
@@ -24,113 +24,114 @@
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-enum Flx_TypeChunk
-{
- /* frame chunks */
- FLX_PREFIX_TYPE = 0xf100,
- FLX_SCRIPT_CHUNK = 0xf1e0,
- FLX_FRAME_TYPE = 0xf1fa,
- FLX_SEGMENT_TABLE = 0xf1fb,
- FLX_HUFFMAN_TABLE = 0xf1fc,
-
- /* sub chunks */
- FLX_CEL_DATA = 3,
- FLX_COLOR256 = 4,
- FLX_SS2 = 7,
- FLX_COLOR64 = 11,
- FLX_LC = 12,
- FLX_BLACK = 13,
- FLX_BRUN = 15,
- FLX_COPY = 16,
- FLX_MINI = 18,
- FLX_DTA_RUN = 25,
- FLX_DTA_COPY = 26,
- FLX_DTA_LC = 27,
- FLX_LABEL = 31,
- FLX_BMP_MASK = 32,
- FLX_MLEV_MASK = 33,
- FLX_SEGMENT = 34,
- FLX_KEY_IMAGE = 35,
- FLX_KEY_PAL = 36,
- FLX_REGION = 37,
- FLX_WAVE = 38,
- FLX_USERSTRING = 39,
- FLX_RGN_MASK = 40,
-
-};
-
-enum Flx_MagicHdr
+extern "C"
{
- FLX_MAGICHDR_FLI = 0xaf11,
- FLX_MAGICHDR_FLC = 0xaf12,
- FLX_MAGICHDR_FLX = 0xaf44,
- FLX_MAGICHDR_HUFFBWT = 0xaf30,
-};
-
-
-
-typedef struct _FlxHeader
-{
- guint32 size;
- guint16 type;
- guint16 frames;
- guint16 width,height,depth,flags;
- guint32 speed;
- guint16 reserved1;
- /* FLC */
- guint32 created,creator,updated,updater;
- guint16 aspect_dx, aspect_dy;
- /* EGI */
- guint16 ext_flags,keyframes,totalframes;
- guint32 req_memory;
- guint16 max_regions,transp_num;
- guchar reserved2[24];
- /* FLC */
- guint32 oframe1,oframe2;
- guchar reserved3[40];
-} FlxHeader;
+#endif /* __cplusplus */
+
+ enum Flx_TypeChunk
+ {
+ /* frame chunks */
+ FLX_PREFIX_TYPE = 0xf100,
+ FLX_SCRIPT_CHUNK = 0xf1e0,
+ FLX_FRAME_TYPE = 0xf1fa,
+ FLX_SEGMENT_TABLE = 0xf1fb,
+ FLX_HUFFMAN_TABLE = 0xf1fc,
+
+ /* sub chunks */
+ FLX_CEL_DATA = 3,
+ FLX_COLOR256 = 4,
+ FLX_SS2 = 7,
+ FLX_COLOR64 = 11,
+ FLX_LC = 12,
+ FLX_BLACK = 13,
+ FLX_BRUN = 15,
+ FLX_COPY = 16,
+ FLX_MINI = 18,
+ FLX_DTA_RUN = 25,
+ FLX_DTA_COPY = 26,
+ FLX_DTA_LC = 27,
+ FLX_LABEL = 31,
+ FLX_BMP_MASK = 32,
+ FLX_MLEV_MASK = 33,
+ FLX_SEGMENT = 34,
+ FLX_KEY_IMAGE = 35,
+ FLX_KEY_PAL = 36,
+ FLX_REGION = 37,
+ FLX_WAVE = 38,
+ FLX_USERSTRING = 39,
+ FLX_RGN_MASK = 40,
+
+ };
+
+ enum Flx_MagicHdr
+ {
+ FLX_MAGICHDR_FLI = 0xaf11,
+ FLX_MAGICHDR_FLC = 0xaf12,
+ FLX_MAGICHDR_FLX = 0xaf44,
+ FLX_MAGICHDR_HUFFBWT = 0xaf30,
+ };
+
+
+
+ typedef struct _FlxHeader
+ {
+ guint32 size;
+ guint16 type;
+ guint16 frames;
+ guint16 width, height, depth, flags;
+ guint32 speed;
+ guint16 reserved1;
+ /* FLC */
+ guint32 created, creator, updated, updater;
+ guint16 aspect_dx, aspect_dy;
+ /* EGI */
+ guint16 ext_flags, keyframes, totalframes;
+ guint32 req_memory;
+ guint16 max_regions, transp_num;
+ guchar reserved2[24];
+ /* FLC */
+ guint32 oframe1, oframe2;
+ guchar reserved3[40];
+ } FlxHeader;
#define FlxHeaderSize 128
-typedef struct _FlxFrameChunk
-{
- guint32 size;
- guint16 id;
-} FlxFrameChunk;
+ typedef struct _FlxFrameChunk
+ {
+ guint32 size;
+ guint16 id;
+ } FlxFrameChunk;
#define FlxFrameChunkSize 6
-typedef struct _FlxPrefixChunk
-{
- guint16 chunks;
- guchar reserved[8];
-} FlxPrefixChunk;
-
-typedef struct _FlxSegmentTable
-{
- guint16 segments;
-} FlxSegmentTable;
-
-typedef struct _FlxHuffmanTable
-{
- guint16 codelength;
- guint16 numcodes;
- guchar reserved[6];
-} FlxHuffmanTable;
-
-typedef struct _FlxFrameType
-{
- guint16 chunks;
- guint16 delay;
- guchar reserved[6];
-} FlxFrameType;
+ typedef struct _FlxPrefixChunk
+ {
+ guint16 chunks;
+ guchar reserved[8];
+ } FlxPrefixChunk;
+
+ typedef struct _FlxSegmentTable
+ {
+ guint16 segments;
+ } FlxSegmentTable;
+
+ typedef struct _FlxHuffmanTable
+ {
+ guint16 codelength;
+ guint16 numcodes;
+ guchar reserved[6];
+ } FlxHuffmanTable;
+
+ typedef struct _FlxFrameType
+ {
+ guint16 chunks;
+ guint16 delay;
+ guchar reserved[6];
+ } FlxFrameType;
#define FlxFrameTypeSize 10
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_FLX_FMT_H__ */
+#endif /* __GST_FLX_FMT_H__ */
diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c
index aaddee58..a84ce2d2 100644
--- a/gst/flx/gstflxdec.c
+++ b/gst/flx/gstflxdec.c
@@ -37,120 +37,122 @@ static GstElementDetails flxdec_details = {
};
/* Flx signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
};
/* input */
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "video/x-fli" )
-);
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-fli")
+ );
/* output */
-static GstStaticPadTemplate src_video_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_VIDEO_CAPS_xRGB_HOST_ENDIAN )
-);
+static GstStaticPadTemplate src_video_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN)
+ );
-static void gst_flxdec_class_init (GstFlxDecClass *klass);
-static void gst_flxdec_base_init (GstFlxDecClass *klass);
-static void gst_flxdec_init (GstFlxDec *flxdec);
+static void gst_flxdec_class_init (GstFlxDecClass * klass);
+static void gst_flxdec_base_init (GstFlxDecClass * klass);
+static void gst_flxdec_init (GstFlxDec * flxdec);
-static void gst_flxdec_loop (GstElement *element);
+static void gst_flxdec_loop (GstElement * element);
-static GstElementStateReturn
- gst_flxdec_change_state (GstElement *element);
+static GstElementStateReturn gst_flxdec_change_state (GstElement * element);
-static void gst_flxdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_flxdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_flxdec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_flxdec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void flx_decode_color (GstFlxDec *, guchar *, guchar *, gint);
-static void flx_decode_brun (GstFlxDec *, guchar *, guchar *);
-static void flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
-static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
+static void flx_decode_color (GstFlxDec *, guchar *, guchar *, gint);
+static void flx_decode_brun (GstFlxDec *, guchar *, guchar *);
+static void flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
+static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
#define rndalign(off) ((off) + ((off) % 2))
static GstElementClass *parent_class = NULL;
GType
-gst_flxdec_get_type(void)
+gst_flxdec_get_type (void)
{
static GType flxdec_type = 0;
if (!flxdec_type) {
static const GTypeInfo flxdec_info = {
- sizeof(GstFlxDecClass),
- (GBaseInitFunc)gst_flxdec_base_init,
+ sizeof (GstFlxDecClass),
+ (GBaseInitFunc) gst_flxdec_base_init,
NULL,
- (GClassInitFunc)gst_flxdec_class_init,
+ (GClassInitFunc) gst_flxdec_class_init,
NULL,
NULL,
- sizeof(GstFlxDec),
+ sizeof (GstFlxDec),
0,
- (GInstanceInitFunc)gst_flxdec_init,
+ (GInstanceInitFunc) gst_flxdec_init,
};
- flxdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstFlxDec", &flxdec_info, 0);
+ flxdec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstFlxDec", &flxdec_info, 0);
}
return flxdec_type;
}
static void
-gst_flxdec_base_init (GstFlxDecClass *klass)
+gst_flxdec_base_init (GstFlxDecClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
-
+
gst_element_class_set_details (gstelement_class, &flxdec_details);
gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&sink_factory));
+ gst_static_pad_template_get (&sink_factory));
gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&src_video_factory));
+ gst_static_pad_template_get (&src_video_factory));
}
-static void
-gst_flxdec_class_init (GstFlxDecClass *klass)
+static void
+gst_flxdec_class_init (GstFlxDecClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) 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_flxdec_set_property;
+ gobject_class->set_property = gst_flxdec_set_property;
gobject_class->get_property = gst_flxdec_get_property;
gstelement_class->change_state = gst_flxdec_change_state;
}
-
-static void
-gst_flxdec_init(GstFlxDec *flxdec)
+
+static void
+gst_flxdec_init (GstFlxDec * flxdec)
{
- flxdec->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_factory), "sink");
- gst_element_add_pad(GST_ELEMENT(flxdec),flxdec->sinkpad);
- gst_element_set_loop_function(GST_ELEMENT(flxdec),gst_flxdec_loop);
+ flxdec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (flxdec), flxdec->sinkpad);
+ gst_element_set_loop_function (GST_ELEMENT (flxdec), gst_flxdec_loop);
- flxdec->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_video_factory), "src");
- gst_element_add_pad(GST_ELEMENT(flxdec),flxdec->srcpad);
+ flxdec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&src_video_factory), "src");
+ gst_element_add_pad (GST_ELEMENT (flxdec), flxdec->srcpad);
flxdec->bs = NULL;
flxdec->frame = NULL;
@@ -158,75 +160,74 @@ gst_flxdec_init(GstFlxDec *flxdec)
}
static void
-flx_decode_chunks (GstFlxDec *flxdec , gulong count, gchar *data, gchar *dest)
+flx_decode_chunks (GstFlxDec * flxdec, gulong count, gchar * data, gchar * dest)
{
- FlxFrameChunk *hdr;
+ FlxFrameChunk *hdr;
- g_return_if_fail(data != NULL);
+ g_return_if_fail (data != NULL);
while (count--) {
- hdr = (FlxFrameChunk *) data;
+ hdr = (FlxFrameChunk *) data;
data += FlxFrameChunkSize;
- switch(hdr->id)
- {
+ switch (hdr->id) {
case FLX_COLOR64:
- flx_decode_color(flxdec, data, dest, 2);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_color (flxdec, data, dest, 2);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_COLOR256:
- flx_decode_color(flxdec, data, dest, 0);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_color (flxdec, data, dest, 0);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_BRUN:
- flx_decode_brun(flxdec, data, dest);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_brun (flxdec, data, dest);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_LC:
- flx_decode_delta_fli(flxdec, data, dest);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_delta_fli (flxdec, data, dest);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_SS2:
- flx_decode_delta_flc(flxdec, data, dest);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_delta_flc (flxdec, data, dest);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_BLACK:
- memset(dest, 0, flxdec->size);
- break;
+ memset (dest, 0, flxdec->size);
+ break;
case FLX_MINI:
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
default:
- g_print("GstFlxDec: Unimplented chunk type: 0x%02x size: %d\n",
- hdr->id, hdr->size);
- g_print("GstFlxDec: Skipping...\n");
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ g_print ("GstFlxDec: Unimplented chunk type: 0x%02x size: %d\n",
+ hdr->id, hdr->size);
+ g_print ("GstFlxDec: Skipping...\n");
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
}
}
}
static void
-flx_decode_color(GstFlxDec *flxdec, guchar *data, guchar *dest, gint scale)
+flx_decode_color (GstFlxDec * flxdec, guchar * data, guchar * dest, gint scale)
{
guint packs, count, indx;
- g_return_if_fail(flxdec != NULL);
+ g_return_if_fail (flxdec != NULL);
packs = (data[0] + (data[1] << 8));
data += 2;
- indx = 0;
+ indx = 0;
- g_print("GstFlxDec: cmap packs: %d\n", packs);
+ g_print ("GstFlxDec: cmap packs: %d\n", packs);
while (packs--) {
/* color map index + skip count */
indx += *data++;
@@ -236,23 +237,23 @@ flx_decode_color(GstFlxDec *flxdec, guchar *data, guchar *dest, gint scale)
if (count == 0)
count = 256;
- g_print("GstFlxDec: cmap count: %d (indx: %d)\n", count, indx);
- flx_set_palette_vector(flxdec->converter, indx, count, data, scale);
+ g_print ("GstFlxDec: cmap count: %d (indx: %d)\n", count, indx);
+ flx_set_palette_vector (flxdec->converter, indx, count, data, scale);
data += (count * 3);
}
}
-static void
-flx_decode_brun(GstFlxDec *flxdec, guchar *data, guchar *dest)
+static void
+flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
{
- gulong count, lines, row;
- guchar x;
-
- g_return_if_fail(flxdec != NULL);
+ gulong count, lines, row;
+ guchar x;
+
+ g_return_if_fail (flxdec != NULL);
lines = flxdec->hdr.height;
- while(lines--) {
+ while (lines--) {
/* packet count.
* should not be used anymore, since the flc format can
* contain more then 255 RLE packets. we use the frame
@@ -261,101 +262,101 @@ flx_decode_brun(GstFlxDec *flxdec, guchar *data, guchar *dest)
data++;
row = flxdec->hdr.width;
- while(row) {
+ while (row) {
count = *data++;
- if (count > 0x7f) {
- /* literal run */
- count = 0x100 - count;
- row -= count;
+ if (count > 0x7f) {
+ /* literal run */
+ count = 0x100 - count;
+ row -= count;
+
+ while (count--)
+ *dest++ = *data++;
- while(count--)
- *dest++ = *data++;
-
} else {
- /* replicate run */
- row -= count;
- x = *data++;
+ /* replicate run */
+ row -= count;
+ x = *data++;
- while(count--)
- *dest++ = x;
+ while (count--)
+ *dest++ = x;
}
}
}
}
-static void
-flx_decode_delta_fli(GstFlxDec *flxdec, guchar *data, guchar *dest)
+static void
+flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
{
- gulong count, packets, lines, start_line, start_l;
- guchar *start_p, x;
-
- g_return_if_fail(flxdec != NULL);
- g_return_if_fail(flxdec->delta != NULL);
+ gulong count, packets, lines, start_line, start_l;
+ guchar *start_p, x;
+
+ g_return_if_fail (flxdec != NULL);
+ g_return_if_fail (flxdec->delta != NULL);
/* use last frame for delta */
- memcpy(dest, GST_BUFFER_DATA(flxdec->delta),
- GST_BUFFER_SIZE(flxdec->delta));
+ memcpy (dest, GST_BUFFER_DATA (flxdec->delta),
+ GST_BUFFER_SIZE (flxdec->delta));
start_line = (data[0] + (data[1] << 8));
- lines = (data[2] + (data[3] << 8));
- data += 4;
+ lines = (data[2] + (data[3] << 8));
+ data += 4;
/* start position of delta */
dest += (flxdec->hdr.width * start_line);
start_p = dest;
start_l = lines;
- while(lines--) {
+ while (lines--) {
/* packet count */
packets = *data++;
- while(packets--) {
+ while (packets--) {
/* skip count */
dest += *data++;
/* RLE count */
count = *data++;
- if (count > 0x7f) {
- /* literal run */
- count = 0x100 - count;
- x = *data++;
+ if (count > 0x7f) {
+ /* literal run */
+ count = 0x100 - count;
+ x = *data++;
- while (count--)
- *dest++ = x;
+ while (count--)
+ *dest++ = x;
} else {
- /* replicate run */
- while (count--)
- *dest++ = *data++;
+ /* replicate run */
+ while (count--)
+ *dest++ = *data++;
}
}
start_p += flxdec->hdr.width;
dest = start_p;
- }
+ }
}
-static void
-flx_decode_delta_flc(GstFlxDec *flxdec, guchar *data, guchar *dest)
+static void
+flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
{
- gulong count, lines, start_l, opcode;
- guchar *start_p;
-
- g_return_if_fail(flxdec != NULL);
- g_return_if_fail(flxdec->delta != NULL);
+ gulong count, lines, start_l, opcode;
+ guchar *start_p;
+
+ g_return_if_fail (flxdec != NULL);
+ g_return_if_fail (flxdec->delta != NULL);
/* use last frame for delta */
- memcpy(dest, GST_BUFFER_DATA(flxdec->delta),
- GST_BUFFER_SIZE(flxdec->delta));
+ memcpy (dest, GST_BUFFER_DATA (flxdec->delta),
+ GST_BUFFER_SIZE (flxdec->delta));
- lines = (data[0] + (data[1] << 8));
- data += 2;
+ lines = (data[0] + (data[1] << 8));
+ data += 2;
- start_p = dest;
- start_l = lines;
+ start_p = dest;
+ start_l = lines;
while (lines) {
dest = start_p + (flxdec->hdr.width * (start_l - lines));
@@ -364,47 +365,47 @@ flx_decode_delta_flc(GstFlxDec *flxdec, guchar *data, guchar *dest)
while ((opcode = (data[0] + (data[1] << 8))) & 0xc000) {
data += 2;
if ((opcode & 0xc000) == 0xc000) {
- /* skip count */
- start_l += (0x10000 - opcode);
- dest += flxdec->hdr.width * (0x10000 - opcode);
+ /* skip count */
+ start_l += (0x10000 - opcode);
+ dest += flxdec->hdr.width * (0x10000 - opcode);
} else {
- /* last pixel */
- dest += flxdec->hdr.width;
- *dest++ = (opcode & 0xff);
- }
+ /* last pixel */
+ dest += flxdec->hdr.width;
+ *dest++ = (opcode & 0xff);
+ }
}
data += 2;
/* last opcode is the packet count */
- while(opcode--) {
+ while (opcode--) {
/* skip count */
dest += *data++;
-
+
/* RLE count */
count = *data++;
-
+
if (count > 0x7f) {
- /* replicate word run */
- count = 0x100 - count;
- while (count--) {
- *dest++ = data[0];
- *dest++ = data[1];
- }
- data += 2;
+ /* replicate word run */
+ count = 0x100 - count;
+ while (count--) {
+ *dest++ = data[0];
+ *dest++ = data[1];
+ }
+ data += 2;
} else {
- /* literal word run */
- while (count--) {
- *dest++ = *data++;
- *dest++ = *data++;
- }
+ /* literal word run */
+ while (count--) {
+ *dest++ = *data++;
+ *dest++ = *data++;
+ }
}
}
lines--;
}
}
-
-static GstBuffer*
-flx_get_data(GstFlxDec *flxdec, gulong size)
+
+static GstBuffer *
+flx_get_data (GstFlxDec * flxdec, gulong size)
{
GstBuffer *retbuf;
guint32 got_bytes;
@@ -424,36 +425,36 @@ flx_get_data(GstFlxDec *flxdec, gulong size)
}
-static void
-gst_flxdec_loop (GstElement *element)
+static void
+gst_flxdec_loop (GstElement * element)
{
- GstBuffer *buf;
- GstBuffer *databuf;
- guchar *data, *chunk;
- GstCaps *caps;
-
- GstFlxDec *flxdec;
- FlxHeader *flxh;
- FlxFrameChunk *flxfh;
-
+ GstBuffer *buf;
+ GstBuffer *databuf;
+ guchar *data, *chunk;
+ GstCaps *caps;
+
+ GstFlxDec *flxdec;
+ FlxHeader *flxh;
+ FlxFrameChunk *flxfh;
+
g_return_if_fail (element != NULL);
- g_return_if_fail (GST_IS_FLXDEC(element));
+ g_return_if_fail (GST_IS_FLXDEC (element));
GST_DEBUG ("entering loop function");
-
- flxdec = GST_FLXDEC(element);
+
+ flxdec = GST_FLXDEC (element);
if (flxdec->state == GST_FLXDEC_READ_HEADER) {
- databuf = flx_get_data(flxdec, FlxHeaderSize);
+ databuf = flx_get_data (flxdec, FlxHeaderSize);
if (!databuf) {
g_print ("empty buffer\n");
return;
}
- data = GST_BUFFER_DATA(databuf);
+ data = GST_BUFFER_DATA (databuf);
- memcpy((char *) &flxdec->hdr, data, sizeof(FlxHeader));
+ memcpy ((char *) &flxdec->hdr, data, sizeof (FlxHeader));
gst_buffer_unref (databuf);
@@ -461,119 +462,115 @@ gst_flxdec_loop (GstElement *element)
/* check header */
if (flxh->type != FLX_MAGICHDR_FLI &&
- flxh->type != FLX_MAGICHDR_FLC &&
- flxh->type != FLX_MAGICHDR_FLX) {
- GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL), ("not a flx file (type %d)\n", flxh->type));
+ flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX) {
+ GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
+ ("not a flx file (type %d)\n", flxh->type));
return;
}
-
-
- g_print("GstFlxDec: size : %d\n", flxh->size);
- g_print("GstFlxDec: frames : %d\n", flxh->frames);
- g_print("GstFlxDec: width : %d\n", flxh->width);
- g_print("GstFlxDec: height : %d\n", flxh->height);
- g_print("GstFlxDec: depth : %d\n", flxh->depth);
- g_print("GstFlxDec: speed : %d\n", flxh->speed);
+
+
+ g_print ("GstFlxDec: size : %d\n", flxh->size);
+ g_print ("GstFlxDec: frames : %d\n", flxh->frames);
+ g_print ("GstFlxDec: width : %d\n", flxh->width);
+ g_print ("GstFlxDec: height : %d\n", flxh->height);
+ g_print ("GstFlxDec: depth : %d\n", flxh->depth);
+ g_print ("GstFlxDec: speed : %d\n", flxh->speed);
flxdec->next_time = 0;
if (flxh->type == FLX_MAGICHDR_FLI) {
flxdec->frame_time = JIFFIE * flxh->speed;
- }
- else {
+ } else {
flxdec->frame_time = flxh->speed * GST_MSECOND;
}
-
+
caps = gst_caps_from_string (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN);
gst_caps_set_simple (caps,
- "width", G_TYPE_INT, flxh->width,
+ "width", G_TYPE_INT, flxh->width,
"height", G_TYPE_INT, flxh->height,
- "framerate", G_TYPE_DOUBLE, GST_SECOND/flxdec->frame_time, NULL);
+ "framerate", G_TYPE_DOUBLE, GST_SECOND / flxdec->frame_time, NULL);
- if (flxh->depth <= 8)
- flxdec->converter = flx_colorspace_converter_new(flxh->width, flxh->height);
+ if (flxh->depth <= 8)
+ flxdec->converter =
+ flx_colorspace_converter_new (flxh->width, flxh->height);
- if (flxh->type == FLX_MAGICHDR_FLC ||
- flxh->type == FLX_MAGICHDR_FLX) {
- g_print("GstFlxDec: (FLC) aspect_dx : %d\n", flxh->aspect_dx);
- g_print("GstFlxDec: (FLC) aspect_dy : %d\n", flxh->aspect_dy);
- g_print("GstFlxDec: (FLC) oframe1 : 0x%08x\n", flxh->oframe1);
- g_print("GstFlxDec: (FLC) oframe2 : 0x%08x\n", flxh->oframe2);
+ if (flxh->type == FLX_MAGICHDR_FLC || flxh->type == FLX_MAGICHDR_FLX) {
+ g_print ("GstFlxDec: (FLC) aspect_dx : %d\n", flxh->aspect_dx);
+ g_print ("GstFlxDec: (FLC) aspect_dy : %d\n", flxh->aspect_dy);
+ g_print ("GstFlxDec: (FLC) oframe1 : 0x%08x\n", flxh->oframe1);
+ g_print ("GstFlxDec: (FLC) oframe2 : 0x%08x\n", flxh->oframe2);
}
-
+
flxdec->size = (flxh->width * flxh->height);
-
+
/* create delta and output frame */
- flxdec->frame = gst_buffer_new();
- flxdec->delta = gst_buffer_new();
- GST_BUFFER_DATA(flxdec->frame) = g_malloc(flxdec->size);
- GST_BUFFER_SIZE(flxdec->frame) = flxdec->size;
- GST_BUFFER_DATA(flxdec->delta) = g_malloc(flxdec->size);
- GST_BUFFER_SIZE(flxdec->delta) = flxdec->size;
+ flxdec->frame = gst_buffer_new ();
+ flxdec->delta = gst_buffer_new ();
+ GST_BUFFER_DATA (flxdec->frame) = g_malloc (flxdec->size);
+ GST_BUFFER_SIZE (flxdec->frame) = flxdec->size;
+ GST_BUFFER_DATA (flxdec->delta) = g_malloc (flxdec->size);
+ GST_BUFFER_SIZE (flxdec->delta) = flxdec->size;
flxdec->state = GST_FLXDEC_PLAYING;
- }
- else if (flxdec->state == GST_FLXDEC_PLAYING) {
+ } else if (flxdec->state == GST_FLXDEC_PLAYING) {
GstBuffer *out;
- databuf = flx_get_data(flxdec, FlxFrameChunkSize);
+ databuf = flx_get_data (flxdec, FlxFrameChunkSize);
if (!databuf)
return;
- flxfh = (FlxFrameChunk *) GST_BUFFER_DATA(databuf);
-
- switch(flxfh->id) {
+ flxfh = (FlxFrameChunk *) GST_BUFFER_DATA (databuf);
+
+ switch (flxfh->id) {
case FLX_FRAME_TYPE:
- buf = flx_get_data(flxdec, flxfh->size-FlxFrameChunkSize);
-
- chunk = GST_BUFFER_DATA(buf);
-
- if (((FlxFrameType *)chunk)->chunks == 0)
- break;
-
- /* create 32 bits output frame */
- out = gst_buffer_new();
- GST_BUFFER_DATA(out) = g_malloc(flxdec->size * 4);
- GST_BUFFER_SIZE(out) = flxdec->size * 4;
-
- /* decode chunks */
- flx_decode_chunks(flxdec,
- ((FlxFrameType *)chunk)->chunks,
- GST_BUFFER_DATA(buf) + FlxFrameTypeSize,
- GST_BUFFER_DATA(flxdec->frame));
-
- /* destroy input buffer*/
- gst_buffer_unref(buf);
-
- /* save copy of the current frame for possible delta. */
- memcpy(GST_BUFFER_DATA(flxdec->delta),
- GST_BUFFER_DATA(flxdec->frame),
- GST_BUFFER_SIZE(flxdec->delta));
-
- /* convert current frame. */
- flx_colorspace_convert(flxdec->converter,
- GST_BUFFER_DATA(flxdec->frame),
- GST_BUFFER_DATA(out));
+ buf = flx_get_data (flxdec, flxfh->size - FlxFrameChunkSize);
+
+ chunk = GST_BUFFER_DATA (buf);
+
+ if (((FlxFrameType *) chunk)->chunks == 0)
+ break;
+
+ /* create 32 bits output frame */
+ out = gst_buffer_new ();
+ GST_BUFFER_DATA (out) = g_malloc (flxdec->size * 4);
+ GST_BUFFER_SIZE (out) = flxdec->size * 4;
+
+ /* decode chunks */
+ flx_decode_chunks (flxdec,
+ ((FlxFrameType *) chunk)->chunks,
+ GST_BUFFER_DATA (buf) + FlxFrameTypeSize,
+ GST_BUFFER_DATA (flxdec->frame));
+
+ /* destroy input buffer */
+ gst_buffer_unref (buf);
+
+ /* save copy of the current frame for possible delta. */
+ memcpy (GST_BUFFER_DATA (flxdec->delta),
+ GST_BUFFER_DATA (flxdec->frame), GST_BUFFER_SIZE (flxdec->delta));
+
+ /* convert current frame. */
+ flx_colorspace_convert (flxdec->converter,
+ GST_BUFFER_DATA (flxdec->frame), GST_BUFFER_DATA (out));
GST_BUFFER_TIMESTAMP (out) = flxdec->next_time;
flxdec->next_time += flxdec->frame_time;
- gst_pad_push(flxdec->srcpad, GST_DATA (out));
-
- break;
+ gst_pad_push (flxdec->srcpad, GST_DATA (out));
+
+ break;
}
/* destroy header buffer */
- gst_buffer_unref(databuf);
+ gst_buffer_unref (databuf);
}
}
-static GstElementStateReturn
-gst_flxdec_change_state (GstElement *element)
+static GstElementStateReturn
+gst_flxdec_change_state (GstElement * element)
{
GstFlxDec *flxdec;
- flxdec = GST_FLXDEC(element);
+ flxdec = GST_FLXDEC (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
@@ -596,20 +593,21 @@ gst_flxdec_change_state (GstElement *element)
case GST_STATE_READY_TO_NULL:
break;
}
-
+
parent_class->change_state (element);
return GST_STATE_SUCCESS;
}
-static void
-gst_flxdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_flxdec_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFlxDec *flxdec;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_FLXDEC(object));
- flxdec = GST_FLXDEC(object);
+ g_return_if_fail (GST_IS_FLXDEC (object));
+ flxdec = GST_FLXDEC (object);
switch (prop_id) {
default:
@@ -617,14 +615,15 @@ gst_flxdec_set_property (GObject *object, guint prop_id, const GValue *value, GP
}
}
-static void
-gst_flxdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_flxdec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFlxDec *flxdec;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_FLXDEC(object));
- flxdec = GST_FLXDEC(object);
+ g_return_if_fail (GST_IS_FLXDEC (object));
+ flxdec = GST_FLXDEC (object);
switch (prop_id) {
default:
@@ -634,23 +633,17 @@ gst_flxdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
return gst_element_register (plugin, "flxdec",
- GST_RANK_PRIMARY, GST_TYPE_FLXDEC);
+ GST_RANK_PRIMARY, GST_TYPE_FLXDEC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "flxdec",
- "FLX video decoder",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "flxdec",
+ "FLX video decoder",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
diff --git a/gst/flx/gstflxdec.h b/gst/flx/gstflxdec.h
index c7d6f386..c5ce60ec 100644
--- a/gst/flx/gstflxdec.h
+++ b/gst/flx/gstflxdec.h
@@ -27,42 +27,46 @@
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
+
+ typedef enum
+ {
+ GST_FLXDEC_READ_HEADER,
+ GST_FLXDEC_PLAYING,
+ } GstFlxDecState;
-typedef enum {
- GST_FLXDEC_READ_HEADER,
- GST_FLXDEC_PLAYING,
-} GstFlxDecState;
-
/* Definition of structure storing data for this element. */
-typedef struct _GstFlxDec GstFlxDec;
+ typedef struct _GstFlxDec GstFlxDec;
-struct _GstFlxDec {
- GstElement element;
+ struct _GstFlxDec
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gboolean active, new_meta;
+ gboolean active, new_meta;
- GstBuffer *delta, *frame;
- GstByteStream *bs;
- gulong size;
- GstFlxDecState state;
- glong frame_time;
- gint64 next_time;
+ GstBuffer *delta, *frame;
+ GstByteStream *bs;
+ gulong size;
+ GstFlxDecState state;
+ glong frame_time;
+ gint64 next_time;
- FlxColorSpaceConverter *converter;
+ FlxColorSpaceConverter *converter;
- FlxHeader hdr;
-};
+ FlxHeader hdr;
+ };
/* Standard definition defining a class for this element. */
-typedef struct _GstFlxDecClass GstFlxDecClass;
-struct _GstFlxDecClass {
- GstElementClass parent_class;
-};
+ typedef struct _GstFlxDecClass GstFlxDecClass;
+ struct _GstFlxDecClass
+ {
+ GstElementClass parent_class;
+ };
/* Standard macros for defining types for this element. */
#define GST_TYPE_FLXDEC \
@@ -77,12 +81,12 @@ struct _GstFlxDecClass {
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FLXDEC))
/* Standard function returning type information. */
-GType gst_flxdec_get_type(void);
+ GType gst_flxdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_FLX_DECODER_H__ */
+#endif /* __GST_FLX_DECODER_H__ */