|  | @@ -120,6 +120,14 @@ static void guess_palette(uint32_t *rgba_palette, | 
														
													
														
															
																|  |  | uint8_t *alpha, |  |  | uint8_t *alpha, | 
														
													
														
															
																|  |  | uint32_t subtitle_color) |  |  | uint32_t subtitle_color) | 
														
													
														
															
																|  |  | { |  |  | { | 
														
													
														
															
																|  |  |  |  |  | static const uint8_t level_map[4][4] = { | 
														
													
														
															
																|  |  |  |  |  | // this configuration (full range, lowest to highest) in tests | 
														
													
														
															
																|  |  |  |  |  | // seemed most common, so assume this | 
														
													
														
															
																|  |  |  |  |  | {0xff}, | 
														
													
														
															
																|  |  |  |  |  | {0x00, 0xff}, | 
														
													
														
															
																|  |  |  |  |  | {0x00, 0x80, 0xff}, | 
														
													
														
															
																|  |  |  |  |  | {0x00, 0x55, 0xaa, 0xff}, | 
														
													
														
															
																|  |  |  |  |  | }; | 
														
													
														
															
																|  |  | uint8_t color_used[16]; |  |  | uint8_t color_used[16]; | 
														
													
														
															
																|  |  | int nb_opaque_colors, i, level, j, r, g, b; |  |  | int nb_opaque_colors, i, level, j, r, g, b; | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
												
													
														
															
																|  | @@ -138,18 +146,18 @@ static void guess_palette(uint32_t *rgba_palette, | 
														
													
														
															
																|  |  | if (nb_opaque_colors == 0) |  |  | if (nb_opaque_colors == 0) | 
														
													
														
															
																|  |  | return; |  |  | return; | 
														
													
														
															
																|  |  | 
 |  |  | 
 | 
														
													
														
															
																|  |  | j = nb_opaque_colors; |  |  |  | 
														
													
														
															
																|  |  |  |  |  | j = 0; | 
														
													
														
															
																|  |  | memset(color_used, 0, 16); |  |  | memset(color_used, 0, 16); | 
														
													
														
															
																|  |  | for(i = 0; i < 4; i++) { |  |  | for(i = 0; i < 4; i++) { | 
														
													
														
															
																|  |  | if (alpha[i] != 0) { |  |  | if (alpha[i] != 0) { | 
														
													
														
															
																|  |  | if (!color_used[colormap[i]])  { |  |  | if (!color_used[colormap[i]])  { | 
														
													
														
															
																|  |  | level = (0xff * j) / nb_opaque_colors; |  |  |  | 
														
													
														
															
																|  |  |  |  |  | level = level_map[nb_opaque_colors][j]; | 
														
													
														
															
																|  |  | r = (((subtitle_color >> 16) & 0xff) * level) >> 8; |  |  | r = (((subtitle_color >> 16) & 0xff) * level) >> 8; | 
														
													
														
															
																|  |  | g = (((subtitle_color >> 8) & 0xff) * level) >> 8; |  |  | g = (((subtitle_color >> 8) & 0xff) * level) >> 8; | 
														
													
														
															
																|  |  | b = (((subtitle_color >> 0) & 0xff) * level) >> 8; |  |  | b = (((subtitle_color >> 0) & 0xff) * level) >> 8; | 
														
													
														
															
																|  |  | rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24); |  |  | rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24); | 
														
													
														
															
																|  |  | color_used[colormap[i]] = (i + 1); |  |  | color_used[colormap[i]] = (i + 1); | 
														
													
														
															
																|  |  | j--; |  |  |  | 
														
													
														
															
																|  |  |  |  |  | j++; | 
														
													
														
															
																|  |  | } else { |  |  | } else { | 
														
													
														
															
																|  |  | rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) | |  |  | rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) | | 
														
													
														
															
																|  |  | ((alpha[i] * 17) << 24); |  |  | ((alpha[i] * 17) << 24); | 
														
													
												
													
														
															
																|  | 
 |