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

Function findOverlap

libhb/sync.c:2646–2685  ·  view source on GitHub ↗

Create a list of buffers that overlap the given start time. Returns a list of buffers and the smallest stop time of those buffers.

Source from the content-addressed store, hash-verified

2644// Returns a list of buffers and the smallest stop time of those
2645// buffers.
2646static hb_buffer_t * findOverlap(subtitle_sanitizer_t *sanitizer,
2647 int64_t start, int64_t *stop_out)
2648{
2649 hb_buffer_list_t list;
2650 hb_buffer_t * buf;
2651 int64_t stop;
2652
2653 stop = INT64_MAX;
2654 hb_buffer_list_clear(&list);
2655 buf = hb_buffer_list_head(&sanitizer->list_current);
2656 while (buf != NULL)
2657 {
2658 if (buf->s.flags & HB_BUF_FLAG_EOF)
2659 {
2660 break;
2661 }
2662 if (buf->s.start > start)
2663 {
2664 if (stop > buf->s.start)
2665 {
2666 *stop_out = buf->s.start;
2667 }
2668 break;
2669 }
2670 if (buf->s.start <= start && start < buf->s.stop)
2671 {
2672 hb_buffer_t * tmp = hb_buffer_dup(buf);
2673 tmp->s.start = start;
2674 hb_buffer_list_append(&list, tmp);
2675 if (stop > buf->s.stop)
2676 {
2677 stop = buf->s.stop;
2678 *stop_out = stop;
2679 }
2680 }
2681 buf = buf->next;
2682 }
2683
2684 return hb_buffer_list_clear(&list);
2685}
2686
2687// Find all subtitles in the list that start "now" and overlap for
2688// some period of time. Create a new subtitle buffer that is the

Callers 1

mergeSubtitleOverlapsFunction · 0.85

Calls 4

hb_buffer_list_clearFunction · 0.85
hb_buffer_list_headFunction · 0.85
hb_buffer_dupFunction · 0.85
hb_buffer_list_appendFunction · 0.85

Tested by

no test coverage detected