Mercurial > mplayer.hg
annotate spudec.c @ 31793:9fdee6f96925
Avoid code duplication, use the generate file name instead of generating it twice.
author | reimar |
---|---|
date | Fri, 30 Jul 2010 18:18:03 +0000 |
parents | da0bfd02286c |
children | e9458f705c3f |
rev | line source |
---|---|
30429
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
1 /* |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
2 * Skeleton of function spudec_process_controll() is from xine sources. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
3 * Further works: |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
4 * LGB,... (yeah, try to improve it and insert your name here! ;-) |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
5 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
6 * Kim Minh Kaplan |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
7 * implement fragments reassembly, RLE decoding. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
8 * read brightness from the IFO. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
9 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
10 * For information on SPU format see <URL:http://sam.zoy.org/doc/dvd/subtitles/> |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
11 * and <URL:http://members.aol.com/mpucoder/DVD/spu.html> |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
12 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
13 * This file is part of MPlayer. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
14 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
15 * MPlayer is free software; you can redistribute it and/or modify |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
16 * it under the terms of the GNU General Public License as published by |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
17 * the Free Software Foundation; either version 2 of the License, or |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
18 * (at your option) any later version. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
19 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
20 * MPlayer is distributed in the hope that it will be useful, |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
23 * GNU General Public License for more details. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
24 * |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
25 * You should have received a copy of the GNU General Public License along |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
26 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
27 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
c1a3f1bbba26
Add license header to all top-level files missing them.
diego
parents:
29263
diff
changeset
|
28 */ |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
29 |
3183 | 30 #include "config.h" |
3822 | 31 #include "mp_msg.h" |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
32 |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
33 #include <errno.h> |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
34 #include <limits.h> |
560 | 35 #include <stdio.h> |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
36 #include <stdlib.h> |
3175 | 37 #include <unistd.h> |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
38 #include <string.h> |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
39 #include <math.h> |
31487
fd422d385a19
Add #include for libvo/sub.h instead of duplicating sub_pos extern declaration.
diego
parents:
31230
diff
changeset
|
40 #include "libvo/sub.h" |
6110 | 41 #include "libvo/video_out.h" |
560 | 42 #include "spudec.h" |
27807 | 43 #include "vobsub.h" |
26069
1318e956c092
FFmpeg now uses different (unified) #include paths.
diego
parents:
25640
diff
changeset
|
44 #include "libavutil/avutil.h" |
27807 | 45 #include "libavutil/intreadwrite.h" |
18861 | 46 #include "libswscale/swscale.h" |
560 | 47 |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
48 /* Valid values for spu_aamode: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
49 0: none (fastest, most ugly) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
50 1: approximate |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
51 2: full (slowest) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
52 3: bilinear (similiar to vobsub, fast and not too bad) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
53 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
|
54 */ |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
55 |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
56 int spu_aamode = 3; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
57 int spu_alignment = -1; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
58 float spu_gaussvar = 1.0; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
59 |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
60 typedef struct packet_t packet_t; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
61 struct packet_t { |
31599
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
62 int is_decoded; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
63 unsigned char *packet; |
31599
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
64 int data_len; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
65 unsigned int palette[4]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
66 unsigned int alpha[4]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
67 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
|
68 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
|
69 processed (for RLE decoding) for |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
70 even and odd lines */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
71 int deinterlace_oddness; /* 0 or 1, index into current_nibble */ |
31761 | 72 unsigned int start_col; |
73 unsigned int start_row; | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
74 unsigned int width, height, stride; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
75 unsigned int start_pts, end_pts; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
76 packet_t *next; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
77 }; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
78 |
31762 | 79 struct palette_crop_cache { |
80 int valid; | |
81 uint32_t palette; | |
82 int sx, sy, ex, ey; | |
83 int result; | |
84 }; | |
85 | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
86 typedef struct { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
87 packet_t *queue_head; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
88 packet_t *queue_tail; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
89 unsigned int global_palette[16]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
90 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
|
91 unsigned char* packet; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
92 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
|
93 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
|
94 unsigned int packet_size; /* size of the packet once all fragments are assembled */ |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
95 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
|
96 unsigned int palette[4]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
97 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
|
98 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
|
99 unsigned int custom; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
100 unsigned int now_pts; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
101 unsigned int start_pts, end_pts; |
31761 | 102 unsigned int start_col; |
103 unsigned int start_row; | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
104 unsigned int width, height, stride; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
105 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
|
106 unsigned char *image; /* Grayscale value */ |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
107 unsigned char *aimage; /* Alpha value */ |
31762 | 108 unsigned int pal_start_col, pal_start_row; |
109 unsigned int pal_width, pal_height; | |
31723
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
110 unsigned char *pal_image; /* palette entry value */ |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
111 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
|
112 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
|
113 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
|
114 size_t scaled_image_size; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
115 unsigned char *scaled_image; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
116 unsigned char *scaled_aimage; |
6110 | 117 int auto_palette; /* 1 if we lack a palette and must use an heuristic. */ |
118 int font_start_level; /* Darkest value used for the computed font */ | |
25219
e82ecde2cbd4
Mark several uses of vo_functions_t as const to stop some of the current
reimar
parents:
25185
diff
changeset
|
119 const vo_functions_t *hw_spu; |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
120 int spu_changed; |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
121 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
|
122 unsigned int is_forced_sub; /* true if current subtitle is a forced subtitle */ |
31762 | 123 |
124 struct palette_crop_cache palette_crop_cache; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
125 } spudec_handle_t; |
560 | 126 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
127 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
|
128 { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
129 if (this->queue_head == NULL) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
130 this->queue_head = packet; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
131 else |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
132 this->queue_tail->next = packet; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
133 this->queue_tail = packet; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
134 } |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
135 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
136 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
|
137 { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
138 packet_t *retval = this->queue_head; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
139 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
140 this->queue_head = retval->next; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
141 if (this->queue_head == NULL) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
142 this->queue_tail = NULL; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
143 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
144 return retval; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
145 } |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
146 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
147 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
|
148 { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
149 if (packet->packet != NULL) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
150 free(packet->packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
151 free(packet); |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
152 } |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
153 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
154 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
|
155 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
156 return (p[0] << 8) + p[1]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
157 } |
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 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
|
160 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
161 return (get_be16(p) << 8) + p[2]; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
162 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
163 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
164 static void next_line(packet_t *packet) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
165 { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
166 if (packet->current_nibble[packet->deinterlace_oddness] % 2) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
167 packet->current_nibble[packet->deinterlace_oddness]++; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
168 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
|
169 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
170 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
171 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
|
172 { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
173 unsigned char nib; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
174 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
|
175 if (*nibblep / 2 >= packet->control_start) { |
3822 | 176 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
|
177 return 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
178 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
179 nib = packet->packet[*nibblep / 2]; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
180 if (*nibblep % 2) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
181 nib &= 0xf; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
182 else |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
183 nib >>= 4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
184 ++*nibblep; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
185 return nib; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
186 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
187 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
188 /* 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
|
189 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
|
190 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
191 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
|
192 unsigned int first_y, last_y; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
193 |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
194 if (this->stride == 0 || this->height == 0) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
195 return; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
196 } |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
197 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
198 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
|
199 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
|
200 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
|
201 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
|
202 //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
|
203 this->start_row += first_y; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
204 |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
205 // Some subtitles trigger this condition |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
206 if (last_y + 1 > first_y ) { |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
207 this->height = last_y - first_y +1; |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
208 } else { |
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
209 this->height = 0; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
210 return; |
6223
7833c711d62b
avoids malloc()ing a negative number (== very big size_t)
pl
parents:
6215
diff
changeset
|
211 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28188
diff
changeset
|
212 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
213 // 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
|
214 |
31731 | 215 if (first_y > 0) { |
216 memmove(this->image, this->image + this->stride * first_y, this->stride * this->height); | |
217 memmove(this->aimage, this->aimage + this->stride * first_y, 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
|
218 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
219 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
220 |
31593
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
221 |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
222 static int spudec_alloc_image(spudec_handle_t *this, int stride, int height) |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
223 { |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
224 if (this->width > stride) // just a safeguard |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
225 this->width = stride; |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
226 this->stride = stride; |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
227 this->height = height; |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
228 if (this->image_size < this->stride * this->height) { |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
229 if (this->image != NULL) { |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
230 free(this->image); |
31725
8e850ff84b27
Allocate memory for paletted image data separately to avoid
reimar
parents:
31724
diff
changeset
|
231 free(this->pal_image); |
31593
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
232 this->image_size = 0; |
31762 | 233 this->pal_width = this->pal_height = 0; |
31593
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
234 } |
31725
8e850ff84b27
Allocate memory for paletted image data separately to avoid
reimar
parents:
31724
diff
changeset
|
235 this->image = malloc(2 * this->stride * this->height); |
31593
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
236 if (this->image) { |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
237 this->image_size = this->stride * this->height; |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
238 this->aimage = this->image + this->image_size; |
31725
8e850ff84b27
Allocate memory for paletted image data separately to avoid
reimar
parents:
31724
diff
changeset
|
239 // use stride here as well to simplify reallocation checks |
8e850ff84b27
Allocate memory for paletted image data separately to avoid
reimar
parents:
31724
diff
changeset
|
240 this->pal_image = malloc(this->stride * this->height); |
31593
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
241 } |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
242 } |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
243 return this->image != NULL; |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
244 } |
22272cbfaf28
Extract spudec image allocation code to a separate function.
reimar
parents:
31487
diff
changeset
|
245 |
31723
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
246 /** |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
247 * \param pal palette in MPlayer-style gray-alpha values, i.e. |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
248 * alpha == 0 means transparent, 1 fully opaque, |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
249 * gray value <= 256 - alpha. |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
250 */ |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
251 static void pal2gray_alpha(const uint16_t *pal, |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
252 const uint8_t *src, int src_stride, |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
253 uint8_t *dst, uint8_t *dsta, |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
254 int dst_stride, int w, int h) |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
255 { |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
256 int x, y; |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
257 for (y = 0; y < h; y++) { |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
258 for (x = 0; x < w; x++) { |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
259 uint16_t pixel = pal[src[x]]; |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
260 *dst++ = pixel; |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
261 *dsta++ = pixel >> 8; |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
262 } |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
263 for (; x < dst_stride; x++) |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
264 *dsta++ = *dst++ = 0; |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
265 src += src_stride; |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
266 } |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
267 } |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
268 |
31762 | 269 static int apply_palette_crop(spudec_handle_t *this, |
270 unsigned crop_x, unsigned crop_y, | |
271 unsigned crop_w, unsigned crop_h) | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
272 { |
31762 | 273 int i; |
274 uint8_t *src; | |
31723
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
275 uint16_t pal[4]; |
31762 | 276 unsigned stride = (crop_w + 7) & ~7; |
277 if (crop_x > this->pal_width || crop_y > this->pal_height || | |
278 crop_w > this->pal_width - crop_x || crop_h > this->pal_width - crop_y || | |
279 crop_w > 0x8000 || crop_h > 0x8000 || | |
280 stride * crop_h > this->image_size) { | |
281 return 0; | |
282 } | |
3166 | 283 for (i = 0; i < 4; ++i) { |
31723
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
284 int color; |
31762 | 285 int alpha = this->alpha[i]; |
31722 | 286 // extend 4 -> 8 bit |
31723
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
287 alpha |= alpha << 4; |
25432 | 288 if (this->custom && (this->cuspal[i] >> 31) != 0) |
31723
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
289 alpha = 0; |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
290 color = this->custom ? this->cuspal[i] : |
31762 | 291 this->global_palette[this->palette[i]]; |
31723
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
292 color = (color >> 16) & 0xff; |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
293 // convert to MPlayer-style gray/alpha palette |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
294 color = FFMIN(color, alpha); |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
295 pal[i] = (-alpha << 8) | color; |
3166 | 296 } |
31762 | 297 src = this->pal_image + crop_y * this->pal_width + crop_x; |
298 pal2gray_alpha(pal, src, this->pal_width, | |
299 this->image, this->aimage, stride, | |
300 crop_w, crop_h); | |
301 this->width = crop_w; | |
302 this->height = crop_h; | |
303 this->stride = stride; | |
304 this->start_col = this->pal_start_col + crop_x; | |
305 this->start_row = this->pal_start_row + crop_y; | |
306 spudec_cut_image(this); | |
3166 | 307 |
31762 | 308 // reset scaled image |
309 this->scaled_frame_width = 0; | |
310 this->scaled_frame_height = 0; | |
311 this->palette_crop_cache.valid = 0; | |
312 return 1; | |
313 } | |
314 | |
315 int spudec_apply_palette_crop(void *this, uint32_t palette, | |
316 int sx, int sy, int ex, int ey) | |
317 { | |
318 spudec_handle_t *spu = this; | |
319 struct palette_crop_cache *c = &spu->palette_crop_cache; | |
320 if (c->valid && c->palette == palette && | |
321 c->sx == sx && c->sy == sy && c->ex == ex && c->ey == ey) | |
322 return c->result; | |
323 spu->palette[0] = (palette >> 28) & 0xf; | |
324 spu->palette[1] = (palette >> 24) & 0xf; | |
325 spu->palette[2] = (palette >> 20) & 0xf; | |
326 spu->palette[3] = (palette >> 16) & 0xf; | |
327 spu->alpha[0] = (palette >> 12) & 0xf; | |
328 spu->alpha[1] = (palette >> 8) & 0xf; | |
329 spu->alpha[2] = (palette >> 4) & 0xf; | |
330 spu->alpha[3] = palette & 0xf; | |
331 spu->spu_changed = 1; | |
332 c->result = apply_palette_crop(spu, | |
333 sx - spu->pal_start_col, sy - spu->pal_start_row, | |
334 ex - sx, ey - sy); | |
335 c->palette = palette; | |
336 c->sx = sx; c->sy = sy; | |
337 c->ex = ex; c->ey = ey; | |
338 c->valid = 1; | |
339 return c->result; | |
340 } | |
341 | |
342 static void spudec_process_data(spudec_handle_t *this, packet_t *packet) | |
343 { | |
344 unsigned int i, x, y; | |
345 uint8_t *dst; | |
346 | |
347 if (!spudec_alloc_image(this, packet->stride, packet->height)) | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
348 return; |
3402 | 349 |
31762 | 350 this->pal_start_col = packet->start_col; |
351 this->pal_start_row = packet->start_row; | |
352 this->pal_height = packet->height; | |
353 this->pal_width = packet->width; | |
354 this->stride = packet->stride; | |
355 memcpy(this->palette, packet->palette, sizeof(this->palette)); | |
356 memcpy(this->alpha, packet->alpha, sizeof(this->alpha)); | |
357 | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
358 i = packet->current_nibble[1]; |
3402 | 359 x = 0; |
360 y = 0; | |
31724 | 361 dst = this->pal_image; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
362 while (packet->current_nibble[0] < i |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
363 && packet->current_nibble[1] / 2 < packet->control_start |
31762 | 364 && y < this->pal_height) { |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
365 unsigned int len, color; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
366 unsigned int rle = 0; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
367 rle = get_nibble(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
368 if (rle < 0x04) { |
31733 | 369 if (rle == 0) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
370 rle = (rle << 4) | get_nibble(packet); |
31733 | 371 if (rle < 0x04) |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
372 rle = (rle << 4) | get_nibble(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
373 } |
31733 | 374 rle = (rle << 4) | get_nibble(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
375 } |
3166 | 376 color = 3 - (rle & 0x3); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
377 len = rle >> 2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
378 x += len; |
31762 | 379 if (len == 0 || x >= this->pal_width) { |
380 len += this->pal_width - x; | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
381 next_line(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
382 x = 0; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
383 ++y; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
384 } |
31724 | 385 memset(dst, color, len); |
386 dst += len; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
387 } |
31762 | 388 apply_palette_crop(this, 0, 0, this->pal_width, this->pal_height); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
389 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
390 |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
391 |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
392 /* |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
393 This function tries to create a usable palette. |
11000 | 394 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
|
395 gray scale values to each color. |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
396 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
|
397 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
|
398 */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
399 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
|
400 { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
401 int used[16],i,cused,start,step,color; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
402 |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
403 memset(used, 0, sizeof(used)); |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
404 for (i=0; i<4; i++) |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
405 if (packet->alpha[i]) /* !Transparent? */ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
406 used[packet->palette[i]] = 1; |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
407 for (cused=0, i=0; i<16; i++) |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
408 if (used[i]) cused++; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
409 if (!cused) return; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
410 if (cused == 1) { |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
411 start = 0x80; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
412 step = 0; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
413 } else { |
6110 | 414 start = this->font_start_level; |
415 step = (0xF0-this->font_start_level)/(cused-1); | |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
416 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
417 memset(used, 0, sizeof(used)); |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
418 for (i=0; i<4; i++) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
419 color = packet->palette[i]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
420 if (packet->alpha[i] && !used[color]) { /* not assigned? */ |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
421 used[color] = 1; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
422 this->global_palette[color] = start<<16; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
423 start += step; |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
424 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
425 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
426 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
427 |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
428 static void spudec_process_control(spudec_handle_t *this, int pts100) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
429 { |
30482
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
430 int a,b,c,d; /* Temporary vars */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
431 unsigned int date, type; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
432 unsigned int off; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
433 unsigned int start_off = 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
434 unsigned int next_off; |
25184 | 435 unsigned int start_pts = 0; |
436 unsigned int end_pts = 0; | |
437 unsigned int current_nibble[2] = {0, 0}; | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
438 unsigned int control_start; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
439 unsigned int display = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
440 unsigned int start_col = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
441 unsigned int end_col = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
442 unsigned int start_row = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
443 unsigned int end_row = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
444 unsigned int width = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
445 unsigned int height = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
446 unsigned int stride = 0; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
447 |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
448 control_start = get_be16(this->packet + 2); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
449 next_off = control_start; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
450 while (start_off != next_off) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
451 start_off = next_off; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
452 date = get_be16(this->packet + start_off) * 1024; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
453 next_off = get_be16(this->packet + start_off + 2); |
3822 | 454 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
|
455 off = start_off + 4; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
456 for (type = this->packet[off++]; type != 0xff; type = this->packet[off++]) { |
3822 | 457 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
|
458 switch(type) { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
459 case 0x00: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
460 /* Menu ID, 1 byte */ |
3822 | 461 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
|
462 /* shouldn't a Menu ID type force display start? */ |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
463 start_pts = pts100 < 0 && -pts100 >= date ? 0 : pts100 + date; |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
464 end_pts = UINT_MAX; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
465 display = 1; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
466 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
|
467 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
468 case 0x01: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
469 /* Start display */ |
3822 | 470 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Start display!\n"); |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
471 start_pts = pts100 < 0 && -pts100 >= date ? 0 : pts100 + date; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
472 end_pts = UINT_MAX; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
473 display = 1; |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
474 this->is_forced_sub=0; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
475 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
476 case 0x02: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
477 /* Stop display */ |
3822 | 478 mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Stop display!\n"); |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
479 end_pts = pts100 < 0 && -pts100 >= date ? 0 : pts100 + date; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
480 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
481 case 0x03: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
482 /* Palette */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
483 this->palette[0] = this->packet[off] >> 4; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
484 this->palette[1] = this->packet[off] & 0xf; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
485 this->palette[2] = this->packet[off + 1] >> 4; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
486 this->palette[3] = this->packet[off + 1] & 0xf; |
3822 | 487 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
|
488 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
|
489 off+=2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
490 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
491 case 0x04: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
492 /* Alpha */ |
30482
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
493 a = this->packet[off] >> 4; |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
494 b = this->packet[off] & 0xf; |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
495 c = this->packet[off + 1] >> 4; |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
496 d = this->packet[off + 1] & 0xf; |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
497 // Note: some DVDs change these values to create a fade-in/fade-out effect |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
498 // We can not handle this, so just keep the highest value during the display time. |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
499 if (display) { |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
500 a = FFMAX(a, this->alpha[0]); |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
501 b = FFMAX(b, this->alpha[1]); |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
502 c = FFMAX(c, this->alpha[2]); |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
503 d = FFMAX(d, this->alpha[3]); |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
504 } |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
505 this->alpha[0] = a; |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
506 this->alpha[1] = b; |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
507 this->alpha[2] = c; |
794b61a63cc7
Fix subtitle display for DVDs using fade-in/fade-out.
reimar
parents:
30481
diff
changeset
|
508 this->alpha[3] = d; |
3822 | 509 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
|
510 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
|
511 off+=2; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
512 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
513 case 0x05: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
514 /* Co-ords */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
515 a = get_be24(this->packet + off); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
516 b = get_be24(this->packet + off + 3); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
517 start_col = a >> 12; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
518 end_col = a & 0xfff; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
519 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
|
520 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
|
521 start_row = b >> 12; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
522 end_row = b & 0xfff; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
523 height = (end_row < start_row) ? 0 : end_row - start_row /* + 1 */; |
3822 | 524 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
|
525 start_col, end_col, start_row, end_row, |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
526 width, height); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
527 off+=6; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
528 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
529 case 0x06: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
530 /* Graphic lines */ |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
531 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
|
532 current_nibble[1] = 2 * get_be16(this->packet + off + 2); |
3822 | 533 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
|
534 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
|
535 off+=4; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
536 break; |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
537 case 0xff: |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
538 /* All done, bye-bye */ |
3822 | 539 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
|
540 return; |
3822 | 541 // break; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
542 default: |
3822 | 543 mp_msg(MSGT_SPUDEC,MSGL_WARN,"spudec: Error determining control type 0x%02x. Skipping %d bytes.\n", |
3402 | 544 type, next_off - off); |
545 goto next_control; | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
546 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
547 } |
3402 | 548 next_control: |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
549 if (!display) |
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
550 continue; |
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
551 if (end_pts == UINT_MAX && start_off != next_off) { |
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
552 end_pts = get_be16(this->packet + next_off) * 1024; |
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
553 end_pts = 1 - pts100 >= end_pts ? 0 : pts100 + end_pts - 1; |
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
554 } |
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
555 if (end_pts > 0) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
556 packet_t *packet = calloc(1, sizeof(packet_t)); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
557 int i; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
558 packet->start_pts = start_pts; |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
559 packet->end_pts = end_pts; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
560 packet->current_nibble[0] = current_nibble[0]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
561 packet->current_nibble[1] = current_nibble[1]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
562 packet->start_row = start_row; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
563 packet->start_col = start_col; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
564 packet->width = width; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
565 packet->height = height; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
566 packet->stride = stride; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
567 packet->control_start = control_start; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
568 for (i=0; i<4; i++) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
569 packet->alpha[i] = this->alpha[i]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
570 packet->palette[i] = this->palette[i]; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
571 } |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
572 packet->packet = malloc(this->packet_size); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
573 memcpy(packet->packet, this->packet, this->packet_size); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
574 spudec_queue_packet(this, packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
575 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
576 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
577 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
578 |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
579 static void spudec_decode(spudec_handle_t *this, int pts100) |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
580 { |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
581 if (!this->hw_spu) |
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
582 spudec_process_control(this, pts100); |
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
583 else if (pts100 >= 0) { |
6110 | 584 static vo_mpegpes_t packet = { NULL, 0, 0x20, 0 }; |
585 static vo_mpegpes_t *pkg=&packet; | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
586 packet.data = this->packet; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
587 packet.size = this->packet_size; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
588 packet.timestamp = pts100; |
6110 | 589 this->hw_spu->draw_frame((uint8_t**)&pkg); |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
590 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
591 } |
560 | 592 |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
593 int spudec_changed(void * this) |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
594 { |
31636 | 595 spudec_handle_t * spu = this; |
26759
8eff880f638c
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26069
diff
changeset
|
596 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
|
597 } |
560 | 598 |
25322
078bdfd44751
Fix spudec to display current vobsub immediately after a seek.
ulion
parents:
25219
diff
changeset
|
599 void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pts100) |
560 | 600 { |
31636 | 601 spudec_handle_t *spu = this; |
3842 | 602 // spudec_heartbeat(this, pts100); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
603 if (len < 2) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
604 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
|
605 return; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
606 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
607 spu->packet_pts = pts100; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
608 if (spu->packet_offset == 0) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
609 unsigned int len2 = get_be16(packet); |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
610 // Start new fragment |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
611 if (spu->packet_reserve < len2) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
612 if (spu->packet != NULL) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
613 free(spu->packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
614 spu->packet = malloc(len2); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
615 spu->packet_reserve = spu->packet != NULL ? len2 : 0; |
560 | 616 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
617 if (spu->packet != NULL) { |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
618 spu->packet_size = len2; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
619 if (len > len2) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
620 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
|
621 return; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
622 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
623 memcpy(spu->packet, packet, len); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
624 spu->packet_offset = len; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
625 spu->packet_pts = pts100; |
3034
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 } else { |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
628 // Continue current fragment |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
629 if (spu->packet_size < spu->packet_offset + len){ |
3822 | 630 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
|
631 spu->packet_size = spu->packet_offset = 0; |
9442 | 632 return; |
3744 | 633 } else { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
634 memcpy(spu->packet + spu->packet_offset, packet, len); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
635 spu->packet_offset += len; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
636 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
637 } |
3820 | 638 #if 1 |
639 // check if we have a complete packet (unfortunatelly packet_size is bad | |
640 // for some disks) | |
7743
a280cc3087ea
All right: The patch adresses two issues which I found, when I analyzed
arpi
parents:
6938
diff
changeset
|
641 // [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
|
642 if ((spu->packet_offset == spu->packet_size) || |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
643 ((spu->packet_offset + 1) == spu->packet_size)){ |
5917 | 644 unsigned int x=0,y; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
645 while(x+4<=spu->packet_offset){ |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
646 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
|
647 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 | 648 if(x>=4 && x==y){ // if it points to self - we're done! |
649 // we got it! | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
650 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
|
651 spudec_decode(spu, pts100); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
652 spu->packet_offset = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
653 break; |
3820 | 654 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
655 if(y<=x || y>=spu->packet_size){ // invalid? |
3822 | 656 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
|
657 spu->packet_size = spu->packet_offset = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
658 break; |
3820 | 659 } |
660 x=y; | |
661 } | |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
662 // [cb] packet is done; start new packet |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
663 spu->packet_offset = 0; |
3820 | 664 } |
665 #else | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
666 if (spu->packet_offset == spu->packet_size) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
667 spudec_decode(spu, pts100); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
668 spu->packet_offset = 0; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
669 } |
3820 | 670 #endif |
560 | 671 } |
672 | |
3744 | 673 void spudec_reset(void *this) // called after seek |
674 { | |
31636 | 675 spudec_handle_t *spu = this; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
676 while (spu->queue_head) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
677 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
|
678 spu->now_pts = 0; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
679 spu->end_pts = 0; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
680 spu->packet_size = spu->packet_offset = 0; |
3744 | 681 } |
682 | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
683 void spudec_heartbeat(void *this, unsigned int pts100) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28188
diff
changeset
|
684 { |
31636 | 685 spudec_handle_t *spu = this; |
8843
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
686 spu->now_pts = pts100; |
c70444c5b516
I have seen problems where DVD subtitles don't display
arpi
parents:
7743
diff
changeset
|
687 |
31597
1eb8dc8f96fa
Make subdelay handling work the same way for all subtitle types and also allow
reimar
parents:
31595
diff
changeset
|
688 // TODO: detect and handle broken timestamps (e.g. due to wrapping) |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
689 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
|
690 packet_t *packet = spudec_dequeue_packet(spu); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
691 spu->start_pts = packet->start_pts; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
692 spu->end_pts = packet->end_pts; |
31599
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
693 if (packet->is_decoded) { |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
694 free(spu->image); |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
695 spu->image_size = packet->data_len; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
696 spu->image = packet->packet; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
697 spu->aimage = packet->packet + packet->stride * packet->height; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
698 packet->packet = NULL; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
699 spu->width = packet->width; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
700 spu->height = packet->height; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
701 spu->stride = packet->stride; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
702 spu->start_col = packet->start_col; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
703 spu->start_row = packet->start_row; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
704 |
31631
67f2fb3ff4c7
Try to get subtitle scaling somewhat right with libavcodec decoded
reimar
parents:
31630
diff
changeset
|
705 // reset scaled image |
31599
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
706 spu->scaled_frame_width = 0; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
707 spu->scaled_frame_height = 0; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
708 } else { |
31629 | 709 if (spu->auto_palette) |
710 compute_palette(spu, packet); | |
711 spudec_process_data(spu, packet); | |
31599
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
712 } |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
713 spudec_free_packet(packet); |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
714 spu->spu_changed = 1; |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
715 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
716 } |
560 | 717 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
718 int spudec_visible(void *this){ |
31636 | 719 spudec_handle_t *spu = this; |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
720 int ret=(spu->start_pts <= spu->now_pts && |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
721 spu->now_pts < spu->end_pts && |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
722 spu->height > 0); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
723 // 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
|
724 return ret; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
725 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5488
diff
changeset
|
726 |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
727 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
|
728 { |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
729 if(this){ |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
730 ((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
|
731 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
|
732 } |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
733 } |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
734 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
735 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
|
736 { |
31636 | 737 spudec_handle_t *spu = this; |
31595 | 738 if (spudec_visible(spu)) |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
739 { |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
740 draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height, |
3402 | 741 spu->image, spu->aimage, spu->stride); |
6778
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
742 spu->spu_changed = 0; |
f33d4ab7a6b2
Make spudec_assemble more resistent in the face of incomplete packets.
kmkaplan
parents:
6459
diff
changeset
|
743 } |
561 | 744 } |
745 | |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
746 /* calc the bbox for spudec subs */ |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
747 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
|
748 { |
31636 | 749 spudec_handle_t *spu = me; |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
750 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
|
751 || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys)) { |
31635 | 752 // unscaled |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
753 bbox[0] = spu->start_col; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
754 bbox[1] = spu->start_col + spu->width; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
755 bbox[2] = spu->start_row; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
756 bbox[3] = spu->start_row + spu->height; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
757 } |
31635 | 758 else { |
759 // scaled | |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
760 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
|
761 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
|
762 bbox[0] = spu->start_col * scalex / 0x100; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
763 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
|
764 switch (spu_alignment) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
765 case 0: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
766 bbox[3] = dys*sub_pos/100 + spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
767 if (bbox[3] > dys) bbox[3] = dys; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
768 bbox[2] = bbox[3] - spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
769 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
770 case 1: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
771 if (sub_pos < 50) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
772 bbox[2] = dys*sub_pos/100 - spu->height * scaley / 0x200; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
773 bbox[3] = bbox[2] + spu->height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
774 } else { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
775 bbox[3] = dys*sub_pos/100 + spu->height * scaley / 0x200; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
776 if (bbox[3] > dys) bbox[3] = dys; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
777 bbox[2] = bbox[3] - spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
778 } |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
779 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
780 case 2: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
781 bbox[2] = dys*sub_pos/100 - spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
782 bbox[3] = bbox[2] + spu->height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
783 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
784 default: /* -1 */ |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
785 bbox[2] = spu->start_row * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
786 bbox[3] = spu->start_row * scaley / 0x100 + spu->height * scaley / 0x100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
787 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
788 } |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
789 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
790 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
791 /* 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
|
792 static inline int canon_alpha(int alpha) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
793 { |
31638 | 794 return (uint8_t)-alpha; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
795 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
796 |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
797 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
|
798 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
|
799 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
|
800 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
|
801 }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
|
802 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
803 |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
804 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
|
805 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
806 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
|
807 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
|
808 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
|
809 int src = 0; |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
810 int src_step; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
811 if (delta_src == 0 || delta_tar == 0) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
812 return; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
813 } |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
814 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
|
815 for (t = 0; t<=delta_tar; src += (src_step << 1), t++){ |
22378 | 816 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
|
817 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
|
818 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
|
819 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
820 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
821 |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
822 /* bilinear scale, similar to vobsub's code */ |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
823 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
|
824 { |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
825 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
|
826 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
|
827 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
|
828 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
|
829 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 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
|
837 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
|
838 scale[0] = (table_x[x].left_up * table_y[y].left_up >> 16) * alpha[0]; |
25640
a51e1bd9ba4f
Add an extra check to avoid a case that cause black lines in scaled
reimar
parents:
25432
diff
changeset
|
839 if (table_y[y].left_up == 0x10000) // necessary to avoid overflow-case |
a51e1bd9ba4f
Add an extra check to avoid a case that cause black lines in scaled
reimar
parents:
25432
diff
changeset
|
840 scale[0] = table_x[x].left_up * alpha[0]; |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
841 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
|
842 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
|
843 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
|
844 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
|
845 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
|
846 if (spu->scaled_aimage[scaled]){ |
28188 | 847 // ensure that MPlayer's simplified alpha-blending can not overflow |
848 spu->scaled_image[scaled] = FFMIN(spu->scaled_image[scaled], spu->scaled_aimage[scaled]); | |
849 // convert to MPlayer-style alpha | |
850 spu->scaled_aimage[scaled] = -spu->scaled_aimage[scaled]; | |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
851 } |
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
852 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
853 |
30590
d218228dc74d
Mark some more functions that are not used outside of their files as static.
diego
parents:
30534
diff
changeset
|
854 static void sws_spu_image(unsigned char *d1, unsigned char *d2, int dw, int dh, |
d218228dc74d
Mark some more functions that are not used outside of their files as static.
diego
parents:
30534
diff
changeset
|
855 int ds, unsigned char *s1, unsigned char *s2, int sw, |
d218228dc74d
Mark some more functions that are not used outside of their files as static.
diego
parents:
30534
diff
changeset
|
856 int sh, int ss) |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
857 { |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
858 struct SwsContext *ctx; |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
859 static SwsFilter filter; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
860 static int firsttime = 1; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
861 static float oldvar; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
862 int i; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
863 |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
864 if (!firsttime && oldvar != spu_gaussvar) sws_freeVec(filter.lumH); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
865 if (firsttime) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
866 filter.lumH = filter.lumV = |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9448
diff
changeset
|
867 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
|
868 sws_normalizeVec(filter.lumH, 1.0); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
869 firsttime = 0; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
870 oldvar = spu_gaussvar; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
871 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28188
diff
changeset
|
872 |
19870
1e5cf11e8b1f
Use PIX_FMT_* instead of IMGFMT_* when calling sws_getContext()
lucabe
parents:
18861
diff
changeset
|
873 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
|
874 sws_scale(ctx,&s1,&ss,0,sh,&d1,&ds); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
875 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
|
876 sws_scale(ctx,&s2,&ss,0,sh,&d2,&ds); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
877 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
|
878 sws_freeContext(ctx); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
879 } |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
880 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
881 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
|
882 { |
31636 | 883 spudec_handle_t *spu = 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
|
884 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
|
885 scale_pixel *table_y; |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
886 |
31595 | 887 if (spudec_visible(spu)) { |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
888 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28188
diff
changeset
|
889 // check if only forced subtitles are requested |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28188
diff
changeset
|
890 if( (spu->forced_subs_only) && !(spu->is_forced_sub) ){ |
10917
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
891 return; |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
892 } |
d45870f67728
Forced subtitles patch by Arne Driescher <driescher@mpi-magdeburg.mpg.de>
attila
parents:
9494
diff
changeset
|
893 |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
894 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
|
895 || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) { |
31637
43958dd88aa1
Call spudec_draw for the unscaled case instead of duplicating code.
reimar
parents:
31636
diff
changeset
|
896 spudec_draw(spu, draw_alpha); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
897 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
898 else { |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
899 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
|
900 /* scaled_x = scalex * x / 0x100 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
901 scaled_y = scaley * y / 0x100 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
902 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
|
903 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
|
904 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
|
905 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
|
906 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
|
907 spu->scaled_width = spu->width * scalex / 0x100; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
908 spu->scaled_height = spu->height * scaley / 0x100; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
909 /* 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
|
910 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
|
911 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
|
912 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
913 free(spu->scaled_image); |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
914 spu->scaled_image_size = 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
915 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
916 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
|
917 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
918 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
|
919 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
|
920 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
921 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
922 if (spu->scaled_image) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
923 unsigned int x, y; |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
924 if (spu->scaled_width <= 1 || spu->scaled_height <= 1) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
925 goto nothing_to_do; |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
926 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
927 switch(spu_aamode&15) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
928 case 4: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
929 sws_spu_image(spu->scaled_image, spu->scaled_aimage, |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
930 spu->scaled_width, spu->scaled_height, spu->scaled_stride, |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
931 spu->image, spu->aimage, spu->width, spu->height, spu->stride); |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
932 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
933 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
|
934 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
|
935 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
|
936 if (!table_x || !table_y) { |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
937 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
|
938 } |
6215
e435026183c3
spu/vobsub speedup patch, new all better bilinear scaler similiar to win vobsub ones. ptyh by Hephooey.
atmos4
parents:
6190
diff
changeset
|
939 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
|
940 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
|
941 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
|
942 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
|
943 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
|
944 free(table_x); |
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
945 free(table_y); |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
946 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
947 case 0: |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
948 /* no antialiasing */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
949 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
|
950 int unscaled_y = y * 0x100 / scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
951 int strides = spu->stride * unscaled_y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
952 int scaled_strides = spu->scaled_stride * y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
953 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
|
954 int unscaled_x = x * 0x100 / scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
955 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
|
956 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
|
957 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
958 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
959 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
960 case 1: |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
961 { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
962 /* Intermediate antialiasing. */ |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
963 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
|
964 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
|
965 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
|
966 if (unscaled_bottom >= spu->height) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
967 unscaled_bottom = spu->height - 1; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
968 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
|
969 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
|
970 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
|
971 unsigned int color = 0; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
972 unsigned int alpha = 0; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
973 unsigned int walkx, walky; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
974 unsigned int base, tmp; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
975 if (unscaled_right >= spu->width) |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
976 unscaled_right = spu->width - 1; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
977 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
|
978 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
|
979 base = walky * spu->stride + walkx; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
980 tmp = canon_alpha(spu->aimage[base]); |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
981 alpha += tmp; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
982 color += tmp * spu->image[base]; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
983 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
984 base = y * spu->scaled_stride + x; |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
985 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
|
986 spu->scaled_aimage[base] = |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
987 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
|
988 /* spu->scaled_aimage[base] = |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
989 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
|
990 if (spu->scaled_aimage[base]) { |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
991 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
|
992 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
|
993 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
|
994 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
995 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
996 } |
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
997 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
998 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
999 case 2: |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1000 { |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
1001 /* Best antialiasing. Very slow. */ |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1002 /* 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
|
1003 rectangular region comprised between the columns |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1004 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
|
1005 unscaled_x and unscaled_x + 0x100 / scalex |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1006 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1007 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
|
1008 represents is cut in 9 rectangular areas like this: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28188
diff
changeset
|
1009 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1010 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1011 | 1 | 2 | 3 | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1012 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1013 | | | | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1014 | 4 | 5 | 6 | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1015 | | | | |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1016 +---+-----------------+---+ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1017 | 7 | 8 | 9 | |
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 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 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
|
1028 one pixel. |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1029 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1030 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
|
1031 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
|
1032 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
|
1033 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
|
1034 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 unscaled_x_right. */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1040 const double inv_scalex = (double) 0x100 / scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1041 const double inv_scaley = (double) 0x100 / scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1042 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
|
1043 const double unscaled_y = y * inv_scaley; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1044 const double unscaled_y_bottom = unscaled_y + inv_scaley; |
22378 | 1045 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
|
1046 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
|
1047 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
|
1048 ? (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
|
1049 : 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1050 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
|
1051 ? unscaled_y_bottom - floor(unscaled_y_bottom) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1052 : 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1053 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
|
1054 const double unscaled_x = x * inv_scalex; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1055 const double unscaled_x_right = unscaled_x + inv_scalex; |
22378 | 1056 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
|
1057 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
|
1058 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
|
1059 ? (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
|
1060 : 0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1061 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
|
1062 ? unscaled_x_right - floor(unscaled_x_right) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1063 : 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1064 double color = 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1065 double alpha = 0.0; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1066 double tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1067 unsigned int base; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1068 /* 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
|
1069 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
|
1070 region's surface and alpha and lightness. |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1071 |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1072 transformed alpha = sum(surface * alpha) / sum(surface) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1073 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
|
1074 */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1075 /* 1: top left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1076 base = spu->stride * (unsigned int) unscaled_y; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1077 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
|
1078 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1079 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
|
1080 /* 2: top center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1081 if (width > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1082 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1083 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
|
1084 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
|
1085 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
|
1086 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1087 color += tmp * spu->image[base]; |
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 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1090 /* 3: top right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1091 if (right > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1092 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
|
1093 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
|
1094 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1095 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1096 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1097 /* 4: center left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1098 if (height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1099 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1100 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
|
1101 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
|
1102 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
|
1103 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1104 color += tmp * spu->image[base]; |
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 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1107 /* 5: center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1108 if (width > 0 && height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1109 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1110 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
|
1111 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1112 base = spu->stride * walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1113 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
|
1114 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
|
1115 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1116 color += tmp * spu->image[base + walkx]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1117 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28188
diff
changeset
|
1118 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1119 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1120 /* 6: center right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1121 if (right > 0.0 && height > 0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1122 unsigned int walky; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1123 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
|
1124 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
|
1125 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
|
1126 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1127 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1128 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1129 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1130 /* 7: bottom left part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1131 if (bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1132 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
|
1133 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
|
1134 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1135 color += tmp * spu->image[base]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1136 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1137 /* 8: bottom center part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1138 if (width > 0 && bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1139 unsigned int walkx; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1140 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
|
1141 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
|
1142 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
|
1143 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1144 color += tmp * spu->image[base + walkx]; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1145 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1146 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1147 /* 9: bottom right part */ |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1148 if (right > 0.0 && bottom > 0.0) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1149 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
|
1150 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
|
1151 alpha += tmp; |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1152 color += tmp * spu->image[base]; |
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 /* 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
|
1155 base = spu->scaled_stride * y + x; |
4180
a70ded82ff77
Add a third scaling algorithm wich should be faster. Select by
kmkaplan
parents:
4122
diff
changeset
|
1156 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
|
1157 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
|
1158 if (spu->scaled_aimage[base]) { |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1159 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
|
1160 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
|
1161 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
|
1162 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1163 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1164 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1165 } |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1166 } |
6225
75e8e1cf1f77
- hardened a bit the new bilinear algo (missing checks)
pl
parents:
6223
diff
changeset
|
1167 nothing_to_do: |
14432
275b2ce30af7
Fix black line on right of subtitle with -spuaa 4 by setting alpha of
reimar
parents:
13373
diff
changeset
|
1168 /* 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
|
1169 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
|
1170 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
|
1171 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
|
1172 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
|
1173 } |
5388
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
1174 spu->scaled_frame_width = dxs; |
3af2729c5c87
* New command line switch for mplayer & mencoder:
kmkaplan
parents:
4810
diff
changeset
|
1175 spu->scaled_frame_height = dys; |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1176 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1177 } |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1178 if (spu->scaled_image){ |
9077
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1179 switch (spu_alignment) { |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1180 case 0: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1181 spu->scaled_start_row = dys*sub_pos/100; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1182 if (spu->scaled_start_row + spu->scaled_height > dys) |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1183 spu->scaled_start_row = dys - spu->scaled_height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1184 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1185 case 1: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1186 spu->scaled_start_row = dys*sub_pos/100 - spu->scaled_height/2; |
24018 | 1187 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
|
1188 spu->scaled_start_row = dys - spu->scaled_height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1189 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1190 case 2: |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1191 spu->scaled_start_row = dys*sub_pos/100 - spu->scaled_height; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1192 break; |
d430529c5b4b
Improvements to spudec (DVD/VobSub) subtitle code:
rfelker
parents:
8843
diff
changeset
|
1193 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1194 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
|
1195 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
|
1196 spu->spu_changed = 0; |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1197 } |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1198 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1199 } |
5474
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1200 else |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1201 { |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1202 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
|
1203 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
|
1204 } |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1205 } |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1206 |
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1207 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
|
1208 { |
31636 | 1209 spudec_handle_t *spu = this; |
6110 | 1210 if (spu && palette) { |
5474
a303ae797429
spudec_update_palette() added - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
5388
diff
changeset
|
1211 memcpy(spu->global_palette, palette, sizeof(spu->global_palette)); |
6110 | 1212 if(spu->hw_spu) |
1213 spu->hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette); | |
1214 } | |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1215 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1216 |
6110 | 1217 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
|
1218 { |
31636 | 1219 spudec_handle_t *spu = this; |
6110 | 1220 spu->font_start_level = (int)(0xF0-(0xE0*factor)); |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1221 } |
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1222 |
27807 | 1223 static void spudec_parse_extradata(spudec_handle_t *this, |
1224 uint8_t *extradata, int extradata_len) | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1225 { |
27807 | 1226 uint8_t *buffer, *ptr; |
1227 unsigned int *pal = this->global_palette, *cuspal = this->cuspal; | |
1228 unsigned int tridx; | |
1229 int i; | |
1230 | |
1231 if (extradata_len == 16*4) { | |
1232 for (i=0; i<16; i++) | |
1233 pal[i] = AV_RB32(extradata + i*4); | |
1234 this->auto_palette = 0; | |
1235 return; | |
1236 } | |
1237 | |
1238 if (!(ptr = buffer = malloc(extradata_len+1))) | |
1239 return; | |
1240 memcpy(buffer, extradata, extradata_len); | |
1241 buffer[extradata_len] = 0; | |
1242 | |
1243 do { | |
30534
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1244 if (*ptr == '#') |
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1245 continue; |
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1246 if (!strncmp(ptr, "size: ", 6)) |
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1247 sscanf(ptr + 6, "%dx%d", &this->orig_frame_width, &this->orig_frame_height); |
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1248 if (!strncmp(ptr, "palette: ", 9) && |
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1249 sscanf(ptr + 9, "%x, %x, %x, %x, %x, %x, %x, %x, " |
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1250 "%x, %x, %x, %x, %x, %x, %x, %x", |
27807 | 1251 &pal[ 0], &pal[ 1], &pal[ 2], &pal[ 3], |
1252 &pal[ 4], &pal[ 5], &pal[ 6], &pal[ 7], | |
1253 &pal[ 8], &pal[ 9], &pal[10], &pal[11], | |
1254 &pal[12], &pal[13], &pal[14], &pal[15]) == 16) { | |
1255 for (i=0; i<16; i++) | |
1256 pal[i] = vobsub_palette_to_yuv(pal[i]); | |
1257 this->auto_palette = 0; | |
1258 } | |
1259 if (!strncasecmp(ptr, "forced subs: on", 15)) | |
1260 this->forced_subs_only = 1; | |
30534
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1261 if (!strncmp(ptr, "custom colors: ON, tridx: ", 26) && |
65a8e80c1474
Avoid using sscanf for basic parsing, it is horribly slow.
reimar
parents:
30482
diff
changeset
|
1262 sscanf(ptr + 26, "%x, colors: %x, %x, %x, %x", |
27807 | 1263 &tridx, cuspal+0, cuspal+1, cuspal+2, cuspal+3) == 5) { |
1264 for (i=0; i<4; i++) { | |
1265 cuspal[i] = vobsub_rgb_to_yuv(cuspal[i]); | |
1266 if (tridx & (1 << (12-4*i))) | |
1267 cuspal[i] |= 1 << 31; | |
1268 } | |
1269 this->custom = 1; | |
1270 } | |
1271 } while ((ptr=strchr(ptr,'\n')) && *++ptr); | |
1272 | |
1273 free(buffer); | |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1274 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1275 |
27807 | 1276 void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len) |
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
|
1277 { |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
1278 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
|
1279 if (this){ |
27807 | 1280 this->orig_frame_height = frame_height; |
31630
78260a246393
10l, also assign the original width in spudec_new_scaled.
reimar
parents:
31629
diff
changeset
|
1281 this->orig_frame_width = frame_width; |
27807 | 1282 // set up palette: |
1283 if (palette) | |
1284 memcpy(this->global_palette, palette, sizeof(this->global_palette)); | |
1285 else | |
1286 this->auto_palette = 1; | |
1287 if (extradata) | |
1288 spudec_parse_extradata(this, extradata, extradata_len); | |
6938 | 1289 /* XXX Although the video frame is some size, the SPU frame is |
1290 always maximum size i.e. 720 wide and 576 or 480 high */ | |
31229
69dbfbd26e05
Fix subtitle display for http://samples.mplayerhq.hu/sub/largeres_vobsub.mkv
reimar
parents:
30995
diff
changeset
|
1291 // For HD files in MKV the VobSub resolution can be higher though, |
69dbfbd26e05
Fix subtitle display for http://samples.mplayerhq.hu/sub/largeres_vobsub.mkv
reimar
parents:
30995
diff
changeset
|
1292 // see largeres_vobsub.mkv |
69dbfbd26e05
Fix subtitle display for http://samples.mplayerhq.hu/sub/largeres_vobsub.mkv
reimar
parents:
30995
diff
changeset
|
1293 if (this->orig_frame_width <= 720 && this->orig_frame_height <= 576) { |
31230 | 1294 this->orig_frame_width = 720; |
1295 if (this->orig_frame_height == 480 || this->orig_frame_height == 240) | |
1296 this->orig_frame_height = 480; | |
1297 else | |
1298 this->orig_frame_height = 576; | |
31229
69dbfbd26e05
Fix subtitle display for http://samples.mplayerhq.hu/sub/largeres_vobsub.mkv
reimar
parents:
30995
diff
changeset
|
1299 } |
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
|
1300 } |
91d766389a5d
VobSub updates, custom palette support and other stuff, can't write the name of the chinese(?) patch supplier.
atmos4
parents:
5638
diff
changeset
|
1301 else |
6110 | 1302 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
|
1303 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
|
1304 } |
5908
31159f453cf9
guessing palette - patch by salvador <salvador@inti.gov.ar>
arpi
parents:
5833
diff
changeset
|
1305 |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1306 void *spudec_new(unsigned int *palette) |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1307 { |
27807 | 1308 return spudec_new_scaled(palette, 0, 0, NULL, 0); |
4078
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1309 } |
a8e7238bb7b4
Add spudec_new_scaled and spudec_draw_scaled for vobsub support.
kmkaplan
parents:
3842
diff
changeset
|
1310 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1311 void spudec_free(void *this) |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1312 { |
31636 | 1313 spudec_handle_t *spu = this; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1314 if (spu) { |
9448
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
1315 while (spu->queue_head) |
5b130e0682a8
Improved subtitle queueing, parameters (start_pts, end_pts, palette, alpha)
ranma
parents:
9442
diff
changeset
|
1316 spudec_free_packet(spudec_dequeue_packet(spu)); |
31726
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1317 free(spu->packet); |
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1318 spu->packet = NULL; |
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1319 free(spu->scaled_image); |
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1320 spu->scaled_image = NULL; |
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1321 free(spu->image); |
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1322 spu->image = NULL; |
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1323 spu->aimage = NULL; |
31725
8e850ff84b27
Allocate memory for paletted image data separately to avoid
reimar
parents:
31724
diff
changeset
|
1324 free(spu->pal_image); |
31726
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1325 spu->pal_image = NULL; |
8adcdb0b8ef6
Remove useless NULL checks before freeing and NULL pointers
reimar
parents:
31725
diff
changeset
|
1326 spu->image_size = 0; |
31762 | 1327 spu->pal_width = spu->pal_height = 0; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1328 free(spu); |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1329 } |
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
673
diff
changeset
|
1330 } |
6110 | 1331 |
25219
e82ecde2cbd4
Mark several uses of vo_functions_t as const to stop some of the current
reimar
parents:
25185
diff
changeset
|
1332 void spudec_set_hw_spu(void *this, const vo_functions_t *hw_spu) |
6110 | 1333 { |
31636 | 1334 spudec_handle_t *spu = this; |
6110 | 1335 if (!spu) |
1336 return; | |
1337 spu->hw_spu = hw_spu; | |
1338 hw_spu->control(VOCTRL_SET_SPU_PALETTE,spu->global_palette); | |
1339 } | |
31599
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1340 |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1341 #define MP_NOPTS_VALUE (-1LL<<63) //both int64_t and double should be able to represent this exactly |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1342 |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1343 /** |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1344 * palette must contain at least 256 32-bit entries, otherwise crashes |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1345 * are possible |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1346 */ |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1347 void spudec_set_paletted(void *this, const uint8_t *pal_img, int pal_stride, |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1348 const void *palette, |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1349 int x, int y, int w, int h, |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1350 double pts, double endpts) |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1351 { |
31641 | 1352 int i; |
1353 uint16_t g8a8_pal[256]; | |
31599
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1354 packet_t *packet; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1355 const uint32_t *pal = palette; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1356 spudec_handle_t *spu = this; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1357 uint8_t *img; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1358 uint8_t *aimg; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1359 int stride = (w + 7) & ~7; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1360 if ((unsigned)w >= 0x8000 || (unsigned)h > 0x4000) |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1361 return; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1362 packet = calloc(1, sizeof(packet_t)); |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1363 packet->is_decoded = 1; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1364 packet->width = w; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1365 packet->height = h; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1366 packet->stride = stride; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1367 packet->start_col = x; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1368 packet->start_row = y; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1369 packet->data_len = 2 * stride * h; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1370 packet->packet = malloc(packet->data_len); |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1371 img = packet->packet; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1372 aimg = packet->packet + stride * h; |
31641 | 1373 for (i = 0; i < 256; i++) { |
1374 uint32_t pixel = pal[i]; | |
31639
cf048df35b00
Fix conversion from paletted to MPlayer's OSD format.
reimar
parents:
31638
diff
changeset
|
1375 int alpha = pixel >> 24; |
cf048df35b00
Fix conversion from paletted to MPlayer's OSD format.
reimar
parents:
31638
diff
changeset
|
1376 int gray = (((pixel & 0x000000ff) >> 0) + |
cf048df35b00
Fix conversion from paletted to MPlayer's OSD format.
reimar
parents:
31638
diff
changeset
|
1377 ((pixel & 0x0000ff00) >> 7) + |
cf048df35b00
Fix conversion from paletted to MPlayer's OSD format.
reimar
parents:
31638
diff
changeset
|
1378 ((pixel & 0x00ff0000) >> 16)) >> 2; |
31641 | 1379 gray = FFMIN(gray, alpha); |
1380 g8a8_pal[i] = (-alpha << 8) | gray; | |
1381 } | |
31723
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
1382 pal2gray_alpha(g8a8_pal, pal_img, pal_stride, |
1f7d9777eecd
Share paletted -> gray/alpha conversion code, and keep a copy
reimar
parents:
31722
diff
changeset
|
1383 img, aimg, stride, w, h); |
31599
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1384 packet->start_pts = 0; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1385 packet->end_pts = 0x7fffffff; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1386 if (pts != MP_NOPTS_VALUE) |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1387 packet->start_pts = pts * 90000; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1388 if (endpts != MP_NOPTS_VALUE) |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1389 packet->end_pts = endpts * 90000; |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1390 spudec_queue_packet(spu, packet); |
cafeb7863de8
Add support for PGS subtitle decoding via libavcodec.
reimar
parents:
31597
diff
changeset
|
1391 } |