560
|
1 /* SPUdec.c
|
673
|
2 Skeleton of function spudec_process_controll() is from xine sources.
|
560
|
3 Further works:
|
|
4 LGB,... (yeah, try to improve it and insert your name here! ;-) */
|
|
5
|
|
6
|
|
7 #include <stdio.h>
|
|
8 #include "spudec.h"
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13 void spudec_process_control(unsigned char *control, int size, int* d1, int* d2)
|
|
14 {
|
|
15 int off = 2;
|
|
16 int a,b; /* Temporary vars */
|
|
17
|
|
18 do {
|
|
19 int type = control[off];
|
|
20 off++;
|
|
21 printf("cmd=%d ",type);
|
|
22
|
|
23 switch(type) {
|
|
24 case 0x00:
|
|
25 /* Menu ID, 1 byte */
|
|
26 printf("Menu ID\n");
|
|
27 break;
|
|
28 case 0x01:
|
|
29 /* Start display */
|
|
30 printf("Start display!\n");
|
|
31 // gSpudec.geom.bIsVisible = 1;
|
|
32 break;
|
|
33 case 0x03:
|
|
34 /* Palette */
|
|
35 printf("Palette\n");
|
|
36 // palette[3] = &(gSpudec.clut[(control[off] >> 4)]);
|
|
37 // palette[2] = &(gSpudec.clut[control[off] & 0xf]);
|
|
38 // palette[1] = &(gSpudec.clut[(control[off+1] >> 4)]);
|
|
39 // palette[0] = &(gSpudec.clut[control[off+1] & 0xf]);
|
|
40 off+=2;
|
|
41 break;
|
|
42 case 0x04:
|
|
43 /* Alpha */
|
|
44 printf("Alpha\n");
|
|
45 // alpha[3] = control[off] & 0xf0;
|
|
46 // alpha[2] = (control[off] & 0xf) << 4;
|
|
47 // alpha[1] = control[off+1] & 0xf0;
|
|
48 // alpha[0] = (control[off+1] & 0xf) << 4;
|
|
49 off+=2;
|
|
50 break;
|
|
51 case 0x05:
|
|
52 /* Co-ords */
|
|
53 a = (control[off] << 16) + (control[off+1] << 8) + control[off+2];
|
|
54 b = (control[off+3] << 16) + (control[off+4] << 8) + control[off+5];
|
|
55
|
|
56 printf("Coords col: %d - %d row: %d - %d\n",a >> 12,a & 0xfff,b >> 12,b & 0xfff);
|
|
57
|
|
58 // gSpudec.geom.start_col = a >> 12;
|
|
59 // gSpudec.geom.end_col = a & 0xfff;
|
|
60 // gSpudec.geom.start_row = b >> 12;
|
|
61 // gSpudec.geom.end_row = b & 0xfff;
|
|
62
|
|
63 off+=6;
|
|
64 break;
|
|
65 case 0x06:
|
|
66 /* Graphic lines */
|
|
67 *(d1) = (control[off] << 8) + control[off+1];
|
|
68 *(d2) = (control[off+2] << 8) + control[off+3];
|
|
69 printf("Graphic pos color: %d b/w: %d\n",*d1,*d2);
|
|
70 off+=4;
|
|
71 break;
|
|
72 case 0xff:
|
|
73 /* All done, bye-bye */
|
|
74 printf("Done!\n");
|
|
75 return;
|
|
76 break;
|
|
77 default:
|
|
78 printf("spudec: Error determining control type 0x%02x.\n",type);
|
|
79 return;
|
|
80 break;
|
|
81 }
|
|
82
|
|
83 /* printf("spudec: Processsed control type 0x%02x.\n",type); */
|
|
84 } while(off < size);
|
|
85 }
|
|
86
|
561
|
87 // SPU packet format: (guess only, by A'rpi)
|
|
88 // 0 word whole packet size
|
|
89 // 2 word x0 sub-packet size
|
|
90 // 4 x0-2 pixel data
|
|
91 // x0+2 word x1 sub-packet size
|
|
92 // x0+4 x1-x0-2 process control data
|
|
93 // x1 word lifetime
|
|
94 // x1+2 word x1 sub-packet size again
|
560
|
95
|
561
|
96 void spudec_decode(unsigned char *packet,int len){
|
|
97 int x0, x1;
|
|
98 int d1, d2;
|
|
99 int lifetime;
|
|
100 x0 = (packet[2] << 8) + packet[3];
|
|
101 x1 = (packet[x0+2] << 8) + packet[x0+3];
|
560
|
102
|
561
|
103 /* /Another/ sanity check. */
|
|
104 if((packet[x1+2]<<8) + packet[x1+3] != x1) {
|
|
105 printf("spudec: Incorrect packet.\n");
|
|
106 return;
|
|
107 }
|
|
108 lifetime= ((packet[x1]<<8) + packet[x1+1]);
|
|
109 printf("lifetime=%d\n",lifetime);
|
|
110
|
|
111 d1 = d2 = -1;
|
|
112 spudec_process_control(packet + x0 + 2, x1-x0-2, &d1, &d2);
|
|
113 // if((d1 != -1) && (d2 != -1)) {
|
|
114 // spudec_process_data(packet, x0, d1, d2);
|
|
115 // }
|
|
116 }
|
|
117
|