| 486 | } |
| 487 | |
| 488 | static int decsrtInit( hb_work_object_t * w, hb_job_t * job ) |
| 489 | { |
| 490 | hb_work_private_t * pv; |
| 491 | int i; |
| 492 | hb_chapter_t * chapter; |
| 493 | |
| 494 | pv = calloc( 1, sizeof( hb_work_private_t ) ); |
| 495 | if (pv == NULL) |
| 496 | { |
| 497 | goto fail; |
| 498 | } |
| 499 | |
| 500 | // For SRT files, libav will generate an SSA subtitle header for us. |
| 501 | // We will copy it into subtitle extradata after the decoder is |
| 502 | // initialized |
| 503 | |
| 504 | pv->ctx = decavsubInit(w, job); |
| 505 | if (pv->ctx == NULL) |
| 506 | { |
| 507 | goto fail; |
| 508 | } |
| 509 | |
| 510 | w->private_data = pv; |
| 511 | |
| 512 | pv->job = job; |
| 513 | pv->current_state = k_state_potential_new_entry; |
| 514 | pv->number_of_entries = 0; |
| 515 | pv->last_entry_number = 0; |
| 516 | pv->current_time = 0; |
| 517 | pv->subtitle = w->subtitle; |
| 518 | |
| 519 | /* |
| 520 | * Figure out the start and stop times from the chapters being |
| 521 | * encoded - drop subtitle not in this range. |
| 522 | */ |
| 523 | pv->start_time = 0; |
| 524 | for( i = 1; i < job->chapter_start; ++i ) |
| 525 | { |
| 526 | chapter = hb_list_item( job->list_chapter, i - 1 ); |
| 527 | if( chapter ) |
| 528 | { |
| 529 | pv->start_time += chapter->duration; |
| 530 | } else { |
| 531 | hb_error( "Could not locate chapter %d for SRT start time", i ); |
| 532 | } |
| 533 | } |
| 534 | pv->stop_time = pv->start_time; |
| 535 | for( i = job->chapter_start; i <= job->chapter_end; ++i ) |
| 536 | { |
| 537 | chapter = hb_list_item( job->list_chapter, i - 1 ); |
| 538 | if( chapter ) |
| 539 | { |
| 540 | pv->stop_time += chapter->duration; |
| 541 | } else { |
| 542 | hb_error( "Could not locate chapter %d for SRT start time", i ); |
| 543 | } |
| 544 | } |
| 545 |
nothing calls this directly
no test coverage detected