Mercurial > mplayer.hg
annotate libmpcodecs/vd_rle.c @ 6409:8d9c6decdfd6
Background now uses CSS, added charset.
author | diego |
---|---|
date | Thu, 13 Jun 2002 00:33:54 +0000 |
parents | e0a0c8d848a1 |
children | 28677d779205 |
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", |
a890a999ca9a
migrating to Melanson's great codec name change... which is of course nonsense but why not...
arpi
parents:
5124
diff
changeset
|
12 VFM_MSRLE, |
4969 | 13 "A'rpi", |
14 "XAnim rip...", | |
15 "native codec" | |
16 }; | |
17 | |
5417
a890a999ca9a
migrating to Melanson's great codec name change... which is of course nonsense but why not...
arpi
parents:
5124
diff
changeset
|
18 LIBVD_EXTERN(msrle) |
4969 | 19 |
20 // to set/get/query special features/parameters | |
21 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
22 return CONTROL_UNKNOWN; | |
23 } | |
24 | |
25 // init driver | |
26 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
|
27 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
|
28 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
|
29 int cols; |
5124 | 30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 if(cols>256) cols=256; |
4969 | 36 if( (((sh->codec->outfmt[sh->outfmtidx]&255)+7)/8)==2 ){ |
37 int i; | |
38 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols); | |
39 for(i=0;i<cols;i++){ | |
40 unsigned int c=pal[i]; | |
41 unsigned int b=c&255; | |
42 unsigned int g=(c>>8)&255; | |
43 unsigned int r=(c>>16)&255; | |
44 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
|
45 dpal[i]=((r>>3)<<10)|((g>>3)<<5)|((b>>3)); |
4969 | 46 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
|
47 dpal[i]=((r>>3)<<11)|((g>>2)<<5)|((b>>3)); |
4969 | 48 } |
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
|
49 } 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
|
50 memcpy(dpal,pal,4*cols); |
4969 | 51 return 1; |
52 } | |
53 | |
54 // uninit driver | |
55 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
|
56 free(sh->context); sh->context=NULL; |
4969 | 57 } |
58 | |
59 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
60 | |
61 void AVI_Decode_RLE8(char *image,char *delta,int tdsize, | |
62 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel); | |
63 | |
64 // decode a frame | |
65 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
66 mp_image_t* mpi; | |
67 if(len<=0) return NULL; // skipped frame | |
68 | |
69 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, | |
70 sh->disp_w, sh->disp_h); | |
71 if(!mpi) return NULL; | |
72 | |
73 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
|
74 (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
|
75 sh->disp_w,sh->disp_h,mpi->bpp/8); |
4969 | 76 |
77 return mpi; | |
78 } | |
79 |