summaryrefslogtreecommitdiffstats
path: root/libhb/sync.c
Commit message (Collapse)AuthorAgeFilesLines
* decsrt: fix p-to-p start time after seekingJohn Stebbins2017-04-151-5/+24
| | | | | | | Reader can skip data at the beginning of the file. We were not informing decsrt how much was skipped when pts_to_start caused the skip. Fixes https://forum.handbrake.fr/viewtopic.php?f=11&t=36258
* sync: fix small video dejitter errorJohn Stebbins2017-03-031-0/+5
| | | | | | | | | | | | | This very small error snowballs into a crash in x264 :-p If the amount of jitter on the first frame in the queue was small (about 1 tick) then jitter would not be removed from that frame. This extra tick of jitter can appear on different frames depending on when frame arrives and how much has been queued. This very small amount of randomness lead to problems in the VFR filter. A frame duration difference as small as 1 tick can lead to an extra frame getting duplicated when doing CFR. When doing 2 pass encoding, this extra frame causes x264 to crash at the end of the 2nd pass.
* sync: fix sync problem with delayed streamsJohn Stebbins2017-02-181-5/+5
| | | | | | If a stream is delayed by a large amount and the first timestamp from the stream is AV_NOPTS_VALUE, sync assumed a 0 timestamp which caused loss of sync. Drop the buffer instead.
* Update copyright dates to 2017.Bradley Sepos2017-01-011-1/+1
|
* sync: don't delay subtitles when duration is knownJohn Stebbins2016-12-151-5/+9
| | | | | | | | | | | | | | Delayed subtitles were causing incorrect muxing in mkv. The mkv muxer writes chunks where all samples should be relative to a chunk's base timestamp. When the subtitle is delayed long enough for a new chunk to start before it gets muxed, the calculated offset to the chunk's base time is negative (which is illegal). Note that this is still a possibility with subtitles that must be delayed (e.g. CC and VOBSUB) because the duration is not known until the next subtitle's start time is known. The only fix for this would be to add a special subtitle parsing pass that caches subtitle timestamps before the main encoding pass is performed.
* sync: fix compiler warningJohn Stebbins2016-12-151-1/+1
|
* sync: fix PtoP hangJohn Stebbins2016-11-211-7/+10
| | | | | | reader adjusts pts_to_start after seeking. if the adjustment makes pts_to_start == 0, sync didn't properly search for the start point and hung.
* sync: more robust handling of p-to-p end timeJohn Stebbins2016-09-261-2/+2
| | | | | Continue processing input queues until none are full after p-to-p end time is reached.
* sync: fix off-by-one errorJohn Stebbins2016-09-261-1/+1
|
* sync: fix a hang with p-to-p end timeJohn Stebbins2016-09-261-1/+22
| | | | | | When a stream is finished, we need to see if there were any other streams that were pending. The other streams could be blocking on a condition variable and need to be unstuck.
* sync: fix use of closed bufferJohn Stebbins2016-09-201-7/+12
| | | | Fixes https://github.com/HandBrake/HandBrake/issues/328
* sync: fix small memory leakJohn Stebbins2016-09-091-0/+3
| | | | an hb_list_t was not freed at the end of an encode
* sync: fix race condition hangJohn Stebbins2016-08-291-1/+8
| | | | | wake up potentially waiting sync threads when p-to-p end point is reached.
* sync: fix audio resamplingJohn Stebbins2016-08-081-0/+1
| | | | The output buffer size was not set correctly after resampling
* sync: speed up p-to-p finalization when there are subtitlesJohn Stebbins2016-06-101-0/+46
| | | | | | | | | | | | | When doing point-to-point encoding, subtitles can cause a long delay in finishing the job when the stop point is reached. This is due to the sparse nature of subtitles. We may not even see any additional subtitle till we reach the end of the file. So when all audio and video streams have reached the end point, force the termination of all subtitle streams by pushing an end-of-stream buffer into each subtitles input fifo. This will cause each subtitle sync worker to wake and return HB_WORK_DONE.
* sync: fix potential stall when searching for p-to-p startJohn Stebbins2016-06-101-2/+11
| | | | A full input queue could cause the search to stall
* sync: when p-to-p end reached return HB_WORK_DONE asapJohn Stebbins2016-06-101-0/+12
|
* sync: fix some p-to-p issuesJohn Stebbins2016-06-091-72/+123
| | | | | | | | | After finding the start position, some data prior to the start from other streams could leak through causing duplicate timestamps in the output. Also, improves alignment of stop times of all streams when a stop time is set.
* sync: fix CC burn-inJohn Stebbins2016-05-251-1/+2
| | | | | | It was dropping subtitles because the "end of CC" marker buffer can have the same time as the next valid CC which triggered the subtitle overlap dropping code.
* sync: correct timestamp discontinuities in sync instead of reader (#192)John Stebbins2016-05-241-42/+459
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * sync: correct timestamp discontinuities in sync instead of reader This patch passes discontinuity information through the pipeline till it reaches sync.c. The timestamps are passed through the pipeline as read and unmodified to sync.c (instead of attempting to correct discontinuities in reader). In sync, when we see a discontinuity, we know where the next timestamp should be based on the timestamp and duration of the previous buffer (before the discontinuity). So we calculate an "SCR" offset based on the timestamp after the discontinuity and what we calculate it should be. The old discontinuity handling code was broken due to the following. The MPEG STD timing model relies heavily on the decoder having an STC that is phase lock looped to the PCRs in the stream. When decoding a broadcast stream, the decoder can count on the time measure between PCRs using the STC to match to a high degree of accuracy. I.e. STC - lastSTC == PCR - lastPCR. When a discontinuity occurs, the decoder calculates a new PCR offset = PCR - STC. I.e. the offset is the new PCR value minus what it would have been if there had been no discontinuity. The above does not work without a reliable STC, which we do not have. We have been attempting to approximate one by avereraging the duration of received packets and extrapolating an "STC" based on the last PTS and the average packet duration. But this is highly variable and unreliable. * decavcodec: fix data type of next_pts It needs to be double so that partial ticks are not lost * deccc608sub: clarify comment * sync: allow queueing more audio Audio is small, and there is often a significant amount of audio in the stream before the first video frame. * sync: improve handling of damaged streams When data is missing, the audio decoder was extrapolating timestamps from the last pts before the error caused by the missing data which caused sync issues. Also, missing data can cause the video decoder to output a frame out of order with the wrong scr sequence. Drop such frames.
* sync: fill queues completelyJohn Stebbins2016-05-211-1/+1
| | | | | | essentially an off-by-one error. OutputBuffer had to wait for one more buffer before any output was performed after the queue should have already been filled to it's minimum levels.
* sync: silence compiler warningJohn Stebbins2016-05-201-1/+1
|
* sync: detect and drop 0 duration initial video frameJohn Stebbins2016-05-191-7/+12
|
* sync: increse min video queue depth for deeper dejitteringJohn Stebbins2016-05-181-1/+1
|
* sync: fix potential dropped chapter marksJohn Stebbins2016-05-181-10/+31
|
* sync: improve code readabilityJohn Stebbins2016-05-181-18/+19
|
* work: don't allocate fifos that are not needed for indepth_scanJohn Stebbins2016-05-181-6/+0
|
* sync: set start and stop when resampling audioJohn Stebbins2016-05-181-0/+2
| | | | | It's not strictly necessary because it gets done elsewhere as well. But putting it here makes the code more understandable.
* sync: fix progress statistics when title longer than sum of chaptersJohn Stebbins2016-05-181-1/+21
|
* sync: dejitter larger video jittersJohn Stebbins2016-05-181-1/+1
|
* sync: handle coarsely interleaved streams betterJohn Stebbins2016-05-181-2/+2
| | | | | ... by allowing a deeper initial buffer when looking for the fist PTS of each stream.
* sync: add timestamp loggingJohn Stebbins2016-05-181-3/+41
| | | | ... at log level 11 ;)
* sync: move comment to more appropriate locationJohn Stebbins2016-05-181-10/+12
|
* sync: do not drop audio before frame p-to-p startJohn Stebbins2016-05-181-11/+33
| | | | | | | We were dropping all buffers before the start frame was found regardless of the buffers start time. Now we keep track of the start time of the last video frame seen and only drop buffers that start before that frame.
* sync: estimate video frame drop duration betterJohn Stebbins2016-05-171-1/+8
|
* sync: cosmeticsJohn Stebbins2016-05-171-39/+39
|
* sync: drop overlapping subtitlesJohn Stebbins2016-05-171-6/+43
|
* sync: interleave subtitle output with other streamsJohn Stebbins2016-05-171-20/+3
|
* sync: send output directly to sync output fifosJohn Stebbins2016-05-171-43/+54
| | | | | | | | since sync interleaves it's output by PTS, the stream of the incoming buffer is mostly not the same as the stream of the outgoing buffer. This causes a delay in the data to get to it's respective fifo until the sync work function for the output stream is called next. Writing directly to the output fifo fixes this.
* sync: sanitize subtitles in OutputBufferJohn Stebbins2016-05-171-31/+53
|
* sync: handle initial pts < 0 betterJohn Stebbins2016-05-171-99/+102
|
* sync: fix race condition that caused double freeJohn Stebbins2016-05-171-0/+4
|
* sync: handle very short streams betterJohn Stebbins2016-05-171-0/+4
| | | | | If the entire stream fits in the sync queues, the first PTS was not detected and initial offsets were not applied.
* sync: fix conversions of AV_NOPTS_VALUE to doubleJohn Stebbins2016-05-171-5/+5
| | | | | The way the constant is defined requires an (int64_t) cast to force it to be signed.
* sync: remove unused variableJohn Stebbins2016-05-171-1/+0
|
* sync: fix merging of multiple SSA to tx3gJohn Stebbins2016-05-171-108/+233
| | | | | | When more than 2 subtitles overlapped in time, they were not merged properly and could result in cases where the subtitle time went backwards
* sync: move chapter logging to sync.cJohn Stebbins2016-05-171-0/+30
|
* move cadence (Film->Video) logging to sync.cJohn Stebbins2016-05-171-0/+95
|
* sync: fix hang at end of p-to-p encoding with subtitlesJohn Stebbins2016-03-111-1/+8
| | | | | If there are no more subtitles in a subtitle track after the stop time of a p-to-p encoding, the encode would never finish.
* sync: fix yet another subtitle issue.John Stebbins2016-03-111-1/+2
| | | | | | subtitle stop time was getting incorrectly squashed when special value AV_NOPTS_VALUE. it should have been set to the next subtitles start time.