aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Fromme <oliver@fromme.com>2014-07-03 16:12:12 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-04 00:35:21 +0200
commitd73823286d5f38afc9c656fdeb943148afb35c5e (patch)
tree12ec0acb8f4f1ab5ef28da3f4ca2ad86ebaf4f77
parent3f0a3e9e127d067c5cf65640a44765c1ddd01622 (diff)
downloadffmpeg-d73823286d5f38afc9c656fdeb943148afb35c5e.tar.gz
avcodec/dvdsubdec: fix alpha in debuging code
improve the debugging function for saving subtitles to PPM files: Actually use the alpha channel. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/dvdsubdec.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 6b94292c04..39b0e25a13 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -462,10 +462,13 @@ static int find_smallest_bounding_rectangle(AVSubtitle *s)
}
#ifdef DEBUG
+#define ALPHA_MIX(A,BACK,FORE) (((255-(A)) * (BACK) + (A) * (FORE)) / 255)
static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h,
uint32_t *rgba_palette)
{
- int x, y, v;
+ int x, y, alpha;
+ uint32_t v;
+ int back[3] = {0, 255, 0}; /* green background */
FILE *f;
f = fopen(filename, "w");
@@ -480,9 +483,10 @@ static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h,
for(y = 0; y < h; y++) {
for(x = 0; x < w; x++) {
v = rgba_palette[bitmap[y * w + x]];
- putc((v >> 16) & 0xff, f);
- putc((v >> 8) & 0xff, f);
- putc((v >> 0) & 0xff, f);
+ alpha = v >> 24;
+ putc(ALPHA_MIX(alpha, back[0], (v >> 16) & 0xff), f);
+ putc(ALPHA_MIX(alpha, back[1], (v >> 8) & 0xff), f);
+ putc(ALPHA_MIX(alpha, back[2], (v >> 0) & 0xff), f);
}
}
fclose(f);
@@ -552,7 +556,7 @@ static int dvdsub_decode(AVCodecContext *avctx,
sub->start_display_time,
sub->end_display_time);
ppm_save(ppm_name, sub->rects[0]->pict.data[0],
- sub->rects[0]->w, sub->rects[0]->h, sub->rects[0]->pict.data[1]);
+ sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]);
}
#endif