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",
|
|
11 "rle",
|
|
12 VFM_RLE,
|
|
13 "A'rpi",
|
|
14 "XAnim rip...",
|
|
15 "native codec"
|
|
16 };
|
|
17
|
|
18 LIBVD_EXTERN(rle)
|
|
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){
|
5124
|
27 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24)) return 0;
|
4969
|
28 if( (((sh->codec->outfmt[sh->outfmtidx]&255)+7)/8)==2 ){
|
|
29 unsigned int* pal=(unsigned int*)(((char*)sh->bih)+40);
|
|
30 int cols=(sh->bih->biSize-40)/4;
|
|
31 //int cols=1<<(sh_video->bih->biBitCount);
|
|
32 int i;
|
|
33 if(cols>256) cols=256;
|
|
34 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols);
|
|
35 for(i=0;i<cols;i++){
|
|
36 unsigned int c=pal[i];
|
|
37 unsigned int b=c&255;
|
|
38 unsigned int g=(c>>8)&255;
|
|
39 unsigned int r=(c>>16)&255;
|
|
40 if((sh->codec->outfmt[sh->outfmtidx]&255)==15)
|
|
41 pal[i]=((r>>3)<<10)|((g>>3)<<5)|((b>>3));
|
|
42 else
|
|
43 pal[i]=((r>>3)<<11)|((g>>2)<<5)|((b>>3));
|
|
44 }
|
|
45 }
|
|
46 return 1;
|
|
47 }
|
|
48
|
|
49 // uninit driver
|
|
50 static void uninit(sh_video_t *sh){
|
|
51 }
|
|
52
|
|
53 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
|
|
54
|
|
55 void AVI_Decode_RLE8(char *image,char *delta,int tdsize,
|
|
56 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel);
|
|
57
|
|
58 // decode a frame
|
|
59 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
|
60 mp_image_t* mpi;
|
|
61 if(len<=0) return NULL; // skipped frame
|
|
62
|
|
63 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
|
|
64 sh->disp_w, sh->disp_h);
|
|
65 if(!mpi) return NULL;
|
|
66
|
|
67 AVI_Decode_RLE8(mpi->planes[0],data,len,
|
|
68 (int*)(((char*)sh->bih)+40),
|
|
69 sh->disp_w,sh->disp_h,((mpi->imgfmt&255)+7)/8);
|
|
70
|
|
71 return mpi;
|
|
72 }
|
|
73
|