Now flxdec works on big-endian machines as well.

Original commit message from CVS:
Now flxdec works on big-endian machines as well.
This commit is contained in:
Zeeshan Ali 2005-12-11 16:43:42 +00:00
parent 81e11ca107
commit 8b6d639c5d
6 changed files with 158 additions and 68 deletions

View file

@ -1,3 +1,12 @@
2005-12-11 Zeeshan Ali <zeenix at gmail dot com>
* gst/flx/flx_color.c: (flx_colorspace_convert):
* gst/flx/flx_color.h:
* gst/flx/flx_fmt.h:
* gst/flx/gstflxdec.c: (flx_decode_chunks), (gst_flxdec_chain):
* gst/flx/gstflxdec.h:
Now flxdec works on big-endian machines as well.
2005-12-11 Tim-Philipp Müller <tim at centricular dot net>
* gst/debug/efence.c: (gst_efence_init), (gst_efence_chain),

View file

@ -60,10 +60,18 @@ flx_colorspace_convert (FlxColorSpaceConverter * flxpal, guchar * src,
while (size--) {
col = (*src++ * 3);
#if G_BYTE_ORDER == G_BIG_ENDIAN
*dest++ = 0;
*dest++ = flxpal->palvec[col];
*dest++ = flxpal->palvec[col + 1];
*dest++ = flxpal->palvec[col + 2];
#else
*dest++ = flxpal->palvec[col + 2];
*dest++ = flxpal->palvec[col + 1];
*dest++ = flxpal->palvec[col];
*dest++ = 0;
#endif
}
}

View file

@ -17,6 +17,8 @@
* Boston, MA 02111-1307, USA.
*/
#include <gst/gst.h>
typedef enum {
FLX_COLORSPACE_RGB8,
FLX_COLORSPACE_RGB32,
@ -31,7 +33,6 @@ struct _FlxColorSpaceConverter {
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);

View file

@ -70,8 +70,6 @@ enum Flx_MagicHdr
FLX_MAGICHDR_HUFFBWT = 0xaf30
};
typedef struct _FlxHeader
{
guint32 size;
@ -127,6 +125,77 @@ typedef struct _FlxFrameType
} FlxFrameType;
#define FlxFrameTypeSize 10
#if G_BYTE_ORDER == G_BIG_ENDIAN
#define LE_TO_BE_16(i16) ((guint16) (((i16) << 8) | ((i16) >> 8)))
#define LE_TO_BE_32(i32) \
(((guint32) (LE_TO_BE_16((guint16) (i32))) << 16) | (LE_TO_BE_16((i32) >> 16)))
#define FLX_FRAME_TYPE_FIX_ENDIANNESS(frm_type_p) \
do { \
(frm_type_p)->chunks = LE_TO_BE_16((frm_type_p)->chunks); \
(frm_type_p)->delay = LE_TO_BE_16((frm_type_p)->delay); \
} while(0)
#define FLX_HUFFMAN_TABLE_FIX_ENDIANNESS(hffmn_table_p) \
do { \
(hffmn_table_p)->codelength = \
LE_TO_BE_16((hffmn_table_p)->codelength); \
(hffmn_table_p)->numcodes = LE_TO_BE_16((hffmn_table_p)->numcodes); \
} while(0)
#define FLX_SEGMENT_TABLE_FIX_ENDIANNESS(sgmnt_table_p) \
((sgmnt_table_p)->segments = LE_TO_BE_16((sgmnt_table_p)->segments))
#define FLX_PREFIX_CHUNK_FIX_ENDIANNESS(prfx_chnk_p) \
do { \
(prfx_chnk_p)->chunks = LE_TO_BE_16((prfx_chnk_p)->chunks); \
} while(0)
#define FLX_FRAME_CHUNK_FIX_ENDIANNESS(frm_chnk_p) \
do { \
(frm_chnk_p)->size = LE_TO_BE_32((frm_chnk_p)->size); \
(frm_chnk_p)->id = LE_TO_BE_16((frm_chnk_p)->id); \
} while(0)
#define FLX_HDR_FIX_ENDIANNESS(hdr_p) \
do { \
(hdr_p)->size = LE_TO_BE_32((hdr_p)->size); \
(hdr_p)->type = LE_TO_BE_16((hdr_p)->type); \
(hdr_p)->frames = LE_TO_BE_16((hdr_p)->frames); \
(hdr_p)->width = LE_TO_BE_16((hdr_p)->width); \
(hdr_p)->height = LE_TO_BE_16((hdr_p)->height); \
(hdr_p)->depth = LE_TO_BE_16((hdr_p)->depth); \
(hdr_p)->flags = LE_TO_BE_16((hdr_p)->flags); \
(hdr_p)->speed = LE_TO_BE_32((hdr_p)->speed); \
(hdr_p)->reserved1 = LE_TO_BE_16((hdr_p)->reserved1); \
(hdr_p)->created = LE_TO_BE_32((hdr_p)->created); \
(hdr_p)->creator = LE_TO_BE_32((hdr_p)->creator); \
(hdr_p)->updated = LE_TO_BE_32((hdr_p)->updated); \
(hdr_p)->updater = LE_TO_BE_32((hdr_p)->updater); \
(hdr_p)->aspect_dx = LE_TO_BE_16((hdr_p)->aspect_dx); \
(hdr_p)->aspect_dy = LE_TO_BE_16((hdr_p)->aspect_dy); \
(hdr_p)->ext_flags = LE_TO_BE_16((hdr_p)->ext_flags); \
(hdr_p)->keyframes = LE_TO_BE_16((hdr_p)->keyframes); \
(hdr_p)->totalframes = LE_TO_BE_16((hdr_p)->totalframes); \
(hdr_p)->req_memory = LE_TO_BE_32((hdr_p)->req_memory); \
(hdr_p)->max_regions = LE_TO_BE_16((hdr_p)->max_regions); \
(hdr_p)->transp_num = LE_TO_BE_16((hdr_p)->transp_num); \
(hdr_p)->oframe1 = LE_TO_BE_32((hdr_p)->oframe1); \
(hdr_p)->oframe2 = LE_TO_BE_32((hdr_p)->oframe2); \
} while(0)
#else
#define LE_TO_BE_16(i16) ((i16))
#define LE_TO_BE_32(i32) ((i32))
#define FLX_FRAME_TYPE_FIX_ENDIANNESS(frm_type_p)
#define FLX_HUFFMAN_TABLE_FIX_ENDIANNESS(hffmn_table_p)
#define FLX_SEGMENT_TABLE_FIX_ENDIANNESS(sgmnt_table_p)
#define FLX_PREFIX_CHUNK_FIX_ENDIANNESS(prfx_chnk_p)
#define FLX_FRAME_CHUNK_FIX_ENDIANNESS(frm_chnk_p)
#define FLX_HDR_FIX_ENDIANNESS(hdr_p)
#endif /* G_BYTE_ORDER == G_BIG_ENDIAN */
#ifdef __cplusplus
}

