2 This file is part of the HandBrake source code.
3 Homepage: <http://handbrake.fr/>.
4 It may be used under the terms of the GNU General Public License. */
7 * Decoder for UTF-8 subtitles obtained from file input-sources.
9 * Input and output packet format is UTF-8 encoded text,
10 * with limited HTML-style markup (only <b>, <i>, and <u>).
12 * @author David Foster (davidfstr)
19 static int decutf8Init( hb_work_object_t * w, hb_job_t * job )
24 static int decutf8Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
25 hb_buffer_t ** buf_out )
27 hb_buffer_t * in = *buf_in;
28 hb_buffer_t * out = NULL;
30 // Pass the packets through without modification
33 // Warn if the subtitle's duration has not been passed through by the demuxer,
34 // which will prevent the subtitle from displaying at all
35 if ( out->stop == 0 ) {
36 hb_log( "decutf8sub: subtitle packet lacks duration" );
39 // We shouldn't be storing the extra NULL character,
40 // but the MP4 muxer expects this, unfortunately.
41 if ( out->size > 0 && out->data[out->size - 1] != '\0' ) {
42 // NOTE: out->size remains unchanged
43 hb_buffer_realloc( out, out->size + 1 );
44 out->data[out->size] = '\0';
52 static void decutf8Close( hb_work_object_t * w )
57 hb_work_object_t hb_decutf8sub =
60 "UTF-8 Subtitle Decoder",