Skip to content

Commit

Permalink
backport from dav1d 1.2.0: threading: Ensure passing the correct re…
Browse files Browse the repository at this point in the history
…tval to decode_frame_exit (#517)

Partially address #224
  • Loading branch information
randomPoison authored Oct 23, 2023
2 parents e24f330 + b3f8ccb commit 4433020
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/thread_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ void *dav1d_worker_task(void *data) {
atomic_load(&f->task_thread.done[0]) &&
(!uses_2pass || atomic_load(&f->task_thread.done[1])))
{
error = atomic_load(&f->task_thread.error);
dav1d_decode_frame_exit(f, error == 1 ? DAV1D_ERR(EINVAL) :
error ? DAV1D_ERR(ENOMEM) : 0);
f->n_tile_data = 0;
Expand Down Expand Up @@ -889,6 +890,7 @@ void *dav1d_worker_task(void *data) {
if (!num_tasks && atomic_load(&f->task_thread.done[0]) &&
atomic_load(&f->task_thread.done[1]))
{
error = atomic_load(&f->task_thread.error);
dav1d_decode_frame_exit(f, error == 1 ? DAV1D_ERR(EINVAL) :
error ? DAV1D_ERR(ENOMEM) : 0);
f->n_tile_data = 0;
Expand Down Expand Up @@ -918,6 +920,7 @@ void *dav1d_worker_task(void *data) {
if (!num_tasks && atomic_load(&f->task_thread.done[0]) &&
(!uses_2pass || atomic_load(&f->task_thread.done[1])))
{
error = atomic_load(&f->task_thread.error);
dav1d_decode_frame_exit(f, error == 1 ? DAV1D_ERR(EINVAL) :
error ? DAV1D_ERR(ENOMEM) : 0);
f->n_tile_data = 0;
Expand Down
9 changes: 9 additions & 0 deletions src/thread_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,9 @@ pub unsafe extern "C" fn rav1d_worker_task(data: *mut c_void) -> *mut c_void {
as *mut atomic_int,
) != 0)
{
error_0 = ::core::intrinsics::atomic_load_seqcst(
&mut (*f).task_thread.error,
);
rav1d_decode_frame_exit(
&mut *f,
if error_0 == 1 {
Expand Down Expand Up @@ -1607,6 +1610,9 @@ pub unsafe extern "C" fn rav1d_worker_task(data: *mut c_void) -> *mut c_void {
as *mut atomic_int,
) != 0
{
error_0 = ::core::intrinsics::atomic_load_seqcst(
&mut (*f).task_thread.error,
);
rav1d_decode_frame_exit(
&mut *f,
if error_0 == 1 {
Expand Down Expand Up @@ -1672,6 +1678,9 @@ pub unsafe extern "C" fn rav1d_worker_task(data: *mut c_void) -> *mut c_void {
as *mut atomic_int,
) != 0)
{
error_0 = ::core::intrinsics::atomic_load_seqcst(
&mut (*f).task_thread.error,
);
rav1d_decode_frame_exit(
&mut *f,
if error_0 == 1 {
Expand Down

0 comments on commit 4433020

Please sign in to comment.