Mercurial > mplayer.hg
annotate spudec.c @ 24671:fbcd9dcb0daf
Get rid of mp_msg_test in vo_png, only reason to use it is performance and
that is not critical here and the way it was used probably would not improve
performance anyway
author | reimar |
---|---|
date | Wed, 03 Oct 2007 11:55:30 +0000 |
parents | 866dd391dda3 |
children | f563ac467e63 |
rev | line source |
---|---|
560 | 1 /* SPUdec.c |
673 | 2 Skeleton of function spudec_process_controll() is from xine sources. |
560 | 3 Further works: |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
4 LGB,... (yeah, try to improve it and insert your name here! ;-) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
5 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
6 Kim Minh Kaplan |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
7 implement fragments reassembly, RLE decoding. |
3166 | 8 read brightness from the IFO. |
560 | 9 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
10 For information on SPU format see <URL:http://sam.zoy.org/doc/dvd/subtitles/> |
3402 | 11 and <URL:http://members.aol.com/mpucoder/DVD/spu.html> |
560 | 12 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
13 */ |
3183 | 14 #include "config.h" |
3822 | 15 #include "mp_msg.h" |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
16 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
17 #include <errno.h> |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
18 #include <limits.h> |
560 | 19 #include <stdio.h> |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
20 #include <stdlib.h> |
3175 | 21 #include <unistd.h> |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
22 #include <string.h> |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
23 #include <math.h> |
6110 | 24 #include "libvo/video_out.h" |
560 | 25 #include "spudec.h" |
21778
bf1fbe97cc40
Fix build with shared libavutil. Approved by Diego.
rathann
parents:
19870
diff
changeset
|
26 #ifdef USE_LIBAVUTIL_SO |
bf1fbe97cc40
Fix build with shared libavutil. Approved by Diego.
rathann
parents:
19870
diff
changeset
|
27 #include <ffmpeg/avutil.h> |
bf1fbe97cc40
Fix build with shared libavutil. Approved by Diego.
rathann
parents:
19870
diff
changeset
|
28 #else |
19870
1e5cf11e8b1f
Use PIX_FMT_* instead of IMGFMT_* when calling sws_getContext()
lucabe
parents:
18861
diff
changeset
|
29 #include "avutil.h" |
21778
bf1fbe97cc40
Fix build with shared libavutil. Approved by Diego.
rathann
parents:
19870
diff
changeset
|
30 #endif |
18861 | 31 #include "libswscale/swscale.h" |
560 | 32 |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
33 /* Valid values for spu_aamode: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
34 0: none (fastest, most ugly) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
35 1: approximate |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
36 2: full (slowest) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
37 3: bilinear (similiar to vobsub, fast and not too bad) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
38 4: uses swscaler gaussian (this is the only one that looks good) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
39 */ |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
40 |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
41 int spu_aamode = 3; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
42 int spu_alignment = -1; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
43 float spu_gaussvar = 1.0; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
44 extern int sub_pos; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
45 |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
46 typedef struct packet_t packet_t; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
47 struct packet_t { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
48 unsigned char *packet; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
49 unsigned int palette[4]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
50 unsigned int alpha[4]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
51 unsigned int control_start; /* index of start of control data */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
52 unsigned int current_nibble[2]; /* next data nibble (4 bits) to be |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
53 processed (for RLE decoding) for |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
54 even and odd lines */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
55 int deinterlace_oddness; /* 0 or 1, index into current_nibble */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
56 unsigned int start_col, end_col; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
57 unsigned int start_row, end_row; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
58 unsigned int width, height, stride; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
59 unsigned int start_pts, end_pts; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
60 packet_t *next; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
61 }; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
62 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
63 typedef struct { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
64 packet_t *queue_head; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
65 packet_t *queue_tail; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
66 unsigned int global_palette[16]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
67 unsigned int orig_frame_width, orig_frame_height; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
68 unsigned char* packet; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
69 size_t packet_reserve; /* size of the memory pointed to by packet */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
70 unsigned int packet_offset; /* end of the currently assembled fragment */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
71 unsigned int packet_size; /* size of the packet once all fragments are assembled */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
72 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
|
73 unsigned int palette[4]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
74 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
|
75 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
|
76 unsigned int custom; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
77 unsigned int now_pts; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
78 unsigned int start_pts, end_pts; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
79 unsigned int start_col, end_col; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
80 unsigned int start_row, end_row; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
81 unsigned int width, height, stride; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
82 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
|
83 unsigned char *image; /* Grayscale value */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
84 unsigned char *aimage; /* Alpha value */ |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
85 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
|
86 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
|
87 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
|
88 size_t scaled_image_size; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
89 unsigned char *scaled_image; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
90 unsigned char *scaled_aimage; |
6110 | 91 int auto_palette; /* 1 if we lack a palette and must use an heuristic. */ |
92 int font_start_level; /* Darkest value used for the computed font */ | |
93 vo_functions_t *hw_spu; | |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
94 int spu_changed; |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
95 unsigned int forced_subs_only; /* flag: 0=display all subtitle, !0 display only forced subtitles */ |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
96 unsigned int is_forced_sub; /* true if current subtitle is a forced subtitle */ |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
97 } spudec_handle_t; |
560 | 98 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
99 static void spudec_queue_packet(spudec_handle_t *this, packet_t *packet) |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
100 { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
101 if (this->queue_head == NULL) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
102 this->queue_head = packet; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
103 else |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
104 this->queue_tail->next = packet; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
105 this->queue_tail = packet; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
106 } |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
107 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
108 static packet_t *spudec_dequeue_packet(spudec_handle_t *this) |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
109 { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
110 packet_t *retval = this->queue_head; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
111 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
112 this->queue_head = retval->next; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
113 if (this->queue_head == NULL) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
114 this->queue_tail = NULL; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
115 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
116 return retval; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
117 } |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
118 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
119 static void spudec_free_packet(packet_t *packet) |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
120 { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
121 if (packet->packet != NULL) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
122 free(packet->packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
123 free(packet); |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
124 } |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
125 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
126 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
|
127 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
128 return (p[0] << 8) + p[1]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
129 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
130 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
131 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
|
132 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
133 return (get_be16(p) << 8) + p[2]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
134 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
135 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
136 static void next_line(packet_t *packet) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
137 { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
138 if (packet->current_nibble[packet->deinterlace_oddness] % 2) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
139 packet->current_nibble[packet->deinterlace_oddness]++; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
140 packet->deinterlace_oddness = (packet->deinterlace_oddness + 1) % 2; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
141 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
142 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
143 static inline unsigned char get_nibble(packet_t *packet) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
144 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
145 unsigned char nib; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
146 unsigned int *nibblep = packet->current_nibble + packet->deinterlace_oddness; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
147 if (*nibblep / 2 >= packet->control_start) { |
3822 | 148 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
|
149 return 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
150 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
151 nib = packet->packet[*nibblep / 2]; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
152 if (*nibblep % 2) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
153 nib &= 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
154 else |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
155 nib >>= 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
156 ++*nibblep; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
157 return nib; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
158 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
159 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
160 static inline int mkalpha(int i) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
161 { |
3166 | 162 /* In mplayer's alpha planes, 0 is transparent, then 1 is nearly |
163 opaque upto 255 which is transparent */ | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
164 switch (i) { |
3166 | 165 case 0xf: |
166 return 1; | |
167 case 0: | |
168 return 0; | |
169 default: | |
170 return (0xf - i) << 4; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
171 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
172 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
173 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
174 /* 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
|
175 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
|
176 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
177 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
|
178 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
|
179 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
|
180 unsigned char *aimage; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
181 |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
182 if (this->stride == 0 || this->height == 0) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
183 return; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
184 } |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
185 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
186 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
|
187 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
|
188 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
|
189 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
|
190 //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
|
191 this->start_row += first_y; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
192 |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
193 // Some subtitles trigger this condition |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
194 if (last_y + 1 > first_y ) { |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
195 this->height = last_y - first_y +1; |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
196 } else { |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
197 this->height = 0; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
198 this->image_size = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
199 return; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
200 } |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
201 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
202 // 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
|
203 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 this->aimage = aimage; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
213 } else { |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
214 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
|
215 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
216 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
217 |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
218 static void spudec_process_data(spudec_handle_t *this, packet_t *packet) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
219 { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
220 unsigned int cmap[4], alpha[4]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
221 unsigned int i, x, y; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
222 |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
223 this->scaled_frame_width = 0; |
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
224 this->scaled_frame_height = 0; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
225 this->start_col = packet->start_col; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
226 this->end_col = packet->end_col; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
227 this->start_row = packet->start_row; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
228 this->end_row = packet->end_row; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
229 this->height = packet->height; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
230 this->width = packet->width; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
231 this->stride = packet->stride; |
3166 | 232 for (i = 0; i < 4; ++i) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
233 alpha[i] = mkalpha(packet->alpha[i]); |
3166 | 234 if (alpha[i] == 0) |
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 } |
3166 | 241 else { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
242 cmap[i] = ((this->global_palette[packet->palette[i]] >> 16) & 0xff); |
4122 | 243 if (cmap[i] + alpha[i] > 255) |
244 cmap[i] = 256 - alpha[i]; | |
3166 | 245 } |
246 } | |
247 | |
3402 | 248 if (this->image_size < this->stride * this->height) { |
249 if (this->image != NULL) { | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
250 free(this->image); |
3402 | 251 this->image_size = 0; |
252 } | |
253 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
|
254 if (this->image) { |
3402 | 255 this->image_size = this->stride * this->height; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
256 this->aimage = this->image + this->image_size; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
257 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
258 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
259 if (this->image == NULL) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
260 return; |
3402 | 261 |
262 /* Kludge: draw_alpha needs width multiple of 8. */ | |
263 if (this->width < this->stride) | |
6459 | 264 for (y = 0; y < this->height; ++y) { |
3402 | 265 memset(this->aimage + y * this->stride + this->width, 0, this->stride - this->width); |
6459 | 266 /* FIXME: Why is this one needed? */ |
267 memset(this->image + y * this->stride + this->width, 0, this->stride - this->width); | |
268 } | |
3402 | 269 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
270 i = packet->current_nibble[1]; |
3402 | 271 x = 0; |
272 y = 0; | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
273 while (packet->current_nibble[0] < i |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
274 && packet->current_nibble[1] / 2 < packet->control_start |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
275 && y < this->height) { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
276 unsigned int len, color; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
277 unsigned int rle = 0; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
278 rle = get_nibble(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
279 if (rle < 0x04) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
280 rle = (rle << 4) | get_nibble(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
281 if (rle < 0x10) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
282 rle = (rle << 4) | get_nibble(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
283 if (rle < 0x040) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
284 rle = (rle << 4) | get_nibble(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
285 if (rle < 0x0004) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
286 rle |= ((this->width - x) << 2); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
287 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
288 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
289 } |
3166 | 290 color = 3 - (rle & 0x3); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
291 len = rle >> 2; |
3402 | 292 if (len > this->width - x || len == 0) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
293 len = this->width - x; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
294 /* FIXME have to use palette and alpha map*/ |
3402 | 295 memset(this->image + y * this->stride + x, cmap[color], len); |
296 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
|
297 x += len; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
298 if (x >= this->width) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
299 next_line(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
300 x = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
301 ++y; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
302 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
303 } |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
304 spudec_cut_image(this); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
305 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
306 |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
307 |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
308 /* |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
309 This function tries to create a usable palette. |
11000 | 310 It determines how many non-transparent colors are used, and assigns different |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
311 gray scale values to each color. |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
312 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
|
313 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
|
314 */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
315 static void compute_palette(spudec_handle_t *this, packet_t *packet) |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
316 { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
317 int used[16],i,cused,start,step,color; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
318 |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
319 memset(used, 0, sizeof(used)); |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
320 for (i=0; i<4; i++) |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
321 if (packet->alpha[i]) /* !Transparent? */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
322 used[packet->palette[i]] = 1; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
323 for (cused=0, i=0; i<16; i++) |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
324 if (used[i]) cused++; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
325 if (!cused) return; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
326 if (cused == 1) { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
327 start = 0x80; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
328 step = 0; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
329 } else { |
6110 | 330 start = this->font_start_level; |
331 step = (0xF0-this->font_start_level)/(cused-1); | |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
332 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
333 memset(used, 0, sizeof(used)); |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
334 for (i=0; i<4; i++) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
335 color = packet->palette[i]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
336 if (packet->alpha[i] && !used[color]) { /* not assigned? */ |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
337 used[color] = 1; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
338 this->global_palette[color] = start<<16; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
339 start += step; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
340 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
341 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
342 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
343 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
344 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
|
345 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
346 int a,b; /* Temporary vars */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
347 unsigned int date, type; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
348 unsigned int off; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
349 unsigned int start_off = 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
350 unsigned int next_off; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
351 unsigned int start_pts; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
352 unsigned int end_pts; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
353 unsigned int current_nibble[2]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
354 unsigned int control_start; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
355 unsigned int display = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
356 unsigned int start_col = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
357 unsigned int end_col = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
358 unsigned int start_row = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
359 unsigned int end_row = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
360 unsigned int width = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
361 unsigned int height = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
362 unsigned int stride = 0; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
363 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
364 control_start = get_be16(this->packet + 2); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
365 next_off = control_start; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
366 while (start_off != next_off) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
367 start_off = next_off; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
368 date = get_be16(this->packet + start_off) * 1024; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
369 next_off = get_be16(this->packet + start_off + 2); |
3822 | 370 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
|
371 off = start_off + 4; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
372 for (type = this->packet[off++]; type != 0xff; type = this->packet[off++]) { |
3822 | 373 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
|
374 switch(type) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
375 case 0x00: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
376 /* Menu ID, 1 byte */ |
3822 | 377 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
|
378 /* shouldn't a Menu ID type force display start? */ |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
379 start_pts = pts100 + date; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
380 end_pts = UINT_MAX; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
381 display = 1; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
382 this->is_forced_sub=~0; // current subtitle is forced |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
383 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
384 case 0x01: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
385 /* Start display */ |
3822 | 386 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Start display!\n"); |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
387 start_pts = pts100 + date; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
388 end_pts = UINT_MAX; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
389 display = 1; |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
390 this->is_forced_sub=0; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
391 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
392 case 0x02: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
393 /* Stop display */ |
3822 | 394 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Stop display!\n"); |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
395 end_pts = pts100 + date; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
396 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
397 case 0x03: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
398 /* Palette */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
399 this->palette[0] = this->packet[off] >> 4; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
400 this->palette[1] = this->packet[off] & 0xf; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
401 this->palette[2] = this->packet[off + 1] >> 4; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
402 this->palette[3] = this->packet[off + 1] & 0xf; |
3822 | 403 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
|
404 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
|
405 off+=2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
406 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
407 case 0x04: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
408 /* Alpha */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
409 this->alpha[0] = this->packet[off] >> 4; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
410 this->alpha[1] = this->packet[off] & 0xf; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
411 this->alpha[2] = this->packet[off + 1] >> 4; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
412 this->alpha[3] = this->packet[off + 1] & 0xf; |
3822 | 413 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
|
414 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
|
415 off+=2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
416 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
417 case 0x05: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
418 /* Co-ords */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
419 a = get_be24(this->packet + off); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
420 b = get_be24(this->packet + off + 3); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
421 start_col = a >> 12; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
422 end_col = a & 0xfff; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
423 width = (end_col < start_col) ? 0 : end_col - start_col + 1; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
424 stride = (width + 7) & ~7; /* Kludge: draw_alpha needs width multiple of 8 */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
425 start_row = b >> 12; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
426 end_row = b & 0xfff; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
427 height = (end_row < start_row) ? 0 : end_row - start_row /* + 1 */; |
3822 | 428 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Coords col: %d - %d row: %d - %d (%dx%d)\n", |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
429 start_col, end_col, start_row, end_row, |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
430 width, height); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
431 off+=6; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
432 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
433 case 0x06: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
434 /* Graphic lines */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
435 current_nibble[0] = 2 * get_be16(this->packet + off); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
436 current_nibble[1] = 2 * get_be16(this->packet + off + 2); |
3822 | 437 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Graphic offset 1: %d offset 2: %d\n", |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
438 current_nibble[0] / 2, current_nibble[1] / 2); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
439 off+=4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
440 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
441 case 0xff: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
442 /* All done, bye-bye */ |
3822 | 443 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
|
444 return; |
3822 | 445 // break; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
446 default: |
3822 | 447 mp_msg(MSGT_SPUDEC,MSGL_WARN,"spudec: Error determining control type 0x%02x. Skipping %d bytes.\n", |
3402 | 448 type, next_off - off); |
449 goto next_control; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
450 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
451 } |
3402 | 452 next_control: |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
453 if (display) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
454 packet_t *packet = calloc(1, sizeof(packet_t)); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
455 int i; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
456 packet->start_pts = start_pts; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
457 if (end_pts == UINT_MAX && start_off != next_off) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
458 start_pts = pts100 + get_be16(this->packet + next_off) * 1024; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
459 packet->end_pts = start_pts - 1; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
460 } else packet->end_pts = end_pts; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
461 packet->current_nibble[0] = current_nibble[0]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
462 packet->current_nibble[1] = current_nibble[1]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
463 packet->start_row = start_row; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
464 packet->end_row = end_row; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
465 packet->start_col = start_col; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
466 packet->end_col = end_col; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
467 packet->width = width; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
468 packet->height = height; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
469 packet->stride = stride; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
470 packet->control_start = control_start; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
471 for (i=0; i<4; i++) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
472 packet->alpha[i] = this->alpha[i]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
473 packet->palette[i] = this->palette[i]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
474 } |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
475 packet->packet = malloc(this->packet_size); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
476 memcpy(packet->packet, this->packet, this->packet_size); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
477 spudec_queue_packet(this, packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
478 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
479 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
480 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
481 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
482 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
|
483 { |
6110 | 484 if(this->hw_spu) { |
485 static vo_mpegpes_t packet = { NULL, 0, 0x20, 0 }; | |
486 static vo_mpegpes_t *pkg=&packet; | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
487 packet.data = this->packet; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
488 packet.size = this->packet_size; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
489 packet.timestamp = pts100; |
6110 | 490 this->hw_spu->draw_frame((uint8_t**)&pkg); |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
491 } else |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
492 spudec_process_control(this, pts100); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
493 } |
560 | 494 |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
495 int spudec_changed(void * this) |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
496 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
497 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
|
498 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
|
499 } |
560 | 500 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
501 void spudec_assemble(void *this, unsigned char *packet, unsigned int len, unsigned int pts100) |
560 | 502 { |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
503 spudec_handle_t *spu = (spudec_handle_t*)this; |
3842 | 504 // spudec_heartbeat(this, pts100); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
505 if (len < 2) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
506 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
|
507 return; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
508 } |
15761 | 509 #if 0 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
510 if ((spu->packet_pts + 10000) < pts100) { |
7743
a280cc3087ea
All right: The patch adresses two issues which I found, when I analyzed
arpi
parents:
6938
diff
changeset
|
511 // [cb] too long since last fragment: force new packet |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
512 spu->packet_offset = 0; |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
513 } |
15761 | 514 #endif |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
515 spu->packet_pts = pts100; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
516 if (spu->packet_offset == 0) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
517 unsigned int len2 = get_be16(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
518 // Start new fragment |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
519 if (spu->packet_reserve < len2) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
520 if (spu->packet != NULL) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
521 free(spu->packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
522 spu->packet = malloc(len2); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
523 spu->packet_reserve = spu->packet != NULL ? len2 : 0; |
560 | 524 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
525 if (spu->packet != NULL) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
526 spu->packet_size = len2; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
527 if (len > len2) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
528 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
|
529 return; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
530 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
531 memcpy(spu->packet, packet, len); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
532 spu->packet_offset = len; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
533 spu->packet_pts = pts100; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
534 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
535 } else { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
536 // Continue current fragment |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
537 if (spu->packet_size < spu->packet_offset + len){ |
3822 | 538 mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUasm: invalid fragment\n"); |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
539 spu->packet_size = spu->packet_offset = 0; |
9442 | 540 return; |
3744 | 541 } else { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
542 memcpy(spu->packet + spu->packet_offset, packet, len); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
543 spu->packet_offset += len; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
544 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
545 } |
3820 | 546 #if 1 |
547 // check if we have a complete packet (unfortunatelly packet_size is bad | |
548 // for some disks) | |
7743
a280cc3087ea
All right: The patch adresses two issues which I found, when I analyzed
arpi
parents:
6938
diff
changeset
|
549 // [cb] packet_size is padded to be even -> may be one byte too long |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
550 if ((spu->packet_offset == spu->packet_size) || |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
551 ((spu->packet_offset + 1) == spu->packet_size)){ |
5917 | 552 unsigned int x=0,y; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
553 while(x+4<=spu->packet_offset){ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
554 y=get_be16(spu->packet+x+2); // next control pointer |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
555 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 | 556 if(x>=4 && x==y){ // if it points to self - we're done! |
557 // we got it! | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
558 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPUgot: off=%d size=%d \n",spu->packet_offset,spu->packet_size); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
559 spudec_decode(spu, pts100); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
560 spu->packet_offset = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
561 break; |
3820 | 562 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
563 if(y<=x || y>=spu->packet_size){ // invalid? |
3822 | 564 mp_msg(MSGT_SPUDEC,MSGL_WARN,"SPUtest: broken packet!!!!! y=%d < x=%d\n",y,x); |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
565 spu->packet_size = spu->packet_offset = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
566 break; |
3820 | 567 } |
568 x=y; | |
569 } | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
570 // [cb] packet is done; start new packet |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
571 spu->packet_offset = 0; |
3820 | 572 } |
573 #else | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
574 if (spu->packet_offset == spu->packet_size) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
575 spudec_decode(spu, pts100); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
576 spu->packet_offset = 0; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
577 } |
3820 | 578 #endif |
560 | 579 } |
580 | |
3744 | 581 void spudec_reset(void *this) // called after seek |
582 { | |
583 spudec_handle_t *spu = (spudec_handle_t*)this; | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
584 while (spu->queue_head) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
585 spudec_free_packet(spudec_dequeue_packet(spu)); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
586 spu->now_pts = 0; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
587 spu->end_pts = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
588 spu->packet_size = spu->packet_offset = 0; |
3744 | 589 } |
590 | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
591 void spudec_heartbeat(void *this, unsigned int pts100) |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
592 { |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
593 spudec_handle_t *spu = (spudec_handle_t*) this; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
594 spu->now_pts = pts100; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
595 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
596 while (spu->queue_head != NULL && pts100 >= spu->queue_head->start_pts) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
597 packet_t *packet = spudec_dequeue_packet(spu); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
598 spu->start_pts = packet->start_pts; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
599 spu->end_pts = packet->end_pts; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
600 if (spu->auto_palette) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
601 compute_palette(spu, packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
602 spudec_process_data(spu, packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
603 spudec_free_packet(packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
604 spu->spu_changed = 1; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
605 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
606 } |
560 | 607 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
608 int spudec_visible(void *this){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
609 spudec_handle_t *spu = (spudec_handle_t *)this; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
610 int ret=(spu->start_pts <= spu->now_pts && |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
611 spu->now_pts < spu->end_pts && |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
612 spu->height > 0); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
613 // 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
|
614 return ret; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
615 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
616 |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
617 void spudec_set_forced_subs_only(void * const this, const unsigned int flag) |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
618 { |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
619 if(this){ |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
620 ((spudec_handle_t *)this)->forced_subs_only=flag; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
621 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPU: Display only forced subs now %s\n", flag ? "enabled": "disabled"); |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
622 } |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
623 } |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
624 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
625 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
|
626 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
627 spudec_handle_t *spu = (spudec_handle_t *)this; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
628 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
|
629 { |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
630 draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, |
3402 | 631 spu->image, spu->aimage, spu->stride); |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
632 spu->spu_changed = 0; |
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
633 } |
561 | 634 } |
635 | |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
636 /* calc the bbox for spudec subs */ |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
637 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
|
638 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
639 spudec_handle_t *spu; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
640 spu = (spudec_handle_t *)me; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
641 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
|
642 || (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
|
643 bbox[0] = spu->start_col; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
644 bbox[1] = spu->start_col + spu->width; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
645 bbox[2] = spu->start_row; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
646 bbox[3] = spu->start_row + spu->height; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
647 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
648 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
|
649 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
|
650 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
|
651 bbox[0] = spu->start_col * scalex / 0x100; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
652 bbox[1] = spu->start_col * scalex / 0x100 + spu->width * scalex / 0x100; |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
653 switch (spu_alignment) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
654 case 0: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
655 bbox[3] = dys*sub_pos/100 + spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
656 if (bbox[3] > dys) bbox[3] = dys; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
657 bbox[2] = bbox[3] - spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
658 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
659 case 1: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
660 if (sub_pos < 50) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
661 bbox[2] = dys*sub_pos/100 - spu->height * scaley / 0x200; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
662 bbox[3] = bbox[2] + spu->height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
663 } else { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
664 bbox[3] = dys*sub_pos/100 + spu->height * scaley / 0x200; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
665 if (bbox[3] > dys) bbox[3] = dys; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
666 bbox[2] = bbox[3] - spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
667 } |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
668 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
669 case 2: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
670 bbox[2] = dys*sub_pos/100 - spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
671 bbox[3] = bbox[2] + spu->height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
672 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
673 default: /* -1 */ |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
674 bbox[2] = spu->start_row * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
675 bbox[3] = spu->start_row * scaley / 0x100 + spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
676 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
677 } |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
678 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
679 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
680 /* 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
|
681 static inline int canon_alpha(int alpha) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
682 { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
683 return alpha ? 256 - alpha : 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
684 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
685 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
686 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
|
687 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
|
688 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
|
689 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
|
690 }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
|
691 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
692 |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
693 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
|
694 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
695 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
|
696 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
|
697 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
|
698 int src = 0; |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
699 int src_step; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
700 if (delta_src == 0 || delta_tar == 0) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
701 return; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
702 } |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
703 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
|
704 for (t = 0; t<=delta_tar; src += (src_step << 1), t++){ |
22378 | 705 table[t].position= FFMIN(src >> 16, end_src - 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
|
706 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
|
707 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
|
708 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
709 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
710 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
711 /* bilinear scale, similar to vobsub's code */ |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
712 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
|
713 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
714 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
|
715 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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 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
|
724 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
|
725 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
|
726 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
|
727 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
|
728 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
|
729 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
|
730 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
|
731 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
|
732 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
|
733 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
|
734 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
|
735 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
|
736 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
|
737 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
738 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
739 |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
740 void sws_spu_image(unsigned char *d1, unsigned char *d2, int dw, int dh, int ds, |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
741 unsigned char *s1, unsigned char *s2, int sw, int sh, int ss) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
742 { |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
743 struct SwsContext *ctx; |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
744 static SwsFilter filter; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
745 static int firsttime = 1; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
746 static float oldvar; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
747 int i; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
748 |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
749 if (!firsttime && oldvar != spu_gaussvar) sws_freeVec(filter.lumH); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
750 if (firsttime) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
751 filter.lumH = filter.lumV = |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
752 filter.chrH = filter.chrV = sws_getGaussianVec(spu_gaussvar, 3.0); |
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
753 sws_normalizeVec(filter.lumH, 1.0); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
754 firsttime = 0; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
755 oldvar = spu_gaussvar; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
756 } |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
757 |
19870
1e5cf11e8b1f
Use PIX_FMT_* instead of IMGFMT_* when calling sws_getContext()
lucabe
parents:
18861
diff
changeset
|
758 ctx=sws_getContext(sw, sh, PIX_FMT_GRAY8, dw, dh, PIX_FMT_GRAY8, SWS_GAUSS, &filter, NULL, NULL); |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
759 sws_scale(ctx,&s1,&ss,0,sh,&d1,&ds); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
760 for (i=ss*sh-1; i>=0; i--) if (!s2[i]) s2[i] = 255; //else s2[i] = 1; |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
761 sws_scale(ctx,&s2,&ss,0,sh,&d2,&ds); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
762 for (i=ds*dh-1; i>=0; i--) if (d2[i]==0) d2[i] = 1; else if (d2[i]==255) d2[i] = 0; |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
763 sws_freeContext(ctx); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
764 } |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
765 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
766 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
|
767 { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
768 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
|
769 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
|
770 scale_pixel *table_y; |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
771 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
772 if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts) { |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
773 |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
774 // check if only forced subtitles are requested |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
775 if( (spu->forced_subs_only) && !(spu->is_forced_sub) ){ |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
776 return; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
777 } |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
778 |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
779 if (!(spu_aamode&16) && (spu->orig_frame_width == 0 || spu->orig_frame_height == 0 |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
780 || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
781 if (spu->image) |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
782 { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
783 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
|
784 spu->image, spu->aimage, spu->stride); |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
785 spu->spu_changed = 0; |
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
786 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
787 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
788 else { |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
789 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
|
790 /* scaled_x = scalex * x / 0x100 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
791 scaled_y = scaley * y / 0x100 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
792 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
|
793 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
|
794 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
|
795 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
|
796 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
|
797 spu->scaled_width = spu->width * scalex / 0x100; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
798 spu->scaled_height = spu->height * scaley / 0x100; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
799 /* 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
|
800 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
|
801 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
|
802 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
803 free(spu->scaled_image); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
804 spu->scaled_image_size = 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
805 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
806 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
|
807 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
808 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
|
809 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
|
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 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
813 unsigned int x, y; |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
814 if (spu->scaled_width <= 1 || spu->scaled_height <= 1) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
815 goto nothing_to_do; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
816 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
817 switch(spu_aamode&15) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
818 case 4: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
819 sws_spu_image(spu->scaled_image, spu->scaled_aimage, |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
820 spu->scaled_width, spu->scaled_height, spu->scaled_stride, |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
821 spu->image, spu->aimage, spu->width, spu->height, spu->stride); |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
822 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
823 case 3: |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
824 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
|
825 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
|
826 if (!table_x || !table_y) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
827 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
|
828 } |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 free(table_x); |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
835 free(table_y); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
836 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
837 case 0: |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
838 /* no antialiasing */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
839 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
|
840 int unscaled_y = y * 0x100 / scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
841 int strides = spu->stride * unscaled_y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
842 int scaled_strides = spu->scaled_stride * y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
843 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
|
844 int unscaled_x = x * 0x100 / scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
845 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
|
846 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
|
847 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
848 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
849 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
850 case 1: |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
851 { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
852 /* Intermediate antialiasing. */ |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
853 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
|
854 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
|
855 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
|
856 if (unscaled_bottom >= spu->height) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
857 unscaled_bottom = spu->height - 1; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
858 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
|
859 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
|
860 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
|
861 unsigned int color = 0; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
862 unsigned int alpha = 0; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
863 unsigned int walkx, walky; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
864 unsigned int base, tmp; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
865 if (unscaled_right >= spu->width) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
866 unscaled_right = spu->width - 1; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
867 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
|
868 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
|
869 base = walky * spu->stride + walkx; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
870 tmp = canon_alpha(spu->aimage[base]); |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
871 alpha += tmp; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
872 color += tmp * spu->image[base]; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
873 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
874 base = y * spu->scaled_stride + x; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
875 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
|
876 spu->scaled_aimage[base] = |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
877 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
|
878 /* spu->scaled_aimage[base] = |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
879 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
|
880 if (spu->scaled_aimage[base]) { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
881 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
|
882 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
|
883 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
|
884 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
885 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
886 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
887 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
888 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
889 case 2: |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
890 { |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
891 /* Best antialiasing. Very slow. */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
892 /* 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
|
893 rectangular region comprised between the columns |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
894 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
|
895 unscaled_x and unscaled_x + 0x100 / scalex |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
896 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
897 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
|
898 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
|
899 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
900 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
901 | 1 | 2 | 3 | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
902 +---+-----------------+---+ |
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 | 4 | 5 | 6 | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
905 | | | | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
906 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
907 | 7 | 8 | 9 | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
908 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
909 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
910 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
|
911 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
|
912 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
|
913 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
|
914 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
|
915 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
|
916 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
|
917 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
|
918 one pixel. |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
919 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
920 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
|
921 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
|
922 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
|
923 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
|
924 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
925 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
|
926 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
|
927 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
|
928 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
|
929 unscaled_x_right. */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
930 const double inv_scalex = (double) 0x100 / scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
931 const double inv_scaley = (double) 0x100 / scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
932 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
|
933 const double unscaled_y = y * inv_scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
934 const double unscaled_y_bottom = unscaled_y + inv_scaley; |
22378 | 935 const unsigned int top_low_row = FFMIN(unscaled_y_bottom, unscaled_y + 1.0); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
936 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
|
937 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
|
938 ? (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
|
939 : 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
940 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
|
941 ? unscaled_y_bottom - floor(unscaled_y_bottom) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
942 : 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
943 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
|
944 const double unscaled_x = x * inv_scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
945 const double unscaled_x_right = unscaled_x + inv_scalex; |
22378 | 946 const unsigned int left_right_column = FFMIN(unscaled_x_right, unscaled_x + 1.0); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
947 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
|
948 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
|
949 ? (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
|
950 : 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
951 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
|
952 ? unscaled_x_right - floor(unscaled_x_right) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
953 : 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
954 double color = 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
955 double alpha = 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
956 double tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
957 unsigned int base; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
958 /* 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
|
959 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
|
960 region's surface and alpha and lightness. |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
961 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
962 transformed alpha = sum(surface * alpha) / sum(surface) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
963 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
|
964 */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
965 /* 1: top left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
966 base = spu->stride * (unsigned int) unscaled_y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
967 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
|
968 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
969 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
|
970 /* 2: top center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
971 if (width > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
972 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
973 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
|
974 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
|
975 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
|
976 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
977 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
978 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
979 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
980 /* 3: top right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
981 if (right > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
982 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
|
983 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
|
984 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
985 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
986 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
987 /* 4: center left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
988 if (height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
989 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
990 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
|
991 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
|
992 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
|
993 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
994 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
995 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
996 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
997 /* 5: center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
998 if (width > 0 && height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
999 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1000 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
|
1001 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1002 base = spu->stride * walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1003 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
|
1004 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
|
1005 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1006 color += tmp * spu->image[base + walkx]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1007 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1008 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1009 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1010 /* 6: center right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1011 if (right > 0.0 && height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1012 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1013 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
|
1014 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
|
1015 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
|
1016 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1017 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1018 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1019 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1020 /* 7: bottom left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1021 if (bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1022 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
|
1023 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
|
1024 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1025 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1026 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1027 /* 8: bottom center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1028 if (width > 0 && bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1029 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1030 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
|
1031 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
|
1032 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
|
1033 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1034 color += tmp * spu->image[base + walkx]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1035 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1036 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1037 /* 9: bottom right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1038 if (right > 0.0 && bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1039 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
|
1040 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
|
1041 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1042 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1043 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1044 /* 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
|
1045 base = spu->scaled_stride * y + x; |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
1046 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
|
1047 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
|
1048 if (spu->scaled_aimage[base]) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1049 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
|
1050 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
|
1051 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
|
1052 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1053 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1054 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1055 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1056 } |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
1057 nothing_to_do: |
14432
275b2ce30af7
Fix black line on right of subtitle with -spuaa 4 by setting alpha of
reimar
parents:
13373
diff
changeset
|
1058 /* Kludge: draw_alpha needs width multiple of 8. */ |
275b2ce30af7
Fix black line on right of subtitle with -spuaa 4 by setting alpha of
reimar
parents:
13373
diff
changeset
|
1059 if (spu->scaled_width < spu->scaled_stride) |
275b2ce30af7
Fix black line on right of subtitle with -spuaa 4 by setting alpha of
reimar
parents:
13373
diff
changeset
|
1060 for (y = 0; y < spu->scaled_height; ++y) { |
275b2ce30af7
Fix black line on right of subtitle with -spuaa 4 by setting alpha of
reimar
parents:
13373
diff
changeset
|
1061 memset(spu->scaled_aimage + y * spu->scaled_stride + spu->scaled_width, 0, |
275b2ce30af7
Fix black line on right of subtitle with -spuaa 4 by setting alpha of
reimar
parents:
13373
diff
changeset
|
1062 spu->scaled_stride - spu->scaled_width); |
275b2ce30af7
Fix black line on right of subtitle with -spuaa 4 by setting alpha of
reimar
parents:
13373
diff
changeset
|
1063 } |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
1064 spu->scaled_frame_width = dxs; |
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
1065 spu->scaled_frame_height = dys; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1066 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1067 } |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1068 if (spu->scaled_image){ |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1069 switch (spu_alignment) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1070 case 0: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1071 spu->scaled_start_row = dys*sub_pos/100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1072 if (spu->scaled_start_row + spu->scaled_height > dys) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1073 spu->scaled_start_row = dys - spu->scaled_height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1074 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1075 case 1: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1076 spu->scaled_start_row = dys*sub_pos/100 - spu->scaled_height/2; |
24018 | 1077 if (sub_pos >= 50 && spu->scaled_start_row + spu->scaled_height > dys) |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1078 spu->scaled_start_row = dys - spu->scaled_height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1079 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1080 case 2: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1081 spu->scaled_start_row = dys*sub_pos/100 - spu->scaled_height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1082 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1083 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1084 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
|
1085 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
|
1086 spu->spu_changed = 0; |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1087 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1088 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1089 } |
5474
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1090 else |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1091 { |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1092 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
|
1093 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
|
1094 } |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1095 } |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1096 |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1097 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
|
1098 { |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1099 spudec_handle_t *spu = (spudec_handle_t *) this; |
6110 | 1100 if (spu && palette) { |
5474
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1101 memcpy(spu->global_palette, palette, sizeof(spu->global_palette)); |
6110 | 1102 if(spu->hw_spu) |
1103 spu->hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette); | |
1104 } | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1105 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1106 |
6110 | 1107 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
|
1108 { |
6110 | 1109 spudec_handle_t *spu = (spudec_handle_t *) this; |
1110 spu->font_start_level = (int)(0xF0-(0xE0*factor)); | |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1111 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1112 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1113 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
|
1114 { |
6938 | 1115 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
|
1116 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1117 |
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
|
1118 /* 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
|
1119 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
|
1120 { |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
1121 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
|
1122 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
|
1123 //(fprintf(stderr,"VobSub Custom Palette: %d,%d,%d,%d", this->cuspal[0], this->cuspal[1], this->cuspal[2],this->cuspal[3]); |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
1124 this->packet = NULL; |
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
|
1125 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
|
1126 this->scaled_image = NULL; |
6938 | 1127 /* XXX Although the video frame is some size, the SPU frame is |
1128 always maximum size i.e. 720 wide and 576 or 480 high */ | |
1129 this->orig_frame_width = 720; | |
1130 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
|
1131 this->custom = custom; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1132 // set up palette: |
6110 | 1133 this->auto_palette = 1; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1134 if (palette){ |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1135 memcpy(this->global_palette, palette, sizeof(this->global_palette)); |
6110 | 1136 this->auto_palette = 0; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1137 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1138 this->custom = custom; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1139 if (custom && cuspal) { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1140 memcpy(this->cuspal, cuspal, sizeof(this->cuspal)); |
6110 | 1141 this->auto_palette = 0; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1142 } |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
1143 // forced subtitles default: show all subtitles |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
1144 this->forced_subs_only=0; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
1145 this->is_forced_sub=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
|
1146 } |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
1147 else |
6110 | 1148 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
|
1149 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
|
1150 } |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1151 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1152 void *spudec_new(unsigned int *palette) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1153 { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1154 return spudec_new_scaled(palette, 0, 0); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1155 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1156 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1157 void spudec_free(void *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1158 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1159 spudec_handle_t *spu = (spudec_handle_t*)this; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1160 if (spu) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
1161 while (spu->queue_head) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
1162 spudec_free_packet(spudec_dequeue_packet(spu)); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
1163 if (spu->packet) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
1164 free(spu->packet); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1165 if (spu->scaled_image) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1166 free(spu->scaled_image); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1167 if (spu->image) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1168 free(spu->image); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1169 free(spu); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1170 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1171 } |
6110 | 1172 |
1173 void spudec_set_hw_spu(void *this, vo_functions_t *hw_spu) | |
1174 { | |
1175 spudec_handle_t *spu = (spudec_handle_t*)this; | |
1176 if (!spu) | |
1177 return; | |
1178 spu->hw_spu = hw_spu; | |
1179 hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette); | |
1180 } |