diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/dectx3gsub.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libhb/dectx3gsub.c b/libhb/dectx3gsub.c index 7a38b1d84..9cfc031ac 100644 --- a/libhb/dectx3gsub.c +++ b/libhb/dectx3gsub.c @@ -77,7 +77,7 @@ static int write_ssa_markup(char *dst, StyleRecord *style) return strlen(dst); } -static hb_buffer_t *tx3g_decode_to_ssa(hb_buffer_t *in, int line) +static hb_buffer_t *tx3g_decode_to_ssa(hb_work_private_t *pv, hb_buffer_t *in) { uint8_t *pos = in->data; uint8_t *end = in->data + in->size; @@ -158,11 +158,13 @@ static hb_buffer_t *tx3g_decode_to_ssa(hb_buffer_t *in, int line) if ( out == NULL ) goto fail; uint8_t *dst = out->data; + uint8_t *start; int charIndex = 0; int styleIndex = 0; - sprintf((char*)dst, "%d,,Default,,0,0,0,,", line); + sprintf((char*)dst, "%d,,Default,,0,0,0,,", pv->line); dst += strlen((char*)dst); + start = dst; for (pos = text, end = text + textLength; pos < end; pos++) { if (IS_10xxxxxx(*pos)) @@ -200,6 +202,13 @@ static hb_buffer_t *tx3g_decode_to_ssa(hb_buffer_t *in, int line) } charIndex++; } + if (start == dst) + { + // No text in the subtitle. This sub is just filler, drop it. + free(styleRecords); + hb_buffer_close(&out); + return NULL; + } *dst = '\0'; dst++; @@ -263,7 +272,7 @@ static int dectx3gWork( hb_work_object_t * w, hb_buffer_t ** buf_in, return HB_WORK_DONE; } - *buf_out = tx3g_decode_to_ssa(in, ++pv->line); + *buf_out = tx3g_decode_to_ssa(pv, in); return HB_WORK_OK; } |