From patchwork Sun May 24 22:40:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 19837 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 58CE244AC5D for ; Mon, 25 May 2020 01:40:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 440E76805A2; Mon, 25 May 2020 01:40:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2104.outbound.protection.outlook.com [40.92.42.104]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2E7AD6808A0 for ; Mon, 25 May 2020 01:40:35 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=naJkkBKlhBm2eqVn7EEPSBDSYvqAuWD9THgZxLequt8VAklgXZxM8Olkm5wOlV/kdTbo9OeSa88etVeBSKqmBjm2pbLHzfT4MYrEMTyUw0YAzUI5uEPxnIX8CKF66BLced5SfmSYjlMq+NzvJh2K7SH3qjurs6s26whblOrc4L237xrxoje257zwghDjpWZ5JryX82imHx1GgyRepHnUwCCVPwT1x7U8alSUF51SD6I1xzjYWrshVYdxbPVoU1me52tZq9DHFiRkdmJHe2Dzwzm1rfooFJNfEMDt93jMRE0XYT01Z8bpg1xG0PQDj28sXGiEa97m2nMQdtz3V+wWbg== 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=89yWJlAtRy639UjHgdK9XZiXHTmaGjd+MLOfMyebCt4=; b=LbVIj2gCiQgSpLOm/GeEM3iBmWPfJVRrnWKRWpx1aQNFODykw2Rf+B1q7MW7d9wFZYlcEDKN/Dd4lVMy0M4rCwbIWvTOm5T7yQ6d10YgpreyU/lIeMjSHZvjKlxdrxFzrK9ZdUIDPOW0mDexFmt6DlGUAxFUoSDLlEvNx8KhvPknL9e8z60nhRTWMWAdcb7lkvMriR9spGWQ7KQrnq9+JISsXpEQtaJIySy7GA7HLLCKENgWETvKmxQpEJVas0HOF3SSOEfunw4wdtQsr6vFiC3MfA4FB+C+wZ+fxaB0VGXrFCvnwjVmFUc309TXIbkp1QTq0XWhyLeoKI/q0HkriA== 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=89yWJlAtRy639UjHgdK9XZiXHTmaGjd+MLOfMyebCt4=; b=VP7s7C105+rESkjD7yFPWr5T5tcdNNb3oNJftQfFgAbYzg+mkqq2qt1snpy1yk8HuGsJoUJVln2aLR+5fo3gAJicbVIBCVG95SGlBnonA2kDPe8JhdGh4nyX/PR5UqhH1zg4xA4CeDWwO3KdluMo6Es9p3n5gHSrHJ1ylp7+IFzFARjeEslW8shgPs0tFYaCIEOmBPwcOszF8oZPoHDHlCfpoD4HNmnKXRDMUVUO4Y+Ir5SaaBznrcQlXoRYnOU87oll88nyApiw+FpvkCjLjDT7ltp+BWdmWW9k7kdCTN1BfinsuzMQewoiQU/rNyEMWwlwy3XqXlvTB0ASBPvqvg== Received: from BN7NAM10FT068.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::4a) by BN7NAM10HT140.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::75) 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 22:40:32 +0000 Received: from BYAPR04MB5222.namprd04.prod.outlook.com (2a01:111:e400:7e8f::4c) by BN7NAM10FT068.mail.protection.outlook.com (2a01:111:e400:7e8f::85) 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 22:40:32 +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 22:40:32 +0000 From: Soft Works To: FFmpeg development discussions and patches Thread-Topic: [PATCH v2] avfilter/qsvvpp: Work around a bug in MSDK where VPP processing hangs under certain conditions Thread-Index: AdYyHEkBfgvuSJbmQQmlysjSvi+E0g== Date: Sun, 24 May 2020 22:40:32 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:7B7FD5B1043D6DF8B56CA1C49139F52D7A616AF285BE78A443DFC82AD1640698; UpperCasedChecksum:C9D35FAC409B2C910CB357DB6D1921F5C3B212D2399019B198973992EB43B0DE; SizeAsReceived:6834; Count:42 x-tmn: [jYkd44y7yiM3JUvtznboHcMOxxZn0Qkd] x-ms-publictraffictype: Email x-incomingheadercount: 42 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 759f2e57-bbc5-44f5-a9d9-08d8003377cd x-ms-traffictypediagnostic: BN7NAM10HT140: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: j/vQSUkwTkqP2pfUJ7ChkiJ31r2lshPRV8EOhNrdryhzQJVLfx/ib+c84kmozAyDDGje4WYpD11VBVcHcPkoTCoB4ftavfOcmrowGtlP4N9v7MTIvgVOvW4TXBiiWDTt12N3dDK9tFDwOGuP8OXgv+5jdB/E7N9td+r1YaNXyvyRnLjffUOzrdeDnFa3FelBk/LuRvnOymgl21iNXQEPZw== 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: ltcZyM+1R10OpqzNyKzDuqCTP4yIKCV5jZsr3+Ybw9ST9CR31k9RisQbKmwdsQJo1OYm6VFuC4Uev4N2Wzy7erKF8iDUsYWE3QtKn6AZSNZKuNrmWnCCxDwarNvAlRyH9evbGWLE8W9QpiwYSHsTqA== 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: 759f2e57-bbc5-44f5-a9d9-08d8003377cd X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2020 22:40:32.4965 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT140 Subject: [FFmpeg-devel] [PATCH v2] 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 are: - Dimensions are already aligned (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 V2: - removed empty line - removed duplicated line --- libavfilter/qsvvpp.c | 7 ++++++- libavfilter/vf_scale_qsv.c | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) 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; 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; 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,