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 8BBCC49560 for ; Thu, 14 Mar 2024 08:16:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1CC8468D182; Thu, 14 Mar 2024 10:16:18 +0200 (EET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7C12C68D13C for ; Thu, 14 Mar 2024 10:16:10 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710404176; x=1741940176; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QwQc+6bciEA2fPKfWGlOQ0DCpeBj4lco2MBc5NGsBWg=; b=cLlAuzGc36c0FCuz3rSPWiVNQ4ae0cS7RbzYrp9ky2rOnKtM1pSu0Uud sqlBBR+Sqi7Qy6HggUQvIMTCFA1K/bmEqXUl6vl1DVAQdFumKdWItDKSa m1CE6nulOjrww17Asi0rF04D57PjeZZGAGf+TMoWNOAVqLtf4V7mA9Oub /j9RpA5VxVilB6nbulFDKsWXhJsL73viEErDxMfn6FFyVPCSxXUabDYAw hMULKuFa91qN+B67DlLXPpFaLKP8/G/wbw8oKvhc5UJqWHJ5hikYccShT z67Zen/Gcu6JIcibVTHXt/ygkgeq74gqag/IyvarU5w5Wh6fq//XfBSPk w==; X-IronPort-AV: E=McAfee;i="6600,9927,11012"; a="9029377" X-IronPort-AV: E=Sophos;i="6.07,124,1708416000"; d="scan'208";a="9029377" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 01:16:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,124,1708416000"; d="scan'208";a="12095268" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.66]) by fmviesa007.fm.intel.com with ESMTP; 14 Mar 2024 01:16:04 -0700 From: tong1.wu-at-intel.com@ffmpeg.org To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Mar 2024 16:14:48 +0800 Message-ID: <20240314081456.379-5-tong1.wu@intel.com> X-Mailer: git-send-email 2.41.0.windows.1 In-Reply-To: <20240314081456.379-1-tong1.wu@intel.com> References: <20240314081456.379-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v7 05/12] avcodec/vaapi_encode: extract a close function for 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 Cc: Tong Wu 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: From: Tong Wu Signed-off-by: Tong Wu --- libavcodec/hw_base_encode.c | 16 ++++++++++++++++ libavcodec/hw_base_encode.h | 2 ++ libavcodec/vaapi_encode.c | 8 +------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c index 71ead512c0..754f990ed0 100644 --- a/libavcodec/hw_base_encode.c +++ b/libavcodec/hw_base_encode.c @@ -630,3 +630,19 @@ int ff_hw_base_encode_init(AVCodecContext *avctx) return 0; } + +int ff_hw_base_encode_close(AVCodecContext *avctx) +{ + HWBaseEncodeContext *ctx = avctx->priv_data; + + av_fifo_freep2(&ctx->encode_fifo); + + av_frame_free(&ctx->frame); + av_packet_free(&ctx->tail_pkt); + + av_buffer_unref(&ctx->device_ref); + av_buffer_unref(&ctx->input_frames_ref); + av_buffer_unref(&ctx->recon_frames_ref); + + return 0; +} diff --git a/libavcodec/hw_base_encode.h b/libavcodec/hw_base_encode.h index c9c8fb43c9..436767b706 100644 --- a/libavcodec/hw_base_encode.h +++ b/libavcodec/hw_base_encode.h @@ -228,6 +228,8 @@ int ff_hw_base_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt); int ff_hw_base_encode_init(AVCodecContext *avctx); +int ff_hw_base_encode_close(AVCodecContext *avctx); + #define HW_BASE_ENCODE_COMMON_OPTIONS \ { "idr_interval", \ "Distance (in I-frames) between key frames", \ diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 887543734b..ffac27a08f 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -2412,16 +2412,10 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) ctx->va_config = VA_INVALID_ID; } - av_frame_free(&base_ctx->frame); - av_packet_free(&base_ctx->tail_pkt); - av_freep(&ctx->codec_sequence_params); av_freep(&ctx->codec_picture_params); - av_fifo_freep2(&base_ctx->encode_fifo); - av_buffer_unref(&base_ctx->recon_frames_ref); - av_buffer_unref(&base_ctx->input_frames_ref); - av_buffer_unref(&base_ctx->device_ref); + ff_hw_base_encode_close(avctx); return 0; } -- 2.41.0.windows.1 _______________________________________________ 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".