annotate libmpcodecs/vd_rle.c @ 5404:534580bc88a8

FreeBSD require stdlib.h
author nexus
date Sat, 30 Mar 2002 14:42:32 +0000
parents 3dcbf67c0de0
children a890a999ca9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
1 #include <stdio.h>
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
2 #include <stdlib.h>
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
3
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
4 #include "config.h"
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
5 #include "mp_msg.h"
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
6
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
7 #include "vd_internal.h"
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
8
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
9 static vd_info_t info = {
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
10 "RLE Video decoder",
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
11 "rle",
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
12 VFM_RLE,
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
13 "A'rpi",
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
14 "XAnim rip...",
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
15 "native codec"
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
16 };
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
17
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
18 LIBVD_EXTERN(rle)
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
19
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
20 // to set/get/query special features/parameters
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
21 static int control(sh_video_t *sh,int cmd,void* arg,...){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
22 return CONTROL_UNKNOWN;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
23 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
24
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
25 // init driver
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
26 static int init(sh_video_t *sh){
5124
3dcbf67c0de0 handle error from mpcodecs_config_vo()
arpi
parents: 4986
diff changeset
27 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24)) return 0;
4969
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
28 if( (((sh->codec->outfmt[sh->outfmtidx]&255)+7)/8)==2 ){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
29 unsigned int* pal=(unsigned int*)(((char*)sh->bih)+40);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
30 int cols=(sh->bih->biSize-40)/4;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
31 //int cols=1<<(sh_video->bih->biBitCount);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
32 int i;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
33 if(cols>256) cols=256;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
34 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
35 for(i=0;i<cols;i++){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
36 unsigned int c=pal[i];
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
37 unsigned int b=c&255;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
38 unsigned int g=(c>>8)&255;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
39 unsigned int r=(c>>16)&255;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
40 if((sh->codec->outfmt[sh->outfmtidx]&255)==15)
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
41 pal[i]=((r>>3)<<10)|((g>>3)<<5)|((b>>3));
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
42 else
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
43 pal[i]=((r>>3)<<11)|((g>>2)<<5)|((b>>3));
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
44 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
45 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
46 return 1;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
47 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
48
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
49 // uninit driver
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
50 static void uninit(sh_video_t *sh){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
51 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
52
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
53 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
54
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
55 void AVI_Decode_RLE8(char *image,char *delta,int tdsize,
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
56 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
57
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
58 // decode a frame
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
59 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
60 mp_image_t* mpi;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
61 if(len<=0) return NULL; // skipped frame
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
62
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
63 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
64 sh->disp_w, sh->disp_h);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
65 if(!mpi) return NULL;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
66
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
67 AVI_Decode_RLE8(mpi->planes[0],data,len,
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
68 (int*)(((char*)sh->bih)+40),
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
69 sh->disp_w,sh->disp_h,((mpi->imgfmt&255)+7)/8);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
70
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
71 return mpi;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
72 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
73