| 623 | } |
| 624 | |
| 625 | static void computeInitialTS( sync_common_t * common, |
| 626 | sync_stream_t * first_stream ) |
| 627 | { |
| 628 | int ii; |
| 629 | hb_buffer_t * prev, * buf; |
| 630 | |
| 631 | // Process first_stream first since it has the initial PTS |
| 632 | prev = NULL; |
| 633 | for (ii = 0; ii < hb_list_count(first_stream->in_queue);) |
| 634 | { |
| 635 | buf = hb_list_item(first_stream->in_queue, ii); |
| 636 | |
| 637 | if (!UpdateSCR(first_stream, buf)) |
| 638 | { |
| 639 | hb_list_rem(first_stream->in_queue, buf); |
| 640 | } |
| 641 | else |
| 642 | { |
| 643 | ii++; |
| 644 | if (first_stream->type == SYNC_TYPE_VIDEO && prev != NULL) |
| 645 | { |
| 646 | double duration = buf->s.start - prev->s.start; |
| 647 | if (duration > 0) |
| 648 | { |
| 649 | prev->s.duration = duration; |
| 650 | prev->s.stop = buf->s.start; |
| 651 | } |
| 652 | } |
| 653 | prev = buf; |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | for (ii = 0; ii < common->stream_count; ii++) |
| 658 | { |
| 659 | sync_stream_t * stream = &common->streams[ii]; |
| 660 | |
| 661 | if (stream == first_stream) |
| 662 | { |
| 663 | // skip first_stream, already done |
| 664 | continue; |
| 665 | } |
| 666 | |
| 667 | int jj; |
| 668 | prev = NULL; |
| 669 | for (jj = 0; jj < hb_list_count(stream->in_queue);) |
| 670 | { |
| 671 | buf = hb_list_item(stream->in_queue, jj); |
| 672 | if (!UpdateSCR(stream, buf)) |
| 673 | { |
| 674 | // Subtitle put into delay queue, remove it from in_queue |
| 675 | hb_list_rem(stream->in_queue, buf); |
| 676 | } |
| 677 | else |
| 678 | { |
| 679 | jj++; |
| 680 | if (stream->type == SYNC_TYPE_VIDEO && prev != NULL) |
| 681 | { |
| 682 | double duration = buf->s.start - prev->s.start; |
no test coverage detected