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

Function QueueBuffer

libhb/sync.c:2055–2132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2053}
2054
2055static void QueueBuffer( sync_stream_t * stream, hb_buffer_t * buf )
2056{
2057 hb_lock(stream->common->mutex);
2058
2059 while (hb_list_count(stream->in_queue) > stream->max_len &&
2060 !stream->done && !stream->common->job->done &&
2061 !*stream->common->job->die)
2062 {
2063 // If the in_queue is full, we have to force some output to
2064 // unblock it. Blocking here would back up the pipeline and
2065 // stall out reader eventually.
2066 hb_unlock(stream->common->mutex);
2067 Synchronize(stream);
2068 hb_lock(stream->common->mutex);
2069 }
2070
2071 // Reader can change job->reader_pts_offset after initialization
2072 // and before we receive the first buffer here. Calculate
2073 // common->pts_to_start here since this is the first opportunity where
2074 // all the necessary information exists.
2075 if (stream->common->pts_to_start == AV_NOPTS_VALUE)
2076 {
2077 hb_job_t * job = stream->common->job;
2078 if (job->pts_to_start > 0)
2079 {
2080 stream->common->start_pts =
2081 stream->common->pts_to_start =
2082 MAX(0, job->pts_to_start - job->reader_pts_offset);
2083 }
2084 }
2085
2086 // Render offset is only useful for decoders, which are all
2087 // upstream of sync. Squash it.
2088 buf->s.renderOffset = AV_NOPTS_VALUE;
2089
2090 hb_deep_log(11,
2091 "type %8s id %x scr seq %d start %"PRId64" stop %"PRId64" dur %f",
2092 getStreamType(stream), getStreamId(stream), buf->s.scr_sequence,
2093 buf->s.start, buf->s.stop, buf->s.duration);
2094
2095 if (stream->common->found_first_pts)
2096 {
2097 if (UpdateSCR(stream, buf) > 0)
2098 {
2099 // Apply any stream slips.
2100 // Stream slips will only temporarily differ between
2101 // the streams. The slips get updated in applyDeltas. When
2102 // all the deltas are absorbed, the stream slips will all
2103 // be equal.
2104 buf->s.start -= stream->pts_slip;
2105 if (buf->s.stop != AV_NOPTS_VALUE)
2106 {
2107 buf->s.stop -= stream->pts_slip;
2108 }
2109
2110 SortedQueueBuffer(stream, buf);
2111 updateDuration(stream);
2112 }

Callers 3

syncVideoWorkFunction · 0.85
syncAudioWorkFunction · 0.85
syncSubtitleWorkFunction · 0.85

Calls 13

hb_lockFunction · 0.85
hb_list_countFunction · 0.85
hb_unlockFunction · 0.85
SynchronizeFunction · 0.85
hb_deep_logFunction · 0.85
getStreamTypeFunction · 0.85
getStreamIdFunction · 0.85
UpdateSCRFunction · 0.85
SortedQueueBufferFunction · 0.85
updateDurationFunction · 0.85
saveChapFunction · 0.85
hb_buffer_closeFunction · 0.85

Tested by

no test coverage detected