Mercurial > mplayer.hg
comparison spudec.c @ 31641:6c5a559d340c
Faster paletted to OSD conversion.
author | reimar |
---|---|
date | Sun, 11 Jul 2010 13:54:23 +0000 |
parents | 0d09c303bfe3 |
children | 92dd02d8ef2c |
comparison
equal
deleted
inserted
replaced
31640:0d09c303bfe3 | 31641:6c5a559d340c |
---|---|
1283 void spudec_set_paletted(void *this, const uint8_t *pal_img, int pal_stride, | 1283 void spudec_set_paletted(void *this, const uint8_t *pal_img, int pal_stride, |
1284 const void *palette, | 1284 const void *palette, |
1285 int x, int y, int w, int h, | 1285 int x, int y, int w, int h, |
1286 double pts, double endpts) | 1286 double pts, double endpts) |
1287 { | 1287 { |
1288 int i; | |
1289 uint16_t g8a8_pal[256]; | |
1288 packet_t *packet; | 1290 packet_t *packet; |
1289 const uint32_t *pal = palette; | 1291 const uint32_t *pal = palette; |
1290 spudec_handle_t *spu = this; | 1292 spudec_handle_t *spu = this; |
1291 uint8_t *img; | 1293 uint8_t *img; |
1292 uint8_t *aimg; | 1294 uint8_t *aimg; |
1302 packet->start_row = y; | 1304 packet->start_row = y; |
1303 packet->data_len = 2 * stride * h; | 1305 packet->data_len = 2 * stride * h; |
1304 packet->packet = malloc(packet->data_len); | 1306 packet->packet = malloc(packet->data_len); |
1305 img = packet->packet; | 1307 img = packet->packet; |
1306 aimg = packet->packet + stride * h; | 1308 aimg = packet->packet + stride * h; |
1307 // TODO: this would be a lot faster by converting the | 1309 for (i = 0; i < 256; i++) { |
1308 // palette first. | 1310 uint32_t pixel = pal[i]; |
1309 for (y = 0; y < h; y++) { | |
1310 for (x = 0; x < w; x++) { | |
1311 uint32_t pixel = pal[pal_img[x]]; | |
1312 int alpha = pixel >> 24; | 1311 int alpha = pixel >> 24; |
1313 int gray = (((pixel & 0x000000ff) >> 0) + | 1312 int gray = (((pixel & 0x000000ff) >> 0) + |
1314 ((pixel & 0x0000ff00) >> 7) + | 1313 ((pixel & 0x0000ff00) >> 7) + |
1315 ((pixel & 0x00ff0000) >> 16)) >> 2; | 1314 ((pixel & 0x00ff0000) >> 16)) >> 2; |
1316 *aimg++ = -alpha; | 1315 gray = FFMIN(gray, alpha); |
1317 *img++ = FFMIN(gray, alpha); | 1316 g8a8_pal[i] = (-alpha << 8) | gray; |
1317 } | |
1318 for (y = 0; y < h; y++) { | |
1319 for (x = 0; x < w; x++) { | |
1320 uint16_t pixel = g8a8_pal[pal_img[x]]; | |
1321 *img++ = pixel; | |
1322 *aimg++ = pixel >> 8; | |
1318 } | 1323 } |
1319 for (; x < stride; x++) | 1324 for (; x < stride; x++) |
1320 *aimg++ = *img++ = 0; | 1325 *aimg++ = *img++ = 0; |
1321 pal_img += pal_stride; | 1326 pal_img += pal_stride; |
1322 } | 1327 } |