View file

@ -211,6 +211,7 @@ flx_decode_chunks (GstFlxDec * flxdec, gulong count, guchar * data,
while (count--) {
hdr = (FlxFrameChunk *) data;
FLX_FRAME_CHUNK_FIX_ENDIANNESS (hdr);
data += FlxFrameChunkSize;
switch (hdr->id) {
@ -466,6 +467,7 @@ gst_flxdec_chain (GstPad * pad, GstBuffer * buf)
const guint8 *data = gst_adapter_peek (flxdec->adapter, FlxHeaderSize);
memcpy ((gchar *) & flxdec->hdr, data, FlxHeaderSize);
FLX_HDR_FIX_ENDIANNESS (&(flxdec->hdr));
gst_adapter_flush (flxdec->adapter, FlxHeaderSize);
flxh = &flxdec->hdr;
@ -474,7 +476,7 @@ gst_flxdec_chain (GstPad * pad, GstBuffer * buf)
if (flxh->type != FLX_MAGICHDR_FLI &&
flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX) {
GST_ELEMENT_ERROR (flxdec, STREAM, WRONG_TYPE, (NULL),
("not a flx file (type %d)\n", flxh->type));
("not a flx file (type %x)\n", flxh->type));
return GST_FLOW_ERROR;
}
@ -537,6 +539,7 @@ gst_flxdec_chain (GstPad * pad, GstBuffer * buf)
const guint8 *data =
gst_adapter_peek (flxdec->adapter, FlxFrameChunkSize);
memcpy (&flxfh, data, FlxFrameChunkSize);
FLX_FRAME_CHUNK_FIX_ENDIANNESS (&flxfh);
switch (flxfh.id) {
case FLX_FRAME_TYPE:
@ -550,6 +553,7 @@ gst_flxdec_chain (GstPad * pad, GstBuffer * buf)
chunk = g_memdup (data, flxfh.size - FlxFrameChunkSize);
to_flush = flxfh.size - FlxFrameChunkSize;
FLX_FRAME_TYPE_FIX_ENDIANNESS ((FlxFrameType *) chunk);
if (((FlxFrameType *) chunk)->chunks == 0)
break;

View file

@ -22,9 +22,8 @@
#include <gst/gst.h>
#include "flx_color.h"
#include <gst/base/gstadapter.h>
#include "flx_color.h"
#ifdef __cplusplus
extern "C" {