Mercurial > mplayer.hg
comparison spudec.c @ 3822:cdaacdac6571
printf->mp_msg
author | arpi |
---|---|
date | Fri, 28 Dec 2001 01:24:49 +0000 |
parents | 8f7fab2e89bf |
children | 32e488a4fc40 |
comparison
equal
deleted
inserted
replaced
3821:a75add28f16c | 3822:cdaacdac6571 |
---|---|
10 For information on SPU format see <URL:http://sam.zoy.org/doc/dvd/subtitles/> | 10 For information on SPU format see <URL:http://sam.zoy.org/doc/dvd/subtitles/> |
11 and <URL:http://members.aol.com/mpucoder/DVD/spu.html> | 11 and <URL:http://members.aol.com/mpucoder/DVD/spu.html> |
12 | 12 |
13 */ | 13 */ |
14 #include "config.h" | 14 #include "config.h" |
15 #include "mp_msg.h" | |
15 | 16 |
16 #ifdef USE_DVDREAD | 17 #ifdef USE_DVDREAD |
17 | 18 |
18 #include <errno.h> | 19 #include <errno.h> |
19 #include <stdio.h> | 20 #include <stdio.h> |
64 static inline unsigned char get_nibble(spudec_handle_t *this) | 65 static inline unsigned char get_nibble(spudec_handle_t *this) |
65 { | 66 { |
66 unsigned char nib; | 67 unsigned char nib; |
67 int *nibblep = this->current_nibble + this->deinterlace_oddness; | 68 int *nibblep = this->current_nibble + this->deinterlace_oddness; |
68 if (*nibblep / 2 >= this->control_start) { | 69 if (*nibblep / 2 >= this->control_start) { |
69 fprintf(stderr, "ERROR: get_nibble past end of packet\n"); | 70 mp_msg(MSGT_SPUDEC,MSGL_WARN, "SPUdec: ERROR: get_nibble past end of packet\n"); |
70 return 0; | 71 return 0; |
71 } | 72 } |
72 nib = this->packet[*nibblep / 2]; | 73 nib = this->packet[*nibblep / 2]; |
73 if (*nibblep % 2) | 74 if (*nibblep % 2) |
74 nib &= 0xf; | 75 nib &= 0xf; |
175 next_off = this->control_start; | 176 next_off = this->control_start; |
176 while (start_off != next_off) { | 177 while (start_off != next_off) { |
177 start_off = next_off; | 178 start_off = next_off; |
178 date = get_be16(this->packet + start_off); | 179 date = get_be16(this->packet + start_off); |
179 next_off = get_be16(this->packet + start_off + 2); | 180 next_off = get_be16(this->packet + start_off + 2); |
180 printf("date=%d\n", date); | 181 mp_msg(MSGT_SPUDEC,MSGL_DBG2, "date=%d\n", date); |
181 off = start_off + 4; | 182 off = start_off + 4; |
182 for (type = this->packet[off++]; type != 0xff; type = this->packet[off++]) { | 183 for (type = this->packet[off++]; type != 0xff; type = this->packet[off++]) { |
183 printf("cmd=%d ",type); | 184 mp_msg(MSGT_SPUDEC,MSGL_DBG2, "cmd=%d ",type); |
184 switch(type) { | 185 switch(type) { |
185 case 0x00: | 186 case 0x00: |
186 /* Menu ID, 1 byte */ | 187 /* Menu ID, 1 byte */ |
187 printf("Menu ID\n"); | 188 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Menu ID\n"); |
188 break; | 189 break; |
189 case 0x01: | 190 case 0x01: |
190 /* Start display */ | 191 /* Start display */ |
191 printf("Start display!\n"); | 192 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Start display!\n"); |
192 this->start_pts = this->now_pts + date; | 193 this->start_pts = this->now_pts + date; |
193 break; | 194 break; |
194 case 0x02: | 195 case 0x02: |
195 /* Stop display */ | 196 /* Stop display */ |
196 printf("Stop display!\n"); | 197 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Stop display!\n"); |
197 this->end_pts = this->now_pts + date; | 198 this->end_pts = this->now_pts + date; |
198 break; | 199 break; |
199 case 0x03: | 200 case 0x03: |
200 /* Palette */ | 201 /* Palette */ |
201 this->palette[0] = this->packet[off] >> 4; | 202 this->palette[0] = this->packet[off] >> 4; |
202 this->palette[1] = this->packet[off] & 0xf; | 203 this->palette[1] = this->packet[off] & 0xf; |
203 this->palette[2] = this->packet[off + 1] >> 4; | 204 this->palette[2] = this->packet[off + 1] >> 4; |
204 this->palette[3] = this->packet[off + 1] & 0xf; | 205 this->palette[3] = this->packet[off + 1] & 0xf; |
205 printf("Palette %d, %d, %d, %d\n", | 206 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Palette %d, %d, %d, %d\n", |
206 this->palette[0], this->palette[1], this->palette[2], this->palette[3]); | 207 this->palette[0], this->palette[1], this->palette[2], this->palette[3]); |
207 off+=2; | 208 off+=2; |
208 break; | 209 break; |
209 case 0x04: | 210 case 0x04: |
210 /* Alpha */ | 211 /* Alpha */ |
211 this->alpha[0] = this->packet[off] >> 4; | 212 this->alpha[0] = this->packet[off] >> 4; |
212 this->alpha[1] = this->packet[off] & 0xf; | 213 this->alpha[1] = this->packet[off] & 0xf; |
213 this->alpha[2] = this->packet[off + 1] >> 4; | 214 this->alpha[2] = this->packet[off + 1] >> 4; |
214 this->alpha[3] = this->packet[off + 1] & 0xf; | 215 this->alpha[3] = this->packet[off + 1] & 0xf; |
215 printf("Alpha %d, %d, %d, %d\n", | 216 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Alpha %d, %d, %d, %d\n", |
216 this->alpha[0], this->alpha[1], this->alpha[2], this->alpha[3]); | 217 this->alpha[0], this->alpha[1], this->alpha[2], this->alpha[3]); |
217 off+=2; | 218 off+=2; |
218 break; | 219 break; |
219 case 0x05: | 220 case 0x05: |
220 /* Co-ords */ | 221 /* Co-ords */ |
225 this->width = this->end_col - this->start_col + 1; | 226 this->width = this->end_col - this->start_col + 1; |
226 this->stride = (this->width + 7) & ~7; /* Kludge: draw_alpha needs width multiple of 8 */ | 227 this->stride = (this->width + 7) & ~7; /* Kludge: draw_alpha needs width multiple of 8 */ |
227 this->start_row = b >> 12; | 228 this->start_row = b >> 12; |
228 this->end_row = b & 0xfff; | 229 this->end_row = b & 0xfff; |
229 this->height = this->end_row - this->start_row /* + 1 */; | 230 this->height = this->end_row - this->start_row /* + 1 */; |
230 printf("Coords col: %d - %d row: %d - %d (%dx%d)\n", | 231 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Coords col: %d - %d row: %d - %d (%dx%d)\n", |
231 this->start_col, this->end_col, this->start_row, this->end_row, | 232 this->start_col, this->end_col, this->start_row, this->end_row, |
232 this->width, this->height); | 233 this->width, this->height); |
233 off+=6; | 234 off+=6; |
234 break; | 235 break; |
235 case 0x06: | 236 case 0x06: |
236 /* Graphic lines */ | 237 /* Graphic lines */ |
237 this->current_nibble[0] = 2 * get_be16(this->packet + off); | 238 this->current_nibble[0] = 2 * get_be16(this->packet + off); |
238 this->current_nibble[1] = 2 * get_be16(this->packet + off + 2); | 239 this->current_nibble[1] = 2 * get_be16(this->packet + off + 2); |
239 printf("Graphic offset 1: %d offset 2: %d\n", | 240 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Graphic offset 1: %d offset 2: %d\n", |
240 this->current_nibble[0] / 2, this->current_nibble[1] / 2); | 241 this->current_nibble[0] / 2, this->current_nibble[1] / 2); |
241 off+=4; | 242 off+=4; |
242 break; | 243 break; |
243 case 0xff: | 244 case 0xff: |
244 /* All done, bye-bye */ | 245 /* All done, bye-bye */ |
245 printf("Done!\n"); | 246 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Done!\n"); |
246 return; | 247 return; |
247 break; | 248 // break; |
248 default: | 249 default: |
249 printf("spudec: Error determining control type 0x%02x. Skipping %d bytes.\n", | 250 mp_msg(MSGT_SPUDEC,MSGL_WARN,"spudec: Error determining control type 0x%02x. Skipping %d bytes.\n", |
250 type, next_off - off); | 251 type, next_off - off); |
251 goto next_control; | 252 goto next_control; |
252 } | 253 } |
253 } | 254 } |
254 next_control: | 255 next_control: |
283 spu->packet_offset = len; | 284 spu->packet_offset = len; |
284 } | 285 } |
285 } else { | 286 } else { |
286 // Continue current fragment | 287 // Continue current fragment |
287 if (spu->packet_size < spu->packet_offset + len){ | 288 if (spu->packet_size < spu->packet_offset + len){ |
288 fprintf(stderr,"invalid fragment\n"); | 289 mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: invalid fragment\n"); |
289 spu->packet_size = spu->packet_offset = 0; | 290 spu->packet_size = spu->packet_offset = 0; |
290 } else { | 291 } else { |
291 memcpy(spu->packet + spu->packet_offset, packet, len); | 292 memcpy(spu->packet + spu->packet_offset, packet, len); |
292 spu->packet_offset += len; | 293 spu->packet_offset += len; |
293 } | 294 } |
297 // for some disks) | 298 // for some disks) |
298 // if (spu->packet_offset == spu->packet_size) | 299 // if (spu->packet_offset == spu->packet_size) |
299 { int x=0,y; | 300 { int x=0,y; |
300 while(x>=0 && x+4<=spu->packet_offset){ | 301 while(x>=0 && x+4<=spu->packet_offset){ |
301 y=get_be16(spu->packet+x+2); // next control pointer | 302 y=get_be16(spu->packet+x+2); // next control pointer |
302 printf("SPUtest: x=%d y=%d off=%d size=%d\n",x,y,spu->packet_offset,spu->packet_size); | 303 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPUtest: x=%d y=%d off=%d size=%d\n",x,y,spu->packet_offset,spu->packet_size); |
303 if(x>=4 && x==y){ // if it points to self - we're done! | 304 if(x>=4 && x==y){ // if it points to self - we're done! |
304 // we got it! | 305 // we got it! |
305 printf("SPUgot: off=%d size=%d \n",spu->packet_offset,spu->packet_size); | 306 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPUgot: off=%d size=%d \n",spu->packet_offset,spu->packet_size); |
306 spudec_decode(spu); | 307 spudec_decode(spu); |
307 spu->packet_offset = 0; | 308 spu->packet_offset = 0; |
308 break; | 309 break; |
309 } | 310 } |
310 if(y<=x || y>=spu->packet_size){ // invalid? | 311 if(y<=x || y>=spu->packet_size){ // invalid? |
311 printf("SPUtest: broken packet!!!!! y=%d < x=%d\n",y,x); | 312 mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUtest: broken packet!!!!! y=%d < x=%d\n",y,x); |
312 spu->packet_size = spu->packet_offset = 0; | 313 spu->packet_size = spu->packet_offset = 0; |
313 break; | 314 break; |
314 } | 315 } |
315 x=y; | 316 x=y; |
316 } | 317 } |