diff options
author | jstebbins <[email protected]> | 2014-08-27 20:43:16 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-08-27 20:43:16 +0000 |
commit | f96c1c84998a1e13bd37d07f1d33e9b375542f89 (patch) | |
tree | 87739ce2598b25e0d7b341e093f2a4b7c64ad702 /libhb/sync.c | |
parent | c72bb7dfa8ff86e45f15a8c103a5d8fd992c0177 (diff) |
libhb: fix merging of ssa subtitles
mergeSubtitle was originally written for pure text subs. But now the
subtitle buffers have extra ssa formatting that needs different treatment.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6374 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/sync.c')
-rw-r--r-- | libhb/sync.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/libhb/sync.c b/libhb/sync.c index 7181e444a..c9ab19279 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -303,6 +303,37 @@ void syncVideoClose( hb_work_object_t * w ) #define ABS(a) ((a) < 0 ? -(a) : (a)) +static hb_buffer_t * merge_ssa(hb_buffer_t *a, hb_buffer_t *b) +{ + int len, ii; + char *text; + hb_buffer_t *buf = hb_buffer_init(a->size + b->size); + buf->s = a->s; + + // Find the text in the second SSA sub + text = (char*)b->data; + for (ii = 0; ii < 8; ii++) + { + text = strchr(text, ','); + if (text == NULL) + break; + text++; + } + if (text != NULL) + { + len = sprintf((char*)buf->data, "%s\n%s", a->data, text); + if (len >= 0) + buf->size = len + 1; + } + else + { + memcpy(buf->data, a->data, a->size); + buf->size = a->size; + } + + return buf; +} + static hb_buffer_t * mergeSubtitles(subtitle_sanitizer_t *sanitizer, int end) { hb_buffer_t *a, *b, *buf, *out = NULL, *last = NULL; @@ -310,9 +341,10 @@ static hb_buffer_t * mergeSubtitles(subtitle_sanitizer_t *sanitizer, int end) do { a = sanitizer->list_current; + b = a != NULL ? a->next : NULL; buf = NULL; - if (a != NULL && end) + if (a != NULL && b == NULL && end) { sanitizer->list_current = a->next; if (sanitizer->list_current == NULL) @@ -322,8 +354,6 @@ static hb_buffer_t * mergeSubtitles(subtitle_sanitizer_t *sanitizer, int end) } else if (a != NULL && a->s.stop != AV_NOPTS_VALUE) { - b = a->next; - if (!sanitizer->merge) { sanitizer->list_current = a->next; @@ -344,9 +374,7 @@ static hb_buffer_t * mergeSubtitles(subtitle_sanitizer_t *sanitizer, int end) a->next = NULL; b->s.start = a->s.stop; - buf = hb_buffer_init(a->size + b->size); - buf->s = a->s; - sprintf((char*)buf->data, "%s\n%s", a->data, b->data); + buf = merge_ssa(a, b); hb_buffer_close(&a); if (b->s.stop != AV_NOPTS_VALUE && ABS(b->s.stop - b->s.start) <= 18000) |