aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_avgblur_vulkan.c
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2020-05-29 13:10:58 +0100
committerLynne <dev@lynne.ee>2020-05-29 13:10:58 +0100
commit83fa39eb06d0d720422e8a5408d15ba472a82ea6 (patch)
tree7157799bf454bbd7d163b19cfce51f6859d1f5ae /libavfilter/vf_avgblur_vulkan.c
parentc0f01eaf12479b5d0160e1a8d10a73744fac5ab2 (diff)
downloadffmpeg-83fa39eb06d0d720422e8a5408d15ba472a82ea6.tar.gz
lavfi/vulkan: use av_get_random_seed instead of rand
We need at least a few bits of entropy to determine the start index of each queue, in order to let filters run in parallel as much as possible, and rand() is not thread safe and disrupts any external API's usage of rand, so instead replace it with av_get_random_seed. While it has more overhead than rand, we only run it once per filter upon init.
Diffstat (limited to 'libavfilter/vf_avgblur_vulkan.c')
-rw-r--r--libavfilter/vf_avgblur_vulkan.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c
index 12d57e0875..89763345d9 100644
--- a/libavfilter/vf_avgblur_vulkan.c
+++ b/libavfilter/vf_avgblur_vulkan.c
@@ -16,6 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/random_seed.h"
#include "libavutil/opt.h"
#include "vulkan.h"
#include "internal.h"
@@ -99,7 +100,7 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
s->vkctx.queue_family_idx = s->vkctx.hwctx->queue_family_comp_index;
s->vkctx.queue_count = GET_QUEUE_COUNT(s->vkctx.hwctx, 0, 1, 0);
- s->vkctx.cur_queue_idx = rand() % s->vkctx.queue_count;
+ s->vkctx.cur_queue_idx = av_get_random_seed() % s->vkctx.queue_count;
{ /* Create shader for the horizontal pass */
desc_i[0].updater = s->input_images;