MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / InitSubtitle

Function InitSubtitle

libhb/sync.c:2223–2303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2221}
2222
2223static int InitSubtitle( sync_common_t * common, int index )
2224{
2225 hb_work_object_t * w = NULL;
2226 hb_work_private_t * pv;
2227 hb_subtitle_t * subtitle;
2228
2229 subtitle = hb_list_item(common->job->list_subtitle, index);
2230 if (subtitle->fifo_raw == NULL)
2231 {
2232 // No input fifo, not configured
2233 return 0;
2234 }
2235 pv = calloc(1, sizeof(hb_work_private_t));
2236 if (pv == NULL) goto fail;
2237
2238 pv->common = common;
2239 pv->stream =
2240 &common->streams[1 + hb_list_count(common->job->list_audio) + index];
2241 pv->stream->common = common;
2242 pv->stream->in_queue = hb_list_init();
2243 pv->stream->scr_delay_queue = hb_list_init();
2244 pv->stream->max_len = SYNC_MAX_SUBTITLE_QUEUE_LEN;
2245 pv->stream->min_len = SYNC_MIN_SUBTITLE_QUEUE_LEN;
2246 if (pv->stream->in_queue == NULL) goto fail;
2247 pv->stream->delta_list = hb_list_init();
2248 if (pv->stream->delta_list == NULL) goto fail;
2249 pv->stream->type = SYNC_TYPE_SUBTITLE;
2250 pv->stream->first_pts = AV_NOPTS_VALUE;
2251 pv->stream->next_pts = (int64_t)AV_NOPTS_VALUE;
2252 pv->stream->last_pts = (int64_t)AV_NOPTS_VALUE;
2253 pv->stream->last_scr_pts = (int64_t)AV_NOPTS_VALUE;
2254 pv->stream->last_scr_sequence = -1;
2255 pv->stream->last_duration = (int64_t)AV_NOPTS_VALUE;
2256 pv->stream->subtitle.subtitle = subtitle;
2257 pv->stream->fifo_out = subtitle->fifo_sync;
2258 pv->stream->fifo_in = subtitle->fifo_in;
2259
2260 w = hb_get_work(common->job->h, WORK_SYNC_SUBTITLE);
2261 w->private_data = pv;
2262 w->subtitle = subtitle;
2263 w->fifo_in = subtitle->fifo_raw;
2264 w->fifo_out = subtitle->fifo_sync;
2265
2266 memset(&pv->stream->subtitle.sanitizer, 0,
2267 sizeof(pv->stream->subtitle.sanitizer));
2268 if (subtitle->format == TEXTSUB && subtitle->config.dest == PASSTHRUSUB &&
2269 (common->job->mux & HB_MUX_MASK_MP4))
2270 {
2271 // Merge overlapping subtitles since mpv tx3g does not support them
2272 pv->stream->subtitle.sanitizer.merge = 1;
2273 }
2274 // PGS & DVB subtitles don't need to be linked because there are explicit
2275 // "clear" subtitle packets that indicate the end time of the
2276 // previous subtitle
2277 if (subtitle->config.dest == PASSTHRUSUB &&
2278 subtitle->source != PGSSUB &&
2279 subtitle->source != DVBSUB)
2280 {

Callers 1

syncVideoInitFunction · 0.85

Calls 7

hb_list_itemFunction · 0.85
hb_list_countFunction · 0.85
hb_list_initFunction · 0.85
hb_get_workFunction · 0.85
hb_buffer_list_clearFunction · 0.85
hb_list_addFunction · 0.85
hb_list_closeFunction · 0.85

Tested by

no test coverage detected