From 2b01fc067844d82524b2e6e9fde8e424687d85d3 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 29 Sep 2010 19:05:13 +0000 Subject: [PATCH] spudec: support "clear" packet type Support "clear" packets that contain no data but instead clear the screen at a given time. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32410 b3059339-0415-0410-9bf9-f77b7e298cf2 Reindent. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32411 b3059339-0415-0410-9bf9-f77b7e298cf2 --- spudec.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/spudec.c b/spudec.c index 5e39846fe6..c2e408c838 100644 --- a/spudec.c +++ b/spudec.c @@ -1367,20 +1367,22 @@ void spudec_set_paletted(void *this, const uint8_t *pal_img, int pal_stride, packet->start_col = x; packet->start_row = y; packet->data_len = 2 * stride * h; - packet->packet = malloc(packet->data_len); - img = packet->packet; - aimg = packet->packet + stride * h; - for (i = 0; i < 256; i++) { - uint32_t pixel = pal[i]; - int alpha = pixel >> 24; - int gray = (((pixel & 0x000000ff) >> 0) + - ((pixel & 0x0000ff00) >> 7) + - ((pixel & 0x00ff0000) >> 16)) >> 2; - gray = FFMIN(gray, alpha); - g8a8_pal[i] = (-alpha << 8) | gray; + if (packet->data_len) { // size 0 is a special "clear" packet + packet->packet = malloc(packet->data_len); + img = packet->packet; + aimg = packet->packet + stride * h; + for (i = 0; i < 256; i++) { + uint32_t pixel = pal[i]; + int alpha = pixel >> 24; + int gray = (((pixel & 0x000000ff) >> 0) + + ((pixel & 0x0000ff00) >> 7) + + ((pixel & 0x00ff0000) >> 16)) >> 2; + gray = FFMIN(gray, alpha); + g8a8_pal[i] = (-alpha << 8) | gray; + } + pal2gray_alpha(g8a8_pal, pal_img, pal_stride, + img, aimg, stride, w, h); } - pal2gray_alpha(g8a8_pal, pal_img, pal_stride, - img, aimg, stride, w, h); packet->start_pts = 0; packet->end_pts = 0x7fffffff; if (pts != MP_NOPTS_VALUE)