From patchwork Thu Oct 22 01:52:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 23143 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4979D44B054 for ; Thu, 22 Oct 2020 04:52:59 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2345368AA33; Thu, 22 Oct 2020 04:52:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0E1C66897CD for ; Thu, 22 Oct 2020 04:52:51 +0300 (EEST) IronPort-SDR: 0HvrEOHxk85t/y2cX+bc9yJdPyq1P0ZlFzJSCfcgqozqOFTanzUU0XRR+Sgl8plufoiMLzRFZk M+GXIQeJmVJg== X-IronPort-AV: E=McAfee;i="6000,8403,9781"; a="229081638" X-IronPort-AV: E=Sophos;i="5.77,402,1596524400"; d="scan'208";a="229081638" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2020 18:52:49 -0700 IronPort-SDR: AWUrtIkhNk0TCwjDEDtogY7LfjVKbPTBm9Ooi+G/8cVT51cdNVbfXockCZ+U2MK9wltCcT/pWF OrlP5lquee/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,402,1596524400"; d="scan'208";a="359084655" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by FMSMGA003.fm.intel.com with ESMTP; 21 Oct 2020 18:52:48 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Oct 2020 09:52:39 +0800 Message-Id: <20201022015239.1675600-1-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] ffmpeg_qsv: respect hwaccel_output_format setting X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Haihao Xiang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Without this change, the output pixel format from qsv decoder is always 'qsv' regardless of the hwaccel_output_format setting, user will get errors when FFmpeg inserts an auto filter to convert 'qsv' format to the specified format Fox example: ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv -hwaccel_output_format yuv420p -i input.h264 -pix_fmt rgb24 -f null - ...... [graph 0 input from stream 0:0 @ 0x55c057c8f050] w:1280 h:720 pixfmt:qsv tb:1/1001 fr:30000/1001 sar:1/1 [auto_scaler_0 @ 0x55c057c90d20] w:iw h:ih flags:'bicubic' interl:0 [format @ 0x55c057c8f990] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format' Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0' Error reinitializing filters! Failed to inject frame into filter network: Function not implemented Error while processing the decoded data for stream #0: --- fftools/ffmpeg_opt.c | 6 ++++++ fftools/ffmpeg_qsv.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 19f719e3ff..6835affa3c 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -884,6 +884,12 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) "with old commandlines. This behaviour is DEPRECATED and will be removed " "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n"); ist->hwaccel_output_format = AV_PIX_FMT_CUDA; + } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "qsv")) { + av_log(NULL, AV_LOG_WARNING, + "WARNING: defaulting hwaccel_output_format to qsv for compatibility " + "with old commandlines. This behaviour is DEPRECATED and will be removed " + "in the future. Please explicitly set \"-hwaccel_output_format qsv\".\n"); + ist->hwaccel_output_format = AV_PIX_FMT_QSV; } else if (hwaccel_output_format) { ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format); if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) { diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c index 960c88b69d..7f01370ada 100644 --- a/fftools/ffmpeg_qsv.c +++ b/fftools/ffmpeg_qsv.c @@ -82,6 +82,8 @@ int qsv_init(AVCodecContext *s) return ret; } + hwaccel_decode_init(s); + av_buffer_unref(&ist->hw_frames_ctx); ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx); if (!ist->hw_frames_ctx)