* Initialize the work object **********************************************************************/
| 2306 | * Initialize the work object |
| 2307 | **********************************************************************/ |
| 2308 | static int syncVideoInit( hb_work_object_t * w, hb_job_t * job) |
| 2309 | { |
| 2310 | hb_work_private_t * pv; |
| 2311 | int ii; |
| 2312 | |
| 2313 | pv = calloc(1, sizeof(hb_work_private_t)); |
| 2314 | if (pv == NULL) goto fail; |
| 2315 | w->private_data = pv; |
| 2316 | pv->common = calloc(1, sizeof(sync_common_t)); |
| 2317 | if (pv->common == NULL) goto fail; |
| 2318 | pv->common->job = job; |
| 2319 | |
| 2320 | // count number of streams we need |
| 2321 | pv->common->stream_count = 1; |
| 2322 | pv->common->stream_count += hb_list_count(job->list_audio); |
| 2323 | pv->common->stream_count += hb_list_count(job->list_subtitle); |
| 2324 | pv->common->streams = calloc(pv->common->stream_count, |
| 2325 | sizeof(sync_stream_t)); |
| 2326 | |
| 2327 | // Allocate streams |
| 2328 | if (pv->common->streams == NULL) goto fail; |
| 2329 | |
| 2330 | // create audio and subtitle work list |
| 2331 | pv->common->list_work = hb_list_init(); |
| 2332 | if (pv->common->list_work == NULL) goto fail; |
| 2333 | |
| 2334 | // mutex to mediate access to pv->common |
| 2335 | pv->common->mutex = hb_lock_init(); |
| 2336 | if (pv->common->mutex == NULL) goto fail; |
| 2337 | |
| 2338 | // Set up video sync work object |
| 2339 | pv->stream = &pv->common->streams[0]; |
| 2340 | pv->stream->common = pv->common; |
| 2341 | pv->stream->in_queue = hb_list_init(); |
| 2342 | pv->stream->scr_delay_queue = hb_list_init(); |
| 2343 | pv->stream->max_len = SYNC_MAX_VIDEO_QUEUE_LEN; |
| 2344 | pv->stream->min_len = SYNC_MIN_VIDEO_QUEUE_LEN; |
| 2345 | if (pv->stream->in_queue == NULL) goto fail; |
| 2346 | pv->stream->delta_list = hb_list_init(); |
| 2347 | if (pv->stream->delta_list == NULL) goto fail; |
| 2348 | pv->stream->type = SYNC_TYPE_VIDEO; |
| 2349 | pv->stream->first_pts = AV_NOPTS_VALUE; |
| 2350 | pv->stream->next_pts = (int64_t)AV_NOPTS_VALUE; |
| 2351 | pv->stream->last_pts = (int64_t)AV_NOPTS_VALUE; |
| 2352 | pv->stream->last_scr_pts = (int64_t)AV_NOPTS_VALUE; |
| 2353 | pv->stream->last_scr_sequence = -1; |
| 2354 | pv->stream->last_duration = (int64_t)AV_NOPTS_VALUE; |
| 2355 | pv->stream->fifo_out = job->fifo_sync; |
| 2356 | pv->stream->video.id = job->title->video_id; |
| 2357 | |
| 2358 | w->fifo_in = job->fifo_raw; |
| 2359 | w->fifo_out = job->fifo_sync; |
| 2360 | |
| 2361 | if (job->pass_id == HB_PASS_ENCODE_FINAL) |
| 2362 | { |
| 2363 | /* We already have an accurate frame count from pass 1 */ |
| 2364 | hb_interjob_t * interjob = hb_interjob_get(job->h); |
| 2365 | pv->common->est_frame_count = interjob->frame_count; |
nothing calls this directly
no test coverage detected