From patchwork Wed Feb 13 10:00:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 12059 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 0C4A5448331 for ; Wed, 13 Feb 2019 04:00:25 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D97E968A7AD; Wed, 13 Feb 2019 04:00:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 954A368A72C for ; Wed, 13 Feb 2019 04:00:18 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2019 18:00:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,364,1544515200"; d="scan'208";a="133839552" Received: from media_lj_kbl.sh.intel.com ([10.239.158.150]) by orsmga002.jf.intel.com with ESMTP; 12 Feb 2019 18:00:14 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Feb 2019 18:00:10 +0800 Message-Id: <20190213100010.30537-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] lavc/qsvdec: reinit if the resolution changes little 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Currently, resolution change detection is based on 16 alignment, small resolution changes (same after FFALIGN 16) in coded width or coded height will not trigger the reinit and will lead to a decode failure. Modify to use last_coded_width and last_coded_height to detect the small resolution change. Signed-off-by: Linjie Fu --- libavcodec/qsvdec.c | 8 +++++--- libavcodec/qsvdec.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 4a0be811fb..b29f869366 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -523,9 +523,9 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, avctx->field_order = q->parser->field_order; /* TODO: flush delayed frames on reinit */ - if (q->parser->format != q->orig_pix_fmt || - FFALIGN(q->parser->coded_width, 16) != FFALIGN(avctx->coded_width, 16) || - FFALIGN(q->parser->coded_height, 16) != FFALIGN(avctx->coded_height, 16)) { + if (q->parser->format != q->orig_pix_fmt || + q->last_coded_height != q->parser->coded_height || + q->last_coded_width != q->parser->coded_width) { enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_QSV, AV_PIX_FMT_NONE, AV_PIX_FMT_NONE }; @@ -558,6 +558,8 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, avctx->coded_height = FFALIGN(q->parser->coded_height, 16); avctx->level = q->avctx_internal->level; avctx->profile = q->avctx_internal->profile; + q->last_coded_width = q->parser->coded_width; + q->last_coded_height = q->parser->coded_height; ret = ff_get_format(avctx, pix_fmts); if (ret < 0) diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index 111536caba..1af0c42404 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -55,6 +55,8 @@ typedef struct QSVContext { int zero_consume_run; int buffered_count; int reinit_flag; + int last_coded_width; + int last_coded_height; // the internal parser and codec context for parsing the data AVCodecParserContext *parser;