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

Function applyDeltas

libhb/sync.c:764–845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

762}
763
764static void applyDeltas( sync_common_t * common )
765{
766 int ii;
767
768 // Apply delta to any applicable buffers in the queue
769 for (ii = 0; ii < common->stream_count; ii++)
770 {
771 sync_stream_t * stream = &common->streams[ii];
772
773 // Make adjustments for deltas found in other streams
774 sync_delta_t * delta = hb_list_item(stream->delta_list, 0);
775 if (delta != NULL)
776 {
777 int jj, index = -1;
778 int64_t prev_start, max = 0;
779 hb_buffer_t * buf;
780
781 prev_start = stream->next_pts;
782 for (jj = 0; jj < hb_list_count(stream->in_queue); jj++)
783 {
784 buf = hb_list_item(stream->in_queue, jj);
785 if (stream->type == SYNC_TYPE_SUBTITLE)
786 {
787 if (buf->s.start > delta->pts)
788 {
789 // absorb gaps in subtitles as soon as possible
790 index = jj;
791 break;
792 }
793 }
794 else if (buf->s.start > delta->pts)
795 {
796 // absorb gap in largest gap found in this stream.
797 if (buf->s.start - prev_start > max)
798 {
799 max = buf->s.start - prev_start;
800 index = jj;
801 }
802 if (stream->type == SYNC_TYPE_AUDIO && max >= delta->delta)
803 {
804 // absorb gaps in audio as soon as possible
805 // when there is a gap that will absorb it.
806 break;
807 }
808 }
809 prev_start = buf->s.start;
810 }
811
812 if (index >= 0)
813 {
814 for (jj = index; jj < hb_list_count(stream->in_queue); jj++)
815 {
816 buf = hb_list_item(stream->in_queue, jj);
817 buf->s.start -= delta->delta;
818 if (buf->s.stop != AV_NOPTS_VALUE)
819 {
820 buf->s.stop -= delta->delta;
821 }

Callers 2

fixAudioGapFunction · 0.85
QueueBufferFunction · 0.85

Calls 3

hb_list_itemFunction · 0.85
hb_list_countFunction · 0.85
hb_list_remFunction · 0.85

Tested by

no test coverage detected