From dfc81d564ff8df06a3fb5635d77a2b9a31afde7b Mon Sep 17 00:00:00 2001 From: kramm Date: Fri, 5 Nov 2004 17:30:08 +0000 Subject: [PATCH] fixed byte order in swf_JPEG2TagToImage(). --- lib/modules/swfbits.c | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/modules/swfbits.c b/lib/modules/swfbits.c index b85eb58..11aac11 100644 --- a/lib/modules/swfbits.c +++ b/lib/modules/swfbits.c @@ -37,7 +37,7 @@ typedef struct _JPEGDESTMGR static void RFXSWF_init_destination(j_compress_ptr cinfo) { JPEGDESTMGR * dmgr = (JPEGDESTMGR *)cinfo->dest; - dmgr->buffer = (JOCTET*)rfx_alloc(OUTBUFFER_SIZE); + dmgr->buffer = (JOCTET*)malloc(OUTBUFFER_SIZE); dmgr->mgr.next_output_byte = dmgr->buffer; dmgr->mgr.free_in_buffer = OUTBUFFER_SIZE; } @@ -53,7 +53,7 @@ static boolean RFXSWF_empty_output_buffer(j_compress_ptr cinfo) static void RFXSWF_term_destination(j_compress_ptr cinfo) { JPEGDESTMGR * dmgr = (JPEGDESTMGR *)cinfo->dest; swf_SetBlock(dmgr->t,(U8*)dmgr->buffer,OUTBUFFER_SIZE-dmgr->mgr.free_in_buffer); - rfx_free(dmgr->buffer); + free(dmgr->buffer); dmgr->mgr.free_in_buffer = 0; } @@ -63,8 +63,10 @@ JPEGBITS * swf_SetJPEGBitsStart(TAG * t,int width,int height,int quality) // redirect compression lib output to local SWF Tag structure - jpeg = (JPEGDESTMGR *)rfx_calloc(sizeof(JPEGDESTMGR)); + jpeg = (JPEGDESTMGR *)malloc(sizeof(JPEGDESTMGR)); + if (!jpeg) return NULL; + memset(jpeg,0x00,sizeof(JPEGDESTMGR)); jpeg->cinfo.err = jpeg_std_error(&jpeg->jerr); jpeg_create_compress(&jpeg->cinfo); @@ -114,7 +116,7 @@ int swf_SetJPEGBitsFinish(JPEGBITS * jpegbits) { JPEGDESTMGR * jpeg = (JPEGDESTMGR *)jpegbits; if (!jpeg) return -1; jpeg_finish_compress(&jpeg->cinfo); - rfx_free(jpeg); + free(jpeg); return 0; } @@ -176,7 +178,7 @@ int swf_SetJPEGBits(TAG * t,char * fname,int quality) jpeg_start_decompress(&cinfo); out = swf_SetJPEGBitsStart(t,cinfo.output_width,cinfo.output_height,quality); - scanline = (U8*)rfx_alloc(4*cinfo.output_width); + scanline = (U8*)malloc(4*cinfo.output_width); if (scanline) { int y; @@ -320,7 +322,7 @@ RGBA* swf_JPEG2TagToImage(TAG*tag, int*width, int*height) jpeg_read_header(&cinfo, TRUE); *width = cinfo.image_width; *height = cinfo.image_height; - dest = rfx_alloc(sizeof(RGBA)*cinfo.image_width*cinfo.image_height); + dest = malloc(sizeof(RGBA)*cinfo.image_width*cinfo.image_height); jpeg_start_decompress(&cinfo); int y; @@ -355,7 +357,7 @@ RGBA* swf_JPEG2TagToImage(TAG*tag, int*width, int*height) int RFXSWF_deflate_wraper(TAG * t,z_stream * zs,boolean finish) { - U8*data=rfx_alloc(OUTBUFFER_SIZE); + U8*data=malloc(OUTBUFFER_SIZE); zs->next_out = data; zs->avail_out = OUTBUFFER_SIZE; while (1) @@ -366,7 +368,7 @@ int RFXSWF_deflate_wraper(TAG * t,z_stream * zs,boolean finish) #ifdef DEBUG_RFXSWF fprintf(stderr,"rfxswf: zlib compression error (%i)\n",status); #endif - rfx_free(data); + free(data); return status; } @@ -381,7 +383,7 @@ int RFXSWF_deflate_wraper(TAG * t,z_stream * zs,boolean finish) } if(!finish) { - rfx_free(data); + free(data); return 0; } @@ -392,7 +394,7 @@ int RFXSWF_deflate_wraper(TAG * t,z_stream * zs,boolean finish) #ifdef DEBUG_RFXSWF fprintf(stderr,"rfxswf: zlib compression error (%i)\n",status); #endif - rfx_free(data); + free(data); return status; } @@ -406,7 +408,7 @@ int RFXSWF_deflate_wraper(TAG * t,z_stream * zs,boolean finish) if(status == Z_STREAM_END) break; } - rfx_free(data); + free(data); return 0; } @@ -458,7 +460,7 @@ int swf_SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * p if (!pal) // create default palette for grayscale images { int i; - pal = rfx_alloc(256*sizeof(RGBA)); + pal = malloc(256*sizeof(RGBA)); for (i=0;i<256;i++) { pal[i].r = pal[i].g = pal[i].b = i; pal[i].a = 0xff;} ncolors = 256; } @@ -481,7 +483,7 @@ int swf_SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * p if (deflateInit(&zs,Z_DEFAULT_COMPRESSION)==Z_OK) { U8 * zpal; // compress palette - if ((zpal = rfx_alloc(ncolors*4))) + if ((zpal = malloc(ncolors*4))) { U8 * pp = zpal; int i; @@ -528,12 +530,12 @@ int swf_SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * p deflateEnd(&zs); - rfx_free(zpal); + free(zpal); } else res = -2; // memory error } else res = -3; // zlib error } - if (!palette) rfx_free(pal); + if (!palette) free(pal); return res; } @@ -552,7 +554,7 @@ RGBA* swf_DefineLosslessBitsTagToImage(TAG*tag, int*dwidth, int*dheight) int pos2=0; char alpha = tag->id == ST_DEFINEBITSLOSSLESS2; int t,x,y; - RGBA*palette = 0; + RGBA*palette; U8*data,*data2; RGBA*dest; if(tag->id != ST_DEFINEBITSLOSSLESS && @@ -576,7 +578,7 @@ RGBA* swf_DefineLosslessBitsTagToImage(TAG*tag, int*dwidth, int*dheight) *dwidth = width = swf_GetU16(tag); *dheight = height = swf_GetU16(tag); - dest = rfx_alloc(sizeof(RGBA)*width*height); + dest = malloc(sizeof(RGBA)*width*height); if(format == 3) cols = swf_GetU8(tag) + 1; else cols = 0; @@ -585,9 +587,9 @@ RGBA* swf_DefineLosslessBitsTagToImage(TAG*tag, int*dwidth, int*dheight) datalen = (width*height*bpp/8+cols*8); do { if(data) - rfx_free(data); + free(data); datalen+=4096; - data = rfx_alloc(datalen); + data = malloc(datalen); error = uncompress (data, &datalen, &tag->data[tag->pos], tag->len-tag->pos); } while(error == Z_BUF_ERROR); if(error != Z_OK) { @@ -595,17 +597,15 @@ RGBA* swf_DefineLosslessBitsTagToImage(TAG*tag, int*dwidth, int*dheight) return 0; } pos = 0; - - if(cols) { - palette = (RGBA*)rfx_alloc(cols*sizeof(RGBA)); - for(t=0;tdata[pos], tag->len - pos - 4); - data=rfx_alloc(OUTBUFFER_SIZE); + data=malloc(OUTBUFFER_SIZE); memset(&zs,0x00,sizeof(z_stream)); if (deflateInit(&zs,Z_DEFAULT_COMPRESSION)!=Z_OK) { @@ -727,7 +727,7 @@ int swf_SetJPEGBits3(TAG * tag,U16 width,U16 height,RGBA* bitmap, int quality) } deflateEnd(&zs); - rfx_free(data); + free(data); return 0; } #endif -- 1.7.10.4