Mercurial > mplayer.hg
annotate spudec.c @ 3814:8c210c467a3f
not "us", but "en" - missed previously
author | gabucino |
---|---|
date | Thu, 27 Dec 2001 23:38:49 +0000 |
parents | d358f4a74690 |
children | 8f7fab2e89bf |
rev | line source |
---|---|
560 | 1 /* SPUdec.c |
673 | 2 Skeleton of function spudec_process_controll() is from xine sources. |
560 | 3 Further works: |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
4 LGB,... (yeah, try to improve it and insert your name here! ;-) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
5 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
6 Kim Minh Kaplan |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
7 implement fragments reassembly, RLE decoding. |
3166 | 8 read brightness from the IFO. |
560 | 9 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
10 For information on SPU format see <URL:http://sam.zoy.org/doc/dvd/subtitles/> |
3402 | 11 and <URL:http://members.aol.com/mpucoder/DVD/spu.html> |
560 | 12 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
13 */ |
3183 | 14 #include "config.h" |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
15 |
3180
d53f70e3c794
spudec_new has a dvd_priv_t as an argument, which is defined in
pl
parents:
3175
diff
changeset
|
16 #ifdef USE_DVDREAD |
d53f70e3c794
spudec_new has a dvd_priv_t as an argument, which is defined in
pl
parents:
3175
diff
changeset
|
17 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
18 #include <errno.h> |
560 | 19 #include <stdio.h> |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
20 #include <stdlib.h> |
3175 | 21 #include <unistd.h> |
560 | 22 #include "spudec.h" |
23 | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
24 typedef struct { |
3166 | 25 dvd_priv_t *dvd_info; /* Info from libmpdemux */ |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
26 unsigned char* packet; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
27 size_t packet_reserve; /* size of the memory pointed to by packet */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
28 int packet_offset; /* end of the currently assembled fragment */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
29 int packet_size; /* size of the packet once all fragments are assembled */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
30 int control_start; /* index of start of control data */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
31 int palette[4]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
32 int alpha[4]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
33 int now_pts; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
34 int start_pts, end_pts; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
35 int start_col, end_col; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
36 int start_row, end_row; |
3402 | 37 int width, height, stride; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
38 int current_nibble[2]; /* next data nibble (4 bits) to be |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
39 processed (for RLE decoding) for |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
40 even and odd lines */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
41 int deinterlace_oddness; /* 0 or 1, index into current_nibble */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
42 size_t image_size; /* Size of the image buffer */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
43 unsigned char *image; /* Grayscale value */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
44 unsigned char *aimage; /* Alpha value */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
45 } spudec_handle_t; |
560 | 46 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
47 static inline unsigned int get_be16(const unsigned char *p) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
48 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
49 return (p[0] << 8) + p[1]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
50 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
51 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
52 static inline unsigned int get_be24(const unsigned char *p) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
53 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
54 return (get_be16(p) << 8) + p[2]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
55 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
56 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
57 static void next_line(spudec_handle_t *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
58 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
59 if (this->current_nibble[this->deinterlace_oddness] % 2) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
60 this->current_nibble[this->deinterlace_oddness]++; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
61 this->deinterlace_oddness = (this->deinterlace_oddness + 1) % 2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
62 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
63 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
64 static inline unsigned char get_nibble(spudec_handle_t *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
65 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
66 unsigned char nib; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
67 int *nibblep = this->current_nibble + this->deinterlace_oddness; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
68 if (*nibblep / 2 >= this->control_start) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
69 fprintf(stderr, "ERROR: get_nibble past end of packet\n"); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
70 return 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
71 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
72 nib = this->packet[*nibblep / 2]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
73 if (*nibblep % 2) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
74 nib &= 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
75 else |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
76 nib >>= 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
77 ++*nibblep; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
78 return nib; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
79 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
80 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
81 static inline int mkalpha(int i) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
82 { |
3166 | 83 /* In mplayer's alpha planes, 0 is transparent, then 1 is nearly |
84 opaque upto 255 which is transparent */ | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
85 switch (i) { |
3166 | 86 case 0xf: |
87 return 1; | |
88 case 0: | |
89 return 0; | |
90 default: | |
91 return (0xf - i) << 4; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
92 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
93 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
94 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
95 static void spudec_process_data(spudec_handle_t *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
96 { |
3166 | 97 int cmap[4], alpha[4]; |
3402 | 98 int i, x, y; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
99 |
3166 | 100 for (i = 0; i < 4; ++i) { |
101 alpha[i] = mkalpha(this->alpha[i]); | |
102 if (alpha[i] == 0) | |
103 cmap[i] = 0; | |
104 else { | |
3402 | 105 cmap[i] = ((this->dvd_info->cur_pgc->palette[this->palette[i]] >> 16) & 0xff) - alpha[i]; |
3166 | 106 if (cmap[i] < 0) |
107 cmap[i] = 0; | |
108 } | |
109 } | |
110 | |
3402 | 111 if (this->image_size < this->stride * this->height) { |
112 if (this->image != NULL) { | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
113 free(this->image); |
3402 | 114 this->image_size = 0; |
115 } | |
116 this->image = malloc(2 * this->stride * this->height); | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
117 if (this->image) { |
3402 | 118 this->image_size = this->stride * this->height; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
119 this->aimage = this->image + this->image_size; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
120 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
121 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
122 if (this->image == NULL) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
123 return; |
3402 | 124 |
125 /* Kludge: draw_alpha needs width multiple of 8. */ | |
126 if (this->width < this->stride) | |
127 for (y = 0; y < this->height; ++y) | |
128 memset(this->aimage + y * this->stride + this->width, 0, this->stride - this->width); | |
129 | |
3166 | 130 i = this->current_nibble[1]; |
3402 | 131 x = 0; |
132 y = 0; | |
3166 | 133 while (this->current_nibble[0] < i |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
134 && this->current_nibble[1] / 2 < this->control_start |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
135 && y < this->height) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
136 int len, color; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
137 unsigned int rle = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
138 rle = get_nibble(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
139 if (rle < 0x04) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
140 rle = (rle << 4) | get_nibble(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
141 if (rle < 0x10) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
142 rle = (rle << 4) | get_nibble(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
143 if (rle < 0x040) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
144 rle = (rle << 4) | get_nibble(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
145 if (rle < 0x0004) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
146 rle |= ((this->width - x) << 2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
147 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
148 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
149 } |
3166 | 150 color = 3 - (rle & 0x3); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
151 len = rle >> 2; |
3402 | 152 if (len > this->width - x || len == 0) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
153 len = this->width - x; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
154 /* FIXME have to use palette and alpha map*/ |
3402 | 155 memset(this->image + y * this->stride + x, cmap[color], len); |
156 memset(this->aimage + y * this->stride + x, alpha[color], len); | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
157 x += len; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
158 if (x >= this->width) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
159 next_line(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
160 x = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
161 ++y; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
162 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
163 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
164 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
165 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
166 static void spudec_process_control(spudec_handle_t *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
167 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
168 int a,b; /* Temporary vars */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
169 int date, type; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
170 int off; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
171 int start_off = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
172 int next_off; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
173 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
174 this->control_start = get_be16(this->packet + 2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
175 next_off = this->control_start; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
176 while (start_off != next_off) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
177 start_off = next_off; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
178 date = get_be16(this->packet + start_off); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
179 next_off = get_be16(this->packet + start_off + 2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
180 printf("date=%d\n", date); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
181 off = start_off + 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
182 for (type = this->packet[off++]; type != 0xff; type = this->packet[off++]) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
183 printf("cmd=%d ",type); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
184 switch(type) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
185 case 0x00: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
186 /* Menu ID, 1 byte */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
187 printf("Menu ID\n"); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
188 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
189 case 0x01: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
190 /* Start display */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
191 printf("Start display!\n"); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
192 this->start_pts = this->now_pts + date; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
193 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
194 case 0x02: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
195 /* Stop display */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
196 printf("Stop display!\n"); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
197 this->end_pts = this->now_pts + date; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
198 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
199 case 0x03: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
200 /* Palette */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
201 this->palette[0] = this->packet[off] >> 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
202 this->palette[1] = this->packet[off] & 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
203 this->palette[2] = this->packet[off + 1] >> 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
204 this->palette[3] = this->packet[off + 1] & 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
205 printf("Palette %d, %d, %d, %d\n", |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
206 this->palette[0], this->palette[1], this->palette[2], this->palette[3]); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
207 off+=2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
208 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
209 case 0x04: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
210 /* Alpha */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
211 this->alpha[0] = this->packet[off] >> 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
212 this->alpha[1] = this->packet[off] & 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
213 this->alpha[2] = this->packet[off + 1] >> 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
214 this->alpha[3] = this->packet[off + 1] & 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
215 printf("Alpha %d, %d, %d, %d\n", |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
216 this->alpha[0], this->alpha[1], this->alpha[2], this->alpha[3]); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
217 off+=2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
218 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
219 case 0x05: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
220 /* Co-ords */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
221 a = get_be24(this->packet + off); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
222 b = get_be24(this->packet + off + 3); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
223 this->start_col = a >> 12; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
224 this->end_col = a & 0xfff; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
225 this->width = this->end_col - this->start_col + 1; |
3402 | 226 this->stride = (this->width + 7) & ~7; /* Kludge: draw_alpha needs width multiple of 8 */ |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
227 this->start_row = b >> 12; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
228 this->end_row = b & 0xfff; |
3166 | 229 this->height = this->end_row - this->start_row /* + 1 */; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
230 printf("Coords col: %d - %d row: %d - %d (%dx%d)\n", |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
231 this->start_col, this->end_col, this->start_row, this->end_row, |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
232 this->width, this->height); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
233 off+=6; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
234 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
235 case 0x06: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
236 /* Graphic lines */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
237 this->current_nibble[0] = 2 * get_be16(this->packet + off); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
238 this->current_nibble[1] = 2 * get_be16(this->packet + off + 2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
239 printf("Graphic offset 1: %d offset 2: %d\n", |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
240 this->current_nibble[0] / 2, this->current_nibble[1] / 2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
241 off+=4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
242 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
243 case 0xff: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
244 /* All done, bye-bye */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
245 printf("Done!\n"); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
246 return; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
247 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
248 default: |
3402 | 249 printf("spudec: Error determining control type 0x%02x. Skipping %d bytes.\n", |
250 type, next_off - off); | |
251 goto next_control; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
252 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
253 } |
3402 | 254 next_control: |
3725 | 255 ; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
256 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
257 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
258 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
259 static void spudec_decode(spudec_handle_t *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
260 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
261 spudec_process_control(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
262 spudec_process_data(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
263 } |
560 | 264 |
265 | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
266 void spudec_assemble(void *this, unsigned char *packet, int len, int pts100) |
560 | 267 { |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
268 spudec_handle_t *spu = (spudec_handle_t*)this; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
269 spudec_heartbeat(this, pts100); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
270 if (spu->packet_offset == 0) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
271 unsigned int len2 = get_be16(packet); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
272 // Start new fragment |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
273 if (spu->packet_reserve < len2) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
274 if (spu->packet != NULL) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
275 free(spu->packet); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
276 spu->packet = malloc(len2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
277 spu->packet_reserve = spu->packet != NULL ? len2 : 0; |
560 | 278 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
279 if (spu->packet != NULL) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
280 spu->deinterlace_oddness = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
281 spu->packet_size = len2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
282 memcpy(spu->packet, packet, len); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
283 spu->packet_offset = len; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
284 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
285 } else { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
286 // Continue current fragment |
3744 | 287 if (spu->packet_size < spu->packet_offset + len){ |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
288 fprintf(stderr,"invalid fragment\n"); |
3744 | 289 spu->packet_size = spu->packet_offset = 0; |
290 } else { | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
291 memcpy(spu->packet + spu->packet_offset, packet, len); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
292 spu->packet_offset += len; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
293 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
294 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
295 if (spu->packet_offset == spu->packet_size) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
296 spudec_decode(spu); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
297 spu->packet_offset = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
298 } |
560 | 299 } |
300 | |
3744 | 301 void spudec_reset(void *this) // called after seek |
302 { | |
303 spudec_handle_t *spu = (spudec_handle_t*)this; | |
304 spu->now_pts = -1; | |
305 spu->packet_size = spu->packet_offset = 0; | |
306 } | |
307 | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
308 void spudec_heartbeat(void *this, int pts100) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
309 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
310 ((spudec_handle_t *)this)->now_pts = pts100; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
311 } |
560 | 312 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
313 void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
314 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
315 spudec_handle_t *spu = (spudec_handle_t *)this; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
316 if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts && spu->image) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
317 draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, |
3402 | 318 spu->image, spu->aimage, spu->stride); |
561 | 319 } |
320 | |
3166 | 321 void *spudec_new(dvd_priv_t *dvd_info) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
322 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
323 spudec_handle_t *this = calloc(1, sizeof(spudec_handle_t)); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
324 if (this) { |
3166 | 325 this->dvd_info = dvd_info; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
326 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
327 else |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
328 perror("FATAL: spudec_init: calloc"); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
329 return this; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
330 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
331 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
332 void spudec_free(void *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
333 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
334 spudec_handle_t *spu = (spudec_handle_t*)this; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
335 if (spu) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
336 if (spu->packet) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
337 free(spu->packet); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
338 if (spu->image) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
339 free(spu->image); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
340 free(spu); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
341 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
342 } |
3180
d53f70e3c794
spudec_new has a dvd_priv_t as an argument, which is defined in
pl
parents:
3175
diff
changeset
|
343 |
d53f70e3c794
spudec_new has a dvd_priv_t as an argument, which is defined in
pl
parents:
3175
diff
changeset
|
344 #endif /* USE_DVDREAD */ |
d53f70e3c794
spudec_new has a dvd_priv_t as an argument, which is defined in
pl
parents:
3175
diff
changeset
|
345 |