From patchwork Wed May 8 07:11:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rosca X-Patchwork-Id: 48663 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9c8f:b0:1af:cdee:28c5 with SMTP id mj15csp25621pzb; Wed, 8 May 2024 00:13:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCijb8ZSk/y8BcczxdaxTNBz7xLlmGjenN9PJh0RzaUJGrdvM2Z+GAPh5e5kTeJCYeN8HiQuAyRm6Zzig7PSUIzb8PhAA2sq2Yzw== X-Google-Smtp-Source: AGHT+IHdqdMZBAjvbqLRYHa7Md6t9fwRSoJZl7CE/0w7QXsoqw/TDzXZ6Mpbl7AURm+q/U0l6qor X-Received: by 2002:a50:8713:0:b0:572:689f:6380 with SMTP id 4fb4d7f45d1cf-5731d9a29d8mr1644806a12.3.1715152394950; Wed, 08 May 2024 00:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715152394; cv=none; d=google.com; s=arc-20160816; b=B6jZA/nq8Ym26kz7+ZsenrfiE6wW++e7SnAGUHwNm/gWod3Yl4PNnHvyeR8S5Zmw9O 3V09Yv3C5LTean+x2RVayPx0AGzKudIRJyy5IM8OhUNm2W7gc1dSif9DZDSaAXZB+TU/ ZDXUltX0Mb5q2WOCZvHtP97HInDnGH2/v+H17UVTJrGq3BCsV6G2RfHLMkyA1Bw2Kbvb JDY0R7esCGVoOeTw60KvlRCJZ4nl8rusR1F0ejIiy2T1+peYjxyBVTlcJSRp9qUKq2vx qi3YZo7KEJ4GvpWU6gaW+OR2j5IYi9hmTa6I2MBAC9MSaoPTY02I/45L5g8oHpwZSYhs voxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=QyukGgEk1XAr25k9qbILTx4kdg6yKzLRJ3F+p3y8b8E=; fh=mbb85L8FZ404unHdLI+iF4ZFmTMGr6nZHIcfO/oKEvw=; b=0c8ndpLDPBOwZFnv/cS4Jq7WKrDe+E5pfeQvSMzpmBQnyQCuM4A1kVjtLtnmezYmBb FwKv+qTrH+qYcoDuDOhMc9q3xAU2PES61rIZZ6wCOxObyaI3I08j4Y717BOHqa6horAH yWxZwZ/AZVa3WjmYDVCGnYi1BVn2y7fDmeAP9Cm2eGBI96bqRZDFgI+ADa7grssNAyUP jY8IDHQXDbtIPR7YtOhvJQt9dkZrTuyGyz5hpeUbvxNvFj8uYJo2KOLsvbCBF7IVxj5+ UxfiIJCu4qGBbz9nYGID0GXtK1+fJfRIk15S62z0pDULbeUHylcXJcXb3eMgWp9KtdnG 8+ug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=O+XtIIZD; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w18-20020a056402269200b00571b9f2bd09si7128266edd.34.2024.05.08.00.13.14; Wed, 08 May 2024 00:13:14 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=O+XtIIZD; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ED92D68D4CA; Wed, 8 May 2024 10:13:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0F82168D48B for ; Wed, 8 May 2024 10:13:04 +0300 (EEST) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-51fea3031c3so5148511e87.0 for ; Wed, 08 May 2024 00:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715152383; x=1715757183; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ffXg2XQu2Z246T8u+pR5mw8scM+kCnRnc2DEIwGVp5Y=; b=O+XtIIZD3mEw83APJDrBeFsRuzwVt3Kyyg3FuAhCXFxtdsjvkBCUAr7QxcnMv6WelI 9waHWdeZ3Gr3gKWpesLlrvATXFJ0NXsZu78H9ddX0YWj/zrCU3bafwiQw8YqmuSxvQku tt2FxjepsnsddQ4Rd9xQQbixME7L88FlPIc5cUbSLO6kWAHWg4yrZ83OgHyoX3y+9tRE cAZq2q+ieBkSd58/Fi/bIad1FrvE2rHNjD2eC0z84uNjH46OiynFFdJZMBvwEoydjAYs FPch8HkUBtEcMFbY772efPUD1fUua4ZoJYkMJsU9wweRXf6fzWVs144L8UzMXffVJF7V /CuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715152383; x=1715757183; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ffXg2XQu2Z246T8u+pR5mw8scM+kCnRnc2DEIwGVp5Y=; b=WORFsv2dMz6yM+ahOJTkfqEjGb37TOSJqIw2Nl55aCSFQOKvma/C8aKz4A1UlIeD6Y 2QYcGwrGFxynBdkMT9+Sl1fZyhOdcYpYQwFMFtCvLJxUFlDWujzhk4lVjO/XSqJJMV1E rnMWVOlrkIuwmPnpa6yK8c+10Sq3stzeeOL2+oFcYVWZE6kQhEdEvFyCGAsdhNH0gDlm LwdTocOaNoI42/FrGVexOMgdRBEpfkrvPJILJR3AFDCwCJD0nFFx5lOh+soX09XC8l7Q RzaoeGq8qE2OR7TZKOBJiAXKPLFdAUm9Y1DNmS2jW5U3ndmVH/K7C3GbPfOGbICYcle6 bpHg== X-Gm-Message-State: AOJu0YxS6mZKvl8CFJt92+Sq4Bu0Q1qCEj4mRz+D6PCG+tLwamYoFb78 7SVtiAxsN4Dvyx9PVifcgIXTj1m0AYmwl2tkchF4F+m3SH+lQHxh6Q6bpA== X-Received: by 2002:ac2:4a71:0:b0:519:e878:9385 with SMTP id 2adb3069b0e04-5217c5671a9mr1284790e87.18.1715152382619; Wed, 08 May 2024 00:13:02 -0700 (PDT) Received: from mitsuki.. (ip-78-45-35-87.bb.vodafone.cz. [78.45.35.87]) by smtp.gmail.com with ESMTPSA id t16-20020a170906609000b00a59d7505366sm2872828ejj.62.2024.05.08.00.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 00:13:02 -0700 (PDT) From: David Rosca To: ffmpeg-devel@ffmpeg.org Date: Wed, 8 May 2024 09:11:11 +0200 Message-ID: <20240508071247.133615-2-nowrep@gmail.com> X-Mailer: git-send-email 2.45.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/2] lavc/vaapi_decode: Make it possible to send multiple slice params buffers 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 Cc: David Rosca Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CXdjf/rnNjyo --- v2: No changes libavcodec/vaapi_av1.c | 2 +- libavcodec/vaapi_decode.c | 3 ++- libavcodec/vaapi_decode.h | 1 + libavcodec/vaapi_h264.c | 2 +- libavcodec/vaapi_hevc.c | 4 ++-- libavcodec/vaapi_mjpeg.c | 2 +- libavcodec/vaapi_mpeg2.c | 2 +- libavcodec/vaapi_mpeg4.c | 2 +- libavcodec/vaapi_vc1.c | 2 +- libavcodec/vaapi_vp8.c | 2 +- libavcodec/vaapi_vp9.c | 2 +- 11 files changed, 13 insertions(+), 11 deletions(-) Reviewed-by: Neal Gompa diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 1f563483b9..4a90db1e09 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -409,7 +409,7 @@ static int vaapi_av1_decode_slice(AVCodecContext *avctx, .tg_end = s->tg_end, }; - err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param, + err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &slice_param, 1, sizeof(VASliceParameterBufferAV1), buffer, size); diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 21b273cd0f..8e9f647c20 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -63,6 +63,7 @@ int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx, int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx, VAAPIDecodePicture *pic, const void *params_data, + int nb_params, size_t params_size, const void *slice_data, size_t slice_size) @@ -88,7 +89,7 @@ int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx, vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, VASliceParameterBufferType, - params_size, 1, (void*)params_data, + params_size, nb_params, (void*)params_data, &pic->slice_buffers[index]); if (vas != VA_STATUS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to create slice " diff --git a/libavcodec/vaapi_decode.h b/libavcodec/vaapi_decode.h index 6beda14e52..702171e108 100644 --- a/libavcodec/vaapi_decode.h +++ b/libavcodec/vaapi_decode.h @@ -73,6 +73,7 @@ int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx, int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx, VAAPIDecodePicture *pic, const void *params_data, + int nb_params, size_t params_size, const void *slice_data, size_t slice_size); diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c index 55cf5a05ee..b47531ce1c 100644 --- a/libavcodec/vaapi_h264.c +++ b/libavcodec/vaapi_h264.c @@ -375,7 +375,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx, slice_param.chroma_offset_l1); err = ff_vaapi_decode_make_slice_buffer(avctx, pic, - &slice_param, sizeof(slice_param), + &slice_param, 1, sizeof(slice_param), buffer, size); if (err) { ff_vaapi_decode_cancel(avctx, pic); diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index 3bdd2dd1b8..3937b7574a 100644 --- a/libavcodec/vaapi_hevc.c +++ b/libavcodec/vaapi_hevc.c @@ -353,7 +353,7 @@ static int vaapi_hevc_end_frame(AVCodecContext *avctx) if (pic->last_size) { last_slice_param->LongSliceFlags.fields.LastSliceOfPic = 1; ret = ff_vaapi_decode_make_slice_buffer(avctx, &pic->pic, - &pic->last_slice_param, slice_param_size, + &pic->last_slice_param, 1, slice_param_size, pic->last_buffer, pic->last_size); if (ret < 0) goto fail; @@ -471,7 +471,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, if (!sh->first_slice_in_pic_flag) { err = ff_vaapi_decode_make_slice_buffer(avctx, &pic->pic, - &pic->last_slice_param, slice_param_size, + &pic->last_slice_param, 1, slice_param_size, pic->last_buffer, pic->last_size); pic->last_buffer = NULL; pic->last_size = 0; diff --git a/libavcodec/vaapi_mjpeg.c b/libavcodec/vaapi_mjpeg.c index 5b8d47bb2a..9557cf5f9b 100644 --- a/libavcodec/vaapi_mjpeg.c +++ b/libavcodec/vaapi_mjpeg.c @@ -131,7 +131,7 @@ static int vaapi_mjpeg_decode_slice(AVCodecContext *avctx, sp.components[i].ac_table_selector = s->ac_index[i]; } - err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &sp, sizeof(sp), buffer, size); + err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &sp, 1, sizeof(sp), buffer, size); if (err) goto fail; diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c index eeb4e87321..171a742c7f 100644 --- a/libavcodec/vaapi_mpeg2.c +++ b/libavcodec/vaapi_mpeg2.c @@ -162,7 +162,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer }; err = ff_vaapi_decode_make_slice_buffer(avctx, pic, - &slice_param, sizeof(slice_param), + &slice_param, 1, sizeof(slice_param), buffer, size); if (err < 0) { ff_vaapi_decode_cancel(avctx, pic); diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index 363b686e42..612de10cd7 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -169,7 +169,7 @@ static int vaapi_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buffer }; err = ff_vaapi_decode_make_slice_buffer(avctx, pic, - &slice_param, sizeof(slice_param), + &slice_param, 1, sizeof(slice_param), buffer, size); if (err < 0) { ff_vaapi_decode_cancel(avctx, pic); diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index 5594118a69..abbe877dd8 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -490,7 +490,7 @@ static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, }; err = ff_vaapi_decode_make_slice_buffer(avctx, pic, - &slice_param, sizeof(slice_param), + &slice_param, 1, sizeof(slice_param), buffer, size); if (err < 0) { ff_vaapi_decode_cancel(avctx, pic); diff --git a/libavcodec/vaapi_vp8.c b/libavcodec/vaapi_vp8.c index 31137a45bd..66fdde1f39 100644 --- a/libavcodec/vaapi_vp8.c +++ b/libavcodec/vaapi_vp8.c @@ -209,7 +209,7 @@ static int vaapi_vp8_decode_slice(AVCodecContext *avctx, for (i = 0; i < 8; i++) sp.partition_size[i+1] = s->coeff_partition_size[i]; - err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &sp, sizeof(sp), data, data_size); + err = ff_vaapi_decode_make_slice_buffer(avctx, pic, &sp, 1, sizeof(sp), data, data_size); if (err) goto fail; diff --git a/libavcodec/vaapi_vp9.c b/libavcodec/vaapi_vp9.c index b8e760c807..a28fc75a59 100644 --- a/libavcodec/vaapi_vp9.c +++ b/libavcodec/vaapi_vp9.c @@ -158,7 +158,7 @@ static int vaapi_vp9_decode_slice(AVCodecContext *avctx, } err = ff_vaapi_decode_make_slice_buffer(avctx, pic, - &slice_param, sizeof(slice_param), + &slice_param, 1, sizeof(slice_param), buffer, size); if (err) { ff_vaapi_decode_cancel(avctx, pic); From patchwork Wed May 8 07:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rosca X-Patchwork-Id: 48664 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9c8f:b0:1af:cdee:28c5 with SMTP id mj15csp25694pzb; Wed, 8 May 2024 00:13:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUU0WAejd+vI8Md/fk24xz5o+Vf/o8BRW6HaRPRrGxjq6S//PLkmyUZRPzd+gHeFBzdlMsfYeq9DopcaKEGU11Y8gnU172C7IbtRw== X-Google-Smtp-Source: AGHT+IG3oXW6Btb0nOsLsgP/8AeKUJDwzM/PSxrC5jUdm6vhgOZQDuI+wXt7iXGX4rN6ViSYQ3D/ X-Received: by 2002:a17:906:6b9a:b0:a59:bae0:b12f with SMTP id a640c23a62f3a-a59fb9ce9d9mr94975366b.57.1715152404530; Wed, 08 May 2024 00:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715152404; cv=none; d=google.com; s=arc-20160816; b=TyPiCxBIX4CkQJzb/tN61GGUtaed+8YXJp0fMtMCWRLhJtQcyPEGQfgMMxf8ud7SjV XasOofP00bXz6aA/3IDgRNOOR8W9kwSTI6uLYm67idB/vFjKHziHELvkE8reWyYGGUnm 3Wac/MdE30bLkfj5e5xLKTuAjS+tfDiqPQoY+x0bVErkuGZ5kvsVFBY36zForQQI6gI6 7KRKgu69eooP/7GjdfgBJDpRoV5cOimWHTnOrFicoplIhvkiGya3wLg8ewhvYd0FvEPl mV9jr2J4EkZvwXU6mU0H4kfz3XnZ5lm3VcvN1/7IyVvb2vbUar5H/YpFy/Egakk6kZDq E2WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=lG1MGLor19Gww/xCmlAJWXZbhpue6ooFmY8SVpcxzoo=; fh=mbb85L8FZ404unHdLI+iF4ZFmTMGr6nZHIcfO/oKEvw=; b=Gf3+xGKpwkxLAdDWLnNlyqQItLga7dBAeke4JLFO0nfgfO9y88/lSZaHMQrNLrFA22 vJ95hHGS2oaiaJcDbE1P6tmZrp0qjDqKSW02GplFORvI92l80hmqZfUjnZ7Ck72ZMj8e 3xPxoevI40uz1A0v7kgYvTpMvHezDaOOn3/p6/lEDhWNieas1xoZv8/EUvXGVMyyslOJ BjLbxoV90InDYTDuDSJyFBl91A/gqOWEATTQJk/mABJhXpbljeejfWyg7jaWnbViIoUD eIDt7wsyJYmNQkCISpWuISkqBrWXlKxkQvB6MihxwIdtPcYmQ6ra6rKNRI924EX2VAEK yXVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=OypvhYGi; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b27-20020a170906151b00b00a59befed255si3984295ejd.576.2024.05.08.00.13.24; Wed, 08 May 2024 00:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=OypvhYGi; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6258868D5D8; Wed, 8 May 2024 10:13:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8ED3B68D5C6 for ; Wed, 8 May 2024 10:13:09 +0300 (EEST) Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a59a934ad50so920836666b.1 for ; Wed, 08 May 2024 00:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715152388; x=1715757188; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2gr9y0ycJUz7g/8locnNp/xbvm4Xt9bm5oGOJk63n1Q=; b=OypvhYGiEgVBtlATeDRoSQ8uoRlMpZj4OZFdaLx8eHWuZ+dnUTUL04V8v+psg5iqL9 A53WZ9lLffgZpj3KrBtoMKXb4wdW7gf4xM5/PKTx5VPQdK6BRLXEKVLSaRzFBWHFu/9b bkQfxnsTF+tKwKnuxomZEnZKdtxK9GzoMx5uPJnT27LqxU6DGSWe4OY9or5BO4iRGThe suvUHkZ7K3MRjncUVtPcm2CF8wIXlbDsD2MROp/GnG7UWUwCZlVIwNiyDlfrygvGSqrb 5hToNlkEs+yKgcH3mQsYQQOOS7zPWj3OZ+3xHufHNmYxXvwlf/l2NVxED2RpgPFHLTIe mYEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715152388; x=1715757188; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2gr9y0ycJUz7g/8locnNp/xbvm4Xt9bm5oGOJk63n1Q=; b=Bd1s9ViPxXl4TdTBYOfQAT9wrkmI1uBRar/MUyJEIHHv1GVO6yy0mGvKXzK9dA7JRf ADq8nqUSLuJm7HVqX03X8vNl8lhQzOHeq0lnTNP8OWU3WLn+8vgINDqrg7u2TBhVJChu fk0aAuG361EckiGCujtlnjWPmUmjaCyWwVqDoPGJQW31L8jqPklOKIEr2Le6Zc7+eX67 1tU4u4MMWZqo4UPVdhYopV1em2EVLvq9eu3PdqK9Bx4Q+DwCYyC3KPxZEJm5xt9EAir0 b4k642TSP4uTtbQCPt/qDI32CsnA+nvz1p5iCJIS3n6WWrKBha+I+Bl1nvtLwQCRCRSP Ap5A== X-Gm-Message-State: AOJu0YyCCVm0AjHkgA3h1/7JMutpn1Aexcggxj5vAwjMMJVANDxR5Prh oeODe3Hr6qmpyzUfxgYYzOINyE0APs4dadLz45mg5zgYptS+BHmNCBegTQ== X-Received: by 2002:a17:906:80c2:b0:a55:5e89:a158 with SMTP id a640c23a62f3a-a59fb9e7628mr98238166b.68.1715152388430; Wed, 08 May 2024 00:13:08 -0700 (PDT) Received: from mitsuki.. (ip-78-45-35-87.bb.vodafone.cz. [78.45.35.87]) by smtp.gmail.com with ESMTPSA id t16-20020a170906609000b00a59d7505366sm2872828ejj.62.2024.05.08.00.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 00:13:08 -0700 (PDT) From: David Rosca To: ffmpeg-devel@ffmpeg.org Date: Wed, 8 May 2024 09:11:13 +0200 Message-ID: <20240508071247.133615-4-nowrep@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240508071247.133615-2-nowrep@gmail.com> References: <20240508071247.133615-2-nowrep@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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 Cc: David Rosca Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: q0qvq9b+ZBYX 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. Reviewed-by: Neal Gompa --- v2: Avoid allocations every slice. libavcodec/vaapi_av1.c | 47 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 4a90db1e09..4ee33a3ae3 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" @@ -42,6 +43,9 @@ typedef struct VAAPIAV1DecContext { */ VAAPIAV1FrameRef ref_tab[AV1_NUM_REF_FRAMES]; AVFrame *tmp_frame; + + int nb_slice_params; + VASliceParameterBufferAV1 *slice_params; } VAAPIAV1DecContext; static VASurfaceID vaapi_av1_surface_id(AV1Frame *vf) @@ -97,6 +101,8 @@ static int vaapi_av1_decode_uninit(AVCodecContext *avctx) for (int i = 0; i < FF_ARRAY_ELEMS(ctx->ref_tab); i++) av_frame_free(&ctx->ref_tab[i].frame); + av_freep(&ctx->slice_params); + return ff_vaapi_decode_uninit(avctx); } @@ -393,13 +399,24 @@ 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; + VAAPIAV1DecContext *ctx = avctx->internal->hwaccel_priv_data; + int err, nb_params; + + nb_params = s->tg_end - s->tg_start + 1; + if (ctx->nb_slice_params < nb_params) { + ctx->slice_params = av_realloc_array(ctx->slice_params, + nb_params, + sizeof(*ctx->slice_params)); + if (!ctx->slice_params) { + ctx->nb_slice_params = 0; + err = AVERROR(ENOMEM); + goto fail; + } + ctx->nb_slice_params = nb_params; + } for (int i = s->tg_start; i <= s->tg_end; i++) { - memset(&slice_param, 0, sizeof(VASliceParameterBufferAV1)); - - slice_param = (VASliceParameterBufferAV1) { + ctx->slice_params[i - s->tg_start] = (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 +425,20 @@ 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, ctx->slice_params, nb_params, + sizeof(VASliceParameterBufferAV1), + buffer, + size); + if (err) + goto fail; + return 0; + +fail: + ff_vaapi_decode_cancel(avctx, pic); + return err; } const FFHWAccel ff_av1_vaapi_hwaccel = {