Mercurial > mplayer.hg
annotate libmpcodecs/vf_ass.c @ 35067:3702a2b88d12
Fix compiler warning by specifying that our class implements
NSWindowDelegate.
author | reimar |
---|---|
date | Tue, 11 Sep 2012 19:25:21 +0000 |
parents | 848835e1b053 |
children | 222713e4d79f |
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" | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
39 #include "libavutil/intreadwrite.h" |
32467 | 40 #include "sub/sub.h" |
18937 | 41 #include "m_option.h" |
42 #include "m_struct.h" | |
43 | |
32461 | 44 #include "sub/ass_mp.h" |
32460 | 45 #include "sub/eosd.h" |
18937 | 46 |
47 #define _r(c) ((c)>>24) | |
48 #define _g(c) (((c)>>16)&0xFF) | |
49 #define _b(c) (((c)>>8)&0xFF) | |
50 #define _a(c) ((c)&0xFF) | |
32096 | 51 #define rgba2y(c) ( (( 263*_r(c) + 516*_g(c) + 100*_b(c)) >> 10) + 16 ) |
18937 | 52 #define rgba2u(c) ( ((-152*_r(c) - 298*_g(c) + 450*_b(c)) >> 10) + 128 ) |
53 #define rgba2v(c) ( (( 450*_r(c) - 376*_g(c) - 73*_b(c)) >> 10) + 128 ) | |
54 | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
55 typedef void (*copy_from_image_func)(struct vf_instance *vf, |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
56 int first_row, int last_row); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
57 typedef void (*copy_to_image_func)(struct vf_instance *vf); |
18937 | 58 |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
59 static const struct vf_priv_s { |
32096 | 60 int outh, outw; |
18937 | 61 |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
62 int is_planar; |
32096 | 63 unsigned int outfmt; |
18937 | 64 |
32096 | 65 // 1 = auto-added filter: insert only if chain does not support EOSD already |
66 // 0 = insert always | |
67 int auto_insert; | |
18937 | 68 |
32096 | 69 unsigned char *planes[3]; |
70 unsigned char *dirty_rows; | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
71 |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
72 copy_from_image_func copy_from_image; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
73 copy_to_image_func copy_to_image; |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
74 } vf_priv_dflt; |
18937 | 75 |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
76 static void copy_from_image_yuv420p(struct vf_instance *, int, int); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
77 static void copy_to_image_yuv420p(struct vf_instance *); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
78 static void copy_from_image_yuv422(struct vf_instance *, int, int); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
79 static void copy_to_image_yuv422(struct vf_instance *); |
18937 | 80 |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
81 static int config(struct vf_instance *vf, |
32096 | 82 int width, int height, int d_width, int d_height, |
83 unsigned int flags, unsigned int outfmt) | |
18937 | 84 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
85 struct mp_eosd_settings res = {0}; |
31927 | 86 |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
87 switch (outfmt) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
88 case IMGFMT_YV12: |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
89 case IMGFMT_I420: |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
90 case IMGFMT_IYUV: |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
91 vf->priv->is_planar = 1; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
92 vf->priv->copy_from_image = copy_from_image_yuv420p; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
93 vf->priv->copy_to_image = copy_to_image_yuv420p; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
94 break; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
95 case IMGFMT_UYVY: |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
96 case IMGFMT_YUY2: |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
97 vf->priv->is_planar = 0; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
98 vf->priv->copy_from_image = copy_from_image_yuv422; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
99 vf->priv->copy_to_image = copy_to_image_yuv422; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
100 break; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
101 default: |
32096 | 102 return 0; |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
103 } |
18937 | 104 |
35033 | 105 vf->priv->outfmt = outfmt; |
32096 | 106 vf->priv->outh = height + ass_top_margin + ass_bottom_margin; |
107 vf->priv->outw = width; | |
18937 | 108 |
32096 | 109 if (!opt_screen_size_x && !opt_screen_size_y) { |
110 d_width = d_width * vf->priv->outw / width; | |
111 d_height = d_height * vf->priv->outh / height; | |
112 } | |
18937 | 113 |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
114 if (!vf->priv->is_planar) |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
115 vf->priv->planes[0] = malloc(vf->priv->outw * vf->priv->outh); |
32096 | 116 vf->priv->planes[1] = malloc(vf->priv->outw * vf->priv->outh); |
117 vf->priv->planes[2] = malloc(vf->priv->outw * vf->priv->outh); | |
118 vf->priv->dirty_rows = malloc(vf->priv->outh); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
119 |
32096 | 120 res.w = vf->priv->outw; |
121 res.h = vf->priv->outh; | |
122 res.srcw = width; | |
123 res.srch = height; | |
124 res.mt = ass_top_margin; | |
125 res.mb = ass_bottom_margin; | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
126 eosd_configure(&res); |
18937 | 127 |
32096 | 128 return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width, |
129 d_height, flags, outfmt); | |
18937 | 130 } |
131 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
132 static void get_image(struct vf_instance *vf, mp_image_t *mpi) |
18937 | 133 { |
32096 | 134 if (mpi->type == MP_IMGTYPE_IPB) |
135 return; | |
136 if (mpi->flags & MP_IMGFLAG_PRESERVE) | |
137 return; | |
138 if (mpi->imgfmt != vf->priv->outfmt) | |
139 return; // colorspace differ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
140 |
32096 | 141 // width never changes, always try full DR |
142 mpi->priv = vf->dmpi = vf_get_image(vf->next, mpi->imgfmt, mpi->type, | |
143 mpi->flags | MP_IMGFLAG_READABLE, | |
34882
649d4cad4619
Request a sufficiently large image for direct rendering.
reimar
parents:
34863
diff
changeset
|
144 FFMAX(mpi->width, vf->priv->outw), |
649d4cad4619
Request a sufficiently large image for direct rendering.
reimar
parents:
34863
diff
changeset
|
145 FFMAX(mpi->height, vf->priv->outh)); |
18937 | 146 |
32096 | 147 if ( (vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) && |
148 !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)) { | |
149 mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible); | |
150 return; | |
151 } | |
152 // set up mpi as a cropped-down image of dmpi: | |
153 if (mpi->flags & MP_IMGFLAG_PLANAR) { | |
154 mpi->planes[0] = vf->dmpi->planes[0] + ass_top_margin * vf->dmpi->stride[0]; | |
155 mpi->planes[1] = vf->dmpi->planes[1] + (ass_top_margin >> mpi->chroma_y_shift) * vf->dmpi->stride[1]; | |
156 mpi->planes[2] = vf->dmpi->planes[2] + (ass_top_margin >> mpi->chroma_y_shift) * vf->dmpi->stride[2]; | |
157 mpi->stride[1] = vf->dmpi->stride[1]; | |
158 mpi->stride[2] = vf->dmpi->stride[2]; | |
159 } else { | |
160 mpi->planes[0] = vf->dmpi->planes[0] + ass_top_margin * vf->dmpi->stride[0]; | |
161 } | |
162 mpi->stride[0] = vf->dmpi->stride[0]; | |
163 mpi->width = vf->dmpi->width; | |
164 mpi->flags |= MP_IMGFLAG_DIRECT; | |
165 mpi->flags &= ~MP_IMGFLAG_DRAW_CALLBACK; | |
166 // vf->dmpi->flags &= ~MP_IMGFLAG_DRAW_CALLBACK; | |
18937 | 167 } |
168 | |
169 static void blank(mp_image_t *mpi, int y1, int y2) | |
170 { | |
32096 | 171 int color[3] = { 16, 128, 128 }; // black (YUV) |
172 int y; | |
173 unsigned char *dst; | |
174 int chroma_rows = (y2 - y1) >> mpi->chroma_y_shift; | |
18937 | 175 |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
176 if (mpi->flags & MP_IMGFLAG_PLANAR) { |
32096 | 177 dst = mpi->planes[0] + y1 * mpi->stride[0]; |
178 for (y = 0; y < y2 - y1; ++y) { | |
179 memset(dst, color[0], mpi->w); | |
180 dst += mpi->stride[0]; | |
181 } | |
182 dst = mpi->planes[1] + (y1 >> mpi->chroma_y_shift) * mpi->stride[1]; | |
183 for (y = 0; y < chroma_rows; ++y) { | |
184 memset(dst, color[1], mpi->chroma_width); | |
185 dst += mpi->stride[1]; | |
186 } | |
187 dst = mpi->planes[2] + (y1 >> mpi->chroma_y_shift) * mpi->stride[2]; | |
188 for (y = 0; y < chroma_rows; ++y) { | |
189 memset(dst, color[2], mpi->chroma_width); | |
190 dst += mpi->stride[2]; | |
191 } | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
192 } else { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
193 unsigned char packed_color[4]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
194 int x; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
195 if (mpi->imgfmt == IMGFMT_UYVY) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
196 packed_color[0] = color[1]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
197 packed_color[1] = color[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
198 packed_color[2] = color[2]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
199 packed_color[3] = color[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
200 } else { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
201 packed_color[0] = color[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
202 packed_color[1] = color[1]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
203 packed_color[2] = color[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
204 packed_color[3] = color[2]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
205 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
206 dst = mpi->planes[0] + y1 * mpi->stride[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
207 for (y = y1; y < y2; ++y) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
208 for (x = 0; x < mpi->w / 2; ++x) |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
209 AV_COPY32(dst + 4 * x, packed_color); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
210 dst += mpi->stride[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
211 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
212 } |
18937 | 213 } |
214 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
215 static int prepare_image(struct vf_instance *vf, mp_image_t *mpi) |
18937 | 216 { |
32096 | 217 if (mpi->flags & MP_IMGFLAG_DIRECT || |
218 mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) { | |
219 vf->dmpi = mpi->priv; | |
220 if (!vf->dmpi) { | |
221 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); | |
222 return 0; | |
223 } | |
224 mpi->priv = NULL; | |
225 // we've used DR, so we're ready... | |
226 if (ass_top_margin) | |
227 blank(vf->dmpi, 0, ass_top_margin); | |
228 if (ass_bottom_margin) | |
229 blank(vf->dmpi, vf->priv->outh - ass_bottom_margin, vf->priv->outh); | |
230 if (!(mpi->flags & MP_IMGFLAG_PLANAR)) | |
231 vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette | |
232 return 0; | |
233 } | |
234 // hope we'll get DR buffer: | |
235 vf->dmpi = vf_get_image(vf->next, vf->priv->outfmt, MP_IMGTYPE_TEMP, | |
236 MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_READABLE, | |
237 vf->priv->outw, vf->priv->outh); | |
18937 | 238 |
32096 | 239 // copy mpi->dmpi... |
240 if (mpi->flags & MP_IMGFLAG_PLANAR) { | |
241 memcpy_pic(vf->dmpi->planes[0] + ass_top_margin * vf->dmpi->stride[0], | |
242 mpi->planes[0], | |
243 mpi->w, | |
244 mpi->h, | |
245 vf->dmpi->stride[0], | |
246 mpi->stride[0]); | |
247 memcpy_pic(vf->dmpi->planes[1] + (ass_top_margin >> mpi->chroma_y_shift) * vf->dmpi->stride[1], | |
248 mpi->planes[1], | |
249 mpi->w >> mpi->chroma_x_shift, | |
250 mpi->h >> mpi->chroma_y_shift, | |
251 vf->dmpi->stride[1], | |
252 mpi->stride[1]); | |
253 memcpy_pic(vf->dmpi->planes[2] + (ass_top_margin >> mpi->chroma_y_shift) * vf->dmpi->stride[2], | |
254 mpi->planes[2], | |
255 mpi->w >> mpi->chroma_x_shift, | |
256 mpi->h >> mpi->chroma_y_shift, | |
257 vf->dmpi->stride[2], | |
258 mpi->stride[2]); | |
259 } else { | |
260 memcpy_pic(vf->dmpi->planes[0] + ass_top_margin * vf->dmpi->stride[0], | |
261 mpi->planes[0], | |
262 mpi->w * (vf->dmpi->bpp / 8), | |
263 mpi->h, | |
264 vf->dmpi->stride[0], | |
265 mpi->stride[0]); | |
266 vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette | |
267 } | |
268 if (ass_top_margin) | |
269 blank(vf->dmpi, 0, ass_top_margin); | |
270 if (ass_bottom_margin) | |
271 blank(vf->dmpi, vf->priv->outh - ass_bottom_margin, vf->priv->outh); | |
272 return 0; | |
18937 | 273 } |
274 | |
275 /** | |
276 * \brief Copy specified rows from render_context.dmpi to render_context.planes, upsampling to 4:4:4 | |
277 */ | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
278 static void copy_from_image_yuv420p(struct vf_instance *vf, int first_row, |
32096 | 279 int last_row) |
18937 | 280 { |
32096 | 281 int pl; |
282 int i, j, k; | |
283 unsigned char val; | |
284 int chroma_rows; | |
18937 | 285 |
32096 | 286 first_row -= (first_row % 2); |
287 last_row += (last_row % 2); | |
288 chroma_rows = (last_row - first_row) / 2; | |
18937 | 289 |
32096 | 290 assert(first_row >= 0); |
291 assert(first_row <= last_row); | |
292 assert(last_row <= vf->priv->outh); | |
29383
e9cab9f6ed62
Make sure clip coordinates are inside the screen area.
eugeni
parents:
29263
diff
changeset
|
293 |
32096 | 294 for (pl = 1; pl < 3; ++pl) { |
295 int dst_stride = vf->priv->outw; | |
296 int src_stride = vf->dmpi->stride[pl]; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
297 |
32096 | 298 unsigned char *src = vf->dmpi->planes[pl] + (first_row / 2) * src_stride; |
299 unsigned char *dst = vf->priv->planes[pl] + first_row * dst_stride; | |
300 unsigned char *dst_next = dst + dst_stride; | |
301 for (i = 0; i < chroma_rows; ++i) { | |
302 if ((vf->priv->dirty_rows[first_row + i * 2 ] == 0) || | |
303 (vf->priv->dirty_rows[first_row + i * 2 + 1] == 0)) { | |
304 for (j = 0, k = 0; j < vf->dmpi->chroma_width; ++j, k += 2) { | |
305 val = *(src + j); | |
306 *(dst + k ) = val; | |
307 *(dst + k + 1) = val; | |
308 *(dst_next + k ) = val; | |
309 *(dst_next + k + 1) = val; | |
310 } | |
311 } | |
312 src += src_stride; | |
313 dst = dst_next + dst_stride; | |
314 dst_next = dst + dst_stride; | |
315 } | |
316 } | |
317 for (i = first_row; i < last_row; ++i) | |
318 vf->priv->dirty_rows[i] = 1; | |
18937 | 319 } |
320 | |
321 /** | |
322 * \brief Copy all previously copied rows back to render_context.dmpi | |
323 */ | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
324 static void copy_to_image_yuv420p(struct vf_instance *vf) |
18937 | 325 { |
32096 | 326 int pl; |
327 int i, j, k; | |
328 for (pl = 1; pl < 3; ++pl) { | |
329 int dst_stride = vf->dmpi->stride[pl]; | |
330 int src_stride = vf->priv->outw; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
331 |
32096 | 332 unsigned char *dst = vf->dmpi->planes[pl]; |
333 unsigned char *src = vf->priv->planes[pl]; | |
334 unsigned char *src_next = vf->priv->planes[pl] + src_stride; | |
34885 | 335 for (i = 0; i < vf->priv->outh / 2; ++i) { |
32096 | 336 if ((vf->priv->dirty_rows[i * 2] == 1)) { |
337 assert(vf->priv->dirty_rows[i * 2 + 1] == 1); | |
338 for (j = 0, k = 0; j < vf->dmpi->chroma_width; ++j, k += 2) { | |
339 unsigned val = 0; | |
340 val += *(src + k); | |
341 val += *(src + k + 1); | |
342 val += *(src_next + k); | |
343 val += *(src_next + k + 1); | |
344 *(dst + j) = val >> 2; | |
345 } | |
346 } | |
347 dst += dst_stride; | |
348 src = src_next + src_stride; | |
349 src_next = src + src_stride; | |
350 } | |
351 } | |
18937 | 352 } |
353 | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
354 static void copy_from_image_yuv422(struct vf_instance *vf, |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
355 int first_row, int last_row) |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
356 { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
357 unsigned char *dirty_rows = vf->priv->dirty_rows; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
358 int src_stride = vf->dmpi->stride[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
359 int dst_stride = vf->priv->outw; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
360 unsigned char *src = vf->dmpi->planes[0] + first_row * src_stride; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
361 unsigned char **dst = vf->priv->planes; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
362 int dst_off = first_row * dst_stride; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
363 int is_uyvy = vf->priv->outfmt == IMGFMT_UYVY; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
364 int i, j, k; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
365 |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
366 for (i = first_row; i < last_row; ++i) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
367 int next_off = dst_off + dst_stride; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
368 if (!dirty_rows[i]) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
369 if (is_uyvy) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
370 for (j = dst_off, k = 0; j < next_off; j += 2, k += 4) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
371 dst[0][j ] = src[k + 1]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
372 dst[0][j + 1] = src[k + 3]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
373 dst[1][j ] = src[k ]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
374 dst[1][j + 1] = src[k ]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
375 dst[2][j ] = src[k + 2]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
376 dst[2][j + 1] = src[k + 2]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
377 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
378 } else { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
379 for (j = dst_off, k = 0; j < next_off; j += 2, k += 4) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
380 dst[0][j ] = src[k ]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
381 dst[0][j + 1] = src[k + 2]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
382 dst[1][j ] = src[k + 1]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
383 dst[1][j + 1] = src[k + 1]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
384 dst[2][j ] = src[k + 3]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
385 dst[2][j + 1] = src[k + 3]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
386 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
387 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
388 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
389 src += src_stride; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
390 dst_off = next_off; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
391 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
392 for (i = first_row; i < last_row; ++i) |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
393 dirty_rows[i] = 1; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
394 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
395 |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
396 static void copy_to_image_yuv422(struct vf_instance *vf) |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
397 { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
398 unsigned char *dirty_rows = vf->priv->dirty_rows; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
399 int src_stride = vf->priv->outw; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
400 int dst_stride = vf->dmpi->stride[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
401 int height = vf->priv->outh; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
402 unsigned char **src = vf->priv->planes; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
403 unsigned char *dst = vf->dmpi->planes[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
404 int src_off = 0; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
405 int is_uyvy = vf->priv->outfmt == IMGFMT_UYVY; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
406 int i, j, k; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
407 |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
408 for (i = 0; i < height; ++i) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
409 int next_off = src_off + src_stride; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
410 if (*dirty_rows++) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
411 #define AVERAGE(a, b) (((unsigned)(a) + (unsigned)(b)) >> 1) |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
412 if (is_uyvy) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
413 for (j = src_off, k = 0; j < next_off; j += 2, k += 4) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
414 dst[k ] = AVERAGE(src[1][j], src[1][j + 1]); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
415 dst[k + 1] = src[0][j]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
416 dst[k + 2] = AVERAGE(src[2][j], src[2][j + 1]); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
417 dst[k + 3] = src[0][j + 1]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
418 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
419 } else { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
420 for (j = src_off, k = 0; j < next_off; j += 2, k += 4) { |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
421 dst[k ] = src[0][j]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
422 dst[k + 1] = AVERAGE(src[1][j], src[1][j + 1]); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
423 dst[k + 2] = src[0][j + 1]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
424 dst[k + 3] = AVERAGE(src[2][j], src[2][j + 1]); |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
425 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
426 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
427 #undef AVERAGE |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
428 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
429 src_off = next_off; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
430 dst += dst_stride; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
431 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
432 } |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
433 |
32096 | 434 static void my_draw_bitmap(struct vf_instance *vf, unsigned char *bitmap, |
435 int bitmap_w, int bitmap_h, int stride, | |
436 int dst_x, int dst_y, unsigned color) | |
18937 | 437 { |
32096 | 438 unsigned char y = rgba2y(color); |
439 unsigned char u = rgba2u(color); | |
440 unsigned char v = rgba2v(color); | |
32261 | 441 unsigned opacity = 255 - _a(color); |
32096 | 442 unsigned char *src, *dsty, *dstu, *dstv; |
443 int i, j; | |
444 mp_image_t *dmpi = vf->dmpi; | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
445 int stride_y = vf->priv->is_planar ? dmpi->stride[0] : vf->priv->outw; |
18937 | 446 |
32261 | 447 opacity = (0x10203 * opacity + 0x80) >> 8; /* 0x10203 = (1<<32)/(255*255) */ |
448 /* 0 <= opacity <= 0x10101 */ | |
32096 | 449 src = bitmap; |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
450 dsty = vf->priv->is_planar ? dmpi->planes[0] : vf->priv->planes[0]; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
451 dsty += dst_x + dst_y * stride_y; |
32096 | 452 dstu = vf->priv->planes[1] + dst_x + dst_y * vf->priv->outw; |
453 dstv = vf->priv->planes[2] + dst_x + dst_y * vf->priv->outw; | |
454 for (i = 0; i < bitmap_h; ++i) { | |
455 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
|
456 unsigned k = src[j]; |
808e9d7eef5d
vf_ass: skip alpha blending for pixels where alpha is zero.
cigaes
parents:
32209
diff
changeset
|
457 if (!k) |
808e9d7eef5d
vf_ass: skip alpha blending for pixels where alpha is zero.
cigaes
parents:
32209
diff
changeset
|
458 continue; |
32261 | 459 k *= opacity; /* 0 <= k <= 0xFFFFFF */ |
460 dsty[j] = (k * y + (0xFFFFFF - k) * dsty[j] + 0x800000) >> 24; | |
461 dstu[j] = (k * u + (0xFFFFFF - k) * dstu[j] + 0x800000) >> 24; | |
462 dstv[j] = (k * v + (0xFFFFFF - k) * dstv[j] + 0x800000) >> 24; | |
32096 | 463 } |
464 src += stride; | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
465 dsty += stride_y; |
32096 | 466 dstu += vf->priv->outw; |
467 dstv += vf->priv->outw; | |
468 } | |
18937 | 469 } |
470 | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
471 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
|
472 struct mp_eosd_image_list *images) |
18937 | 473 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
474 struct mp_eosd_image *img; |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
475 copy_from_image_func copy_from_image = vf->priv->copy_from_image; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
476 copy_to_image_func copy_to_image = vf->priv->copy_to_image; |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
477 |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
478 img = eosd_image_first(images); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
479 if (!img) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
480 return; |
32096 | 481 memset(vf->priv->dirty_rows, 0, vf->priv->outh); // reset dirty rows |
482 while (img) { | |
483 copy_from_image(vf, img->dst_y, img->dst_y + img->h); | |
484 my_draw_bitmap(vf, img->bitmap, img->w, img->h, img->stride, | |
485 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
|
486 img = eosd_image_next(images); |
32096 | 487 } |
488 copy_to_image(vf); | |
18937 | 489 } |
490 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
491 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) |
18937 | 492 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
493 struct mp_eosd_image_list images; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
494 eosd_render_frame(pts, &images); |
32096 | 495 prepare_image(vf, mpi); |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32261
diff
changeset
|
496 render_frame(vf, mpi, &images); |
32096 | 497 return vf_next_put_image(vf, vf->dmpi, pts); |
18937 | 498 } |
499 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
500 static int query_format(struct vf_instance *vf, unsigned int fmt) |
18937 | 501 { |
32096 | 502 switch (fmt) { |
503 case IMGFMT_YV12: | |
504 case IMGFMT_I420: | |
505 case IMGFMT_IYUV: | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
506 case IMGFMT_UYVY: |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
507 case IMGFMT_YUY2: |
35033 | 508 return vf_next_query_format(vf, fmt) | VFCAP_EOSD; |
32096 | 509 } |
510 return 0; | |
18937 | 511 } |
512 | |
513 static int control(vf_instance_t *vf, int request, void *data) | |
514 { | |
32096 | 515 switch (request) { |
516 case VFCTRL_INIT_EOSD: | |
517 return CONTROL_TRUE; | |
518 case VFCTRL_DRAW_EOSD: | |
519 return CONTROL_TRUE; | |
520 } | |
521 return vf_next_control(vf, request, data); | |
18937 | 522 } |
523 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
524 static void uninit(struct vf_instance *vf) |
18937 | 525 { |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
526 if (!vf->priv->is_planar) |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
527 free(vf->priv->planes[0]); |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
528 free(vf->priv->planes[1]); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
529 free(vf->priv->planes[2]); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
530 free(vf->priv->dirty_rows); |
18937 | 531 } |
532 | |
32096 | 533 static const unsigned int fmt_list[] = { |
534 IMGFMT_YV12, | |
535 IMGFMT_I420, | |
536 IMGFMT_IYUV, | |
35039
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
537 IMGFMT_UYVY, |
848835e1b053
vf_ass: add support for rendering on YUY2 and UYVY images.
reimar
parents:
35033
diff
changeset
|
538 IMGFMT_YUY2, |
32096 | 539 0 |
18937 | 540 }; |
541 | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30633
diff
changeset
|
542 static int vf_open(vf_instance_t *vf, char *args) |
18937 | 543 { |
32096 | 544 int flags; |
35033 | 545 unsigned outfmt = vf_match_csp(&vf->next, fmt_list, IMGFMT_YV12); |
546 if (outfmt) | |
547 flags = vf_next_query_format(vf, outfmt); | |
548 if (!outfmt || (vf->priv->auto_insert && flags & VFCAP_EOSD)) { | |
32096 | 549 uninit(vf); |
550 return 0; | |
551 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
552 |
32096 | 553 if (vf->priv->auto_insert) |
554 mp_msg(MSGT_ASS, MSGL_INFO, "[ass] auto-open\n"); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26727
diff
changeset
|
555 |
32096 | 556 vf->config = config; |
557 vf->query_format = query_format; | |
558 vf->uninit = uninit; | |
559 vf->control = control; | |
560 vf->get_image = get_image; | |
561 vf->put_image = put_image; | |
562 vf->default_caps = VFCAP_EOSD; | |
563 return 1; | |
18937 | 564 } |
565 | |
566 #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
|
567 static const m_option_t vf_opts_fields[] = { |
32096 | 568 {"auto", ST_OFF(auto_insert), CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
569 {NULL, NULL, 0, 0, 0, 0, NULL} | |
18937 | 570 }; |
571 | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
572 static const m_struct_t vf_opts = { |
32096 | 573 "ass", |
574 sizeof(struct vf_priv_s), | |
575 &vf_priv_dflt, | |
576 vf_opts_fields | |
18937 | 577 }; |
578 | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
24545
diff
changeset
|
579 const vf_info_t vf_info_ass = { |
32096 | 580 "Render ASS/SSA subtitles", |
581 "ass", | |
582 "Evgeniy Stepanov", | |
583 "", | |
584 vf_open, | |
585 &vf_opts | |
18937 | 586 }; |