annotate spudec.c @ 2726:d81c978eacc4

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