From patchwork Fri Feb 19 05:09:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenbin Chen X-Patchwork-Id: 25774 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 A0297448AFC for ; Fri, 19 Feb 2021 07:11:09 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D15E689E51; Fri, 19 Feb 2021 07:11:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5CA096883B3 for ; Fri, 19 Feb 2021 07:11:02 +0200 (EET) IronPort-SDR: aBKTU12TGj55EdZueciBOi+VGVOxS3BRV0pvq/0Ir3DHWMz3UU4FUZjKoyMZkXvNk/VehZFPML 4Q0zySsMhpzQ== X-IronPort-AV: E=McAfee;i="6000,8403,9899"; a="203011614" X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="203011614" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2021 21:10:59 -0800 IronPort-SDR: edYNpUZDDWFqzpbIR0Ew4Jc99asOOs59dZ2JFvexeIuvLeyUcAVDt7VlX2evFmQxtn/N7dd9Ic /xZTWDOWUbTQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="440101934" Received: from chenwenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.3]) by orsmga001.jf.intel.com with ESMTP; 18 Feb 2021 21:10:58 -0800 From: wenbin.chen@intel.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Feb 2021 13:09:20 +0800 Message-Id: <20210219050920.1730759-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavcodec/qsvdec: skip non-key frame after "seek" function 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: "Chen,Wenbin" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: "Chen,Wenbin" Fix #9095. Qsv decoder assume that after calling seek funcion, the first frame should be key frame. However this is not true for some videos. If the frame is not key frame after seek(), there will be error. Conditional statements are added to skip these frame until reading a key frame. Signed-off-by: Wenbin Chen --- libavcodec/qsvdec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index d10f90a0db..8133406085 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -616,6 +616,13 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, } if (!q->initialized) { + + /* skip non-key frame when decoder is reinitialized. + Adding before will skip all the non-key frames so add + it here */ + if (ret < 0) + return ret; + ret = qsv_decode_init_context(avctx, q, ¶m); if (ret < 0) goto reinit_fail;