Mercurial > mplayer.hg
comparison sub/spudec.c @ 37172:cad608ae7295
Fix incorrect use of pal2gray_alpha for av_sub.
It would clear previously draw subtitle rectangles
at the same vertical position, and it could potentially
write outside the destination.
author | reimar |
---|---|
date | Sat, 06 Sep 2014 19:52:00 +0000 |
parents | 6d654ac9201e |
children |
comparison
equal
deleted
inserted
replaced
37171:29802bb119f6 | 37172:cad608ae7295 |
---|---|
252 * gray value <= 256 - alpha. | 252 * gray value <= 256 - alpha. |
253 */ | 253 */ |
254 static void pal2gray_alpha(const uint16_t *pal, | 254 static void pal2gray_alpha(const uint16_t *pal, |
255 const uint8_t *src, int src_stride, | 255 const uint8_t *src, int src_stride, |
256 uint8_t *dst, uint8_t *dsta, | 256 uint8_t *dst, uint8_t *dsta, |
257 int dst_stride, int w, int h) | 257 int dst_stride, int w, int h, int skip_stride) |
258 { | 258 { |
259 int x, y; | 259 int x, y; |
260 for (y = 0; y < h; y++) { | 260 for (y = 0; y < h; y++) { |
261 for (x = 0; x < w; x++) { | 261 for (x = 0; x < w; x++) { |
262 uint16_t pixel = pal[src[x]]; | 262 uint16_t pixel = pal[src[x]]; |
263 *dst++ = pixel; | 263 *dst++ = pixel; |
264 *dsta++ = pixel >> 8; | 264 *dsta++ = pixel >> 8; |
265 } | 265 } |
266 for (; x < dst_stride; x++) | 266 if (skip_stride) { |
267 dst += dst_stride - w; | |
268 dsta += dst_stride - w; | |
269 } else for (; x < dst_stride; x++) | |
267 *dsta++ = *dst++ = 0; | 270 *dsta++ = *dst++ = 0; |
268 src += src_stride; | 271 src += src_stride; |
269 } | 272 } |
270 } | 273 } |
271 | 274 |
304 pal[i] = (-alpha << 8) | color; | 307 pal[i] = (-alpha << 8) | color; |
305 } | 308 } |
306 src = this->pal_image + crop_y * this->pal_width + crop_x; | 309 src = this->pal_image + crop_y * this->pal_width + crop_x; |
307 pal2gray_alpha(pal, src, this->pal_width, | 310 pal2gray_alpha(pal, src, this->pal_width, |
308 this->image, this->aimage, stride, | 311 this->image, this->aimage, stride, |
309 crop_w, crop_h); | 312 crop_w, crop_h, 0); |
310 this->width = crop_w; | 313 this->width = crop_w; |
311 this->height = crop_h; | 314 this->height = crop_h; |
312 this->stride = stride; | 315 this->stride = stride; |
313 this->start_col = this->pal_start_col + crop_x; | 316 this->start_col = this->pal_start_col + crop_x; |
314 this->start_row = this->pal_start_row + crop_y; | 317 this->start_row = this->pal_start_row + crop_y; |
1417 ((pixel & 0x00ff0000) >> 16)) >> 2; | 1420 ((pixel & 0x00ff0000) >> 16)) >> 2; |
1418 gray = FFMIN(gray, alpha); | 1421 gray = FFMIN(gray, alpha); |
1419 g8a8_pal[i] = (-alpha << 8) | gray; | 1422 g8a8_pal[i] = (-alpha << 8) | gray; |
1420 } | 1423 } |
1421 pal2gray_alpha(g8a8_pal, pal_img, pal_stride, | 1424 pal2gray_alpha(g8a8_pal, pal_img, pal_stride, |
1422 img, aimg, packet->stride, w, h); | 1425 img, aimg, packet->stride, w, h, 1); |
1423 } | 1426 } |
1424 | 1427 |
1425 void spudec_packet_send(void *spu, packet_t *packet, double pts, double endpts) | 1428 void spudec_packet_send(void *spu, packet_t *packet, double pts, double endpts) |
1426 { | 1429 { |
1427 packet->start_pts = 0; | 1430 packet->start_pts = 0; |