Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2022-02-17 01:40:37 +0300
committerRonald S. Bultje <rsbultje@gmail.com>2022-02-17 16:46:19 +0300
commit2a00fb6d4746a9bd0c15e0dcbcb148ce0b3e681d (patch)
tree2fe852b7ac6e27a7e12bf55d803fb2dbdf5d4529 /src
parent00d4715ca2a16f41f5cec2118c6333ce99067f07 (diff)
Forward frame-thread decoding errors back to user thread
Diffstat (limited to 'src')
-rw-r--r--src/decode.c7
-rw-r--r--src/internal.h1
-rw-r--r--src/lib.c12
-rw-r--r--src/obu.c7
4 files changed, 25 insertions, 2 deletions
diff --git a/src/decode.c b/src/decode.c
index 8768541..9af9143 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -3498,7 +3498,12 @@ int dav1d_submit_frame(Dav1dContext *const c) {
if (c->task_thread.cur && c->task_thread.cur < c->n_fc)
c->task_thread.cur--;
}
- if (out_delayed->p.data[0]) {
+ const int error = f->task_thread.retval;
+ if (error) {
+ f->task_thread.retval = 0;
+ c->cached_error = error;
+ dav1d_thread_picture_unref(out_delayed);
+ } else if (out_delayed->p.data[0]) {
const unsigned progress = atomic_load_explicit(&out_delayed->progress[1],
memory_order_relaxed);
if ((out_delayed->visible || c->output_invisible_frames) &&
diff --git a/src/internal.h b/src/internal.h
index 8edb80f..c4644e0 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -162,6 +162,7 @@ struct Dav1dContext {
int drain;
enum PictureFlags frame_flags;
enum Dav1dEventFlags event_flags;
+ int cached_error;
Dav1dLogger logger;
diff --git a/src/lib.c b/src/lib.c
index 6b50a53..5a61d19 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -377,6 +377,12 @@ static int drain_picture(Dav1dContext *const c, Dav1dPicture *const out) {
if (++c->frame_thread.next == c->n_fc)
c->frame_thread.next = 0;
pthread_mutex_unlock(&c->task_thread.lock);
+ const int error = f->task_thread.retval;
+ if (error) {
+ f->task_thread.retval = 0;
+ dav1d_thread_picture_unref(out_delayed);
+ return error;
+ }
if (out_delayed->p.data[0]) {
const unsigned progress =
atomic_load_explicit(&out_delayed->progress[1],
@@ -450,6 +456,12 @@ int dav1d_get_picture(Dav1dContext *const c, Dav1dPicture *const out)
validate_input_or_ret(c != NULL, DAV1D_ERR(EINVAL));
validate_input_or_ret(out != NULL, DAV1D_ERR(EINVAL));
+ if (c->cached_error) {
+ const int res = c->cached_error;
+ c->cached_error = 0;
+ return res;
+ }
+
const int drain = c->drain;
c->drain = 1;
diff --git a/src/obu.c b/src/obu.c
index dee6e13..bd6ac93 100644
--- a/src/obu.c
+++ b/src/obu.c
@@ -1574,7 +1574,12 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, const int globa
if (c->task_thread.cur && c->task_thread.cur < c->n_fc)
c->task_thread.cur--;
}
- if (out_delayed->p.data[0]) {
+ const int error = f->task_thread.retval;
+ if (error) {
+ c->cached_error = error;
+ f->task_thread.retval = 0;
+ dav1d_thread_picture_unref(out_delayed);
+ } else if (out_delayed->p.data[0]) {
const unsigned progress = atomic_load_explicit(&out_delayed->progress[1],
memory_order_relaxed);
if ((out_delayed->visible || c->output_invisible_frames) &&