summaryrefslogtreecommitdiffstats
path: root/spudec.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-07-11 13:54:23 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:14:43 +0200
commit15575403e5edcbf3e2f84d28b18db4b43134b834 (patch)
tree9736dd5b2d38b55c0f332200c4bcb9f9ac8c7e35 /spudec.c
parent95db5dd48c3b7cf3e4866fa35c9566e93a128c72 (diff)
downloadmpv-15575403e5edcbf3e2f84d28b18db4b43134b834.tar.bz2
mpv-15575403e5edcbf3e2f84d28b18db4b43134b834.tar.xz
spudec: Faster paletted to OSD conversion
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31707 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'spudec.c')
-rw-r--r--spudec.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/spudec.c b/spudec.c
index b57edfdfce..ec1b13bc31 100644
--- a/spudec.c
+++ b/spudec.c
@@ -1285,6 +1285,8 @@ void spudec_set_paletted(void *this, const uint8_t *pal_img, int pal_stride,
int x, int y, int w, int h,
double pts, double endpts)
{
+ int i;
+ uint16_t g8a8_pal[256];
packet_t *packet;
const uint32_t *pal = palette;
spudec_handle_t *spu = this;
@@ -1304,17 +1306,20 @@ void spudec_set_paletted(void *this, const uint8_t *pal_img, int pal_stride,
packet->packet = malloc(packet->data_len);
img = packet->packet;
aimg = packet->packet + stride * h;
- // TODO: this would be a lot faster by converting the
- // palette first.
- for (y = 0; y < h; y++) {
- for (x = 0; x < w; x++) {
- uint32_t pixel = pal[pal_img[x]];
+ 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;
- *aimg++ = -alpha;
- *img++ = FFMIN(gray, alpha);
+ gray = FFMIN(gray, alpha);
+ g8a8_pal[i] = (-alpha << 8) | gray;
+ }
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ uint16_t pixel = g8a8_pal[pal_img[x]];
+ *img++ = pixel;
+ *aimg++ = pixel >> 8;
}
for (; x < stride; x++)
*aimg++ = *img++ = 0;