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 68AE9435EC for ; Thu, 18 Aug 2022 02:25:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1A06468B93E; Thu, 18 Aug 2022 05:25:12 +0300 (EEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9EAF168B920 for ; Thu, 18 Aug 2022 05:25:05 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660789510; x=1692325510; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=gaqKNOlL0RBxPFi4ZlzjJsALt/9LjB8PVRPfSG1rqCg=; b=EbgJ41pQXKAlviBUh2Hw5FrdzzXTKOcfZHH1NJTZ7qMglPEgPw/yOwBl AyJxWXmxX0EfXYMylapQ4NCBubxb2cF+e3VO6henpHeqZjavWEBFThG9C NZ+xUjjzdVaom4EinPiizYUan4w9aHXtmjKtHPiIzUM+GkrUId8B7N2Yo P6+JkokVCOmDsitvglXkoptmHd4HN5rUCA61JheFknGg2W8nmiZmKE8J7 U2ZRp8hROqtm+hSegClMEEYtgpGA+1BhtqM7w9g9L/AmymNJiSMdA1moj oZUwqDNwpByTQqdhW2bu7xzoq7SPTJFo/54c1CPr50+NWNhNJxDlfwc/o w==; X-IronPort-AV: E=McAfee;i="6500,9779,10442"; a="378941401" X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="378941401" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2022 19:25:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,245,1654585200"; d="scan'208";a="935613377" Received: from t.sh.intel.com ([10.239.159.159]) by fmsmga005.fm.intel.com with ESMTP; 17 Aug 2022 19:25:02 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 10:25:05 +0800 Message-Id: <20220818022507.1780806-1-fei.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/3] lavc/decode: Warp get_hw_config function 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: Fei Wang , Linjie Fu 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: Linjie Fu Wrap the procedure of getting the hardware config from a pixel format into a function. Signed-off-by: Linjie Fu Signed-off-by: Fei Wang --- libavcodec/decode.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 75373989c6..3b69426c09 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1156,6 +1156,24 @@ static void hwaccel_uninit(AVCodecContext *avctx) av_buffer_unref(&avctx->hw_frames_ctx); } +static const AVCodecHWConfigInternal *get_hw_config(AVCodecContext *avctx, enum AVPixelFormat fmt) +{ + const AVCodecHWConfigInternal *hw_config; + + if (!ffcodec(avctx->codec)->hw_configs) + return NULL; + + for (int i = 0;; i++) { + hw_config = ffcodec(avctx->codec)->hw_configs[i]; + if (!hw_config) + return NULL; + if (hw_config->public.pix_fmt == fmt) + return hw_config; + } + + return NULL; +} + int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) { const AVPixFmtDescriptor *desc; @@ -1213,18 +1231,7 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) break; } - if (ffcodec(avctx->codec)->hw_configs) { - for (i = 0;; i++) { - hw_config = ffcodec(avctx->codec)->hw_configs[i]; - if (!hw_config) - break; - if (hw_config->public.pix_fmt == user_choice) - break; - } - } else { - hw_config = NULL; - } - + hw_config = get_hw_config(avctx, user_choice); if (!hw_config) { // No config available, so no extra setup required. ret = user_choice; -- 2.25.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".