| 585 | } |
| 586 | |
| 587 | static int hb_vfr_work( hb_filter_object_t * filter, |
| 588 | hb_buffer_t ** buf_in, |
| 589 | hb_buffer_t ** buf_out ) |
| 590 | { |
| 591 | hb_filter_private_t * pv = filter->private_data; |
| 592 | hb_buffer_t * in = *buf_in; |
| 593 | hb_buffer_t * out = NULL; |
| 594 | |
| 595 | *buf_in = NULL; |
| 596 | *buf_out = NULL; |
| 597 | |
| 598 | if (in->s.flags & HB_BUF_FLAG_EOF) |
| 599 | { |
| 600 | hb_buffer_list_t list; |
| 601 | hb_buffer_t * next; |
| 602 | int counter = 2; |
| 603 | |
| 604 | // Flush the delay_queue and frame rate adjustment |
| 605 | hb_buffer_list_clear(&list); |
| 606 | while ((next = hb_fifo_get(pv->delay_queue)) != NULL) |
| 607 | { |
| 608 | |
| 609 | /* We can't use the given time stamps. Previous frames |
| 610 | might already have been extended, throwing off the |
| 611 | raw values fed to render.c. Instead, their |
| 612 | stop and start times are stored in arrays. |
| 613 | The 4th cached frame will be the to use. |
| 614 | If it needed its duration extended to make up |
| 615 | lost time, it will have happened above. */ |
| 616 | next->s.start = pv->last_start[counter]; |
| 617 | next->s.stop = pv->last_stop[counter--]; |
| 618 | |
| 619 | hb_buffer_list_append(&list, adjust_frame_rate(pv, next)); |
| 620 | } |
| 621 | hb_buffer_list_append(&list, flush_frames(pv)); |
| 622 | hb_buffer_list_append(&list, in); |
| 623 | *buf_out = hb_buffer_list_clear(&list); |
| 624 | return HB_FILTER_DONE; |
| 625 | } |
| 626 | |
| 627 | // If there is a gap between the last stop and the current start |
| 628 | // then frame(s) were dropped. |
| 629 | if (hb_fifo_size(pv->delay_queue) > 0 && in->s.start > pv->last_stop[0]) |
| 630 | { |
| 631 | /* We need to compensate for the time lost by dropping frame(s). |
| 632 | Spread its duration out in quarters, because usually dropped frames |
| 633 | maintain a 1-out-of-5 pattern and this spreads it out amongst |
| 634 | the remaining ones. Store these in the lost_time array, which |
| 635 | has 4 slots in it. Because not every frame duration divides |
| 636 | evenly by 4, and we can't lose the remainder, we have to go |
| 637 | through an awkward process to preserve it in the 4th array index. |
| 638 | */ |
| 639 | int64_t temp_duration = in->s.start - pv->last_stop[0]; |
| 640 | pv->lost_time[0] += (temp_duration / 4); |
| 641 | pv->lost_time[1] += (temp_duration / 4); |
| 642 | pv->lost_time[2] += (temp_duration / 4); |
| 643 | pv->lost_time[3] += ( temp_duration - 3 * (temp_duration / 4) ); |
| 644 |
nothing calls this directly
no test coverage detected