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

Function fixVideoOverlap

libhb/sync.c:927–974  ·  view source on GitHub ↗

Fix video overlaps that could not be corrected by dejitter

Source from the content-addressed store, hash-verified

925
926// Fix video overlaps that could not be corrected by dejitter
927static void fixVideoOverlap( sync_stream_t * stream )
928{
929 int drop = 0;
930 int64_t overlap;
931 hb_buffer_t * buf;
932
933 // If time goes backwards drop the frame.
934 // Check if subsequent buffers also overlap.
935 while ((buf = hb_list_item(stream->in_queue, 0)) != NULL)
936 {
937 // For video, an overlap is where the entire frame is
938 // in the past.
939 overlap = stream->next_pts - buf->s.stop;
940 if (overlap >= 0)
941 {
942 if (stream->drop == 0)
943 {
944 stream->drop_pts = buf->s.start;
945 }
946 hb_list_rem(stream->in_queue, buf);
947 // Video frame durations are assumed to be variable and are
948 // adjusted based on the start time of the next frame before
949 // we get to this point.
950 //
951 // Estimate duration dropped based on average framerate
952 stream->drop_duration +=
953 90000. * stream->common->job->title->vrate.den /
954 stream->common->job->title->vrate.num;
955 stream->drop++;
956 drop++;
957 saveChap(stream, buf);
958 hb_buffer_close(&buf);
959 }
960 else
961 {
962 break;
963 }
964 }
965
966 if (drop <= 0 && stream->drop > 0)
967 {
968 hb_log("sync: video time went backwards %d ms, dropped %d frames. "
969 "PTS %"PRId64"",
970 (int)stream->drop_duration / 90, stream->drop, stream->drop_pts);
971 stream->drop_duration = 0;
972 stream->drop = 0;
973 }
974}
975
976static void removeAudioJitter(sync_stream_t * stream, int stop)
977{

Callers 1

fixStreamTimestampsFunction · 0.85

Calls 5

hb_list_itemFunction · 0.85
hb_list_remFunction · 0.85
saveChapFunction · 0.85
hb_buffer_closeFunction · 0.85
hb_logFunction · 0.85

Tested by

no test coverage detected