Mercurial > mplayer.hg
annotate libmpcodecs/vf_ass.c @ 34661:4fce278264b9
Fix formatting errors in skin XML code.
It wasn't well-formed.
author | ib |
---|---|
date | Mon, 20 Feb 2012 16:22:01 +0000 |
parents | 8fa2f43cb760 |
children | 04cd132753bc |
rev | line source |
---|---|
20008
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19563
diff
changeset
|
1 /* |
26727 | 2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com> |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
20008
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19563
diff
changeset
|
20 |
18937 | 21 #include "config.h" |
22 | |
23 #include <stdio.h> | |
24 #include <stdlib.h> | |
25 #include <string.h> | |
24545
9e5126679d44
Replace stdint.h #include by functionally equivalent inttypes.h.
diego
parents:
23134
diff
changeset
|
26 #include <inttypes.h> |
18937 | 27 #include <assert.h> |
28 | |
29 #include "config.h" | |
30 #include "mp_msg.h" | |
31 #include "help_mp.h" | |
31489 | 32 #include "mpcommon.h" |
18937 | 33 #include "img_format.h" |
34 #include "mp_image.h" | |
30653
3d23e24c5c60
Declare externally used variables from vd.c as extern in vd.h.
diego
parents:
30642
diff
changeset
|
35 #include "vd.h" |
18937 | 36 #include "vf.h" |
37 | |
38 #include "libvo/fastmemcpy.h" | |
32467 | 39 #include "sub/sub.h" |
18937 | 40 #include "m_option.h" |
41 #include "m_struct.h" | |
42 | |
32461 | 43 #include "sub/ass_mp.h" |
32460 | 44 #include "sub/eosd.h" |
18937 | 45 |
46 #define _r(c) ((c)>>24) | |
47 #define _g(c) (((c)>>16)&0xFF) | |
48 #define _b(c) (((c)>>8)&0xFF) | |
49 #define _a(c) ((c)&0xFF) | |
32096 | 50 #define rgba2y(c) ( (( 263*_r(c) + 516*_g(c) + 100*_b(c)) >> 10) + 16 ) |
18937 | 51 #define rgba2u(c) ( ((-152*_r(c) - 298*_g(c) + 450*_b(c)) >> 10) + 128 ) |
52 #define rgba2v(c) ( (( 450*_r(c) - 376*_g(c) - 73*_b(c)) >> 10) + 128 ) | |
53 | |
54 | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
55 static const struct vf_priv_s { |
32096 | 56 int outh, outw; |
18937 | 57 |
32096 | 58 unsigned int outfmt; |
18937 | 59 |
32096 | 60 // 1 = auto-added filter: insert only if chain does not support EOSD already |
61 // 0 = insert always | |
62 int auto_insert; | |
18937 | 63 |
32096 | 64 unsigned char *planes[3]; |
65 unsigned char *dirty_rows; | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
66 } vf_priv_dflt; |
18937 | 67 |
68 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
69 static int config(struct vf_instance *vf, |
32096 | 70 int width, int height, int d_width, int d_height, |
71 unsigned int flags, unsigned int outfmt) | |
18937 | 72 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
73 struct mp_eosd_settings res = {0}; |
31927 | 74 |
32096 | 75 if (outfmt == IMGFMT_IF09) |
76 return 0; | |
18937 | 77 |
32096 | 78 vf->priv->outh = height + ass_top_margin + ass_bottom_margin; |
79 vf->priv->outw = width; | |
18937 | 80 |
32096 | 81 if (!opt_screen_size_x && !opt_screen_size_y) { |
82 d_width = d_width * vf->priv->outw / width; | |
83 d_height = d_height * vf->priv->outh / height; | |
84 } | |
18937 | 85 |
32096 | 86 vf->priv->planes[1] = malloc(vf->priv->outw * vf->priv->outh); |
87 vf->priv->planes[2] = malloc(vf->priv->outw * vf->priv->outh); | |
88 vf->priv->dirty_rows = malloc(vf->priv->outh); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
89 |
32096 | 90 res.w = vf->priv->outw; |
91 res.h = vf->priv->outh; | |
92 res.srcw = width; | |
93 res.srch = height; | |
94 res.mt = ass_top_margin; | |
95 res.mb = ass_bottom_margin; | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
96 eosd_configure(&res); |
18937 | 97 |
32096 | 98 return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width, |
99 d_height, flags, outfmt); | |
18937 | 100 } |
101 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
102 static void get_image(struct vf_instance *vf, mp_image_t *mpi) |
18937 | 103 { |
32096 | 104 if (mpi->type == MP_IMGTYPE_IPB) |
105 return; | |
106 if (mpi->flags & MP_IMGFLAG_PRESERVE) | |
107 return; | |
108 if (mpi->imgfmt != vf->priv->outfmt) | |
109 return; // colorspace differ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
110 |
32096 | 111 // width never changes, always try full DR |
112 mpi->priv = vf->dmpi = vf_get_image(vf->next, mpi->imgfmt, mpi->type, | |
113 mpi->flags | MP_IMGFLAG_READABLE, | |
114 vf->priv->outw, vf->priv->outh); | |
18937 | 115 |
32096 | 116 if ( (vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) && |
117 !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)) { | |
118 mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible); | |
119 return; | |
120 } | |
121 // set up mpi as a cropped-down image of dmpi: | |
122 if (mpi->flags & MP_IMGFLAG_PLANAR) { | |
123 mpi->planes[0] = vf->dmpi->planes[0] + ass_top_margin * vf->dmpi->stride[0]; | |
124 mpi->planes[1] = vf->dmpi->planes[1] + (ass_top_margin >> mpi->chroma_y_shift) * vf->dmpi->stride[1]; | |
125 mpi->planes[2] = vf->dmpi->planes[2] + (ass_top_margin >> mpi->chroma_y_shift) * vf->dmpi->stride[2]; | |
126 mpi->stride[1] = vf->dmpi->stride[1]; | |
127 mpi->stride[2] = vf->dmpi->stride[2]; | |
128 } else { | |
129 mpi->planes[0] = vf->dmpi->planes[0] + ass_top_margin * vf->dmpi->stride[0]; | |
130 } | |
131 mpi->stride[0] = vf->dmpi->stride[0]; | |
132 mpi->width = vf->dmpi->width; | |
133 mpi->flags |= MP_IMGFLAG_DIRECT; | |
134 mpi->flags &= ~MP_IMGFLAG_DRAW_CALLBACK; | |
135 // vf->dmpi->flags &= ~MP_IMGFLAG_DRAW_CALLBACK; | |
18937 | 136 } |
137 | |
138 static void blank(mp_image_t *mpi, int y1, int y2) | |
139 { | |
32096 | 140 int color[3] = { 16, 128, 128 }; // black (YUV) |
141 int y; | |
142 unsigned char *dst; | |
143 int chroma_rows = (y2 - y1) >> mpi->chroma_y_shift; | |
18937 | 144 |
32096 | 145 dst = mpi->planes[0] + y1 * mpi->stride[0]; |
146 for (y = 0; y < y2 - y1; ++y) { | |
147 memset(dst, color[0], mpi->w); | |
148 dst += mpi->stride[0]; | |
149 } | |
150 dst = mpi->planes[1] + (y1 >> mpi->chroma_y_shift) * mpi->stride[1]; | |
151 for (y = 0; y < chroma_rows; ++y) { | |
152 memset(dst, color[1], mpi->chroma_width); | |
153 dst += mpi->stride[1]; | |
154 } | |
155 dst = mpi->planes[2] + (y1 >> mpi->chroma_y_shift) * mpi->stride[2]; | |
156 for (y = 0; y < chroma_rows; ++y) { | |
157 memset(dst, color[2], mpi->chroma_width); | |
158 dst += mpi->stride[2]; | |
159 } | |
18937 | 160 } |
161 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
162 static int prepare_image(struct vf_instance *vf, mp_image_t *mpi) |
18937 | 163 { |
32096 | 164 if (mpi->flags & MP_IMGFLAG_DIRECT || |
165 mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) { | |
166 vf->dmpi = mpi->priv; | |
167 if (!vf->dmpi) { | |
168 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); | |
169 return 0; | |
170 } | |
171 mpi->priv = NULL; | |
172 // we've used DR, so we're ready... | |
173 if (ass_top_margin) | |
174 blank(vf->dmpi, 0, ass_top_margin); | |
175 if (ass_bottom_margin) | |
176 blank(vf->dmpi, vf->priv->outh - ass_bottom_margin, vf->priv->outh); | |
177 if (!(mpi->flags & MP_IMGFLAG_PLANAR)) | |
178 vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette | |
179 return 0; | |
180 } | |
181 // hope we'll get DR buffer: | |
182 vf->dmpi = vf_get_image(vf->next, vf->priv->outfmt, MP_IMGTYPE_TEMP, | |
183 MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_READABLE, | |
184 vf->priv->outw, vf->priv->outh); | |
18937 | 185 |
32096 | 186 // copy mpi->dmpi... |
187 if (mpi->flags & MP_IMGFLAG_PLANAR) { | |
188 memcpy_pic(vf->dmpi->planes[0] + ass_top_margin * vf->dmpi->stride[0], | |
189 mpi->planes[0], | |
190 mpi->w, | |
191 mpi->h, | |
192 vf->dmpi->stride[0], | |
193 mpi->stride[0]); | |
194 memcpy_pic(vf->dmpi->planes[1] + (ass_top_margin >> mpi->chroma_y_shift) * vf->dmpi->stride[1], | |
195 mpi->planes[1], | |
196 mpi->w >> mpi->chroma_x_shift, | |
197 mpi->h >> mpi->chroma_y_shift, | |
198 vf->dmpi->stride[1], | |
199 mpi->stride[1]); | |
200 memcpy_pic(vf->dmpi->planes[2] + (ass_top_margin >> mpi->chroma_y_shift) * vf->dmpi->stride[2], | |
201 mpi->planes[2], | |
202 mpi->w >> mpi->chroma_x_shift, | |
203 mpi->h >> mpi->chroma_y_shift, | |
204 vf->dmpi->stride[2], | |
205 mpi->stride[2]); | |
206 } else { | |
207 memcpy_pic(vf->dmpi->planes[0] + ass_top_margin * vf->dmpi->stride[0], | |
208 mpi->planes[0], | |
209 mpi->w * (vf->dmpi->bpp / 8), | |
210 mpi->h, | |
211 vf->dmpi->stride[0], | |
212 mpi->stride[0]); | |
213 vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette | |
214 } | |
215 if (ass_top_margin) | |
216 blank(vf->dmpi, 0, ass_top_margin); | |
217 if (ass_bottom_margin) | |
218 blank(vf->dmpi, vf->priv->outh - ass_bottom_margin, vf->priv->outh); | |
219 return 0; | |
18937 | 220 } |
221 | |
222 /** | |
223 * \brief Copy specified rows from render_context.dmpi to render_context.planes, upsampling to 4:4:4 | |
224 */ | |
32096 | 225 static void copy_from_image(struct vf_instance *vf, int first_row, |
226 int last_row) | |
18937 | 227 { |
32096 | 228 int pl; |
229 int i, j, k; | |
230 unsigned char val; | |
231 int chroma_rows; | |
18937 | 232 |
32096 | 233 first_row -= (first_row % 2); |
234 last_row += (last_row % 2); | |
235 chroma_rows = (last_row - first_row) / 2; | |
18937 | 236 |
32096 | 237 assert(first_row >= 0); |
238 assert(first_row <= last_row); | |
239 assert(last_row <= vf->priv->outh); | |
29383
e9cab9f6ed62
Make sure clip coordinates are inside the screen area.
eugeni
parents:
29263
diff
changeset
|
240 |
32096 | 241 for (pl = 1; pl < 3; ++pl) { |
242 int dst_stride = vf->priv->outw; | |
243 int src_stride = vf->dmpi->stride[pl]; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
244 |
32096 | 245 unsigned char *src = vf->dmpi->planes[pl] + (first_row / 2) * src_stride; |
246 unsigned char *dst = vf->priv->planes[pl] + first_row * dst_stride; | |
247 unsigned char *dst_next = dst + dst_stride; | |
248 for (i = 0; i < chroma_rows; ++i) { | |
249 if ((vf->priv->dirty_rows[first_row + i * 2 ] == 0) || | |
250 (vf->priv->dirty_rows[first_row + i * 2 + 1] == 0)) { | |
251 for (j = 0, k = 0; j < vf->dmpi->chroma_width; ++j, k += 2) { | |
252 val = *(src + j); | |
253 *(dst + k ) = val; | |
254 *(dst + k + 1) = val; | |
255 *(dst_next + k ) = val; | |
256 *(dst_next + k + 1) = val; | |
257 } | |
258 } | |
259 src += src_stride; | |
260 dst = dst_next + dst_stride; | |
261 dst_next = dst + dst_stride; | |
262 } | |
263 } | |
264 for (i = first_row; i < last_row; ++i) | |
265 vf->priv->dirty_rows[i] = 1; | |
18937 | 266 } |
267 | |
268 /** | |
269 * \brief Copy all previously copied rows back to render_context.dmpi | |
270 */ | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
271 static void copy_to_image(struct vf_instance *vf) |
18937 | 272 { |
32096 | 273 int pl; |
274 int i, j, k; | |
275 for (pl = 1; pl < 3; ++pl) { | |
276 int dst_stride = vf->dmpi->stride[pl]; | |
277 int src_stride = vf->priv->outw; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
278 |
32096 | 279 unsigned char *dst = vf->dmpi->planes[pl]; |
280 unsigned char *src = vf->priv->planes[pl]; | |
281 unsigned char *src_next = vf->priv->planes[pl] + src_stride; | |
282 for (i = 0; i < vf->dmpi->chroma_height; ++i) { | |
283 if ((vf->priv->dirty_rows[i * 2] == 1)) { | |
284 assert(vf->priv->dirty_rows[i * 2 + 1] == 1); | |
285 for (j = 0, k = 0; j < vf->dmpi->chroma_width; ++j, k += 2) { | |
286 unsigned val = 0; | |
287 val += *(src + k); | |
288 val += *(src + k + 1); | |
289 val += *(src_next + k); | |
290 val += *(src_next + k + 1); | |
291 *(dst + j) = val >> 2; | |
292 } | |
293 } | |
294 dst += dst_stride; | |
295 src = src_next + src_stride; | |
296 src_next = src + src_stride; | |
297 } | |
298 } | |
18937 | 299 } |
300 | |
32096 | 301 static void my_draw_bitmap(struct vf_instance *vf, unsigned char *bitmap, |
302 int bitmap_w, int bitmap_h, int stride, | |
303 int dst_x, int dst_y, unsigned color) | |
18937 | 304 { |
32096 | 305 unsigned char y = rgba2y(color); |
306 unsigned char u = rgba2u(color); | |
307 unsigned char v = rgba2v(color); | |
32261 | 308 unsigned opacity = 255 - _a(color); |
32096 | 309 unsigned char *src, *dsty, *dstu, *dstv; |
310 int i, j; | |
311 mp_image_t *dmpi = vf->dmpi; | |
18937 | 312 |
32261 | 313 opacity = (0x10203 * opacity + 0x80) >> 8; /* 0x10203 = (1<<32)/(255*255) */ |
314 /* 0 <= opacity <= 0x10101 */ | |
32096 | 315 src = bitmap; |
316 dsty = dmpi->planes[0] + dst_x + dst_y * dmpi->stride[0]; | |
317 dstu = vf->priv->planes[1] + dst_x + dst_y * vf->priv->outw; | |
318 dstv = vf->priv->planes[2] + dst_x + dst_y * vf->priv->outw; | |
319 for (i = 0; i < bitmap_h; ++i) { | |
320 for (j = 0; j < bitmap_w; ++j) { | |
32226
808e9d7eef5d
vf_ass: skip alpha blending for pixels where alpha is zero.
cigaes
parents:
32209
diff
changeset
|
321 unsigned k = src[j]; |
808e9d7eef5d
vf_ass: skip alpha blending for pixels where alpha is zero.
cigaes
parents:
32209
diff
changeset
|
322 if (!k) |
808e9d7eef5d
vf_ass: skip alpha blending for pixels where alpha is zero.
cigaes
parents:
32209
diff
changeset
|
323 continue; |
32261 | 324 k *= opacity; /* 0 <= k <= 0xFFFFFF */ |
325 dsty[j] = (k * y + (0xFFFFFF - k) * dsty[j] + 0x800000) >> 24; | |
326 dstu[j] = (k * u + (0xFFFFFF - k) * dstu[j] + 0x800000) >> 24; | |
327 dstv[j] = (k * v + (0xFFFFFF - k) * dstv[j] + 0x800000) >> 24; | |
32096 | 328 } |
329 src += stride; | |
330 dsty += dmpi->stride[0]; | |
331 dstu += vf->priv->outw; | |
332 dstv += vf->priv->outw; | |
333 } | |
18937 | 334 } |
335 | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
336 static void render_frame(struct vf_instance *vf, mp_image_t *mpi, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
337 struct mp_eosd_image_list *images) |
18937 | 338 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
339 struct mp_eosd_image *img; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
340 img = eosd_image_first(images); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
341 if (!img) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
342 return; |
32096 | 343 memset(vf->priv->dirty_rows, 0, vf->priv->outh); // reset dirty rows |
344 while (img) { | |
345 copy_from_image(vf, img->dst_y, img->dst_y + img->h); | |
346 my_draw_bitmap(vf, img->bitmap, img->w, img->h, img->stride, | |
347 img->dst_x, img->dst_y, img->color); | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
348 img = eosd_image_next(images); |
32096 | 349 } |
350 copy_to_image(vf); | |
18937 | 351 } |
352 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
353 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) |
18937 | 354 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
355 struct mp_eosd_image_list images; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
356 eosd_render_frame(pts, &images); |
32096 | 357 prepare_image(vf, mpi); |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
358 render_frame(vf, mpi, &images); |
32096 | 359 return vf_next_put_image(vf, vf->dmpi, pts); |
18937 | 360 } |
361 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
362 static int query_format(struct vf_instance *vf, unsigned int fmt) |
18937 | 363 { |
32096 | 364 switch (fmt) { |
365 case IMGFMT_YV12: | |
366 case IMGFMT_I420: | |
367 case IMGFMT_IYUV: | |
368 return vf_next_query_format(vf, vf->priv->outfmt); | |
369 } | |
370 return 0; | |
18937 | 371 } |
372 | |
373 static int control(vf_instance_t *vf, int request, void *data) | |
374 { | |
32096 | 375 switch (request) { |
376 case VFCTRL_INIT_EOSD: | |
377 return CONTROL_TRUE; | |
378 case VFCTRL_DRAW_EOSD: | |
379 return CONTROL_TRUE; | |
380 } | |
381 return vf_next_control(vf, request, data); | |
18937 | 382 } |
383 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
384 static void uninit(struct vf_instance *vf) |
18937 | 385 { |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
386 free(vf->priv->planes[1]); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
387 free(vf->priv->planes[2]); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
388 free(vf->priv->dirty_rows); |
18937 | 389 } |
390 | |
32096 | 391 static const unsigned int fmt_list[] = { |
392 IMGFMT_YV12, | |
393 IMGFMT_I420, | |
394 IMGFMT_IYUV, | |
395 0 | |
18937 | 396 }; |
397 | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30633
diff
changeset
|
398 static int vf_open(vf_instance_t *vf, char *args) |
18937 | 399 { |
32096 | 400 int flags; |
401 vf->priv->outfmt = vf_match_csp(&vf->next, fmt_list, IMGFMT_YV12); | |
402 if (vf->priv->outfmt) | |
403 flags = vf_next_query_format(vf, vf->priv->outfmt); | |
404 if (!vf->priv->outfmt || (vf->priv->auto_insert && flags & VFCAP_EOSD)) { | |
405 uninit(vf); | |
406 return 0; | |
407 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
408 |
32096 | 409 if (vf->priv->auto_insert) |
410 mp_msg(MSGT_ASS, MSGL_INFO, "[ass] auto-open\n"); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
411 |
32096 | 412 vf->config = config; |
413 vf->query_format = query_format; | |
414 vf->uninit = uninit; | |
415 vf->control = control; | |
416 vf->get_image = get_image; | |
417 vf->put_image = put_image; | |
418 vf->default_caps = VFCAP_EOSD; | |
419 return 1; | |
18937 | 420 } |
421 | |
422 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
423 static const m_option_t vf_opts_fields[] = { |
32096 | 424 {"auto", ST_OFF(auto_insert), CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
425 {NULL, NULL, 0, 0, 0, 0, NULL} | |
18937 | 426 }; |
427 | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
428 static const m_struct_t vf_opts = { |
32096 | 429 "ass", |
430 sizeof(struct vf_priv_s), | |
431 &vf_priv_dflt, | |
432 vf_opts_fields | |
18937 | 433 }; |
434 | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
435 const vf_info_t vf_info_ass = { |
32096 | 436 "Render ASS/SSA subtitles", |
437 "ass", | |
438 "Evgeniy Stepanov", | |
439 "", | |
440 vf_open, | |
441 &vf_opts | |
18937 | 442 }; |