summaryrefslogtreecommitdiffstats
path: root/libhb/decutf8sub.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-04-13 16:22:16 +0000
committerjstebbins <[email protected]>2014-04-13 16:22:16 +0000
commit6db1a1e531ad62ba977f4587fb9011b0fd0b3416 (patch)
tree2c6882e9344b8181a11238835ae163d52e98e49e /libhb/decutf8sub.c
parente6ca45c979ec69bd1736bc943063083b08ce1914 (diff)
Convert all text subtitles to ASS subs
Add support for font color to tx3g. Allow more than one style flag at time in tx3g. Add positioning support to CC subs git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6163 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/decutf8sub.c')
-rw-r--r--libhb/decutf8sub.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/libhb/decutf8sub.c b/libhb/decutf8sub.c
index fac5b31a8..b8ea9bf5f 100644
--- a/libhb/decutf8sub.c
+++ b/libhb/decutf8sub.c
@@ -19,15 +19,33 @@
#include <stdlib.h>
#include <stdio.h>
#include "hb.h"
+#include "decsrtsub.h"
+
+struct hb_work_private_s
+{
+ int line; // SSA line number
+};
static int decutf8Init(hb_work_object_t *w, hb_job_t *job)
{
+ hb_work_private_t * pv;
+ pv = calloc( 1, sizeof( hb_work_private_t ) );
+ if (pv == NULL)
+ return 1;
+ w->private_data = pv;
+
+ // Generate generic SSA Script Info.
+ int height = job->title->height - job->crop[0] - job->crop[1];
+ int width = job->title->width - job->crop[2] - job->crop[3];
+ hb_subtitle_add_ssa_header(w->subtitle, width, height);
+
return 0;
}
static int decutf8Work(hb_work_object_t * w,
hb_buffer_t **buf_in, hb_buffer_t **buf_out)
{
+ hb_work_private_t * pv = w->private_data;
// Pass the packets through without modification
hb_buffer_t *out = *buf_in;
@@ -40,22 +58,19 @@ static int decutf8Work(hb_work_object_t * w,
hb_log("decutf8sub: subtitle packet lacks duration");
}
- // We shouldn't be storing the extra NULL character,
- // but the MP4 muxer expects this, unfortunately.
- if (out->size > 0 && out->data[out->size - 1] != '\0')
- {
- hb_buffer_realloc(out, ++out->size);
- out->data[out->size - 1] = '\0';
- }
+ hb_srt_to_ssa(out, ++pv->line);
*buf_in = NULL;
*buf_out = out;
+
+ if (out->size == 0)
+ return HB_WORK_DONE;
return HB_WORK_OK;
}
static void decutf8Close(hb_work_object_t *w)
{
- // nothing
+ free(w->private_data);
}
hb_work_object_t hb_decutf8sub =