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 642264ABE0 for ; Tue, 14 May 2024 20:55:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B3F4368D74F; Tue, 14 May 2024 23:55:42 +0300 (EEST) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D6B368D72A for ; Tue, 14 May 2024 23:55:37 +0300 (EEST) Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-34ef66c0178so4124877f8f.1 for ; Tue, 14 May 2024 13:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20230601.gappssmtp.com; s=20230601; t=1715720136; x=1716324936; 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=Pj44MAkxxM3XNRu5uXKt/QNrgu9eliPNPRWiHlLXK3M=; b=kzn60MJnux5cDe4tkRnxbP8ISPQ4vIwG6UgEDMR7JfgPyG8oaqz9tvECwLdkZQ00IO 4GyBWwUCSynXihxjUBwPHIc6bzUZhZv4d4Swx9E2wjbIZ5YE/XmpnnJu4Adu6/iZrlcn qnPLI1AAPRTTDldhurTECpF9R3jXo9MPTAECrpDfO95P75k6LURa2R9H0h/y+ucx3lmT 9epy6wP24RO8In69XdM4m34pdlvc31xScZsRFPt+aMatBvKzD1BOOWPPST5Yqo1MqicF 3nQArmL6tb1ow/S99fxFZAzzjnNsyGi/FcPuCXWLKizuT7dtNUuLjKqqE5GwR5Dorcjp T6fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715720136; x=1716324936; 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=Pj44MAkxxM3XNRu5uXKt/QNrgu9eliPNPRWiHlLXK3M=; b=i8v0yuF5VEszqY41NK+vagI0qmqSaudNa7xnBP0aPymQ6PMLdW/5W7eoqTUFnjVCnf kn6WB6OLkTRdNUARcqC92c0djonWlm0Aufxbhsdu5wt2zIGfyRM5m5L0IHyvqFOBSylz NLviJuyvvf2xwtzGUIOqafrC32KmKMZiQeLEOu+bN8yGx86eFXk7jHeBq/iEMU1HqKbm soyDDkZuwOqEX5ecOkxsU8k/N0VaLZnrmzo437JNEHz1bPPtlRwmJ+Vof9AgdwPYjXPO qmcqMCfRu3pD2FejvanrWnvtva4zl9/3YCphmFm9pXH00wO8RdplQyn3T9kiXvgLbVL3 8Dgw== X-Gm-Message-State: AOJu0YzAvCaQe0j0m1Hj4oFi3ESoaIJypojM3ogZXTbMKfKKC7xqle+T wvu/NzXHqO/RTJufBSjka6TO8B9Jb7AT+SIBQvZlMe06kdxWfTqjR9HxFO4WqqtfBPWqI3celfO S X-Google-Smtp-Source: AGHT+IFhNvoNce/EfrOCDpU5bKsEKYCkCfNuu6ZfgmujboOC4oTTW1gn7BUFUigTDllqsZekid7puQ== X-Received: by 2002:adf:e501:0:b0:34d:b79c:511 with SMTP id ffacd0b85a97d-3504a632b2cmr14613487f8f.20.1715720136193; Tue, 14 May 2024 13:55:36 -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 ffacd0b85a97d-3502bbbc002sm14506525f8f.102.2024.05.14.13.55.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 May 2024 13:55:35 -0700 (PDT) Message-ID: Date: Tue, 14 May 2024 21:56:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240418085910.547-1-tong1.wu@intel.com> <20240418085910.547-6-tong1.wu@intel.com> From: Mark Thompson In-Reply-To: <20240418085910.547-6-tong1.wu@intel.com> Subject: Re: [FFmpeg-devel] [PATCH v8 06/15] avcodec/vaapi_encode: extract the init function to base layer 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 18/04/2024 09:59, tong1.wu-at-intel.com@ffmpeg.org wrote: > From: Tong Wu > > Related parameters are also moved to base layer. > > Signed-off-by: Tong Wu > --- > libavcodec/hw_base_encode.c | 33 ++++++++++++++++ > libavcodec/hw_base_encode.h | 11 ++++++ > libavcodec/vaapi_encode.c | 68 ++++++++++----------------------- > libavcodec/vaapi_encode.h | 6 --- > libavcodec/vaapi_encode_av1.c | 2 +- > libavcodec/vaapi_encode_h264.c | 2 +- > libavcodec/vaapi_encode_h265.c | 2 +- > libavcodec/vaapi_encode_mjpeg.c | 6 ++- > 8 files changed, 72 insertions(+), 58 deletions(-) > > diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c > index 1d9a255f69..14f3ecfc94 100644 > --- a/libavcodec/hw_base_encode.c > +++ b/libavcodec/hw_base_encode.c > @@ -598,3 +598,36 @@ end: > > return 0; > } > + > +int ff_hw_base_encode_init(AVCodecContext *avctx) > +{ > + HWBaseEncodeContext *ctx = avctx->priv_data; > + > + ctx->frame = av_frame_alloc(); > + if (!ctx->frame) > + return AVERROR(ENOMEM); > + > + if (!avctx->hw_frames_ctx) { > + av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is " > + "required to associate the encoding device.\n"); > + return AVERROR(EINVAL); > + } > + > + ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx); > + if (!ctx->input_frames_ref) > + return AVERROR(ENOMEM); > + > + ctx->input_frames = (AVHWFramesContext *)ctx->input_frames_ref->data; > + > + ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref); > + if (!ctx->device_ref) > + return AVERROR(ENOMEM); > + > + ctx->device = (AVHWDeviceContext *)ctx->device_ref->data; > + > + ctx->tail_pkt = av_packet_alloc(); > + if (!ctx->tail_pkt) > + return AVERROR(ENOMEM); > + > + return 0; > +} > diff --git a/libavcodec/hw_base_encode.h b/libavcodec/hw_base_encode.h > index b5b676b9a8..f7e385e840 100644 > --- a/libavcodec/hw_base_encode.h > +++ b/libavcodec/hw_base_encode.h > @@ -19,6 +19,7 @@ > #ifndef AVCODEC_HW_BASE_ENCODE_H > #define AVCODEC_HW_BASE_ENCODE_H > > +#include "libavutil/hwcontext.h" > #include "libavutil/fifo.h" > > #define MAX_DPB_SIZE 16 > @@ -117,6 +118,14 @@ typedef struct HWBaseEncodeContext { > // Hardware-specific hooks. > const struct HWEncodePictureOperation *op; > > + // The hardware device context. > + AVBufferRef *device_ref; > + AVHWDeviceContext *device; > + > + // The hardware frame context containing the input frames. > + AVBufferRef *input_frames_ref; > + AVHWFramesContext *input_frames; > + > // Current encoding window, in display (input) order. > HWBaseEncodePicture *pic_start, *pic_end; > // The next picture to use as the previous reference picture in > @@ -183,6 +192,8 @@ typedef struct HWBaseEncodeContext { > > int ff_hw_base_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt); > > +int ff_hw_base_encode_init(AVCodecContext *avctx); > + > #define HW_BASE_ENCODE_COMMON_OPTIONS \ > { "async_depth", "Maximum processing parallelism. " \ > "Increase this to improve single channel performance.", \ Maybe this patch should be merged with 9/15 to keep the init/close symmetry? It's not clear that the intermediate makes sense, and it has some churn. > ... 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".