Mercurial > mplayer.hg
annotate libmpcodecs/vd_rle.c @ 7186:02b1976e12e2
fix vfm and add afm support
author | pontscho |
---|---|
date | Sat, 31 Aug 2002 09:45:59 +0000 |
parents | 28677d779205 |
children |
rev | line source |
---|---|
4969 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 | |
4 #include "config.h" | |
5 #include "mp_msg.h" | |
6 | |
7 #include "vd_internal.h" | |
8 | |
9 static vd_info_t info = { | |
10 "RLE Video decoder", | |
5417
a890a999ca9a
migrating to Melanson's great codec name change... which is of course nonsense but why not...
arpi
parents:
5124
diff
changeset
|
11 "msrle", |
4969 | 12 "A'rpi", |
13 "XAnim rip...", | |
14 "native codec" | |
15 }; | |
16 | |
5417
a890a999ca9a
migrating to Melanson's great codec name change... which is of course nonsense but why not...
arpi
parents:
5124
diff
changeset
|
17 LIBVD_EXTERN(msrle) |
4969 | 18 |
19 // to set/get/query special features/parameters | |
20 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
21 return CONTROL_UNKNOWN; | |
22 } | |
23 | |
24 // init driver | |
25 static int init(sh_video_t *sh){ | |
5419
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
26 unsigned int* pal; |
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
27 unsigned int* dpal; |
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
28 int cols; |
5124 | 29 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24)) return 0; |
5419
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
30 sh->context=dpal=malloc(4*256); // for the palette |
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
31 memset(dpal,0,4*256); |
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
32 pal=(unsigned int*)(((char*)sh->bih)+40); |
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
33 cols=(sh->bih->biSize-40)/4; |
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
34 if(cols>256) cols=256; |
4969 | 35 if( (((sh->codec->outfmt[sh->outfmtidx]&255)+7)/8)==2 ){ |
36 int i; | |
37 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols); | |
38 for(i=0;i<cols;i++){ | |
39 unsigned int c=pal[i]; | |
40 unsigned int b=c&255; | |
41 unsigned int g=(c>>8)&255; | |
42 unsigned int r=(c>>16)&255; | |
43 if((sh->codec->outfmt[sh->outfmtidx]&255)==15) | |
5419
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
44 dpal[i]=((r>>3)<<10)|((g>>3)<<5)|((b>>3)); |
4969 | 45 else |
5419
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
46 dpal[i]=((r>>3)<<11)|((g>>2)<<5)|((b>>3)); |
4969 | 47 } |
5419
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
48 } else |
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
49 memcpy(dpal,pal,4*cols); |
4969 | 50 return 1; |
51 } | |
52 | |
53 // uninit driver | |
54 static void uninit(sh_video_t *sh){ | |
5419
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
55 free(sh->context); sh->context=NULL; |
4969 | 56 } |
57 | |
58 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
59 | |
60 void AVI_Decode_RLE8(char *image,char *delta,int tdsize, | |
61 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel); | |
62 | |
63 // decode a frame | |
64 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
65 mp_image_t* mpi; | |
66 if(len<=0) return NULL; // skipped frame | |
67 | |
68 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, | |
69 sh->disp_w, sh->disp_h); | |
70 if(!mpi) return NULL; | |
71 | |
72 AVI_Decode_RLE8(mpi->planes[0],data,len, | |
5419
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
73 (int*)sh->context, |
e0a0c8d848a1
copy palette to 4*256 bytes area to avoid sig11 when colors<256 but index>colors (broken files)
arpi
parents:
5417
diff
changeset
|
74 sh->disp_w,sh->disp_h,mpi->bpp/8); |
4969 | 75 |
76 return mpi; | |
77 } | |
78 |