4969
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3
|
|
4 #include "config.h"
|
|
5 #include "mp_msg.h"
|
|
6
|
|
7 #include "codec-cfg.h"
|
|
8 #include "../libvo/img_format.h"
|
|
9
|
|
10 #include "stream.h"
|
|
11 #include "demuxer.h"
|
|
12 #include "stheader.h"
|
|
13
|
|
14 #include "vd.h"
|
|
15 #include "vd_internal.h"
|
|
16
|
|
17 static vd_info_t info = {
|
|
18 "RLE Video decoder",
|
|
19 "rle",
|
|
20 VFM_RLE,
|
|
21 "A'rpi",
|
|
22 "XAnim rip...",
|
|
23 "native codec"
|
|
24 };
|
|
25
|
|
26 LIBVD_EXTERN(rle)
|
|
27
|
|
28 // to set/get/query special features/parameters
|
|
29 static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
30 return CONTROL_UNKNOWN;
|
|
31 }
|
|
32
|
|
33 // init driver
|
|
34 static int init(sh_video_t *sh){
|
|
35 mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24);
|
|
36 if( (((sh->codec->outfmt[sh->outfmtidx]&255)+7)/8)==2 ){
|
|
37 unsigned int* pal=(unsigned int*)(((char*)sh->bih)+40);
|
|
38 int cols=(sh->bih->biSize-40)/4;
|
|
39 //int cols=1<<(sh_video->bih->biBitCount);
|
|
40 int i;
|
|
41 if(cols>256) cols=256;
|
|
42 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols);
|
|
43 for(i=0;i<cols;i++){
|
|
44 unsigned int c=pal[i];
|
|
45 unsigned int b=c&255;
|
|
46 unsigned int g=(c>>8)&255;
|
|
47 unsigned int r=(c>>16)&255;
|
|
48 if((sh->codec->outfmt[sh->outfmtidx]&255)==15)
|
|
49 pal[i]=((r>>3)<<10)|((g>>3)<<5)|((b>>3));
|
|
50 else
|
|
51 pal[i]=((r>>3)<<11)|((g>>2)<<5)|((b>>3));
|
|
52 }
|
|
53 }
|
|
54 return 1;
|
|
55 }
|
|
56
|
|
57 // uninit driver
|
|
58 static void uninit(sh_video_t *sh){
|
|
59 }
|
|
60
|
|
61 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
|
|
62
|
|
63 void AVI_Decode_RLE8(char *image,char *delta,int tdsize,
|
|
64 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel);
|
|
65
|
|
66 // decode a frame
|
|
67 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
|
68 mp_image_t* mpi;
|
|
69 if(len<=0) return NULL; // skipped frame
|
|
70
|
|
71 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
|
|
72 sh->disp_w, sh->disp_h);
|
|
73 if(!mpi) return NULL;
|
|
74
|
|
75 AVI_Decode_RLE8(mpi->planes[0],data,len,
|
|
76 (int*)(((char*)sh->bih)+40),
|
|
77 sh->disp_w,sh->disp_h,((mpi->imgfmt&255)+7)/8);
|
|
78
|
|
79 return mpi;
|
|
80 }
|
|
81
|