[Mplayer-cvslog] CVS: main/xa rle8.c,NONE,1.1
Arpi of Ize
arpi at mplayer.dev.hu
Mon Sep 24 22:19:51 CEST 2001
- Previous message: [Mplayer-cvslog] CVS: main/DOCS/German faq.html,NONE,1.1
- Next message: [Mplayer-cvslog] CVS: main codec-cfg.c,1.36,1.37 codec-cfg.h,1.16,1.17 dec_video.c,1.36,1.37 Makefile,1.67,1.68
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/mplayer/main/xa
In directory mplayer:/var/tmp.root/cvs-serv5322
Added Files:
rle8.c
Log Message:
ms-rle8 codec from xanim
--- NEW FILE ---
// MS-RLE8 decoder, based on code from XAnim
#include <stdio.h>
typedef char xaBYTE;
typedef short xaSHORT;
typedef int xaLONG;
typedef unsigned char xaUBYTE;
typedef unsigned short xaUSHORT;
typedef unsigned int xaULONG;
#define xaFALSE 0
#define xaTRUE 1
#define DEBUG_LEVEL2 if(0)
// image -> buffer
// delta -> compressed frame
// tdsize = size of compressed frame
void AVI_Decode_RLE8(xaUBYTE *image,xaUBYTE *delta,xaULONG tdsize,
xaULONG *map,xaULONG imagex,xaULONG imagey,xaUBYTE x11_bytes_pixel)
{ xaULONG map_flag = map ? xaTRUE:xaFALSE;
xaULONG opcode,mod;
xaLONG x,y,min_x,max_x,min_y,max_y;
xaUBYTE *dptr;
xaLONG dsize = tdsize;
max_x = max_y = 0; min_x = imagex; min_y = imagey;
x = 0; y = imagey - 1;
dptr = delta;
while( (y >= 0) && (dsize > 0) )
{
mod = *dptr++;
opcode = *dptr++; dsize-=2;
DEBUG_LEVEL2 fprintf(stdout,"MOD %x OPCODE %x <%d,%d>\n",mod,opcode,x,y);
if (mod == 0x00) /* END-OF-LINE */
{
if (opcode==0x00)
{
while(x > imagex) { x -=imagex; y--; }
x = 0; y--;
DEBUG_LEVEL2 fprintf(stdout,"EOL <%d,%d>\n",x,y);
}
else if (opcode==0x01) /* END Of Image */
{
y = -1;
DEBUG_LEVEL2 fprintf(stdout,"EOI <%d,%d>\n",x,y);
}
else if (opcode==0x02) /* SKIP */
{
xaULONG yskip,xskip;
xskip = *dptr++;
yskip = *dptr++; dsize-=2;
x += xskip;
y -= yskip;
DEBUG_LEVEL2 fprintf(stdout,"SKIP <%d,%d>\n",x,y);
}
else /* ABSOLUTE MODE */
{
int cnt = opcode;
dsize-=cnt;
while(x >= imagex) { x -= imagex; y--; }
if (y > max_y) max_y = y; if (x < min_x) min_x = x;
if (map_flag==xaTRUE){
if (x11_bytes_pixel==1)
{ xaUBYTE *iptr = (xaUBYTE *)(image + (y * imagex + x) );
while(cnt--)
{ if (x >= imagex) { max_x = imagex; min_x = 0;
x -= imagex; y--; iptr = (xaUBYTE *)(image+y*imagex+x); }
*iptr++ = (xaUBYTE)map[*dptr++]; x++;
}
}
else if (x11_bytes_pixel==2)
{ xaUSHORT *iptr = (xaUSHORT *)(image + ((y * imagex + x)<<1) );
while(cnt--)
{ if (x >= imagex) { max_x = imagex; min_x = 0;
x -= imagex; y--; iptr = (xaUSHORT *)(image+y*imagex+x); }
*iptr++ = (xaUSHORT)map[*dptr++]; x++;
}
}
else /* if (x11_bytes_pixel==4) */
{ xaULONG *iptr = (xaULONG *)(image + ((y * imagex + x)<<2) );
while(cnt--)
{ if (x >= imagex) { max_x = imagex; min_x = 0;
x -= imagex; y--; iptr = (xaULONG *)(image+y*imagex+x); }
*iptr++ = (xaULONG)map[*dptr++]; x++;
}
}
}
else
{ xaUBYTE *iptr = (xaUBYTE *)(image + (y * imagex + x) );
while(cnt--)
{ if (x >= imagex) { max_x = imagex; min_x = 0;
x -=imagex; y--; iptr = (xaUBYTE *)(image+y*imagex+x); }
*iptr++ = (xaUBYTE)(*dptr++); x++;
}
}
DEBUG_LEVEL2 fprintf(stdout,"ABSOLUTE <%d,%d>\n",x,y);
/* PAD to Short */
if (opcode & 0x01) { dptr++; dsize--; }
if (y < min_y) min_y = y; if (x > max_x) max_x = x;
}
}
else /* ENCODED MODE */
{
int color,cnt;
while(x >= imagex) { x -=imagex; y--; }
if (y > max_y) max_y = y; if (x < min_x) min_x = x; /* OPT */
cnt = mod;
color = (map_flag==xaTRUE)?(map[opcode]):(opcode);
if ( (map_flag==xaFALSE) || (x11_bytes_pixel==1) )
{ xaUBYTE *iptr = (xaUBYTE *)(image + (y * imagex + x) );
xaUBYTE clr = (xaUBYTE)color;
while(cnt--)
{ if (x >= imagex) { max_x = imagex; min_x = 0;
x -=imagex; y--; iptr = (xaUBYTE *)(image+y*imagex+x); }
*iptr++ = clr; x++;
}
}
else if (x11_bytes_pixel==2)
{ xaUSHORT *iptr = (xaUSHORT *)(image + ((y * imagex + x)<<1) );
xaUSHORT clr = (xaUSHORT)color;
while(cnt--)
{ if (x >= imagex) { max_x = imagex; min_x = 0;
x -=imagex; y--; iptr = (xaUSHORT *)(image+y*imagex+x); }
*iptr++ = clr; x++;
}
}
else /* if (x11_bytes_pixel==4) */
{ xaULONG *iptr = (xaULONG *)(image + ((y * imagex + x)<<2) );
xaULONG clr = (xaULONG)color;
while(cnt--)
{ if (x >= imagex) { max_x = imagex; min_x = 0;
x -=imagex; y--; iptr = (xaULONG *)(image+y*imagex+x); }
*iptr++ = clr; x++;
}
}
if (y < min_y) min_y = y; if (x > max_x) max_x = x;
DEBUG_LEVEL2 fprintf(stdout,"ENCODED <%d,%d>\n",x,y);
}
} /* end of while */
DEBUG_LEVEL2
{
fprintf(stdout,"dsize %d\n ",dsize);
while(dsize) { int d = *dptr++; fprintf(stdout,"<%02x> ",d); dsize--; }
fprintf(stdout,"\n");
}
#if 0
if (xa_optimize_flag == xaTRUE)
{
max_x++; if (max_x>imagex) max_x=imagex;
max_y++; if (max_y>imagey) max_y=imagey;
if ((min_x >= max_x) || (min_y >= max_y)) /* no change */
{ dec_info->xs = dec_info->ys = dec_info->xe = dec_info->ye = 0;
return(ACT_DLTA_NOP); }
else { dec_info->xs=min_x; dec_info->ys=min_y;
dec_info->xe=max_x; dec_info->ye=max_y; }
}
else { dec_info->xs = dec_info->ys = 0;
dec_info->xe = imagex; dec_info->ye = imagey; }
#endif
// if (map_flag) return(ACT_DLTA_MAPD);
// else return(ACT_DLTA_NORM);
}
- Previous message: [Mplayer-cvslog] CVS: main/DOCS/German faq.html,NONE,1.1
- Next message: [Mplayer-cvslog] CVS: main codec-cfg.c,1.36,1.37 codec-cfg.h,1.16,1.17 dec_video.c,1.36,1.37 Makefile,1.67,1.68
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list