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

Function reader_init

libhb/reader.c:242–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242static int reader_init( hb_work_object_t * w, hb_job_t * job )
243{
244 hb_work_private_t * r;
245
246 r = calloc( sizeof( hb_work_private_t ), 1 );
247 w->private_data = r;
248
249 r->h = job->h;
250 r->job = job;
251 r->title = job->title;
252 r->die = job->die;
253
254 r->demux.last_scr = AV_NOPTS_VALUE;
255 r->last_pts = AV_NOPTS_VALUE;
256
257 r->chapter_end = job->chapter_end;
258 if (!job->pts_to_start)
259 {
260 r->start_found = 1;
261 }
262 else
263 {
264 // The frame at the actual start time may not be an i-frame
265 // so can't be decoded without starting a little early.
266 // sync.c will drop early frames.
267 // Starting a little over 10 seconds early
268 r->pts_to_start = MAX(0, job->pts_to_start - 1000000);
269 }
270
271 if (job->pts_to_stop > 0)
272 {
273 r->duration = job->pts_to_start + job->pts_to_stop;
274 }
275 else if (job->frame_to_stop)
276 {
277 int frames = job->frame_to_start + job->frame_to_stop;
278 r->duration = (int64_t)frames * job->title->vrate.den * 90000 /
279 job->title->vrate.num;
280 }
281 else
282 {
283 int count = hb_list_count(job->title->list_chapter);
284
285 if (job->chapter_end > count || job->chapter_start > count || job->chapter_start > job->chapter_end)
286 {
287 hb_error("Invalid chapter start/end indexes");
288 return 1;
289 }
290
291 if (count == 0 || count <= job->chapter_end)
292 {
293 r->duration = job->title->duration;
294 }
295 else
296 {
297 r->duration = chapter_end_pts(job->title, job->chapter_end);
298 }
299 }

Callers

nothing calls this directly

Calls 5

hb_list_countFunction · 0.85
hb_errorFunction · 0.85
chapter_end_ptsFunction · 0.85
hb_list_itemFunction · 0.85
hb_reader_openFunction · 0.85

Tested by

no test coverage detected