Revision a363effb

View differences:

libavcodec/dvdsubdec.c
79 79
}
80 80

  
81 81
static void guess_palette(uint32_t *rgba_palette,
82
                          uint8_t *palette,
82
                          uint8_t *colormap,
83 83
                          uint8_t *alpha,
84 84
                          uint32_t subtitle_color)
85 85
{
......
92 92
    memset(color_used, 0, 16);
93 93
    nb_opaque_colors = 0;
94 94
    for(i = 0; i < 4; i++) {
95
        if (alpha[i] != 0 && !color_used[palette[i]]) {
96
            color_used[palette[i]] = 1;
95
        if (alpha[i] != 0 && !color_used[colormap[i]]) {
96
            color_used[colormap[i]] = 1;
97 97
            nb_opaque_colors++;
98 98
        }
99 99
    }
......
105 105
    memset(color_used, 0, 16);
106 106
    for(i = 0; i < 4; i++) {
107 107
        if (alpha[i] != 0) {
108
            if (!color_used[palette[i]])  {
108
            if (!color_used[colormap[i]])  {
109 109
                level = (0xff * j) / nb_opaque_colors;
110 110
                r = (((subtitle_color >> 16) & 0xff) * level) >> 8;
111 111
                g = (((subtitle_color >> 8) & 0xff) * level) >> 8;
112 112
                b = (((subtitle_color >> 0) & 0xff) * level) >> 8;
113 113
                rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24);
114
                color_used[palette[i]] = (i + 1);
114
                color_used[colormap[i]] = (i + 1);
115 115
                j--;
116 116
            } else {
117
                rgba_palette[i] = (rgba_palette[color_used[palette[i]] - 1] & 0x00ffffff) |
117
                rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) |
118 118
                                    ((alpha[i] * 17) << 24);
119 119
            }
120 120
        }
......
125 125
                                const uint8_t *buf, int buf_size)
126 126
{
127 127
    int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
128
    uint8_t palette[4], alpha[4];
128
    uint8_t colormap[4], alpha[4];
129 129
    int date;
130 130
    int i;
131 131
    int is_menu = 0;
......
168 168
                sub_header->end_display_time = (date << 10) / 90;
169 169
                break;
170 170
            case 0x03:
171
                /* set palette */
171
                /* set colormap */
172 172
                if ((buf_size - pos) < 2)
173 173
                    goto fail;
174
                palette[3] = buf[pos] >> 4;
175
                palette[2] = buf[pos] & 0x0f;
176
                palette[1] = buf[pos + 1] >> 4;
177
                palette[0] = buf[pos + 1] & 0x0f;
174
                colormap[3] = buf[pos] >> 4;
175
                colormap[2] = buf[pos] & 0x0f;
176
                colormap[1] = buf[pos + 1] >> 4;
177
                colormap[0] = buf[pos + 1] & 0x0f;
178 178
                pos += 2;
179 179
                break;
180 180
            case 0x04:
......
249 249
                decode_rle(bitmap + w, w * 2, w, h / 2,
250 250
                           buf, offset2 * 2, buf_size);
251 251
                guess_palette(sub_header->rects[0].rgba_palette,
252
                              palette, alpha, 0xffff00);
252
                              colormap, alpha, 0xffff00);
253 253
                sub_header->rects[0].x = x1;
254 254
                sub_header->rects[0].y = y1;
255 255
                sub_header->rects[0].w = w;

Also available in: Unified diff