Commit cd9a99f3 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Fix flush if n_input_frames < n_frame_threads.

Fixes #11.
parent 1c749e6b
......@@ -153,10 +153,12 @@ int dav1d_decode(Dav1dContext *const c,
validate_input_or_ret(c != NULL, -EINVAL);
validate_input_or_ret(out != NULL, -EINVAL);
while (!in) {
if (!in) {
if (c->n_fc == 1) return -EAGAIN;
// flush
int flush_count = 0;
do {
const unsigned next = c->frame_thread.next;
Dav1dFrameContext *const f = &c->fc[next];
......@@ -167,9 +169,9 @@ int dav1d_decode(Dav1dContext *const c,
pthread_mutex_unlock(&f->frame_thread.td.lock);
Dav1dThreadPicture *const out_delayed =
&c->frame_thread.out_delayed[next];
if (out_delayed->p.data[0]) {
if (++c->frame_thread.next == c->n_fc)
c->frame_thread.next = 0;
if (out_delayed->p.data[0]) {
if (out_delayed->visible) {
dav1d_picture_ref(out, &out_delayed->p);
}
......@@ -178,9 +180,9 @@ int dav1d_decode(Dav1dContext *const c,
return 0;
}
// else continue
} else {
return -EAGAIN;
}
} while (++flush_count < c->n_fc);
return -EAGAIN;
}
while (in->sz > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment