Mercurial > mplayer.hg
comparison libvo/spuenc.c @ 29263:0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
author | diego |
---|---|
date | Wed, 13 May 2009 02:58:57 +0000 |
parents | d5d66bff938a |
children | 358ac046eccc |
comparison
equal
deleted
inserted
replaced
29262:7d545a6b8aff | 29263:0f1b5b68af32 |
---|---|
2 * encode a pixmap with RLE | 2 * encode a pixmap with RLE |
3 * | 3 * |
4 * Copyright (C) 2000 Alejandro J. Cura <alecu@protocultura.net> | 4 * Copyright (C) 2000 Alejandro J. Cura <alecu@protocultura.net> |
5 * | 5 * |
6 * (modified a bit to work with the dxr3 driver...4/2/2002 cg) | 6 * (modified a bit to work with the dxr3 driver...4/2/2002 cg) |
7 * | 7 * |
8 * Based on the hard work of: | 8 * Based on the hard work of: |
9 * | 9 * |
10 * Samuel Hocevar <sam@via.ecp.fr> and Michel Lespinasse <walken@via.ecp.fr> | 10 * Samuel Hocevar <sam@via.ecp.fr> and Michel Lespinasse <walken@via.ecp.fr> |
11 * | 11 * |
12 * This file is part of MPlayer. | 12 * This file is part of MPlayer. |
46 bottom= top + pb->y - 1; | 46 bottom= top + pb->y - 1; |
47 right= left + pb->x - 1; | 47 right= left + pb->x - 1; |
48 | 48 |
49 /* the format of this is well described by a page: | 49 /* the format of this is well described by a page: |
50 * http://members.aol.com/mpucoder/DVD/spu.html | 50 * http://members.aol.com/mpucoder/DVD/spu.html |
51 * | 51 * |
52 * note I changed the layout of commands to turn off the subpic as the | 52 * note I changed the layout of commands to turn off the subpic as the |
53 * first command, and then turn on the new subpic...this is so we can | 53 * first command, and then turn on the new subpic...this is so we can |
54 * leave the subpic on for an arbitrary ammount of time as controlled by | 54 * leave the subpic on for an arbitrary ammount of time as controlled by |
55 * mplayer (ie when we turn on the subpic we don't know how long it should | 55 * mplayer (ie when we turn on the subpic we don't know how long it should |
56 * stay on when using mplayer). | 56 * stay on when using mplayer). |
57 * with this layout we turn off the last subpic as we are turning on the | 57 * with this layout we turn off the last subpic as we are turning on the |
58 * new one. | 58 * new one. |
59 * The original hd it turn on the subpic, and delay the turn off command using | 59 * The original hd it turn on the subpic, and delay the turn off command using |
60 * the durration/delay feature. | 60 * the durration/delay feature. |
61 * */ | 61 * */ |
62 /* start at x0+2*/ | 62 /* start at x0+2*/ |
63 i= controlstart; | 63 i= controlstart; |
64 /* display duration... */ | 64 /* display duration... */ |
65 // ed->data[i++]= 0x00; | 65 // ed->data[i++]= 0x00; |
66 // ed->data[i++]= 0x00; //durration before turn off command occurs | 66 // ed->data[i++]= 0x00; //durration before turn off command occurs |
67 //in 90000/1024 units | 67 //in 90000/1024 units |
68 | 68 |
69 /* x1 */ | 69 /* x1 */ |
70 // x1=i+4; | 70 // x1=i+4; |
71 // ed->data[i++]= x1 >> 8;//location of next command block | 71 // ed->data[i++]= x1 >> 8;//location of next command block |
72 // ed->data[i++]= x1 & 0xff; | 72 // ed->data[i++]= x1 & 0xff; |
73 /* finish it */ | 73 /* finish it */ |
74 // ed->data[i++]= 0x02;//turn off command | 74 // ed->data[i++]= 0x02;//turn off command |
75 // ed->data[i++]= 0xff;//end of command block | 75 // ed->data[i++]= 0xff;//end of command block |
76 x1= i; //marker for last command block address | 76 x1= i; //marker for last command block address |
77 | 77 |
78 /* display duration... */ | 78 /* display duration... */ |
79 ed->data[i++]= 0x00; | 79 ed->data[i++]= 0x00; |
80 ed->data[i++]= 0x00; //durration before turn on command occurs | 80 ed->data[i++]= 0x00; //durration before turn on command occurs |
81 //in 90000/1024 units | 81 //in 90000/1024 units |
82 /* x1 */ | 82 /* x1 */ |
90 /* 0x03: palette info */ | 90 /* 0x03: palette info */ |
91 ed->data[i++]= 0x03; | 91 ed->data[i++]= 0x03; |
92 ed->data[i++]= 0x08; | 92 ed->data[i++]= 0x08; |
93 ed->data[i++]= 0x7f; | 93 ed->data[i++]= 0x7f; |
94 /* | 94 /* |
95 * The palette is a coded index (one of 16) 0 is black, 0xf is white | 95 * The palette is a coded index (one of 16) 0 is black, 0xf is white |
96 * (unless you screw with the default palette) | 96 * (unless you screw with the default palette) |
97 * for what I am doing I only use white. | 97 * for what I am doing I only use white. |
98 * 7 is lt grey, and 8 is dk grey... | 98 * 7 is lt grey, and 8 is dk grey... |
99 * */ | 99 * */ |
100 /* 0x04: transparency info (reversed) */ | 100 /* 0x04: transparency info (reversed) */ |
101 ed->data[i++]= 0x04; | 101 ed->data[i++]= 0x04; |
102 ed->data[i++]= 0xFF;//change the opacity values of the color entries | 102 ed->data[i++]= 0xFF;//change the opacity values of the color entries |
128 } | 128 } |
129 | 129 |
130 /* x0 */ | 130 /* x0 */ |
131 ed->data[2]= (controlstart) >> 8; | 131 ed->data[2]= (controlstart) >> 8; |
132 ed->data[3]= (controlstart) & 0xff; | 132 ed->data[3]= (controlstart) & 0xff; |
133 | 133 |
134 /* packet size */ | 134 /* packet size */ |
135 ed->data[0]= i >> 8; | 135 ed->data[0]= i >> 8; |
136 ed->data[1]= i & 0xff; | 136 ed->data[1]= i & 0xff; |
137 | 137 |
138 ed->count= i; | 138 ed->count= i; |
139 } | 139 } |
140 | 140 |
141 static void | 141 static void |
142 encode_put_nibble( encodedata* ed, unsigned char nibble ) { | 142 encode_put_nibble( encodedata* ed, unsigned char nibble ) { |
177 encode_do_row( encodedata* ed, pixbuf* pb, int row ) { | 177 encode_do_row( encodedata* ed, pixbuf* pb, int row ) { |
178 int i= 0; | 178 int i= 0; |
179 unsigned char* pix= pb->pixels + row * pb->x; | 179 unsigned char* pix= pb->pixels + row * pb->x; |
180 int color= *pix; | 180 int color= *pix; |
181 int n= 0; /* the number of pixels of this color */ | 181 int n= 0; /* the number of pixels of this color */ |
182 | 182 |
183 while( i++ < pb->x ) { | 183 while( i++ < pb->x ) { |
184 /* FIXME: watch this space for EOL */ | 184 /* FIXME: watch this space for EOL */ |
185 if( *pix != color || n == 255 ) { | 185 if( *pix != color || n == 255 ) { |
186 encode_pixels( ed, color, n ); | 186 encode_pixels( ed, color, n ); |
187 color= *pix; | 187 color= *pix; |
231 } | 231 } |
232 | 232 |
233 | 233 |
234 void | 234 void |
235 pixbuf_load_xpm( pixbuf* pb, char* xpm[] ) { | 235 pixbuf_load_xpm( pixbuf* pb, char* xpm[] ) { |
236 int colors, chrs, l, n; | 236 int colors, chrs, l, n; |
237 char c[4], table[256]; | 237 char c[4], table[256]; |
238 unsigned char *b, *i; | 238 unsigned char *b, *i; |
239 | 239 |
240 sscanf( xpm[0], "%d %d %d %d", &pb->x, &pb->y, &colors, &chrs); | 240 sscanf( xpm[0], "%d %d %d %d", &pb->x, &pb->y, &colors, &chrs); |
241 if( colors > 4 ) { | 241 if( colors > 4 ) { |
248 } | 248 } |
249 if( pb->x > 0xFFF || pb->y > 0xFFF ) { | 249 if( pb->x > 0xFFF || pb->y > 0xFFF ) { |
250 fprintf( stderr, "the size is excesive\n"); | 250 fprintf( stderr, "the size is excesive\n"); |
251 exit (-1); | 251 exit (-1); |
252 } | 252 } |
253 | 253 |
254 for( l=0; l<colors; l++ ) { | 254 for( l=0; l<colors; l++ ) { |
255 n= sscanf( xpm[l+1], "%c c #%x", &c[l], &pb->rgb[l]); | 255 n= sscanf( xpm[l+1], "%c c #%x", &c[l], &pb->rgb[l]); |
256 if( n < 2 ) { | 256 if( n < 2 ) { |
257 /* this one is transparent */ | 257 /* this one is transparent */ |
258 pb->rgb[l]=0xff000000; | 258 pb->rgb[l]=0xff000000; |
260 table[(int)c[l]]=l; | 260 table[(int)c[l]]=l; |
261 } | 261 } |
262 | 262 |
263 pb->pixels= malloc( pb->x * pb->y ); | 263 pb->pixels= malloc( pb->x * pb->y ); |
264 b= pb->pixels; | 264 b= pb->pixels; |
265 | 265 |
266 for( l= colors+1; l <= pb->y + colors; l++ ) { | 266 for( l= colors+1; l <= pb->y + colors; l++ ) { |
267 i= xpm[l]; | 267 i= xpm[l]; |
268 while( (int)*i) { | 268 while( (int)*i) { |
269 *b++ = table[*i++]; | 269 *b++ = table[*i++]; |
270 } | 270 } |