annotate libmpcodecs/vd_rle.c @ 5564:efe856039f8f

VFCAP defines moved out from vf.h, to be easier to include in libvo
author arpi
date Thu, 11 Apr 2002 20:55:10 +0000
parents e0a0c8d848a1
children 28677d779205
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",
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
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
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
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){
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
3dcbf67c0de0 handle error from mpcodecs_config_vo()
arpi
parents: 4986
diff changeset
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
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
36 if( (((sh->codec->outfmt[sh->outfmtidx]&255)+7)/8)==2 ){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
37 int i;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
38 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
39 for(i=0;i<cols;i++){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
40 unsigned int c=pal[i];
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
41 unsigned int b=c&255;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
42 unsigned int g=(c>>8)&255;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
43 unsigned int r=(c>>16)&255;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
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
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
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
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
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
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
51 return 1;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
52 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
53
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
54 // uninit driver
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
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
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
57 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
58
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
59 //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
60
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
61 void AVI_Decode_RLE8(char *image,char *delta,int tdsize,
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
62 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
63
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
64 // decode a frame
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
65 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
66 mp_image_t* mpi;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
67 if(len<=0) return NULL; // skipped frame
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
68
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
69 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
70 sh->disp_w, sh->disp_h);
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
71 if(!mpi) return NULL;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
72
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
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
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
76
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
77 return mpi;
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
78 }
db86fcf25ede xanim, raw, rle added
arpi
parents:
diff changeset
79