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

Function alignStream

libhb/sync.c:465–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463}
464
465static void alignStream( sync_common_t * common, sync_stream_t * stream,
466 int64_t pts )
467{
468 if (hb_list_count(stream->in_queue) <= 0 ||
469 stream->type == SYNC_TYPE_SUBTITLE)
470 {
471 return;
472 }
473
474 hb_buffer_t * buf = hb_list_item(stream->in_queue, 0);
475 int64_t gap = buf->s.start - pts;
476
477 if (gap == 0)
478 {
479 return;
480 }
481 if (gap < 0)
482 {
483 int ii;
484
485 // Drop frames from other streams
486 for (ii = 0; ii < common->stream_count; ii++)
487 {
488 sync_stream_t * other_stream = &common->streams[ii];
489 if (stream == other_stream)
490 {
491 continue;
492 }
493 while (hb_list_count(other_stream->in_queue) > 0)
494 {
495 buf = hb_list_item(other_stream->in_queue, 0);
496 if (buf->s.start < pts)
497 {
498 if (other_stream->type == SYNC_TYPE_SUBTITLE &&
499 buf->s.stop > pts)
500 {
501 // Subtitle ends after start time, keep sub and
502 // adjust it's start time
503 buf->s.start = pts;
504 break;
505 }
506 else
507 {
508 hb_list_rem(other_stream->in_queue, buf);
509 hb_buffer_close(&buf);
510 }
511 }
512 else
513 {
514 // Fill the partial frame gap left after dropping frames
515 alignStream(common, other_stream, pts);
516 break;
517 }
518 }
519 }
520 }
521 else
522 {

Callers 1

alignStreamsFunction · 0.85

Calls 7

hb_list_countFunction · 0.85
hb_list_itemFunction · 0.85
hb_list_remFunction · 0.85
hb_buffer_closeFunction · 0.85
CreateSilenceBufFunction · 0.85
CreateBlackBufFunction · 0.85
hb_list_insertFunction · 0.85

Tested by

no test coverage detected