aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vulkan_av1.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-09-12 19:23:26 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2023-09-15 13:08:37 +0200
commitfa77cb258b29f636255ebf20c0a70b0dfc5e8a43 (patch)
tree5d6902cdf89f66923ddffdb5022f1fba84ea17b5 /libavcodec/vulkan_av1.c
parentd2bc039501cdfe2067365ca1bf4be7201f071c05 (diff)
downloadffmpeg-fa77cb258b29f636255ebf20c0a70b0dfc5e8a43.tar.gz
avcodec/h264dec: Fix data race when updating decode_error_flags
When using multi-threaded decoding, every decoding thread has its own DBP consisting of H264Pictures and each of these points to its own AVFrames. They are synced during update_thread_context via av_frame_ref() and therefore the threads actually decoding (as well as all the others) must not modify any field that is copied by av_frame_ref() after ff_thread_finish_setup(). Yet this is exactly what happens when an error occurs during decoding and the AVFrame's decode_error_flags are updated. Given that these errors only become apparent during decoding, this can't be set before ff_thread_finish_setup() without defeating the point of frame-threading; in practice, this meant that the decoder did not set these flags correctly in case frame-threading was in use. (This means that e.g. the ffmpeg cli tool fails to output its "corrupt decoded frame" message in a nondeterministic fashion.) This commit fixes this by adding a new H264Picture field that is actually propagated across threads; the field is an AVBufferRef* whose data is an atomic_int; it is atomic in order to allow multiple threads to update it concurrently and not to provide synchronization between the threads setting the field and the thread ultimately returning the AVFrame. This unfortunately has the overhead of one allocation per H264Picture (both the original one as well as creating a reference to an existing one), even in case of no errors. In order to mitigate this, an AVBufferPool has been used and only if frame-threading is actually in use. This expense will be removed as soon as a proper API for refcounted objects (not based upon AVBuffer) is in place. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/vulkan_av1.c')
0 files changed, 0 insertions, 0 deletions