diff mbox series

[FFmpeg-devel,8/8] lavfi/vf_scale: pass the thread count to the scaler

Message ID 20210712110709.15532-9-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,1/8] tools/venc_data_dump: factor out demux/decode code
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Anton Khirnov July 12, 2021, 11:07 a.m. UTC
---
 libavfilter/vf_scale.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michael Niedermayer July 12, 2021, 7:13 p.m. UTC | #1
On Mon, Jul 12, 2021 at 01:07:09PM +0200, Anton Khirnov wrote:
> ---
>  libavfilter/vf_scale.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index cdff3ab7ed..f676f5d82e 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -543,6 +543,7 @@ static int config_props(AVFilterLink *outlink)
>              av_opt_set_int(*s, "sws_flags", scale->flags, 0);
>              av_opt_set_int(*s, "param0", scale->param[0], 0);
>              av_opt_set_int(*s, "param1", scale->param[1], 0);
> +            av_opt_set_int(*s, "threads", ff_filter_get_nb_threads(ctx), 0);
>              if (scale->in_range != AVCOL_RANGE_UNSPECIFIED)
>                  av_opt_set_int(*s, "src_range",
>                                 scale->in_range == AVCOL_RANGE_JPEG, 0);
> -- 
> 2.30.2

seems to crash:

-f image2 -vcodec pgmyuv -i tests/vsynth1/01.pgm  -vf format=xyz12le -vcodec rawvideo -pix_fmt xyz12le -y file-xyz.j2k

==13394== Thread 35:
==13394== Invalid read of size 2
==13394==    at 0x118F1BA: rgb48Toxyz12 (swscale.c:705)
==13394==    by 0x1190A9A: scale_internal (swscale.c:1048)
==13394==    by 0x11911C7: ff_sws_slice_worker (swscale.c:1206)
==13394==    by 0x126205E: run_jobs (slicethread.c:61)
==13394==    by 0x1262130: thread_worker (slicethread.c:85)
==13394==    by 0xCB4E6DA: start_thread (pthread_create.c:463)
==13394==    by 0xCE8771E: clone (clone.S:95)
==13394==  Address 0x370db89e is 608,286 bytes inside a block of size 608,287 alloc'd
==13394==    at 0x4C33E76: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13394==    by 0x4C33F91: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13394==    by 0x123235A: av_malloc (mem.c:87)
==13394==    by 0x1218455: av_buffer_alloc (buffer.c:72)
==13394==    by 0x12184D4: av_buffer_allocz (buffer.c:85)
==13394==    by 0x1218EA5: pool_alloc_buffer (buffer.c:351)
==13394==    by 0x1218FED: av_buffer_pool_get (buffer.c:388)
==13394==    by 0x2B47E9: ff_frame_pool_get (framepool.c:221)
==13394==    by 0x472F03: ff_default_get_video_buffer (video.c:90)
==13394==    by 0x472FBD: ff_get_video_buffer (video.c:109)
==13394==    by 0x472D0E: ff_null_get_video_buffer (video.c:41)
==13394==    by 0x472F9E: ff_get_video_buffer (video.c:106)
==13394==    by 0x472D0E: ff_null_get_video_buffer (video.c:41)
==13394==    by 0x472F9E: ff_get_video_buffer (video.c:106)
==13394==    by 0x3E6FDD: scale_frame (vf_scale.c:755)
==13394==    by 0x3E7557: filter_frame (vf_scale.c:838)
==13394==    by 0x29B314: ff_filter_frame_framed (avfilter.c:969)
==13394==    by 0x29BBCF: ff_filter_frame_to_filter (avfilter.c:1117)
==13394==    by 0x29BDDF: ff_filter_activate_default (avfilter.c:1166)
==13394==    by 0x29C003: ff_filter_activate (avfilter.c:1324)

[...]
diff mbox series

Patch

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index cdff3ab7ed..f676f5d82e 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -543,6 +543,7 @@  static int config_props(AVFilterLink *outlink)
             av_opt_set_int(*s, "sws_flags", scale->flags, 0);
             av_opt_set_int(*s, "param0", scale->param[0], 0);
             av_opt_set_int(*s, "param1", scale->param[1], 0);
+            av_opt_set_int(*s, "threads", ff_filter_get_nb_threads(ctx), 0);
             if (scale->in_range != AVCOL_RANGE_UNSPECIFIED)
                 av_opt_set_int(*s, "src_range",
                                scale->in_range == AVCOL_RANGE_JPEG, 0);