From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D79BF4AA3C for ; Tue, 7 May 2024 20:01:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BDE3968D70E; Tue, 7 May 2024 23:01:26 +0300 (EEST) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2A71068D3FE for ; Tue, 7 May 2024 23:01:20 +0300 (EEST) Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-34da35cd01cso3238266f8f.2 for ; Tue, 07 May 2024 13:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20230601.gappssmtp.com; s=20230601; t=1715112079; x=1715716879; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=kDodxgWIb9kYvuEqIFiYbDhFmAuDd8bIvEtfTu5NWsc=; b=m+sVBPF7BJgr+OTin7f/the78nX5Fz8DIfr/sVfRIzEv4+1xVLdRtV/GrVJoJQJV3R a6Q/Asx99Bj1d6jUJOdw4JN/EfL4Je3zjc6qLaiilIOSFAJr/G40tsR18NmbJ88T/5BO PiknAPAKQNeadH7sQwV199WrvaihZfkDnSIrsSbDOcNrUmEifcffLcaRoCdgQkZJS0Uf +ZFMnZEFj+naPS4BMI6Vus8EuKYRFxMeR6Vo4Sge0ZVloBZYmQAVyV2++T6XH8JmmTU7 WlSGv/fHQ7hqCq5qwrjVDzHOqJOe0vu067D2xhRbJAzzVIdvMBxfaQibiBSl9OZMxcyY UNkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715112079; x=1715716879; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kDodxgWIb9kYvuEqIFiYbDhFmAuDd8bIvEtfTu5NWsc=; b=IVAZa9p3ebRuhiK7C0KbDjHVL2UDBbVZmYnXbo/5o4Zmcu8OnFgFUtrAUE9LCY38fq YFrf94vFKQjBhJIAEpj5rSehNGQMmm96vfccJlQoBwj3ZQdEIDEIgPmhFJULlTXI7IiM MiXCTYaTJMNdCkIl/LvI8xuXPrfVO2ZA/lrrIYyPU40qEem8MoiLBQebdznnW1Djky0K VRTAmkiBo+PeM6nsPoMXapjPZcpf8dGLxe81cpEarv6IV7h615mVeosi6e0eu6PmIDdo DGJTF5FDAaV7odxIRr4I9iTV7KdCwXwSLMxtlnetPaAnskOdtO15zPduBWJHwzEFzWjC mdiA== X-Gm-Message-State: AOJu0Yxa74420gMymFFc5SLo0osmCVlKeV0+812C15OppDWvaQ+vBdTv GAtmhAENLWhXbGKnOVfIZPUzZ9KJ0spTR3pAw5QS2ScquIQGsSiYtjps9kJO7zoAIA9xHPUCSly 1 X-Google-Smtp-Source: AGHT+IGpPqwUdI5ZIZvRd8PNDRVO1mv96XgGtsJJ2xv900xYLRs6xgqZ05/jJfNR8+zG2usiStKgjg== X-Received: by 2002:a05:600c:c09:b0:41a:e5f5:99f8 with SMTP id 5b1f17b1804b1-41f714f6dffmr6761785e9.18.1715112079113; Tue, 07 May 2024 13:01:19 -0700 (PDT) Received: from [192.168.0.15] (cpc92302-cmbg19-2-0-cust1183.5-4.cable.virginm.net. [82.1.212.160]) by smtp.gmail.com with ESMTPSA id t9-20020a05600c450900b0041bd920d41csm20546641wmo.1.2024.05.07.13.01.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 May 2024 13:01:18 -0700 (PDT) Message-ID: <55738793-334d-4a0e-a493-fb0e6bd06919@jkqxz.net> Date: Tue, 7 May 2024 21:01:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240428072650.168514-1-nowrep@gmail.com> <20240428072650.168514-2-nowrep@gmail.com> From: Mark Thompson In-Reply-To: <20240428072650.168514-2-nowrep@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_av1: Avoid sending the same slice buffer multiple times X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 28/04/2024 08:26, David Rosca wrote: > When there are multiple tiles in one slice buffer, use multiple slice > params to avoid sending the same slice buffer multiple times and thus > increasing the bitstream size the driver will need to upload to hw. > --- > libavcodec/vaapi_av1.c | 37 +++++++++++++++++++++++-------------- > 1 file changed, 23 insertions(+), 14 deletions(-) Can you confirm that this works on at least iHD (Intel) and Mesa (AMD)? (I don't expect any issue, but it's good to check in case of something strange going on matching up to what this was previously doing.) > diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c > index 4a90db1e09..567f505fbd 100644 > --- a/libavcodec/vaapi_av1.c > +++ b/libavcodec/vaapi_av1.c > @@ -19,6 +19,7 @@ > */ > > #include "libavutil/frame.h" > +#include "libavutil/mem.h" > #include "hwaccel_internal.h" > #include "vaapi_decode.h" > #include "internal.h" > @@ -393,13 +394,17 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx, > { > const AV1DecContext *s = avctx->priv_data; > VAAPIDecodePicture *pic = s->cur_frame.hwaccel_picture_private; > - VASliceParameterBufferAV1 slice_param; > - int err = 0; > + VASliceParameterBufferAV1 *slice_params; > + int err = 0, nb_params = 0; Remove the spurious initialisation on err? > > - for (int i = s->tg_start; i <= s->tg_end; i++) { > - memset(&slice_param, 0, sizeof(VASliceParameterBufferAV1)); > + slice_params = av_calloc(s->tg_end - s->tg_start + 1, sizeof(*slice_params)); I suggest allocating this into VAAPIAV1DecContext to avoid the alloc/free on every call. (Only reallocate if it needs to be bigger than the previous maximum.) > + if (!slice_params) { > + err = AVERROR(ENOMEM); > + goto fail; > + } > > - slice_param = (VASliceParameterBufferAV1) { > + for (int i = s->tg_start; i <= s->tg_end; i++) { > + slice_params[nb_params++] = (VASliceParameterBufferAV1) { > .slice_data_size = s->tile_group_info[i].tile_size, > .slice_data_offset = s->tile_group_info[i].tile_offset, > .slice_data_flag = VA_SLICE_DATA_FLAG_ALL, > @@ -408,18 +413,22 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx, > .tg_start = s->tg_start, > .tg_end = s->tg_end, > }; > - > - err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param, 1, > - sizeof(VASliceParameterBufferAV1), > - buffer, > - size); > - if (err) { > - ff_vaapi_decode_cancel(avctx, pic); > - return err; > - } > } > > + err = ff_vaapi_decode_make_slice_buffer(avctx, pic, slice_params, nb_params, > + sizeof(VASliceParameterBufferAV1), > + buffer, > + size); > + av_free(slice_params); > + > + if (err) > + goto fail; > + > return 0; > + > +fail: > + ff_vaapi_decode_cancel(avctx, pic); > + return err; > } > > const FFHWAccel ff_av1_vaapi_hwaccel = { It's amusing that this quadratic behaviour was around for so long! (I guess people don't use many tiles.) Thanks, - Mark _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".