summaryrefslogtreecommitdiffstats
path: root/libhb/sync.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-09-20 13:52:04 -0700
committerJohn Stebbins <[email protected]>2016-09-20 13:58:08 -0700
commit8729a0fefffd31935cd9034aa10587a36c9a52cf (patch)
tree3505fc1c39f3243a64903ced059135bf81d58b1f /libhb/sync.c
parent4916e2e73090718af63af97382e1cea9708161c8 (diff)
sync: fix use of closed buffer
Fixes https://github.com/HandBrake/HandBrake/issues/328
Diffstat (limited to 'libhb/sync.c')
-rw-r--r--libhb/sync.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/libhb/sync.c b/libhb/sync.c
index 7fcd71603..03de14909 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -293,17 +293,22 @@ static void shiftTS( sync_common_t * common, int64_t delta )
static void computeInitialTS( sync_common_t * common,
sync_stream_t * first_stream )
{
- int ii, count;
+ int ii;
hb_buffer_t * prev;
// Process first_stream first since it has the initial PTS
prev = NULL;
- count = hb_list_count(first_stream->in_queue);
- for (ii = 0; ii < count; ii++)
+ for (ii = 0; ii < hb_list_count(first_stream->in_queue);)
{
hb_buffer_t * buf = hb_list_item(first_stream->in_queue, ii);
- if (UpdateSCR(first_stream, buf))
+
+ if (!UpdateSCR(first_stream, buf))
{
+ hb_list_rem(first_stream->in_queue, buf);
+ }
+ else
+ {
+ ii++;
if (first_stream->type == SYNC_TYPE_VIDEO && prev != NULL)
{
double duration = buf->s.start - prev->s.start;
@@ -313,8 +318,8 @@ static void computeInitialTS( sync_common_t * common,
prev->s.stop = buf->s.start;
}
}
+ prev = buf;
}
- prev = buf;
}
for (ii = 0; ii < common->stream_count; ii++)
{
@@ -348,8 +353,8 @@ static void computeInitialTS( sync_common_t * common,
prev->s.stop = buf->s.start;
}
}
+ prev = buf;
}
- prev = buf;
}
}
}
@@ -1866,7 +1871,7 @@ static void QueueBuffer( sync_stream_t * stream, hb_buffer_t * buf )
if (stream->common->found_first_pts)
{
- if (UpdateSCR(stream, buf))
+ if (UpdateSCR(stream, buf) > 0)
{
// Apply any stream slips.
// Stream slips will only temporarily differ between