Mercurial > mplayer.hg
annotate spudec.c @ 7489:f00412e45b89
sync by Fire <sefanja@gmx.net>
author | jaf |
---|---|
date | Mon, 23 Sep 2002 07:49:25 +0000 |
parents | d796833e77af |
children | a280cc3087ea |
rev | line source |
---|---|
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
1 /* Valid values for ANTIALIASING_ALGORITHM: |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
2 -1: bilinear (similiar to vobsub, fast and good quality) |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
3 0: none (fastest, most ugly) |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
4 1: approximate |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
5 2: full (slowest, best looking) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
6 */ |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
7 #define ANTIALIASING_ALGORITHM -1 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
8 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
9 /* Valid values for SUBPOS: |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
10 0: leave the sub on it's original place |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
11 1: put the sub at the bottom of the picture |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
12 */ |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
13 #define SUBPOS 0 |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
14 |
560 | 15 /* SPUdec.c |
673 | 16 Skeleton of function spudec_process_controll() is from xine sources. |
560 | 17 Further works: |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
18 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
|
19 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
20 Kim Minh Kaplan |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
21 implement fragments reassembly, RLE decoding. |
3166 | 22 read brightness from the IFO. |
560 | 23 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
24 For information on SPU format see <URL:http://sam.zoy.org/doc/dvd/subtitles/> |
3402 | 25 and <URL:http://members.aol.com/mpucoder/DVD/spu.html> |
560 | 26 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
27 */ |
3183 | 28 #include "config.h" |
3822 | 29 #include "mp_msg.h" |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
30 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
31 #include <errno.h> |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
32 #include <limits.h> |
560 | 33 #include <stdio.h> |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
34 #include <stdlib.h> |
3175 | 35 #include <unistd.h> |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
36 #include <string.h> |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
37 #if ANTIALIASING_ALGORITHM == 2 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
38 #include <math.h> |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
39 #endif |
6110 | 40 #include "libvo/video_out.h" |
560 | 41 #include "spudec.h" |
42 | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
43 #define MIN(a, b) ((a)<(b)?(a):(b)) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
44 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
45 typedef struct { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
46 unsigned int global_palette[16]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
47 unsigned int orig_frame_width, orig_frame_height; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
48 unsigned char* packet; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
49 size_t packet_reserve; /* size of the memory pointed to by packet */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
50 unsigned int packet_offset; /* end of the currently assembled fragment */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
51 unsigned int packet_size; /* size of the packet once all fragments are assembled */ |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
52 unsigned int packet_pts; /* PTS for this packet */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
53 unsigned int control_start; /* index of start of control data */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
54 unsigned int palette[4]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
55 unsigned int alpha[4]; |
5833
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
56 unsigned int cuspal[4]; |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
57 unsigned int custom; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
58 unsigned int now_pts; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
59 unsigned int start_pts, end_pts; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
60 unsigned int start_col, end_col; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
61 unsigned int start_row, end_row; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
62 unsigned int width, height, stride; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
63 unsigned int current_nibble[2]; /* next data nibble (4 bits) to be |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
64 processed (for RLE decoding) for |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
65 even and odd lines */ |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
66 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
|
67 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
|
68 unsigned char *image; /* Grayscale value */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
69 unsigned char *aimage; /* Alpha value */ |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
70 unsigned int scaled_frame_width, scaled_frame_height; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
71 unsigned int scaled_start_col, scaled_start_row; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
72 unsigned int scaled_width, scaled_height, scaled_stride; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
73 size_t scaled_image_size; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
74 unsigned char *scaled_image; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
75 unsigned char *scaled_aimage; |
6110 | 76 int auto_palette; /* 1 if we lack a palette and must use an heuristic. */ |
77 int font_start_level; /* Darkest value used for the computed font */ | |
78 vo_functions_t *hw_spu; | |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
79 int spu_changed; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
80 } spudec_handle_t; |
560 | 81 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
82 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
|
83 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
84 return (p[0] << 8) + p[1]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
85 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
86 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
87 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
|
88 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
89 return (get_be16(p) << 8) + p[2]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
90 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
91 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
92 static void next_line(spudec_handle_t *this) |
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 if (this->current_nibble[this->deinterlace_oddness] % 2) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
95 this->current_nibble[this->deinterlace_oddness]++; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
96 this->deinterlace_oddness = (this->deinterlace_oddness + 1) % 2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
97 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
98 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
99 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
|
100 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
101 unsigned char nib; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
102 unsigned int *nibblep = this->current_nibble + this->deinterlace_oddness; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
103 if (*nibblep / 2 >= this->control_start) { |
3822 | 104 mp_msg(MSGT_SPUDEC,MSGL_WARN, "SPUdec: ERROR: get_nibble past end of packet\n"); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
105 return 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
106 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
107 nib = this->packet[*nibblep / 2]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
108 if (*nibblep % 2) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
109 nib &= 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
110 else |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
111 nib >>= 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
112 ++*nibblep; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
113 return nib; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
114 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
115 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
116 static inline int mkalpha(int i) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
117 { |
3166 | 118 /* In mplayer's alpha planes, 0 is transparent, then 1 is nearly |
119 opaque upto 255 which is transparent */ | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
120 switch (i) { |
3166 | 121 case 0xf: |
122 return 1; | |
123 case 0: | |
124 return 0; | |
125 default: | |
126 return (0xf - i) << 4; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
127 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
128 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
129 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
130 /* Cut the sub to visible part */ |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
131 static inline void spudec_cut_image(spudec_handle_t *this) |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
132 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
133 unsigned int fy, ly; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
134 unsigned int first_y, last_y; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
135 unsigned char *image; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
136 unsigned char *aimage; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
137 |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
138 if (this->stride == 0 || this->height == 0) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
139 return; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
140 } |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
141 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
142 for (fy = 0; fy < this->image_size && !this->aimage[fy]; fy++); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
143 for (ly = this->stride * this->height-1; ly && !this->aimage[ly]; ly--); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
144 first_y = fy / this->stride; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
145 last_y = ly / this->stride; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
146 //printf("first_y: %d, last_y: %d\n", first_y, last_y); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
147 this->start_row += first_y; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
148 |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
149 // Some subtitles trigger this condition |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
150 if (last_y + 1 > first_y ) { |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
151 this->height = last_y - first_y +1; |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
152 } else { |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
153 this->height = 0; |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
154 } |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
155 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
156 //printf("new h %d new start %d (sz %d st %d)---\n\n", this->height, this->start_row, this->image_size, this->stride); |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
157 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
158 image = malloc(2 * this->stride * this->height); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
159 if(image){ |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
160 this->image_size = this->stride * this->height; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
161 aimage = image + this->image_size; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
162 memcpy(image, this->image + this->stride * first_y, this->image_size); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
163 memcpy(aimage, this->aimage + this->stride * first_y, this->image_size); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
164 free(this->image); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
165 this->image = image; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
166 this->aimage = aimage; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
167 } else { |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
168 mp_msg(MSGT_SPUDEC, MSGL_FATAL, "Fatal: update_spu: malloc requested %d bytes\n", 2 * this->stride * this->height); |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
169 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
170 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
171 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
172 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
|
173 { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
174 unsigned int cmap[4], alpha[4]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
175 unsigned int i, x, y; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
176 |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
177 this->scaled_frame_width = 0; |
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
178 this->scaled_frame_height = 0; |
3166 | 179 for (i = 0; i < 4; ++i) { |
180 alpha[i] = mkalpha(this->alpha[i]); | |
181 if (alpha[i] == 0) | |
182 cmap[i] = 0; | |
5833
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
183 else if (this->custom){ |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
184 cmap[i] = ((this->cuspal[i] >> 16) & 0xff); |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
185 if (cmap[i] + alpha[i] > 255) |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
186 cmap[i] = 256 - alpha[i]; |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
187 } |
3166 | 188 else { |
4122 | 189 cmap[i] = ((this->global_palette[this->palette[i]] >> 16) & 0xff); |
190 if (cmap[i] + alpha[i] > 255) | |
191 cmap[i] = 256 - alpha[i]; | |
3166 | 192 } |
193 } | |
194 | |
3402 | 195 if (this->image_size < this->stride * this->height) { |
196 if (this->image != NULL) { | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
197 free(this->image); |
3402 | 198 this->image_size = 0; |
199 } | |
200 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
|
201 if (this->image) { |
3402 | 202 this->image_size = this->stride * this->height; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
203 this->aimage = this->image + this->image_size; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
204 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
205 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
206 if (this->image == NULL) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
207 return; |
3402 | 208 |
209 /* Kludge: draw_alpha needs width multiple of 8. */ | |
210 if (this->width < this->stride) | |
6459 | 211 for (y = 0; y < this->height; ++y) { |
3402 | 212 memset(this->aimage + y * this->stride + this->width, 0, this->stride - this->width); |
6459 | 213 /* FIXME: Why is this one needed? */ |
214 memset(this->image + y * this->stride + this->width, 0, this->stride - this->width); | |
215 } | |
3402 | 216 |
3166 | 217 i = this->current_nibble[1]; |
3402 | 218 x = 0; |
219 y = 0; | |
3166 | 220 while (this->current_nibble[0] < i |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
221 && this->current_nibble[1] / 2 < this->control_start |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
222 && y < this->height) { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
223 unsigned int len, color; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
224 unsigned int rle = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
225 rle = get_nibble(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
226 if (rle < 0x04) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
227 rle = (rle << 4) | get_nibble(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
228 if (rle < 0x10) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
229 rle = (rle << 4) | get_nibble(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
230 if (rle < 0x040) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
231 rle = (rle << 4) | get_nibble(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
232 if (rle < 0x0004) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
233 rle |= ((this->width - x) << 2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
234 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
235 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
236 } |
3166 | 237 color = 3 - (rle & 0x3); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
238 len = rle >> 2; |
3402 | 239 if (len > this->width - x || len == 0) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
240 len = this->width - x; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
241 /* FIXME have to use palette and alpha map*/ |
3402 | 242 memset(this->image + y * this->stride + x, cmap[color], len); |
243 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
|
244 x += len; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
245 if (x >= this->width) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
246 next_line(this); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
247 x = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
248 ++y; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
249 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
250 } |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
251 spudec_cut_image(this); |
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 |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
254 |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
255 /* |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
256 This function tries to create a usable palette. |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
257 Is searchs how many non-transparent colors are used and assigns different |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
258 gray scale values to each color. |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
259 I tested it with four streams and even got something readable. Half of the |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
260 times I got black characters with white around and half the reverse. |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
261 */ |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
262 static void compute_palette(spudec_handle_t *this) |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
263 { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
264 int used[16],i,cused,start,step,color; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
265 |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
266 memset(used, 0, sizeof(used)); |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
267 for (i=0; i<4; i++) |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
268 if (this->alpha[i]) /* !Transparent? */ |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
269 used[this->palette[i]] = 1; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
270 for (cused=0, i=0; i<16; i++) |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
271 if (used[i]) cused++; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
272 if (!cused) return; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
273 if (cused == 1) { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
274 start = 0x80; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
275 step = 0; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
276 } else { |
6110 | 277 start = this->font_start_level; |
278 step = (0xF0-this->font_start_level)/(cused-1); | |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
279 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
280 memset(used, 0, sizeof(used)); |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
281 for (i=0; i<4; i++) { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
282 color = this->palette[i]; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
283 if (this->alpha[i] && !used[color]) { /* not assigned? */ |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
284 used[color] = 1; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
285 this->global_palette[color] = start<<16; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
286 start += step; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
287 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
288 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
289 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
290 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
291 static void spudec_process_control(spudec_handle_t *this, unsigned int pts100) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
292 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
293 int a,b; /* Temporary vars */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
294 unsigned int date, type; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
295 unsigned int off; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
296 unsigned int start_off = 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
297 unsigned int next_off; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
298 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
299 this->control_start = get_be16(this->packet + 2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
300 next_off = this->control_start; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
301 while (start_off != next_off) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
302 start_off = next_off; |
5488
3f183ca22747
fixed SPU pts, it's 1024/90000 based instead of 1/100
arpi
parents:
5474
diff
changeset
|
303 date = get_be16(this->packet + start_off) * 1024; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
304 next_off = get_be16(this->packet + start_off + 2); |
3822 | 305 mp_msg(MSGT_SPUDEC,MSGL_DBG2, "date=%d\n", date); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
306 off = start_off + 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
307 for (type = this->packet[off++]; type != 0xff; type = this->packet[off++]) { |
3822 | 308 mp_msg(MSGT_SPUDEC,MSGL_DBG2, "cmd=%d ",type); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
309 switch(type) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
310 case 0x00: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
311 /* Menu ID, 1 byte */ |
3822 | 312 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Menu ID\n"); |
5474
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
313 /* shouldn't a Menu ID type force display start? */ |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
314 //this->start_pts = pts100 + date; |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
315 //this->end_pts = UINT_MAX; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
316 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
317 case 0x01: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
318 /* Start display */ |
3822 | 319 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Start display!\n"); |
3842 | 320 this->start_pts = pts100 + date; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
321 this->end_pts = UINT_MAX; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
322 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
323 case 0x02: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
324 /* Stop display */ |
3822 | 325 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Stop display!\n"); |
3842 | 326 this->end_pts = pts100 + date; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
327 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
328 case 0x03: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
329 /* Palette */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
330 this->palette[0] = this->packet[off] >> 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
331 this->palette[1] = this->packet[off] & 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
332 this->palette[2] = this->packet[off + 1] >> 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
333 this->palette[3] = this->packet[off + 1] & 0xf; |
3822 | 334 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Palette %d, %d, %d, %d\n", |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
335 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
|
336 off+=2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
337 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
338 case 0x04: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
339 /* Alpha */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
340 this->alpha[0] = this->packet[off] >> 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
341 this->alpha[1] = this->packet[off] & 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
342 this->alpha[2] = this->packet[off + 1] >> 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
343 this->alpha[3] = this->packet[off + 1] & 0xf; |
6110 | 344 if (this->auto_palette) { |
345 compute_palette(this); | |
346 this->auto_palette = 0; | |
347 } | |
3822 | 348 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Alpha %d, %d, %d, %d\n", |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
349 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
|
350 off+=2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
351 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
352 case 0x05: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
353 /* Co-ords */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
354 a = get_be24(this->packet + off); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
355 b = get_be24(this->packet + off + 3); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
356 this->start_col = a >> 12; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
357 this->end_col = a & 0xfff; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
358 this->width = (this->end_col < this->start_col) ? 0 : this->end_col - this->start_col + 1; |
3402 | 359 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
|
360 this->start_row = b >> 12; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
361 this->end_row = b & 0xfff; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
362 this->height = (this->end_row < this->start_row) ? 0 : this->end_row - this->start_row /* + 1 */; |
3822 | 363 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Coords col: %d - %d row: %d - %d (%dx%d)\n", |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
364 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
|
365 this->width, this->height); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
366 off+=6; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
367 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
368 case 0x06: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
369 /* Graphic lines */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
370 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
|
371 this->current_nibble[1] = 2 * get_be16(this->packet + off + 2); |
3822 | 372 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Graphic offset 1: %d offset 2: %d\n", |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
373 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
|
374 off+=4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
375 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
376 case 0xff: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
377 /* All done, bye-bye */ |
3822 | 378 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Done!\n"); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
379 return; |
3822 | 380 // break; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
381 default: |
3822 | 382 mp_msg(MSGT_SPUDEC,MSGL_WARN,"spudec: Error determining control type 0x%02x. Skipping %d bytes.\n", |
3402 | 383 type, next_off - off); |
384 goto next_control; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
385 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
386 } |
3402 | 387 next_control: |
3725 | 388 ; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
389 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
390 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
391 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
392 static void spudec_decode(spudec_handle_t *this, unsigned int pts100) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
393 { |
6110 | 394 if(this->hw_spu) { |
395 static vo_mpegpes_t packet = { NULL, 0, 0x20, 0 }; | |
396 static vo_mpegpes_t *pkg=&packet; | |
397 packet.data = this->packet; | |
398 packet.size = this->packet_size; | |
399 packet.timestamp = pts100; | |
400 this->hw_spu->draw_frame((uint8_t**)&pkg); | |
401 } else { | |
402 spudec_process_control(this, pts100); | |
403 spudec_process_data(this); | |
404 } | |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
405 this->spu_changed = 1; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
406 } |
560 | 407 |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
408 int spudec_changed(void * this) |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
409 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
410 spudec_handle_t * spu = (spudec_handle_t*)this; |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
411 return (spu->spu_changed || spu->now_pts > spu->end_pts); |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
412 } |
560 | 413 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
414 void spudec_assemble(void *this, unsigned char *packet, unsigned int len, unsigned int pts100) |
560 | 415 { |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
416 spudec_handle_t *spu = (spudec_handle_t*)this; |
3842 | 417 // spudec_heartbeat(this, pts100); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
418 if (len < 2) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
419 mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: packet too short\n"); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
420 return; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
421 } |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
422 if (spu->packet_pts < pts100) { |
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
423 spu->packet_pts = pts100; |
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
424 spu->packet_offset = 0; |
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
425 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
426 if (spu->packet_offset == 0) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
427 unsigned int len2 = get_be16(packet); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
428 // Start new fragment |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
429 if (spu->packet_reserve < len2) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
430 if (spu->packet != NULL) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
431 free(spu->packet); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
432 spu->packet = malloc(len2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
433 spu->packet_reserve = spu->packet != NULL ? len2 : 0; |
560 | 434 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
435 if (spu->packet != NULL) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
436 spu->deinterlace_oddness = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
437 spu->packet_size = len2; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
438 if (len > len2) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
439 mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: invalid frag len / len2: %d / %d \n", len, len2); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
440 return; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
441 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
442 memcpy(spu->packet, packet, len); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
443 spu->packet_offset = len; |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
444 spu->packet_pts = pts100; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
445 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
446 } else { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
447 // Continue current fragment |
3744 | 448 if (spu->packet_size < spu->packet_offset + len){ |
3822 | 449 mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: invalid fragment\n"); |
3744 | 450 spu->packet_size = spu->packet_offset = 0; |
451 } else { | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
452 memcpy(spu->packet + spu->packet_offset, packet, len); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
453 spu->packet_offset += len; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
454 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
455 } |
3820 | 456 #if 1 |
457 // check if we have a complete packet (unfortunatelly packet_size is bad | |
458 // for some disks) | |
5917 | 459 if (spu->packet_offset == spu->packet_size){ |
460 unsigned int x=0,y; | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
461 while(x+4<=spu->packet_offset){ |
3820 | 462 y=get_be16(spu->packet+x+2); // next control pointer |
3822 | 463 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPUtest: x=%d y=%d off=%d size=%d\n",x,y,spu->packet_offset,spu->packet_size); |
3820 | 464 if(x>=4 && x==y){ // if it points to self - we're done! |
465 // we got it! | |
3822 | 466 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPUgot: off=%d size=%d \n",spu->packet_offset,spu->packet_size); |
3842 | 467 spudec_decode(spu, pts100); |
3820 | 468 spu->packet_offset = 0; |
469 break; | |
470 } | |
471 if(y<=x || y>=spu->packet_size){ // invalid? | |
3822 | 472 mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUtest: broken packet!!!!! y=%d < x=%d\n",y,x); |
3820 | 473 spu->packet_size = spu->packet_offset = 0; |
474 break; | |
475 } | |
476 x=y; | |
477 } | |
478 } | |
479 #else | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
480 if (spu->packet_offset == spu->packet_size) { |
3842 | 481 spudec_decode(spu, pts100); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
482 spu->packet_offset = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
483 } |
3820 | 484 #endif |
560 | 485 } |
486 | |
3744 | 487 void spudec_reset(void *this) // called after seek |
488 { | |
489 spudec_handle_t *spu = (spudec_handle_t*)this; | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
490 spu->now_pts = 0; |
3744 | 491 spu->packet_size = spu->packet_offset = 0; |
492 } | |
493 | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
494 void spudec_heartbeat(void *this, unsigned int pts100) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
495 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
496 ((spudec_handle_t *)this)->now_pts = pts100; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
497 } |
560 | 498 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
499 int spudec_visible(void *this){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
500 spudec_handle_t *spu = (spudec_handle_t *)this; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
501 int ret=(spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
502 // printf("spu visible: %d \n",ret); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
503 return ret; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
504 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
505 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
506 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
|
507 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
508 spudec_handle_t *spu = (spudec_handle_t *)this; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
509 if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts && spu->image) |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
510 { |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
511 draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, |
3402 | 512 spu->image, spu->aimage, spu->stride); |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
513 spu->spu_changed = 0; |
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
514 } |
561 | 515 } |
516 | |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
517 /* calc the bbox for spudec subs */ |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
518 void spudec_calc_bbox(void *me, unsigned int dxs, unsigned int dys, unsigned int* bbox) |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
519 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
520 spudec_handle_t *spu; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
521 spu = (spudec_handle_t *)me; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
522 if (spu->orig_frame_width == 0 || spu->orig_frame_height == 0 |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
523 || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys)) { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
524 bbox[0] = spu->start_col; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
525 bbox[1] = spu->start_col + spu->width; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
526 bbox[2] = spu->start_row; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
527 bbox[3] = spu->start_row + spu->height; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
528 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
529 else if (spu->scaled_frame_width != dxs || spu->scaled_frame_height != dys) { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
530 unsigned int scalex = 0x100 * dxs / spu->orig_frame_width; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
531 unsigned int scaley = 0x100 * dys / spu->orig_frame_height; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
532 bbox[0] = spu->start_col * scalex / 0x100; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
533 bbox[1] = spu->start_col * scalex / 0x100 + spu->width * scalex / 0x100; |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
534 #if SUBPOS == 0 |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
535 bbox[2] = spu->start_row * scaley / 0x100; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
536 bbox[3] = spu->start_row * scaley / 0x100 + spu->height * scaley / 0x100; |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
537 #elif SUBPOS == 1 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
538 bbox[3] = dys -1; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
539 bbox[2] = bbox[3] -spu->height * scaley / 0x100; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
540 #endif |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
541 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
542 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
543 /* transform mplayer's alpha value into an opacity value that is linear */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
544 static inline int canon_alpha(int alpha) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
545 { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
546 return alpha ? 256 - alpha : 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
547 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
548 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
549 typedef struct { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
550 unsigned position; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
551 unsigned left_up; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
552 unsigned right_down; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
553 }scale_pixel; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
554 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
555 |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
556 #if ANTIALIASING_ALGORITHM == -1 |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
557 static void scale_table(unsigned int start_src, unsigned int start_tar, unsigned int end_src, unsigned int end_tar, scale_pixel * table) |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
558 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
559 unsigned int t; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
560 unsigned int delta_src = end_src - start_src; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
561 unsigned int delta_tar = end_tar - start_tar; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
562 int src = 0; |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
563 int src_step; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
564 if (delta_src == 0 || delta_tar == 0) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
565 return; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
566 } |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
567 src_step = (delta_src << 16) / delta_tar >>1; |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
568 for (t = 0; t<=delta_tar; src += (src_step << 1), t++){ |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
569 table[t].position= MIN(src >> 16, end_src - 1); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
570 table[t].right_down = src & 0xffff; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
571 table[t].left_up = 0x10000 - table[t].right_down; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
572 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
573 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
574 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
575 /* bilinear scale, similar to vobsub's code */ |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
576 static void scale_image(int x, int y, scale_pixel* table_x, scale_pixel* table_y, spudec_handle_t * spu) |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
577 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
578 int alpha[4]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
579 int color[4]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
580 unsigned int scale[4]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
581 int base = table_y[y].position * spu->stride + table_x[x].position; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
582 int scaled = y * spu->scaled_stride + x; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
583 alpha[0] = canon_alpha(spu->aimage[base]); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
584 alpha[1] = canon_alpha(spu->aimage[base + 1]); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
585 alpha[2] = canon_alpha(spu->aimage[base + spu->stride]); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
586 alpha[3] = canon_alpha(spu->aimage[base + spu->stride + 1]); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
587 color[0] = spu->image[base]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
588 color[1] = spu->image[base + 1]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
589 color[2] = spu->image[base + spu->stride]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
590 color[3] = spu->image[base + spu->stride + 1]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
591 scale[0] = (table_x[x].left_up * table_y[y].left_up >> 16) * alpha[0]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
592 scale[1] = (table_x[x].right_down * table_y[y].left_up >>16) * alpha[1]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
593 scale[2] = (table_x[x].left_up * table_y[y].right_down >> 16) * alpha[2]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
594 scale[3] = (table_x[x].right_down * table_y[y].right_down >> 16) * alpha[3]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
595 spu->scaled_image[scaled] = (color[0] * scale[0] + color[1] * scale[1] + color[2] * scale[2] + color[3] * scale[3])>>24; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
596 spu->scaled_aimage[scaled] = (scale[0] + scale[1] + scale[2] + scale[3]) >> 16; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
597 if (spu->scaled_aimage[scaled]){ |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
598 spu->scaled_aimage[scaled] = 256 - spu->scaled_aimage[scaled]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
599 if(spu->scaled_aimage[scaled] + spu->scaled_image[scaled] > 255) |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
600 spu->scaled_image[scaled] = 256 - spu->scaled_aimage[scaled]; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
601 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
602 } |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
603 #endif |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
604 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
605 void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
606 { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
607 spudec_handle_t *spu = (spudec_handle_t *)me; |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
608 scale_pixel *table_x; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
609 scale_pixel *table_y; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
610 if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
611 if (spu->orig_frame_width == 0 || spu->orig_frame_height == 0 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
612 || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys)) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
613 if (spu->image) |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
614 { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
615 draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
616 spu->image, spu->aimage, spu->stride); |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
617 spu->spu_changed = 0; |
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
618 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
619 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
620 else { |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
621 if (spu->scaled_frame_width != dxs || spu->scaled_frame_height != dys) { /* Resizing is needed */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
622 /* scaled_x = scalex * x / 0x100 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
623 scaled_y = scaley * y / 0x100 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
624 order of operations is important because of rounding. */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
625 unsigned int scalex = 0x100 * dxs / spu->orig_frame_width; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
626 unsigned int scaley = 0x100 * dys / spu->orig_frame_height; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
627 spu->scaled_start_col = spu->start_col * scalex / 0x100; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
628 spu->scaled_start_row = spu->start_row * scaley / 0x100; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
629 spu->scaled_width = spu->width * scalex / 0x100; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
630 spu->scaled_height = spu->height * scaley / 0x100; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
631 /* Kludge: draw_alpha needs width multiple of 8 */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
632 spu->scaled_stride = (spu->scaled_width + 7) & ~7; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
633 if (spu->scaled_image_size < spu->scaled_stride * spu->scaled_height) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
634 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
635 free(spu->scaled_image); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
636 spu->scaled_image_size = 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
637 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
638 spu->scaled_image = malloc(2 * spu->scaled_stride * spu->scaled_height); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
639 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
640 spu->scaled_image_size = spu->scaled_stride * spu->scaled_height; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
641 spu->scaled_aimage = spu->scaled_image + spu->scaled_image_size; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
642 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
643 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
644 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
645 unsigned int x, y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
646 /* Kludge: draw_alpha needs width multiple of 8. */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
647 if (spu->scaled_width < spu->scaled_stride) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
648 for (y = 0; y < spu->scaled_height; ++y) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
649 memset(spu->scaled_aimage + y * spu->scaled_stride + spu->scaled_width, 0, |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
650 spu->scaled_stride - spu->scaled_width); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
651 /* FIXME: Why is this one needed? */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
652 memset(spu->scaled_image + y * spu->scaled_stride + spu->scaled_width, 0, |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
653 spu->scaled_stride - spu->scaled_width); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
654 } |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
655 if (spu->scaled_width <= 1 || spu->scaled_height <= 1) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
656 goto nothing_to_do; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
657 } |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
658 #if ANTIALIASING_ALGORITHM == -1 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
659 table_x = calloc(spu->scaled_width, sizeof(scale_pixel)); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
660 table_y = calloc(spu->scaled_height, sizeof(scale_pixel)); |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
661 if (!table_x || !table_y) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
662 mp_msg(MSGT_SPUDEC, MSGL_FATAL, "Fatal: spudec_draw_scaled: calloc failed\n"); |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
663 } |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
664 scale_table(0, 0, spu->width - 1, spu->scaled_width - 1, table_x); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
665 scale_table(0, 0, spu->height - 1, spu->scaled_height - 1, table_y); |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
666 for (y = 0; y < spu->scaled_height; y++) |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
667 for (x = 0; x < spu->scaled_width; x++) |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
668 scale_image(x, y, table_x, table_y, spu); |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
669 free(table_x); |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
670 free(table_y); |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
671 #elif ANTIALIASING_ALGORITHM == 0 |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
672 /* no antialiasing */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
673 for (y = 0; y < spu->scaled_height; ++y) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
674 int unscaled_y = y * 0x100 / scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
675 int strides = spu->stride * unscaled_y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
676 int scaled_strides = spu->scaled_stride * y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
677 for (x = 0; x < spu->scaled_width; ++x) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
678 int unscaled_x = x * 0x100 / scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
679 spu->scaled_image[scaled_strides + x] = spu->image[strides + unscaled_x]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
680 spu->scaled_aimage[scaled_strides + x] = spu->aimage[strides + unscaled_x]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
681 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
682 } |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
683 #elif ANTIALIASING_ALGORITHM == 1 |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
684 { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
685 /* Intermediate antialiasing. */ |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
686 for (y = 0; y < spu->scaled_height; ++y) { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
687 const unsigned int unscaled_top = y * spu->orig_frame_height / dys; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
688 unsigned int unscaled_bottom = (y + 1) * spu->orig_frame_height / dys; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
689 if (unscaled_bottom >= spu->height) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
690 unscaled_bottom = spu->height - 1; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
691 for (x = 0; x < spu->scaled_width; ++x) { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
692 const unsigned int unscaled_left = x * spu->orig_frame_width / dxs; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
693 unsigned int unscaled_right = (x + 1) * spu->orig_frame_width / dxs; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
694 unsigned int color = 0; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
695 unsigned int alpha = 0; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
696 unsigned int walkx, walky; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
697 unsigned int base, tmp; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
698 if (unscaled_right >= spu->width) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
699 unscaled_right = spu->width - 1; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
700 for (walky = unscaled_top; walky <= unscaled_bottom; ++walky) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
701 for (walkx = unscaled_left; walkx <= unscaled_right; ++walkx) { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
702 base = walky * spu->stride + walkx; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
703 tmp = canon_alpha(spu->aimage[base]); |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
704 alpha += tmp; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
705 color += tmp * spu->image[base]; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
706 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
707 base = y * spu->scaled_stride + x; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
708 spu->scaled_image[base] = alpha ? color / alpha : 0; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
709 spu->scaled_aimage[base] = |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
710 alpha * (1 + unscaled_bottom - unscaled_top) * (1 + unscaled_right - unscaled_left); |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
711 /* spu->scaled_aimage[base] = |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
712 alpha * dxs * dys / spu->orig_frame_width / spu->orig_frame_height; */ |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
713 if (spu->scaled_aimage[base]) { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
714 spu->scaled_aimage[base] = 256 - spu->scaled_aimage[base]; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
715 if (spu->scaled_aimage[base] + spu->scaled_image[base] > 255) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
716 spu->scaled_image[base] = 256 - spu->scaled_aimage[base]; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
717 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
718 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
719 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
720 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
721 #else |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
722 { |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
723 /* Best antialiasing. Very slow. */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
724 /* Any pixel (x, y) represents pixels from the original |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
725 rectangular region comprised between the columns |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
726 unscaled_y and unscaled_y + 0x100 / scaley and the rows |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
727 unscaled_x and unscaled_x + 0x100 / scalex |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
728 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
729 The original rectangular region that the scaled pixel |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
730 represents is cut in 9 rectangular areas like this: |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
731 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
732 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
733 | 1 | 2 | 3 | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
734 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
735 | | | | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
736 | 4 | 5 | 6 | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
737 | | | | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
738 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
739 | 7 | 8 | 9 | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
740 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
741 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
742 The width of the left column is at most one pixel and |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
743 it is never null and its right column is at a pixel |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
744 boundary. The height of the top row is at most one |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
745 pixel it is never null and its bottom row is at a |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
746 pixel boundary. The width and height of region 5 are |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
747 integral values. The width of the right column is |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
748 what remains and is less than one pixel. The height |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
749 of the bottom row is what remains and is less than |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
750 one pixel. |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
751 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
752 The row above 1, 2, 3 is unscaled_y. The row between |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
753 1, 2, 3 and 4, 5, 6 is top_low_row. The row between 4, |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
754 5, 6 and 7, 8, 9 is (unsigned int)unscaled_y_bottom. |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
755 The row beneath 7, 8, 9 is unscaled_y_bottom. |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
756 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
757 The column left of 1, 4, 7 is unscaled_x. The column |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
758 between 1, 4, 7 and 2, 5, 8 is left_right_column. The |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
759 column between 2, 5, 8 and 3, 6, 9 is (unsigned |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
760 int)unscaled_x_right. The column right of 3, 6, 9 is |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
761 unscaled_x_right. */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
762 const double inv_scalex = (double) 0x100 / scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
763 const double inv_scaley = (double) 0x100 / scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
764 for (y = 0; y < spu->scaled_height; ++y) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
765 const double unscaled_y = y * inv_scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
766 const double unscaled_y_bottom = unscaled_y + inv_scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
767 const unsigned int top_low_row = MIN(unscaled_y_bottom, unscaled_y + 1.0); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
768 const double top = top_low_row - unscaled_y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
769 const unsigned int height = unscaled_y_bottom > top_low_row |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
770 ? (unsigned int) unscaled_y_bottom - top_low_row |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
771 : 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
772 const double bottom = unscaled_y_bottom > top_low_row |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
773 ? unscaled_y_bottom - floor(unscaled_y_bottom) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
774 : 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
775 for (x = 0; x < spu->scaled_width; ++x) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
776 const double unscaled_x = x * inv_scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
777 const double unscaled_x_right = unscaled_x + inv_scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
778 const unsigned int left_right_column = MIN(unscaled_x_right, unscaled_x + 1.0); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
779 const double left = left_right_column - unscaled_x; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
780 const unsigned int width = unscaled_x_right > left_right_column |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
781 ? (unsigned int) unscaled_x_right - left_right_column |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
782 : 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
783 const double right = unscaled_x_right > left_right_column |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
784 ? unscaled_x_right - floor(unscaled_x_right) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
785 : 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
786 double color = 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
787 double alpha = 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
788 double tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
789 unsigned int base; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
790 /* Now use these informations to compute a good alpha, |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
791 and lightness. The sum is on each of the 9 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
792 region's surface and alpha and lightness. |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
793 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
794 transformed alpha = sum(surface * alpha) / sum(surface) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
795 transformed color = sum(surface * alpha * color) / sum(surface * alpha) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
796 */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
797 /* 1: top left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
798 base = spu->stride * (unsigned int) unscaled_y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
799 tmp = left * top * canon_alpha(spu->aimage[base + (unsigned int) unscaled_x]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
800 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
801 color += tmp * spu->image[base + (unsigned int) unscaled_x]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
802 /* 2: top center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
803 if (width > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
804 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
805 for (walkx = left_right_column; walkx < (unsigned int) unscaled_x_right; ++walkx) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
806 base = spu->stride * (unsigned int) unscaled_y + walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
807 tmp = /* 1.0 * */ top * canon_alpha(spu->aimage[base]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
808 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
809 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
810 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
811 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
812 /* 3: top right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
813 if (right > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
814 base = spu->stride * (unsigned int) unscaled_y + (unsigned int) unscaled_x_right; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
815 tmp = right * top * canon_alpha(spu->aimage[base]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
816 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
817 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
818 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
819 /* 4: center left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
820 if (height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
821 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
822 for (walky = top_low_row; walky < (unsigned int) unscaled_y_bottom; ++walky) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
823 base = spu->stride * walky + (unsigned int) unscaled_x; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
824 tmp = left /* * 1.0 */ * canon_alpha(spu->aimage[base]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
825 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
826 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
827 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
828 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
829 /* 5: center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
830 if (width > 0 && height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
831 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
832 for (walky = top_low_row; walky < (unsigned int) unscaled_y_bottom; ++walky) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
833 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
834 base = spu->stride * walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
835 for (walkx = left_right_column; walkx < (unsigned int) unscaled_x_right; ++walkx) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
836 tmp = /* 1.0 * 1.0 * */ canon_alpha(spu->aimage[base + walkx]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
837 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
838 color += tmp * spu->image[base + walkx]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
839 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
840 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
841 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
842 /* 6: center right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
843 if (right > 0.0 && height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
844 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
845 for (walky = top_low_row; walky < (unsigned int) unscaled_y_bottom; ++walky) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
846 base = spu->stride * walky + (unsigned int) unscaled_x_right; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
847 tmp = right /* * 1.0 */ * canon_alpha(spu->aimage[base]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
848 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
849 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
850 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
851 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
852 /* 7: bottom left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
853 if (bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
854 base = spu->stride * (unsigned int) unscaled_y_bottom + (unsigned int) unscaled_x; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
855 tmp = left * bottom * canon_alpha(spu->aimage[base]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
856 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
857 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
858 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
859 /* 8: bottom center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
860 if (width > 0 && bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
861 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
862 base = spu->stride * (unsigned int) unscaled_y_bottom; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
863 for (walkx = left_right_column; walkx < (unsigned int) unscaled_x_right; ++walkx) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
864 tmp = /* 1.0 * */ bottom * canon_alpha(spu->aimage[base + walkx]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
865 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
866 color += tmp * spu->image[base + walkx]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
867 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
868 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
869 /* 9: bottom right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
870 if (right > 0.0 && bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
871 base = spu->stride * (unsigned int) unscaled_y_bottom + (unsigned int) unscaled_x_right; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
872 tmp = right * bottom * canon_alpha(spu->aimage[base]); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
873 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
874 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
875 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
876 /* Finally mix these transparency and brightness information suitably */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
877 base = spu->scaled_stride * y + x; |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
878 spu->scaled_image[base] = alpha > 0 ? color / alpha : 0; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
879 spu->scaled_aimage[base] = alpha * scalex * scaley / 0x10000; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
880 if (spu->scaled_aimage[base]) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
881 spu->scaled_aimage[base] = 256 - spu->scaled_aimage[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
882 if (spu->scaled_aimage[base] + spu->scaled_image[base] > 255) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
883 spu->scaled_image[base] = 256 - spu->scaled_aimage[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
884 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
885 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
886 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
887 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
888 #endif |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
889 nothing_to_do: |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
890 spu->scaled_frame_width = dxs; |
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
891 spu->scaled_frame_height = dys; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
892 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
893 } |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
894 if (spu->scaled_image){ |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
895 #if SUBPOS == 1 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
896 /*set subs at the bottom, i don't like to put it at the very bottom, so -1 :)*/ |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
897 spu->scaled_start_row = dys - spu->scaled_height - 1; |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
898 #endif |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
899 draw_alpha(spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height, |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
900 spu->scaled_image, spu->scaled_aimage, spu->scaled_stride); |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
901 spu->spu_changed = 0; |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
902 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
903 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
904 } |
5474
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
905 else |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
906 { |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
907 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPU not displayed: start_pts=%d end_pts=%d now_pts=%d\n", |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
908 spu->start_pts, spu->end_pts, spu->now_pts); |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
909 } |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
910 } |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
911 |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
912 void spudec_update_palette(void * this, unsigned int *palette) |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
913 { |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
914 spudec_handle_t *spu = (spudec_handle_t *) this; |
6110 | 915 if (spu && palette) { |
5474
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
916 memcpy(spu->global_palette, palette, sizeof(spu->global_palette)); |
6110 | 917 if(spu->hw_spu) |
918 spu->hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette); | |
919 } | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
920 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
921 |
6110 | 922 void spudec_set_font_factor(void * this, double factor) |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
923 { |
6110 | 924 spudec_handle_t *spu = (spudec_handle_t *) this; |
925 spu->font_start_level = (int)(0xF0-(0xE0*factor)); | |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
926 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
927 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
928 void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
929 { |
6938 | 930 return spudec_new_scaled_vobsub(palette, NULL, 0, frame_width, frame_height); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
931 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
932 |
5833
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
933 /* get palette custom color, width, height from .idx file */ |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
934 void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsigned int custom, unsigned int frame_width, unsigned int frame_height) |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
935 { |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
936 spudec_handle_t *this = calloc(1, sizeof(spudec_handle_t)); |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
937 if (this){ |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
938 //(fprintf(stderr,"VobSub Custom Palette: %d,%d,%d,%d", this->cuspal[0], this->cuspal[1], this->cuspal[2],this->cuspal[3]); |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
939 this->packet = NULL; |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
940 this->image = NULL; |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
941 this->scaled_image = NULL; |
6938 | 942 /* XXX Although the video frame is some size, the SPU frame is |
943 always maximum size i.e. 720 wide and 576 or 480 high */ | |
944 this->orig_frame_width = 720; | |
945 this->orig_frame_height = (frame_height == 480 || frame_height == 240) ? 480 : 576; | |
5833
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
946 this->custom = custom; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
947 // set up palette: |
6110 | 948 this->auto_palette = 1; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
949 if (palette){ |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
950 memcpy(this->global_palette, palette, sizeof(this->global_palette)); |
6110 | 951 this->auto_palette = 0; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
952 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
953 this->custom = custom; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
954 if (custom && cuspal) { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
955 memcpy(this->cuspal, cuspal, sizeof(this->cuspal)); |
6110 | 956 this->auto_palette = 0; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
957 } |
5833
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
958 } |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
959 else |
6110 | 960 mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc"); |
5833
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
961 return this; |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
962 } |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
963 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
964 void *spudec_new(unsigned int *palette) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
965 { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
966 return spudec_new_scaled(palette, 0, 0); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
967 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
968 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
969 void spudec_free(void *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
970 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
971 spudec_handle_t *spu = (spudec_handle_t*)this; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
972 if (spu) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
973 if (spu->packet) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
974 free(spu->packet); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
975 if (spu->scaled_image) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
976 free(spu->scaled_image); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
977 if (spu->image) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
978 free(spu->image); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
979 free(spu); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
980 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
981 } |
6110 | 982 |
983 void spudec_set_hw_spu(void *this, vo_functions_t *hw_spu) | |
984 { | |
985 spudec_handle_t *spu = (spudec_handle_t*)this; | |
986 if (!spu) | |
987 return; | |
988 spu->hw_spu = hw_spu; | |
989 hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette); | |
990 } |