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 D059943F7A for ; Tue, 23 Aug 2022 08:20:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0881F68BA3B; Tue, 23 Aug 2022 11:20:06 +0300 (EEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 23AF968B842 for ; Tue, 23 Aug 2022 11:19:58 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661242804; x=1692778804; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=gaqKNOlL0RBxPFi4ZlzjJsALt/9LjB8PVRPfSG1rqCg=; b=Z7ylsLRQ8BTg9xyiULQU/loWik9PUl2Wv29O/6xVfSjIbDT4Fpgxgtdl 08Y0fz17bEe+TTIXFlZpKouWFET9lNyBIT/3/vWKMB00juNayvVSCZpcJ JRmU8zUQPZisf31u7FIYwNjrhVdsPYbgsp7zA6Ath9fhqyPQx/krm57iu m8wHyzZZH+N5Sh1BUvlM1uOIulT/KvlXIUAjvlo49NyRNB99GZOQmt1nG VE9ZbQabUxBy+LKI+WQNKscQWyrX83Hqct0DSrcsfH8gLRv3av65euFTF 3ihaufjcmZn2g6vrV6/ofN2+K+X/5pqMW5oJOObXVlQtWqvCqg3A6sguV g==; X-IronPort-AV: E=McAfee;i="6500,9779,10447"; a="357604433" X-IronPort-AV: E=Sophos;i="5.93,257,1654585200"; d="scan'208";a="357604433" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2022 01:19:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,257,1654585200"; d="scan'208";a="638556912" Received: from t.sh.intel.com ([10.239.159.159]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2022 01:19:56 -0700 From: Fei Wang To: ffmpeg-devel@ffmpeg.org Date: Tue, 23 Aug 2022 16:19:27 +0800 Message-Id: <20220823081929.413947-1-fei.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 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".