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

Function checkFirstPts

libhb/sync.c:696–749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694}
695
696static void checkFirstPts( sync_common_t * common )
697{
698 int ii;
699 int64_t first_pts = INT64_MAX;
700 sync_stream_t * first_stream = NULL;
701
702 for (ii = 0; ii < common->stream_count; ii++)
703 {
704 sync_stream_t *stream = &common->streams[ii];
705 if (stream->type == SYNC_TYPE_SUBTITLE)
706 {
707 // only wait for audio and video
708 continue;
709 }
710
711 // If buffers are queued, find the lowest initial PTS
712 while (hb_list_count(stream->in_queue) > 0)
713 {
714 hb_buffer_t * buf = hb_list_item(stream->in_queue, 0);
715 if (buf->s.start != AV_NOPTS_VALUE)
716 {
717 // We require an initial pts for every stream
718 if (buf->s.start < first_pts)
719 {
720 first_pts = buf->s.start;
721 first_stream = stream;
722 }
723 break;
724 }
725 else
726 {
727 hb_list_rem(stream->in_queue, buf);
728 hb_buffer_close(&buf);
729 }
730 }
731 }
732 // We should *always* find a first pts because we let the queues
733 // fill before performing this test.
734 if (first_pts != INT64_MAX)
735 {
736 common->found_first_pts = 1;
737 // We may have buffers that have no timestamps (i.e. AV_NOPTS_VALUE).
738 // Compute these timestamps based on previous buffer's timestamp
739 // and duration.
740 computeInitialTS(common, first_stream);
741 // After this initialization, all AV_NOPTS_VALUE timestamps
742 // will be filled in by UpdateSCR()
743 }
744 else
745 {
746 // This should never happen
747 hb_error("checkFirstPts: No initial PTS found!\n");
748 }
749}
750
751static void addDelta( sync_common_t * common, int64_t start, int64_t delta)
752{

Callers 2

flushStreamsFunction · 0.85
SynchronizeFunction · 0.85

Calls 6

hb_list_countFunction · 0.85
hb_list_itemFunction · 0.85
hb_list_remFunction · 0.85
hb_buffer_closeFunction · 0.85
computeInitialTSFunction · 0.85
hb_errorFunction · 0.85

Tested by

no test coverage detected