From b6d6afc07f0708f207ce51afb6b4967d90f52d01 Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 27 Jul 2013 09:24:51 +0200 Subject: [PATCH] libeplayer3/continer_ass: crude hack to improve subtitle readability --- libeplayer3/container/container_ass.c | 83 ++++++++++++++++++------- libeplayer3/output/writer/framebuffer.c | 11 ++-- 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/libeplayer3/container/container_ass.c b/libeplayer3/container/container_ass.c index 379daaf..fa814ee 100644 --- a/libeplayer3/container/container_ass.c +++ b/libeplayer3/container/container_ass.c @@ -293,30 +293,21 @@ void checkRegions() /* store a display region for later release */ void storeRegion(unsigned int x, unsigned int y, unsigned int w, unsigned int h, time_t undisplay) { - region_t* new; + region_t** new = &firstRegion; ass_printf(100, "%d %d %d %d %ld\n", x, y, w, h, undisplay); - - if (firstRegion == NULL) - { - firstRegion = malloc(sizeof(region_t)); - new = firstRegion; - } else - { - new = firstRegion; - while (new->next != NULL) - new = new->next; - - new->next = malloc(sizeof(region_t)); - new = new->next; - } - new->next = NULL; - new->x = x; - new->y = y; - new->w = w; - new->h = h; - new->undisplay = undisplay; + while (*new) + new = &(*new)->next; + + *new = malloc(sizeof(region_t)); + + (*new)->next = NULL; + (*new)->x = x; + (*new)->y = y; + (*new)->w = w; + (*new)->h = h; + (*new)->undisplay = undisplay; } /* **************************** */ @@ -397,10 +388,53 @@ static void ASSThread(Context_t *context) { if (change != 0) releaseRegions(); - while (context && context->playback && context->playback->isPlaying && - (img) && (change != 0)) + time_t now = time(NULL); + time_t undisplay = now + 10; + + if (ass_track && ass_track->events) + undisplay = now + (ass_track->events->Duration + 500) / 90000; + + if (shareFramebuffer) { + ASS_Image *it; + int x0 = screen_width - 1; + int y0 = screen_height - 1; + int x1 = 0; + int y1 = 0; + for (it = img; it; it = it->next) { + if (it->w && it->h) { + if (it->dst_x < x0) + x0 = it->dst_x; + if (it->dst_y < y0) + y0 = it->dst_y; + if (it->dst_x + it->w > x1) + x1 = it->dst_x + it->w; + if (it->dst_y + it->h > y1) + y1 = it->dst_y + it->h; + } + } + if (x1 > 0 && y1 > 0) + { + int x, y; + unsigned char *dst = destination + y0 * destStride + 4 * x0; + int destStrideDiff = destStride - (x1 - x0 + 1) * 4; + for (y = y0; y <= y1; y++) { + for (x = x0; x <= x1; x++) { + *dst++ = 128; + *dst++ = 128; + *dst++ = 128; + *dst++ = 128; + } + dst += destStrideDiff; + } + storeRegion(x0, y0, x1 - x0 + 1, y1 - y0 + 1, undisplay); + needsBlit = 1; + } + } + + while (context && context->playback && context->playback->isPlaying && img) { WriterFBCallData_t out; +#if 0 time_t now = time(NULL); time_t undisplay = now + 10; @@ -408,6 +442,7 @@ static void ASSThread(Context_t *context) { { undisplay = now + (ass_track->events->Duration + 500) / 90000; } +#endif ass_printf(100, "w %d h %d s %d x %d y %d c %d chg %d now %ld und %ld\n", img->w, img->h, img->stride, @@ -433,8 +468,10 @@ static void ASSThread(Context_t *context) { out.destination = destination; out.destStride = destStride; +#if 0 storeRegion(img->dst_x, img->dst_y, img->w, img->h, undisplay); +#endif if (shareFramebuffer) { diff --git a/libeplayer3/output/writer/framebuffer.c b/libeplayer3/output/writer/framebuffer.c index c6666b8..644e897 100644 --- a/libeplayer3/output/writer/framebuffer.c +++ b/libeplayer3/output/writer/framebuffer.c @@ -155,10 +155,13 @@ static int writeData(void* _call) { k = ((unsigned)src[x]) * opacity / 256; #if 1 // HAVE_SPARK_HARDWARE - *dst++ = b; - *dst++ = g; - *dst++ = r; - *dst++ = k; + if (src[x]) { + *dst++ = b; + *dst++ = g; + *dst++ = r; + *dst++ = k; + } else + dst += 4; #else ck = 255 - k; t = *dst;