3 Copyright (c) 2003-2015 HandBrake Team
4 This file is part of the HandBrake source code
5 Homepage: <http://handbrake.fr/>.
6 It may be used under the terms of the GNU General Public License v2.
7 For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
11 * Decoder for UTF-8 subtitles obtained from file input-sources.
13 * Input and output packet format is UTF-8 encoded text,
14 * with limited HTML-style markup (only <b>, <i>, and <u>).
16 * @author David Foster (davidfstr)
22 #include "decsrtsub.h"
24 struct hb_work_private_s
26 int line
; // SSA line number
29 static int decutf8Init(hb_work_object_t
*w
, hb_job_t
*job
)
31 hb_work_private_t
* pv
;
32 pv
= calloc( 1, sizeof( hb_work_private_t
) );
37 // Generate generic SSA Script Info.
38 int height
= job
->title
->geometry
.height
- job
->crop
[0] - job
->crop
[1];
39 int width
= job
->title
->geometry
.width
- job
->crop
[2] - job
->crop
[3];
40 hb_subtitle_add_ssa_header(w
->subtitle
, "Arial",
41 .066 * job
->title
->geometry
.height
,
47 static int decutf8Work(hb_work_object_t
* w
,
48 hb_buffer_t
**buf_in
, hb_buffer_t
**buf_out
)
50 hb_work_private_t
* pv
= w
->private_data
;
51 hb_buffer_t
* in
= *buf_in
;
52 hb_buffer_t
*out
= *buf_in
;
55 if (in
->s
.flags
& HB_BUF_FLAG_EOF
)
61 // Warn if the subtitle's duration has not been passed through by the
62 // demuxer, which will prevent the subtitle from displaying at all
65 hb_log("decutf8sub: subtitle packet lacks duration");
68 hb_srt_to_ssa(out
, ++pv
->line
);
69 out
->s
.frametype
= HB_FRAME_SUBTITLE
;
75 static void decutf8Close(hb_work_object_t
*w
)
77 free(w
->private_data
);
80 hb_work_object_t hb_decutf8sub
=
83 "UTF-8 Subtitle Decoder",