Skip to content

Commit

Permalink
avcodec/ffv1dec: Remove redundant writes, fix races
Browse files Browse the repository at this point in the history
Every modification of the data that is copied in update_thread_context()
is a data race if it happens after ff_thread_finish_setup. ffv1dec's
update_thread_context() simply uses memcpy for updating the new context,
so that every modification of the src's context is a race.
Some of these modifications are unnecessary: picture_number is write-only
for the decoder and cur will be reset when decoding the next frame anyway.
So remove them. And while just at it, also don't set cur for the slice
contexts as this variable is write-only.

Reviewed-by: Anton Khirnov <[email protected]>
Signed-off-by: Andreas Rheinhardt <[email protected]>
  • Loading branch information
mkver committed Dec 19, 2021
1 parent dfd06ee commit 17605d1
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions libavcodec/ffv1dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
fs->c.bytestream_end = buf_p + v;

fs->avctx = avctx;
fs->cur = p;
}

avctx->execute(avctx,
Expand Down Expand Up @@ -965,11 +964,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
}
ff_thread_report_progress(&f->picture, INT_MAX, 0);

f->picture_number++;

if (f->last_picture.f)
ff_thread_release_buffer(avctx, &f->last_picture);
f->cur = NULL;
if ((ret = av_frame_ref(data, f->picture.f)) < 0)
return ret;

Expand Down

0 comments on commit 17605d1

Please sign in to comment.