From patchwork Sun May 24 12:13:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 19830 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 3801A44A3FE for ; Sun, 24 May 2020 15:13:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B02768AA9C; Sun, 24 May 2020 15:13:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11olkn2037.outbound.protection.outlook.com [40.92.19.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D0B6D68065A for ; Sun, 24 May 2020 15:13:09 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E9Cw5Yc80uvfA7GCrMgtlolBoRJ6+8AyhCvBTkPb4GmPBERG2lcA0yRbrDB8dAowMOhQHw3cBcmorncYvxe+8xti2FyLlA6jzLezlA9G66Rampil0B0gTIxHg5zgyxX07EjbCPRMmcW5/cJ+331ArE5Yz4ylBMFSrKw3/NkaT05/JH6kE3oL/ntSfGwIzibaf2+uc6zx40efYh86f1BHaiEWvB7gRpX63HBdzquzckhA54xIIYkOmyFErJQrDqRgUaqXZpzeXTMPjJS3XDQfJ6qI84N7X2/SMyDypqJ5k4i5ngVVfeSJ5HkMtduQtJmlr6S1RLUGAXJlb8XteiIHCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lKp2hfBEqRmzOtsgVdYFRs/QWjD0w/jU06tx/btoymc=; b=WpKK9JMy+aD1OQPNXPKnUpYBmUnRtY0wqoc+SzZ+pRk39YQV0BtCbRiOHxw3N3XD2p+7RvVmwtmOn0WLUcaHi0O+o6RjE9QvfYhmdTUPZxQtBpMc/jwvlM/s/kIfycODzJ6lzr9dYTt/b45LcAXelvEB9hyrexdWUbaQZKnjhLAWgh+FUMpFYjIzIcSCrRs+JtNY4+t+CB4TE91zD6wkpyBf0ZFYSUbAtKRLr3+6L2Kvq0sKuojdxd3qPElndMQZ9jfEkrIfAsou/mWnXii87AD3RTt4nWP3ExTQrxY8O3gKrmmcMgrdPwBQ0Z7zBaCxGuZVZkMlu2VwRYi1lzER6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lKp2hfBEqRmzOtsgVdYFRs/QWjD0w/jU06tx/btoymc=; b=hoEW55qv8CHvPP2iwBxrk12i6T6ZMIaGMR/u79tr8a87nK2lE6K/k8HSeLyGEw559cjyetMkVcIdChFAtKVuId+qnaEdRVTsrpVwyDS1kBiKULhFUWVW/OyW7npz9TuAxiPFslwQsygaN4DXDATAD8mtdd9BpDq61J2tqkJIVn/9LcnDDQ5G07JLFr5I29zqkzHQJD0C76LLrGfHpJuVzW+cixlq63qJYFJw6Kj5h44wt0VPojg8420UMeBOx0/xnANsVor7rPXTOJ6wFcX4XcbaffmhaXCs40oCxL5KLO35soRp4+3GCE/Zzef4+xRNrNpSJLL4SvFfQA6tQDZxFQ== Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::40) by BN8NAM11HT105.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Sun, 24 May 2020 12:13:07 +0000 Received: from BYAPR04MB5222.namprd04.prod.outlook.com (2a01:111:e400:fc4b::41) by BN8NAM11FT036.mail.protection.outlook.com (2a01:111:e400:fc4b::424) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Sun, 24 May 2020 12:13:07 +0000 Received: from BYAPR04MB5222.namprd04.prod.outlook.com ([fe80::29ab:2d14:7382:3385]) by BYAPR04MB5222.namprd04.prod.outlook.com ([fe80::29ab:2d14:7382:3385%7]) with mapi id 15.20.3021.027; Sun, 24 May 2020 12:13:07 +0000 From: Soft Works To: FFmpeg development discussions and patches Thread-Topic: [PATCH] avfilter/qsvvpp: Work around a bug in MSDK where VPP processing hangs under certain conditions Thread-Index: AdYxxH7doHwLDII8RNiQhKovnpTPfQ== Date: Sun, 24 May 2020 12:13:07 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:F9DDE3A3CDFC5FF9694D08483A18EF5DF97C359A8ACB34DECA4642570D89AB2E; UpperCasedChecksum:3168DFC5232F3CCC74E466E8522D9E83C867B1C53BA87457E2FA7B5BF32ECD52; SizeAsReceived:6818; Count:42 x-tmn: [eoFHk+RQ4imtZXsZeSj1uUJlN2j//EGq] x-ms-publictraffictype: Email x-incomingheadercount: 42 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 9e8a0eba-6dcd-448e-3385-08d7ffdbd1b2 x-ms-traffictypediagnostic: BN8NAM11HT105: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: x+aM+mMaWHAIq0MY5DDP1K9DlxCr7MWroLxVgAw/x25lLEmF5HwQ5qPtvJ4cauwh3W2WtBzb/QoqNV/7VzbiFdekfI6xMrTVn8vMj8f8QS4PiWNjedWTG3N5mc4ycW/vgWdPfc5F+wMQ7onddekgHq5VANu8z/9TlEjterCfasOBZ6Yew2Is7zh4bXrA5tcMRnBpufnKHc+PaTDpWqL/zQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:0; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR04MB5222.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:; DIR:OUT; SFP:1901; x-ms-exchange-antispam-messagedata: rVAtueTiJSYmEqc7Yf5IywEvi+Ob5LhgaRM/o0de1YqbpTwzgiA3NT3SxjMczieRPRFrxbZ+d/8DeTZCmv3GKcdF3SbLKBHApRxZOvQYlv6JybGcKwLqoZkk1cwB4o1jB95UoiD1okZlia/Sy2ylDQ== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 9e8a0eba-6dcd-448e-3385-08d7ffdbd1b2 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2020 12:13:07.7042 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM11HT105 Subject: [FFmpeg-devel] [PATCH] avfilter/qsvvpp: Work around a bug in MSDK where VPP processing hangs under certain conditions 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" These conditions are: - Dimensions are aligned to 16/32 byte (e.g. 1920x800) - No scaling is done - Color format conversion (e.g. 10bit to 8bit) Example command: ffmpeg -c:v hevc_qsv -hwaccel qsv -i hevc_10bit_1920_800.mkv -filter_complex "scale_qsv=format=nv12" -c:v h264_qsv out.mkv Fix: - Increase the frame height to the next alignment value --- libavfilter/qsvvpp.c | 7 ++++++- libavfilter/vf_scale_qsv.c | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 1bbb7a7e68..98d2353d1c 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -420,6 +420,7 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) mfxHandleType handle_type; mfxVersion ver; mfxIMPL impl; + int height_align_adjust = 0; int ret, i; if (inlink->hw_frames_ctx) { @@ -463,9 +464,13 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) out_frames_ctx = (AVHWFramesContext *)out_frames_ref->data; out_frames_hwctx = out_frames_ctx->hwctx; + /* work around a bug in MSDK where VPP processing hangs under certain conditions */ + if (inlink->h == outlink->h) + height_align_adjust = 1; + out_frames_ctx->format = AV_PIX_FMT_QSV; out_frames_ctx->width = FFALIGN(outlink->w, 32); - out_frames_ctx->height = FFALIGN(outlink->h, 32); + out_frames_ctx->height = FFALIGN(outlink->h + height_align_adjust, 32); out_frames_ctx->sw_format = s->out_sw_format; out_frames_ctx->initial_pool_size = 64; if (avctx->extra_hw_frames > 0) diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index 5259104a4f..303d2101a9 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -181,8 +181,10 @@ static int init_out_pool(AVFilterContext *ctx, AVQSVFramesContext *out_frames_hwctx; enum AVPixelFormat in_format; enum AVPixelFormat out_format; + int height_align_adjust = 0; int i, ret; + /* check that we have a hw context */ if (!ctx->inputs[0]->hw_frames_ctx) { av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n"); @@ -191,6 +193,7 @@ static int init_out_pool(AVFilterContext *ctx, in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data; in_frames_hwctx = in_frames_ctx->hwctx; + in_format = in_frames_ctx->sw_format; in_format = in_frames_ctx->sw_format; out_format = (s->format == AV_PIX_FMT_NONE) ? in_format : s->format; @@ -200,9 +203,13 @@ static int init_out_pool(AVFilterContext *ctx, out_frames_ctx = (AVHWFramesContext*)outlink->hw_frames_ctx->data; out_frames_hwctx = out_frames_ctx->hwctx; + /* work around a bug in MSDK where VPP processing hangs under certain conditions */ + if (in_frames_ctx->height == out_height) + height_align_adjust = 1; + out_frames_ctx->format = AV_PIX_FMT_QSV; out_frames_ctx->width = FFALIGN(out_width, 16); - out_frames_ctx->height = FFALIGN(out_height, 16); + out_frames_ctx->height = FFALIGN(out_height + height_align_adjust, 16); out_frames_ctx->sw_format = out_format; out_frames_ctx->initial_pool_size = 4;