Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2012-10-14 13:54:58 +0400
committerHendrik Leppkes <h.leppkes@gmail.com>2017-08-04 20:12:11 +0300
commit395aeaf9d9f0f3a438e61d839769029eeb539fc7 (patch)
tree45f648adec88b8f85f73a71b28f2dd609591010e /libavcodec
parent993b59fdd701aa5f600a295f10129b3707e91e14 (diff)
HACK: dvdsubdec: try to improve default dvd subtitle color guessing
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/dvdsubdec.c42
1 files changed, 9 insertions, 33 deletions
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index e18113c20c..1ff80f2ce5 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -147,16 +147,12 @@ static void guess_palette(DVDSubContext* ctx,
uint32_t *rgba_palette,
uint32_t subtitle_color)
{
- static const uint8_t level_map[4][4] = {
+ static const uint8_t level_map[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},
+ 0x00, 0xe0, 0x80, 0x20
};
- uint8_t color_used[16] = { 0 };
- int nb_opaque_colors, i, level, j, r, g, b;
+ int i, level, r, g, b;
uint8_t *colormap = ctx->colormap, *alpha = ctx->alpha;
if(ctx->has_palette) {
@@ -169,33 +165,13 @@ static void guess_palette(DVDSubContext* ctx,
for(i = 0; i < 4; i++)
rgba_palette[i] = 0;
- nb_opaque_colors = 0;
- for(i = 0; i < 4; i++) {
- if (alpha[i] != 0 && !color_used[colormap[i]]) {
- color_used[colormap[i]] = 1;
- nb_opaque_colors++;
- }
- }
-
- if (nb_opaque_colors == 0)
- return;
-
- j = 0;
- memset(color_used, 0, 16);
for(i = 0; i < 4; i++) {
if (alpha[i] != 0) {
- if (!color_used[colormap[i]]) {
- level = level_map[nb_opaque_colors - 1][j];
- r = (((subtitle_color >> 16) & 0xff) * level) >> 8;
- g = (((subtitle_color >> 8) & 0xff) * level) >> 8;
- b = (((subtitle_color >> 0) & 0xff) * level) >> 8;
- rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17U) << 24);
- color_used[colormap[i]] = (i + 1);
- j++;
- } else {
- rgba_palette[i] = (rgba_palette[color_used[colormap[i]] - 1] & 0x00ffffff) |
- ((alpha[i] * 17U) << 24);
- }
+ level = level_map[i];
+ r = (((subtitle_color >> 16) & 0xff) * level) >> 8;
+ g = (((subtitle_color >> 8) & 0xff) * level) >> 8;
+ b = (((subtitle_color >> 0) & 0xff) * level) >> 8;
+ rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17U) << 24);
}
}
}
@@ -400,7 +376,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
} else {
sub_header->rects[0]->nb_colors = 4;
guess_palette(ctx, (uint32_t*)sub_header->rects[0]->data[1],
- 0xffff00);
+ 0xffffff);
}
sub_header->rects[0]->x = x1;
sub_header->rects[0]->y = y1;