From patchwork Sat Apr 24 10:53:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27284 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2020922yba; Sat, 24 Apr 2021 03:54:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaz39LJEE58hWnUKDLfFyGuL0/NDgb/Rb5zf75sB7lK9SCaIh0lYN1zhp13plrozyvtjMP X-Received: by 2002:a05:6402:510f:: with SMTP id m15mr9796179edd.328.1619261641075; Sat, 24 Apr 2021 03:54:01 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e18si7549465edj.485.2021.04.24.03.54.00; Sat, 24 Apr 2021 03:54:01 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=pvonEMyz; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1591368025A; Sat, 24 Apr 2021 13:53:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2083.outbound.protection.outlook.com [40.92.89.83]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 721DC680074 for ; Sat, 24 Apr 2021 13:53:50 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DUsBd1so8RJGS1mu0OAyyShcA2QqebTYa7Pyj+GkqwREbo6Bz7YUpWjkdAa5qGON2Kt/Nd328prdqUZnxkRRpv08T6Fp3PlkjxntebAu/3YeVOs/YrRe0rkCca+jPaEes1UayjfL05iWQTPKgV48BpqXlj8Wv6p79mzGMT65EFW8zWJTH3J/QE1YaLj3l9zBKw09tWSQgBONGmW96RGb9FxGfhLJO0k55pj+bfdXYsiFVV3Nxw+/fvNuwjVw2bLt00ADe5nJ7J7JSxuyRqlgaFrY22R07GE/z5JjwlJ/1gE7hvnzWAV6yQq0xEGipWIs6UhKpMMgpnHD1q9fk8qs7g== 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=s/uiV2KCc2iF7JIl5Au5l6W0UL7kU8NkDaKaH/S46Xc=; b=VEU81nHRM5f43VDKPjSeMMUbRODOkpNw11Uj2U2cGHlZg6tk89QlQ8IwSVsHaEYX/xqo94r2pEfuatTFzFK3sR+KcgXftMewgwigfQX+iVx5Q3RgxowM74NmnTObEWREb5z3JohqUionf/f4AVtohe9cFheG4CWVgk9C0JNuvih77aINh04ZbrzDWzC94aKtw59TGCw9qqk+TwBJHRFObdDSuQuwvyDp2GFHA02LQlsKmvXfI1DD+7yadG9fT901EUNbUvhGH7V4dCOkQzf2rOBc6rWxwrZfn4tLBwUMOvo/SSsvtOGniqhhbfqzHIpIXfCh2EW4zcu+Qr6isItrXg== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s/uiV2KCc2iF7JIl5Au5l6W0UL7kU8NkDaKaH/S46Xc=; b=pvonEMyzE7TRECVSjt32dqoNKYaaAdOCsqGZK4W/sD+zratJ/O7tggOHuaMMN14O0t+2c+Ov25eIO/NNEu0TUxpCZrDTSf2/bV8Q8WbGb7SX57cMiigZF4f8uykOc5yDO0w59ZvED5oZLyYRbdI7lhtmiLgcoXupw4vMd6vrOVAJD2+XVnQjU3k66KeAwmqgZN6JmxJcJMCC/zPlcADduZFuadwCMTQ/bAK9qqWa4fLfUTTpITOLr6zoxz2YTFLQYZ8+ch6QpJ/+bgGLSVDbbSJ1uAbxJl/whvhImAe/oUx+/fc0kfcS+XP6ksyhKnoVErWv0JWJqlPzSuWJdVDc9w== Received: from VI1EUR05FT043.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::53) by VI1EUR05HT059.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 10:53:48 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc12::4d) by VI1EUR05FT043.mail.protection.outlook.com (2a01:111:e400:fc12::351) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 10:53:48 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:020C169BF8A05C31FFD3309FDF69712400A9BBA582CC6A204EB7808A41301F04; UpperCasedChecksum:55D9303BAB3660540E5B5C115B02E3CE346E9A80C81A130BEE9627D6F6C0EE6F; SizeAsReceived:7393; Count:46 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 10:53:48 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 12:53:24 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 X-TMN: [T1NVDIWt3RGDD1PHqSetb2FEESDIRmEh] X-ClientProxiedBy: ZR0P278CA0088.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:22::21) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424105337.30172-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0088.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:22::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Sat, 24 Apr 2021 10:53:47 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 66d49010-6ac5-48f2-afee-08d9070f3d19 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNUdbPdAvhx5/8x6B2xiI3vbNIUHPAMPd6HmzuKh9Dc6vOjc2NmR8mQWhLGlbBVBi2DsRQXHCFQa/7ShHsWY5khChF9A+uPAGNAbSxW+MiDyqkDf/PdEwY04EzggFucNKXYm8g9yeLNxzlUKAW+LdRWGP00wT/cretChHW9G/k76Vjc2D6PYY+eVV+4n6tMYI32e4gt5qH35zV4QBgSHoIA0igD7ZgjRAWgyTK/2nG70nFE69UiNMIoTsAd9vo+TnIGsdHr9AhnxBU1QC4AG8Dp4EzTP2nxGXH0PhzhTRltDnMxxP8+Y0MIyyxJRElEE5Mi+8QFE3zapxcnM+Ipc7H6PVszXbjKj8V8X4KqwWZ6xkO6iMNm5hmO7Dm4iDjd/54IC8SjmbRef2hmUGecaBpdLbsv9cAhEFQRKlqKU1EpjZfkbVJNoaoMdG1g5EeErmpuM4HrKbFHIlP1TWRxhvpUv57XhAaUxFxigm2DViWNewvtUBXjG555wb8YPRLl0grZGmN+cYFDQKBNNCh55rYuOQLzZJddURaCvOLrKZ5R30wg3AjBl9/kxmzK2tL7xUmT1nuYaKjuEA+KceghKtvwtoE3jHvSi33WQVnjm3ykUgl+GQzxfBFvRDdVwirnbGcrthSdE0oEq/wQX+NHaho9yeoTtTwTCRF+3c13uB9C5YtxImXmemqmW+tWJILtXVzVAn0kLBZUoVLCqKJtqhlvjDhx3qxMQ7OI= X-MS-TrafficTypeDiagnostic: VI1EUR05HT059: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8z/kCJsSmyZEnHf2NO7s9xo1xMLSbLLrG09z/Cyj0FmAV0q2vZrhfnTrizw3UtWZhxDGI/g6+vAX+RnilLmTFG3VbrEiiSOvSpS/oGXT+9FQbkRTJuplDz4H4hFJD0JjpvmMfnbu4tUUfCxsMgkzgj3TocE1juPQlHpLUzx0oMf3C7pyNRioV8+majx3v/ltjNi8sc2gN7856Oji9Nh8xQ8OBfk7FbGVf7IrH2KMuj5VpH4ZcNiU0LqBFxw7j7dg4oaWExMwZuIEv5ALyepiiyt2K2jm5Zy8TjllPGZAIvNGGSyZHH1I94Jv6DppTR/qdAn3BozacfCSD4X7r6qDHPLoHzdK/YPih9lf+QTHZJvDUnbsjh3+OoAPnUab9cCPxctISV1tzOwZuRA5ssYXXA== X-MS-Exchange-AntiSpam-MessageData: QEoRdI7ZOLBOASLrYHrM9Ckg9oTag5tVxtB0w104FlAaLFuLvZSGUwYwjE2Hc25GjAsCG9ti+ORd/v0Exm0k43B6ojyeCHVklcxVHvDcixC3kDZXdqbSZscMUqnL+SldVp5pjeCKHSvl8tBDcFSeTw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66d49010-6ac5-48f2-afee-08d9070f3d19 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 10:53:48.5641 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT043.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR05HT059 Subject: [FFmpeg-devel] [PATCH 01/14] avcodec/ffv1dec: Remove redundant writes, fix races X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mAwTNBETNOCt Content-Length: 1899 Every modification of the data that is copied in update_thread_context() is a data race if it happens after ff_thread_finish_setup. ffv1dec's update_thread_context() simply uses memcpy for updating the new context, so that every modification of the src's context is a race. Some of these modifications are unnecessary: picture_number is write-only for the decoder and cur will be reset when decoding the next frame anyway. So remove them. And while just at it, also don't set cur for the slice contexts as this variable is write-only. Signed-off-by: Andreas Rheinhardt --- Weirdly ubitux's TSAN fate-box (which uses frame threading by default) does not show any failing FFV1 tests; although (Clang-)TSAN does it for me and it is totally obvious that these are data races. libavcodec/ffv1dec.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 8516fef5d7..24dfc68ca4 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -924,7 +924,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac fs->c.bytestream_end = buf_p + v; fs->avctx = avctx; - fs->cur = p; } avctx->execute(avctx, @@ -966,11 +965,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac } ff_thread_report_progress(&f->picture, INT_MAX, 0); - f->picture_number++; - if (f->last_picture.f) ff_thread_release_buffer(avctx, &f->last_picture); - f->cur = NULL; if ((ret = av_frame_ref(data, f->picture.f)) < 0) return ret; From patchwork Sat Apr 24 11:14:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27261 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2034399yba; Sat, 24 Apr 2021 04:15:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkrHCByfeKt94hRgYLLpuOw95OsoILfK54h+zf0JTaSwR/B1Ub6B8Od5zC8OOf6eK4/fZT X-Received: by 2002:a17:906:2b05:: with SMTP id a5mr8800073ejg.446.1619262920023; Sat, 24 Apr 2021 04:15:20 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w2si9117023edi.199.2021.04.24.04.15.19; Sat, 24 Apr 2021 04:15:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=XWPDU5Si; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1908168987B; Sat, 24 Apr 2021 14:15:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073038.outbound.protection.outlook.com [40.92.73.38]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 045BC680260 for ; Sat, 24 Apr 2021 14:15:10 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XAoHJXhYyi9EOt5LkcrN9xmB5NRhWtrPZsoDT78niYzoH05gqSkMm2tkc81XvODHB3V/HwWL+PPf8xlIW/W1NsI373wWOSflb5Wr8ZQdbrLB7LSBMA2oKokPx4gD4nxqb6omx5Ghm2AZkUOFmNh3BvRoZIvdjfuWu5JE283rU80CkrvyMdOwj9E6jzS6b/Kfdul2r2TgGZTNrcv6RS7or6Kz8CrfYNX2Q8zznJpwWBkGC7Z9NBXpAZMqWWZtM+nRc5ZzgP59bbKkJR+zg7OuPX/vU2SBOFvD+w/Wwf/BSk1ECsgEmhv2k4rH/uA91ekUW6EZGFJtVh1HB3tFLiQ4hw== 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=B1gS9zvHXM1geFrSEyBuEaKoF7M6pNCR13CErZFsYX4=; b=g2M+94kZGtlQtF8St7Dw/NUd6S7gmw0fiDdilFl48RdIIbPdCllLgdEP+wSuhs7oLQiwr3dV0QKoAOvLTNPV3IJgJcEq/8d1tK6E0fEoVccdBaBco+r6ayFVb0UG+y1zDzek+3fVaxF7WpnzkEyblFNydvQU3n83WKrWBPoctw4cQFhmG5seFlBu3Q9sAO1WI8gEIJA0vx/AeBqW7alKFw8tTUApT4pOqxibjhCtkQ9LnIvUJQdn+umcby64Ktv21eqXAKIXMsNynxt8cgue2nxRMzgBYvntV0HVs92j6DXwVFpsnyX4dOZ4LmB1fo+kPs0aQsELHTMWnkFYgyi70g== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B1gS9zvHXM1geFrSEyBuEaKoF7M6pNCR13CErZFsYX4=; b=XWPDU5SiBxCj4lVR950/HHgzfSzMsEiyTAedFISBStOhMw1hb3+AauEaqCUi0Xxe3aMH5kve1+aFIun7qQ6OCbSvulZgO0dAbqKnklbPXSTIKfJKCVtpI4T8hGf5RHpPbva0ou79Zy/lX8BLwSzlNlfkDm81MJ4hiNwAQcLam5QdgLbhT4r8B+Fw+knt4rBREzpHRi6GP+NyAEJbj4ixCgcLTMD/fIPkVh1XImXKHF2YK0bMXRTnmabaOHyfhmA+BWRu5p4Jd9ZhFxJFfyHOE7j4Upw7G2vhEC+Tz3VekdEuoQ9BZQRopM6bCHLIC0Z+7PiqJod/yN77HB0xLsORfA== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::40) by HE1EUR04HT079.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:09 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:09 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:2DB19B7F3223853F510C49BD5956B6D28584677F06A67E542F9B1D08E70A01CA; UpperCasedChecksum:994FC82A9A0831588C417218DBCF51E5DBAF676660E43269399C848B51DBC59A; SizeAsReceived:7588; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:14:57 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:34 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [bsQYRLk1vQ97HKyttV7v6y65MyCknDKO] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:14:56 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: b2958f18-16cd-4a3a-1e64-08d907123168 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEuQ75gPcT42JOUsIEYyvf9YjmoxZbA1YbxeVKaxwGPngjqY8QEAPD5P2Jm98BZv96s6RR0Vbnm5YQrONCbF1N5thd6teGEPxkl0ZA606UiJaniO71+6vU4PLpS4B1nmFEok8rGkHQKRfO8ryWTVy8OyP1uN9NLVuPXhAFiMXSAFyKd2HlkUYL3b6i76Ry2I8y6UNHAXI5C2W1bWvw+zsSB6DqzqU/PKE/JdRWKXzWCb0unJ3ii1YwILVpvaqxrC/FLoiKiXytP2DkG/aczzRaFdqYa8PBeqXDs6vZRTPNwHQD/Ojk5coGBjwN9gfl5aC8l/4Q6bOwxMHhnAraVeQdM3ChFE9IKk1SlW0LI4qHTpeIzAnzHIEM2BL3lFjJFIzq38zKMDnXyhh+sbwqZxoYXSCjXGczmEv4TI1gjUm43Kpw26vI+uevnhNQS4tFSa828gtFODbgwM3MNDCefviosCMwVCS8aQfvEfvglS4lfrQs/p8ocXqLPfRKud2GF/j+GrAtXCiupgFIghInvqdO6DsSTOiKslKCQm3CXo11xlTvmoP6eS4wznEiW7ZIq1J/W9C07GpHuS3JHQ7PIIs//zOuvob/s8IOCCY57B5yQymnZCE6ZkLuTUap47ythrwlsXEAvvY2PLxosw44oyhGtFa2yNTm/HojEYRAdXppfFDYsP+ykMYaAGuNRLRdq1rzFgqTaRwKa0TzbsratCDJotqJ8i5db+pfaoCnGNyy2jJtZS5rlFhcsMs6wsVM2NNoPC2Li+yG7+z3dYYuYUdNC6 X-MS-TrafficTypeDiagnostic: HE1EUR04HT079: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dk/ERvASt/6qWLgagQUyuP/aUU7HxpCbtwQQG6FESKh2O4bZYiZ8oipaZ5uRVXOdR5/utpj81EZpz/4R8+gCpX0kZQL1/YUA+8zfgCIynmHQ/aGD8tMskkoul/O+PJ2HbQM91OZ0j5gPZBm/j+weNMiF67M7ZHXT8WcYE0uRfC0b+Sekgbzeof2dqr8YcFUFTbLNbGWKHyV0GX97Hylw/VCgIWL8VzpdzQ6A5aBgIAE/u2VXTDZJNuogqnLWud+t0oSiTs/PMrEdMxyZc+yaNa1W8U8hVYnikM1bK1NqbLGlbsnARd65X+CBKCaYnUjWvruJM+r7gr4zJxFnUHj8D3FphAsVOuVhW7o+o1FJ4KQszt39CFZZHv88Emp0PR7DBjCl8o+m69pq/g7uwwjVow== X-MS-Exchange-AntiSpam-MessageData: KwPw/PFTmNQPUVawLSwtNBL7ToDWHG4iRKJ1oWZ8Iwas2LSeg4tFxTfKcJ1dwL+dAU7Rl34JpMZHyqfH4LWaneLW046f9cODTSinlk2XRxJCt4nk8C4rwTfnNdScA6snqZvwKSGPN2l0u4yCDC4big== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2958f18-16cd-4a3a-1e64-08d907123168 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:14:57.1587 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT079 Subject: [FFmpeg-devel] [PATCH 02/14] avcodec/ffv1dec: Don't set ThreadFrame properties, fix race X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FqkNXdAQfgYr Content-Length: 6008 Each FFV1 slice has its own SAR and picture structure encoded; when a slice header was parsed, the relevant fields of a ThreadFrame's AVFrame were directly set based upon the parsed values. This is a data race in case slice threading is in use because of the concurrent writes. In case of frame threading, it is also a data race because the writes happen after ff_thread_finish_setup(), so that the reads performed by ff_thread_ref_frame() are unsynchronized with the writes performed when parsing the header. This commit fixes these issues by not writing to the ThreadFrame at all; instead the raw data is read into the each SliceContext first; after decoding the current frame and creating the actual output frame these values are compared to each other. If they are valid and coincide, the derived value is written directly to the output frame, not to the ThreadFrame, thereby avoiding data races. This fixes most FFV1 FATE-tests completely when using slice threading; the exceptions are fate-vsynth3-ffv1, vsynth3-ffv1-v3-yuv420p and vsynth3-ffv1-v3-yuv422p10. (In these tests the partitioning into slices does not honour chroma subsampling; as a result, chroma pixels at slice borders get set by more than one thread without any synchronization.) Signed-off-by: Andreas Rheinhardt --- The spec [1] does not rule out that these values differ on a per-slice basis; I don't know whether this is even intended (is there a use-case for this?). That the slice dimensions needn't be compatible with subsampling is very weird. I think it is possible for two adjacent slices to set different values for the same chroma pixel. libavcodec/ffv1.h | 2 ++ libavcodec/ffv1dec.c | 62 ++++++++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 147fe7ae16..81cbe8757d 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -96,6 +96,8 @@ typedef struct FFV1Context { struct FFV1Context *fsrc; AVFrame *cur; + int picture_structure; + AVRational sample_aspect_ratio; int plane_count; int ac; ///< 1=range coder <-> 0=golomb rice int ac_byte_count; ///< number of bytes used for AC coding diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 24dfc68ca4..b3481df922 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -165,7 +165,7 @@ static int decode_slice_header(FFV1Context *f, FFV1Context *fs) { RangeCoder *c = &fs->c; uint8_t state[CONTEXT_SIZE]; - unsigned ps, i, context_count; + unsigned i, context_count; memset(state, 128, sizeof(state)); av_assert0(f->version > 2); @@ -203,26 +203,9 @@ static int decode_slice_header(FFV1Context *f, FFV1Context *fs) p->context_count = context_count; } - ps = get_symbol(c, state, 0); - if (ps == 1) { - f->cur->interlaced_frame = 1; - f->cur->top_field_first = 1; - } else if (ps == 2) { - f->cur->interlaced_frame = 1; - f->cur->top_field_first = 0; - } else if (ps == 3) { - f->cur->interlaced_frame = 0; - } - f->cur->sample_aspect_ratio.num = get_symbol(c, state, 0); - f->cur->sample_aspect_ratio.den = get_symbol(c, state, 0); - - if (av_image_check_sar(f->width, f->height, - f->cur->sample_aspect_ratio) < 0) { - av_log(f->avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", - f->cur->sample_aspect_ratio.num, - f->cur->sample_aspect_ratio.den); - f->cur->sample_aspect_ratio = (AVRational){ 0, 1 }; - } + fs->picture_structure = get_symbol(c, state, 0); + fs->sample_aspect_ratio.num = get_symbol(c, state, 0); + fs->sample_aspect_ratio.den = get_symbol(c, state, 0); if (fs->version > 3) { fs->slice_reset_contexts = get_rac(c, state); @@ -967,9 +950,44 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac if (f->last_picture.f) ff_thread_release_buffer(avctx, &f->last_picture); - if ((ret = av_frame_ref(data, f->picture.f)) < 0) + p = data; + if ((ret = av_frame_ref(p, f->picture.f)) < 0) return ret; + if (f->version > 2) { + AVRational sar = f->slice_context[0]->sample_aspect_ratio; + int picture_structure; + + for (i = f->slice_count - 1; i > 0; i--) + if (f->slice_context[i]->sample_aspect_ratio.num != sar.num || + f->slice_context[i]->sample_aspect_ratio.den != sar.den) + break; + if (i > 0) { + av_log(avctx, AV_LOG_WARNING, "ignoring inconsistent SAR\n"); + p->sample_aspect_ratio = (AVRational){ 0, 1 }; + } else if (av_image_check_sar(f->width, f->height, sar) < 0) { + av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", + sar.num, sar.den); + p->sample_aspect_ratio = (AVRational){ 0, 1 }; + } else + p->sample_aspect_ratio = sar; + + picture_structure = f->slice_context[0]->picture_structure; + for (i = f->slice_count - 1; i > 0; i--) + if (f->slice_context[i]->picture_structure != picture_structure) + break; + if (!i) { + if (picture_structure == 1) { + p->interlaced_frame = 1; + p->top_field_first = 1; + } else if (picture_structure == 2) { + p->interlaced_frame = 1; + p->top_field_first = 0; + } else if (picture_structure == 3) + p->interlaced_frame = 0; + } + } + *got_frame = 1; return buf_size; From patchwork Sat Apr 24 11:14:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27250 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2034481yba; Sat, 24 Apr 2021 04:15:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx06oE1lr02sRT/yYiM03RIOZP4bP1iKTIxgPNtRHi04SrR+BR1HLLVGoc55/ZiDjyafNvx X-Received: by 2002:a05:6402:14da:: with SMTP id f26mr1324824edx.351.1619262928779; Sat, 24 Apr 2021 04:15:28 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j16si9557708edj.401.2021.04.24.04.15.28; Sat, 24 Apr 2021 04:15:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=DqxRqPCD; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1CE7C689CC5; Sat, 24 Apr 2021 14:15:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074090.outbound.protection.outlook.com [40.92.74.90]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 684C1680074 for ; Sat, 24 Apr 2021 14:15:20 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mmMg/LPf8V/DFXgpFVPuU+U0Hft0L/AMHgPaqEc0SmdAQQtVZwWMXocqZt1LLWvVqVGfg6aDHktwSZoRqLIurlrQ/iYZ7X+z4qIB3EjiSVX7XZZg4/JK+xeUA2cvGAPYNVEfVm2udQdAor2dqJgwJ3Nna75aUvofCUv1p4OC+hiOmzIp45itzSKXAmMzdD6/LT8ch52OHfHMWa13rgq1kmufb/bSBA9r7nyKlxzu/45S0KlQqcOHf8wG+U35E7Sl0sa9DtBrpfthB9+Jxt9r/FcwV+VZy0beTWhiGA7vcUlVXVklZMMWqZEGOug7E1Ex8jbc0ynyAVdqGripIXFnoA== 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=HorHbN2lvmG76L9BmeWy2oz8toGIbbm5sNsjnv6kI/s=; b=Jt6Y02sRkwEZTjgf9Mo4nok87IA9YCUCIAjL4jh202hUmzBF6i7vr4bjfMLxlWnB9wLfZGIVUHNZGiAhpfjxssMLlrlwpX8hdaG5B1mEG78hGZvi62sRmhDXXDekKi3NFTBgz3zk9PFrQWSZm5MI67eodt1LjbH7sL/kWHRhMuHl9GBlLMTh7SdV6FvIGhQN5GDvVsDyv8N7Wo43DVpKV0rLanLYbYM4afDLfBtxNgDaQZQRc6gog8jPinVc9zQAn/br7+GJCSDJ7s8iXshKcCp2i/it4a+2IBQD99yGV3Uk28jB685saZX9kmJg+5xi5kurMLP1tMNbpAsvM+Rr3g== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HorHbN2lvmG76L9BmeWy2oz8toGIbbm5sNsjnv6kI/s=; b=DqxRqPCDnDt13Bk40KfubZoEPriq2GiWE0DdEdkXCHf6ndNeuCgS0kdACSn2/fdQuDWIe2wyav/2HuwSqCjDU3qxLtaf8gTzaldKM2e5D1ipJ/e9ts35nGeglz16RGKCn3VRgNCpOr11P6BgCSeonarm4S4qHVXjRo81QNlpvej3a9+tzx8xoKcMeb+eNv7kWylDTb/BAi9vTdn/yXdurTHiy6mERmz3sl8GczKTINMaA1rQ8O1KgWAfh1V+W2m+ViK3qhtuArYsqRF0qekw6iWhlHlFR8AWm8j+eezo0Rl7pFHVlDiTHIlw5ezxAfKc7VWhnytY1qay5wNMV1BFdg== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04HT200.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::398) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:18 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:18 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:7F1FF28D93E18FEC7616D97A2C3F652111D48A4439AC620206822E7D0E9A8B0A; UpperCasedChecksum:BBFAA2BAA97D55A99CE3F6AD25467DC6A189A913C9A740CCF85C16D901FDB99F; SizeAsReceived:7588; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:35 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [TIs1WkLhVo50JXdV8F8VmHsB1wIBBGd3] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:17 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 653ba83c-b4e7-4975-2a20-08d907123e62 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSHACczraePvIduOTLAdlimsBwclWOeIZl26ND0JD2eHcOb+FmPthLETEZU0CQnls3gMgI0PgogdeU/EZMjUcF8ui6RWMwd7NFqaAkZPtkAwMmvZYf3vOspEjHJt8zcbB+q/w71xQBZUQGA4DDYQGhyk2lDSq/kgypVU79RACGYoQOJmb5oGqeB99jJHsJtqK4YLt0Q1tNrkFOqwpzbWEz5RAVe89JHu6pqB2EAh/A4OevNwWBWWlanPSEgvS92+w6lzzKlx5FexBf229j5fmnyhP/IJJOqQ0hwojdshBB00PrzTCvAn4DDzo+7BklzNlO7mli3KpqejqYI5yztqMr1pDXIhV66Bk0SeFqv5d8pWN0myFVJdbKPr16lLY173Y9e6OTkE+JZtrwq90LegjF+Jzp1t1V0fZAsGqciCzW+Sc/BgYmF6RWUmQtCDxk2hdnh+ZRMPU7VwchaLY3LsC/fr1D8d195I7kIyx81dbEeSD1+1WM2UC3mhQCU38jJdHwFXUna7a8qCYLuKIGMC8cBoWF+PFL1a7uLlhx5UwzefaBFt/hZHhfKjrT6shMgltHx728pvU1cYM/8iAW2lygMzQhKfl90g4MYm1sR1kQrxBDpNGche+mKH6G5zjNhxEIj9QHzMgqaYhXpnVHFCI/MpWHrpE6ay/W4VQJrFlV454zm7D/eZfvU1gy974nRxiPzcdpS5v/fffTkQk0nRGELh1P36SEysuKtPIO+sEcFd3kzS9eUggGVjhXZAG4pNYQ= X-MS-TrafficTypeDiagnostic: HE1EUR04HT200: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BR+ZZEjY41mz2jmJ+eAUY7satiz0As1Tg09hsSEWBZ1PqrlWaDCt935VNGWCGAHUqqcgDQXt0sxvnmfiXdE4M7FixVycF5DWO5RptjDYbOFbOxuUbyqlbyf+7OnsMwUGOceiCv6AxpJFIJKZ24/dQugqiu+HaD59MwntaXFpRjDzBywUCRnYo3C/SDsmUwIvgUASIP08+DSRvaZjIGonBE4kFXBdMiNCglFZ0LVawSKHHg7oj41WLR7+L1WVvPkucj/mrfhXX8TQhLMQE+bWm9mTDMPf8smkycT6kjPReQLG2pwhsvJRp1lDZo6FL2wrLpPpMqhoSQuJeIxLsPn0AybD/Alzegu7QIEruowauehe8Z80s6EIhqcAG6Vvnrn+s5v3HOrthlUXabBohb0U0w== X-MS-Exchange-AntiSpam-MessageData: GI73TnE+qcISdgqifaHB+hwtr7q1MEZFjADAnS7x2c6tdHrkuMIUvtjz23snHnqffwWw6lp6J9LPxXyq8H/23gfT+nX49frfSJlNW2tQ+/rrEk/ICl63pnmyboPopY7uJdRlAP6kfscjDUVfugF2mg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 653ba83c-b4e7-4975-2a20-08d907123e62 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:18.8991 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT200 Subject: [FFmpeg-devel] [PATCH 03/14] avcodec/ffv1, ffv1dec: Add const where appropriate X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Kriq2xKqJ1hx Content-Length: 2782 Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1.c | 4 ++-- libavcodec/ffv1.h | 4 ++-- libavcodec/ffv1dec.c | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 1c580c3b49..47bb032876 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -63,7 +63,7 @@ av_cold int ff_ffv1_common_init(AVCodecContext *avctx) return 0; } -av_cold int ff_ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs) +av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs) { int j, i; @@ -170,7 +170,7 @@ int ff_ffv1_allocate_initial_states(FFV1Context *f) return 0; } -void ff_ffv1_clear_slice_state(FFV1Context *f, FFV1Context *fs) +void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1Context *fs) { int i, j; diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 81cbe8757d..f5ac8090bd 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -142,11 +142,11 @@ typedef struct FFV1Context { } FFV1Context; int ff_ffv1_common_init(AVCodecContext *avctx); -int ff_ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs); +int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs); int ff_ffv1_init_slices_state(FFV1Context *f); int ff_ffv1_init_slice_contexts(FFV1Context *f); int ff_ffv1_allocate_initial_states(FFV1Context *f); -void ff_ffv1_clear_slice_state(FFV1Context *f, FFV1Context *fs); +void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1Context *fs); int ff_ffv1_close(AVCodecContext *avctx); static av_always_inline int fold(int diff, int bits) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index b3481df922..3ac2904b63 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -161,7 +161,7 @@ static int decode_plane(FFV1Context *s, uint8_t *src, return 0; } -static int decode_slice_header(FFV1Context *f, FFV1Context *fs) +static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) { RangeCoder *c = &fs->c; uint8_t state[CONTEXT_SIZE]; @@ -993,7 +993,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac return buf_size; } -static void copy_fields(FFV1Context *fsdst, FFV1Context *fssrc, FFV1Context *fsrc) +static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, + const FFV1Context *fsrc) { fsdst->version = fsrc->version; fsdst->micro_version = fsrc->micro_version; From patchwork Sat Apr 24 11:14:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27277 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2034665yba; Sat, 24 Apr 2021 04:15:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyKPtGOwGsRWjayA3UYPFdzu1Zv05cFZjXSSkKeHRyI+jY1PM1T+y4JKeYNq32KL6MOO8W X-Received: by 2002:a05:6402:4386:: with SMTP id o6mr9726162edc.33.1619262949107; Sat, 24 Apr 2021 04:15:49 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q20si7524983eji.300.2021.04.24.04.15.48; Sat, 24 Apr 2021 04:15:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=AUuj40lP; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F423689F16; Sat, 24 Apr 2021 14:15:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074076.outbound.protection.outlook.com [40.92.74.76]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 44A78689BFF for ; Sat, 24 Apr 2021 14:15:32 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d/ur3kzoY94pDbPysSbqC0bYgi4Pn1KyTLdhBqvmFy9oscyIpzVK6h/27ZeWutn2kI0Y7DUrZT0Q9Cq0TlI5mBjLBQ/XEI7qMiCktK/siYOCoRwJJNigzc0N8atBjLq9S8ZLDPdtadxrEpRlJMTIos1yrYhvdqmCZA1+/x1nq2g6CM/ROUpLNPaNbRZ7yMKbBdTHGUgWc6iFHQrkLFv3h63KU14b/4fPKdS3+/oKhI5ElQpcWzW6YB1/8BSnYpqTcGEiG6Px3CINa929FjGgiemJ6Pdjp33ms2C7eOPKJNXpRNA76ZwLeWjPXJNAgiZfZp3ASeVlpsM9Xs7bJtWR5g== 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=PLo+XATTFNR2dUQ0AxllEAcYOfIQa2UWb+kd3yXOOco=; b=QTiIoppCpckyiVuTbbScS4wyHGj/ugYAD/COTQB16rWGNCgv4sFxClLnpezCFnMh/01kDygqIuI40SsLAJmEsE52cxLy1PzxsjiPll0oVE33JBw6KhSEMWzXCTr+PaSbLVFLxJZw43p+DC0teYnGdPtDgqYV9Zscnv/dCQijDb9uHcqnI1+R8z405nHMewDu+zlrVOg3R9sMz7caVYBcM6859WxkbDImD9be4gi4ib/inQhFpvcCtfDVGHhvCECmVonNvfQEehTP7DGu0/d7VEnAYz75F1SAdNh/NTmYcIq//rWlcs6dLGaLJBUakWdz8HipDPGhpH4CY2oJ0acDxQ== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PLo+XATTFNR2dUQ0AxllEAcYOfIQa2UWb+kd3yXOOco=; b=AUuj40lP+m6RZJAyZuypW7433liI/nIhHmlKJ63V3MeHqiOFC103R+N9d+q6B0wKDYq3YvLChm1LE1rUzJw0guT0clu+jRpyNbTSodUXJHvQGi+jXlf1cx52DiOuOgF0+2fBtO/DT10MhyDSwnivNZAi+hFX4psVZC9DGjGtSAqLuSw+or49dlF44t0AR7ZUiBXFYr/4vEL0EUG83L3yqs3ULFEunU9YY91SiotWF9a8+4NpCtKXJ2pcXJJztnokJaALzXdZYX82Rtkv+Bw737mADnvARS7fULdKhcU9zqH0y6gliq7MgFb6FtxHkZV2gPO3JFPvFIsZkRGKhnm3Wg== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::4c) by HE1EUR04HT022.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:31 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:31 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:1E3573EECB94819F3C4D88D8C4D480AAB12EF22FB81814EAF58BE0A7AE92709F; UpperCasedChecksum:F300EC059CF72613BDD089291594C491292BD3FCC9C91B1EF3E5B55A01953755; SizeAsReceived:7579; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:31 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:36 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [NNMGlcBziTDtKKZilh4xMiy4MTtvoJgy] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:30 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c578262a-7937-4fe1-aea8-08d9071245ed X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSHACczraePvIduOTLAdlimfhyPvNe+GCt/zzK3uecuDebl6L7+CrrzJbRgFuIEyIj9XR7edORZ9zQRgiLKUiGNpohGRhJCDYAxe4xN6yq7O/H4JDSVS5zAa7rfaUrm18vVRCs1R7pXkYLyWKlUN711s1MzxO91i0tntnSTu3b5JMKKwNDB94oK+SbP/tPv8eSWO5p8e5Lyu+mXbTSLku/kzQOQgVr4I5xrhVbtWbwJikfKc0kHW5bGONKTZ3Vmp6LITVqC5XRa8KvQiek7ATPomZgNgt9ekT5JTa+3dPnRfxL6qQJtSK/u2R8ZV+qjVbYcxlWPhFiCiImfi40CXErPbUdot+hHmx1vz84t/RCoUngSucPRRwyxSbFNHQx8ZmPUS29af0RKOj+WR219EmxwBpdt/I5q94HXEeHXgkeAtaRqPYdJgP1Ik0AEfzdkqPsWVFEiMDhfd4ATzD5ETzb+jGJBKszqDQESr5AhC4mS0I9tK4crBmZpyFLjjDc9NLR80TZBhd3SWBaUTZdWiFwZ5sGTLR+ovOrlnomZrn0mwCWREufkSJMBIWXLVX4X0P/0SHULZvK82WRxKCGYEcGmRnCNA6B/14YhHz8wEMf+F5WHV7I5wyMJpGeq93A4u5lyEdliI5uJlTvOLS2f3ntcymLieIAhK7xn45UU5vaJIEgxJ2yKbZGEzVBZ3tW4QlM6c14s5wa4NXgfoyPmZgyQHPqd+3jiiI7iF8I3NubAxBHyGLJu3A8c5IRkEa7rvqQ= X-MS-TrafficTypeDiagnostic: HE1EUR04HT022: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1u+yTZPE1gLxEpvzg+PgGdCCfIgFCSrC6CMwI3kb7lTHRjeRWl+PDTpx+SEqhb6Tenf/ozaT/wfo2WxQxdwtx/mPMOgkIjdJLqyjqXYr3ZqFzbDX5YMuZKJ45fa7c+1urClvd4h5opwfDU0qLryZv1oEBuE6ABtCPEYUy3UzdB+5Je8+YVjsHuhsfQ1A6VmSn8IP+0Ifl3h4exQOCF3U8dBFIFwcIlEqNdFqW2c0wEVQhJT6mlC5BJrgjEcbF4BvHRU3p/HhPeM6s7ANZbKEFySVNBlhfPZvia+uRqnYQWHTOHJnUgsBhjVHGt/rYG4QuDMmdFP6Rmp3Kd5IUk+Hw7RIS9nuoMOHOaPq/niU2ARxbzsPe9QamVK6zy7+nGkH/sZT4fFf8zRnFFIx2z6CFQ== X-MS-Exchange-AntiSpam-MessageData: cbEXn9GBEa6+ERfQF+FGueqQsKLsU7MmSbzhrQ2sDtz1DFMSU9JZ8BeSe3en56nqRpRZvMdxIDlNdYJ3yGkPXqBxoYysCcFZuB0vzt9vRBYvYXC+tOGQoyIxnd/oS31SJwz7TgO5hymVMMpqMyHGVQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c578262a-7937-4fe1-aea8-08d9071245ed X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:31.5835 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT022 Subject: [FFmpeg-devel] [PATCH 04/14] avcodec/ffv1dec: Don't copy unused field X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1KUJ7h/bBKb5 Content-Length: 1002 The decoder always uses AVCodecContext.bits_per_raw_sample. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 3ac2904b63..c08ec5c1b7 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -1011,7 +1011,6 @@ static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, fsdst->slice_damaged = fssrc->slice_damaged; fsdst->key_frame_ok = fsrc->key_frame_ok; - fsdst->bits_per_raw_sample = fsrc->bits_per_raw_sample; fsdst->packed_at_lsb = fsrc->packed_at_lsb; fsdst->slice_count = fsrc->slice_count; if (fsrc->version<3){ From patchwork Sat Apr 24 11:14:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27254 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2034562yba; Sat, 24 Apr 2021 04:15:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrLLUq0gsrVfDmWdwGgL1xZUCv5XUQej10gLYvYhYlKotcS+XoN4TS88/CDR0NI3em5pBS X-Received: by 2002:a05:6402:698:: with SMTP id f24mr9648377edy.217.1619262938240; Sat, 24 Apr 2021 04:15:38 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u16si7583549edi.298.2021.04.24.04.15.37; Sat, 24 Apr 2021 04:15:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=SeTj4PiC; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 14AC1689E41; Sat, 24 Apr 2021 14:15:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075043.outbound.protection.outlook.com [40.92.75.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F642689A61 for ; Sat, 24 Apr 2021 14:15:33 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nhLhJsjdHqtCCFPfnI9pf7tdwMPDHY84mCYoobPXlDTJtgI4orxkjy+9C82telmZWJ5cvoroZ65EcYW9moDq2sVKz3pJOv8u/gIRCSpDX1jvgRlPCFysnRQvsoQuTGZ3fZzZdvj/dWUcPomA2a3bLHuVel5/OjZudSAI3Fpq2aXb3qIOmvh6INg6Onyf9LfdsNMtSmYTB3SZy93XCBq0SiDpZ6DmU3KYAo5QqjOwHEItJ5hFS+81Vhnb9UOv/gYMD4Dd5hdDKcizYNDWFpEAffC80sbv++ReAV608kwPWcykt5Lnn3iWiXw7d8EIT7rNECPWmtX/bMD2r5u1zMdUvA== 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=U7wZ0PSsPYQg2iGuBTrmGWBiGX6kWBQfpE/CI0GpYV0=; b=fwXye0wkKbUkyXnnzo5HQq1Eg30j6SdndFtexVj3rK1Gamdf9zv3YCUDjLaFYxAvbGwisX/lqXgZmAdegqN2PLGrgyaXqGlL/8T7JdnLi4iBes6uP/fpx7XwmzF2uzDUIpEpdwP5kard1eIE+ariNifTKm8yL+6Vq43cBw/ZwC1ZIw3pxq6bfMKJD7dvq5qun7iGzzvicxIx5Vmh2E+kBDhQFDd8KVnaW2dzbifEEpmd1yxtdvUUaJ8/bybNUfQdu5lNEPc/CZOSy6uRfwrs0yJIIa8nDvphFMO/uwWgqL2q4BBN8GKDfSb+UBcEQu0X92TVB6wOvBdX9aS8HlQY6w== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U7wZ0PSsPYQg2iGuBTrmGWBiGX6kWBQfpE/CI0GpYV0=; b=SeTj4PiCU2+R+7XzxWAgUIbDjHsMvughsyENx1P1Uo26nfNOFkDPgb4s39PFO9uenxJo+TxJpnjiciPQBkAbTWq91YbIg4GcH4Ybw5UZrw8/o/YKOIvY2C/0XOPcDB+T4Ii0FY3wrQbdZxZmVGIF0TuGhuH+M0oUHQkW6jnVpefRpRkORN1geDKwIrDdP33D2Re41AlxoGjOXKShoEM+/jTwyOFuBOcVGcqCKJgfpmSb1gos66dcv0hD9puKLayNjI20LV0doebhjOC1OfrO8Q72mbdfvZfsKjviK/CZ1uThwIh7UGuqPJCgs3pigsl02O7Q1N8H+F0+d6nhGE3SXQ== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::43) by HE1EUR04HT105.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:32 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:32 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:1543264E4E5AA30854AC637F79BF76ECA132F76F9AABF98D2E74BBB5ED4E2F34; UpperCasedChecksum:41B0FF6D2658ECA59C008219F91B80B723D52CB8D53F9EF712FADB5DA015A7D2; SizeAsReceived:7606; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:32 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:37 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [6O4/kVlZt5/AK9klit1f+Axa2s0zUNTq] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:31 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 9320ac6a-aef8-46d1-9d20-08d907124668 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSHACczraePvIduOTLAdlimzofZQIdO6ckY6iSIQobtjRB9/OkbNilEvcSo7HpzcJ7NYwcYYPJOh16U70eg+lWfxUzCC7ezw8uhvDBd+eBciqrRdMbQinoZ1hSkzhNd0nMVqzz2Lggbij753QBWVJzsVpkO6WcoTwG5HMTOeW+unF3NA6Pe8N1cQ32vwBy+Sq5xWG4T0rF4wtV4BKkiTSjNSqtd3TYKg0QrD21ZYO/7xFK3PoUOSfjCFfNQwDNJJl/c+CK8u1XwHTYjXN/f8XgaPEA31y/iM+alExN/m8a1BA9dYXFM7vy+r7eBJiPkGh3jMAuqx2mT5kpEDSdx5QZhFrqQL2eRRrmBn9Qku/K5hNVulS+HuZvtDfIfZHWwy1P7JS8M8NR90m6W1RzPLjTlIRhvKCTakvzuIuqdAK/X98AQynTHb0P0i/XbASRSq4bmo1T0hZRjM9g5s8lspC4gratANfO8nEmkopf32FpEiwCFT+ANlD8UOzab5ZN1OO1f8WdohqSc7rCeWcQUx3HUGpdpA06BP+GexuffaQbOBjxIW0xrgAqzz6oNgRbVpG1IKyotgn26hl6Id77ZA6PqZotgpPObk8XREhOdeuCtRI8d/KNsJkpbUjoTCMThTO0pWFWW6ikBQIRm+GcLNJyzKv7pz7X8VnBgE1FKGWx+4GBWOKZ6VQuTfidIoQwO7f8mtalVWYA0nt7s/Ebd13JlZjxurc740jgZENEYgYIEMVCiaheLacyqltrCIBXnRNU= X-MS-TrafficTypeDiagnostic: HE1EUR04HT105: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y8o4TNbsHDop0M+MFSQWLwPzZ++MfgEAAdvcklWSd8m+LkR6GVp67qRTo1CvU2ttVdpJXuJnBGK4sjC7uq6yTvTwnTOvTm7YD9rMdmPZy4beOpAD4Flecg611cbvJQnPZK7U36HsB/VbN30r/aeGfA0IKJstnvfEh0eDCiF1Ow7rJCDy8M51+WGSPdcQMwomKRXCuHpDVFA7HX9z9xK4ew7qA+hv7NRDYTCPMzxMA/AD4yK1b54AxoEZbX5ZeXkF3Uwef4es+GuMeLVfAek7CJEaL/qJEMLOr80OEZ3IE2D8ZsS7qWIjQbr67nNluxM3mEEErDAiQRc2B1wm7lw7suiJejcTj3PiYaezxudabgwRJ+9T6/xxY3GBRnYe2Qk9zu+UWqD7kTlOv+7r4M5M0g== X-MS-Exchange-AntiSpam-MessageData: 9Hr9JtFn12en6cxYhUNMSz3mf5XHJkbhte5a/uUwbbqVufMzG5rD/tl390qH1rd9qEtkmqzouJIpRdfyBqs4VbdplQ+g3ot+571s+Okn4wkY6dTmsfsmEEuj4/xQPt17Ga3oHXwGb9vJBUkiH9Ffqw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9320ac6a-aef8-46d1-9d20-08d907124668 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:32.3391 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT105 Subject: [FFmpeg-devel] [PATCH 05/14] avcodec/ffv1dec: Fix data races emanating from copying whole context X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: f7fwGe2f+0zU Content-Length: 2660 When using frame threading, the FFV1 decoder's update_thread_context() function copies the whole context and afterwards restores some allocated fields with backups made earlier. Among these fields are the ThreadFrames and the source context's ThreadFrames can change concurrently without any synchronization, leading to data races which are undefined behaviour even if they don't lead to problems in practice (as the destination's own ThreadFrames are restored directly thereafter). Fix this by only copying the actually needed fields. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index c08ec5c1b7..9a9ee10a4c 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -1031,18 +1031,12 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) if (dst == src) return 0; - { - ThreadFrame picture = fdst->picture, last_picture = fdst->last_picture; - uint8_t (*initial_states[MAX_QUANT_TABLES])[32]; - struct FFV1Context *slice_context[MAX_SLICES]; - memcpy(initial_states, fdst->initial_states, sizeof(fdst->initial_states)); - memcpy(slice_context, fdst->slice_context , sizeof(fdst->slice_context)); - - memcpy(fdst, fsrc, sizeof(*fdst)); - memcpy(fdst->initial_states, initial_states, sizeof(fdst->initial_states)); - memcpy(fdst->slice_context, slice_context , sizeof(fdst->slice_context)); - fdst->picture = picture; - fdst->last_picture = last_picture; + copy_fields(fdst, fsrc, fsrc); + fdst->use32bit = fsrc->use32bit; + memcpy(fdst->state_transition, fsrc->state_transition, + sizeof(fdst->state_transition)); + memcpy(fdst->quant_table, fsrc->quant_table, sizeof(fsrc->quant_table)); + for (i = 0; inum_h_slices * fdst->num_v_slices; i++) { FFV1Context *fssrc = fsrc->slice_context[i]; FFV1Context *fsdst = fdst->slice_context[i]; @@ -1050,7 +1044,6 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) } av_assert0(!fdst->plane[0].state); av_assert0(!fdst->sample_buffer); - } av_assert1(fdst->max_slice_count == fsrc->max_slice_count); From patchwork Sat Apr 24 11:14:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27274 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2034793yba; Sat, 24 Apr 2021 04:16:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvzFaarcG5Fg8nVxzblWmBmB2LO4QC/nOuugjpGFf51+05iwRMfoDDJMFM2gdktkMVhzCx X-Received: by 2002:aa7:c4c1:: with SMTP id p1mr9589061edr.133.1619262960993; Sat, 24 Apr 2021 04:16:00 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l11si7295940edr.343.2021.04.24.04.16.00; Sat, 24 Apr 2021 04:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=EA1oZCtR; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4ECE668A03B; Sat, 24 Apr 2021 14:15:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074033.outbound.protection.outlook.com [40.92.74.33]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 522EA689D60 for ; Sat, 24 Apr 2021 14:15:34 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D4S4/pMb8GxAqwWuWNgbFV/t9vOhIO67FHooe5xr2VVn6KTmnzgf4ffh+GyFebPnF/ACI9poadoOccDe4dHBQYoxDVMfVFNlkZU+wYZAya5zrAFQU8Myz8EEot0zuJoQAx7X5tGlBUwG409pAt45ddZrEMdziWdCLQCgTHQQgqQQKcItqMtSOs4NwmJZEclx9k4DC3XZr0hoIqOPi6ZKw2vAUdWh2Ps2FXGpjA9zVGz/qwifKbM5cwN1JdUfwg/UVwnrZ4r0zr2979sx/bvI//zKZikn7tPrqg/jlAe7JP6qsdA1hOdvXNOqZk+z/JRsN45+6icj1cUgXLYfklU7WA== 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=XJAZIuC+opJCZViAoQ69M+iRPtMxx4xy3ZpJmp7Lz9o=; b=fSPB8dGYrmNjjOa9m/NLS3v4FhZIQ+481mZ7XcbBmS+/HIyO8eKL6XDGhypd5XOpaLgbr60XYPzSSfKFHe/4vFbffm5fX0G9Km3A96s4NdQXKpVWNY54cDiCyrX4/JOMhL/d+ZcyrYX2iOvI2Y/z4ev6pifOH2rTLMa9e3e1ZHosdlhFSxgk9DbP3Ee8nx/gn+bpfzTLHWqi+/r+7HNP64iVX/j3qMizZfaYI7riPuQ9Z+jsELnr7wK8A1dKW/cFuVjmZ8rQp4fj9mLshtGAvDsfpN55jh3VTRXEJA3NQihK7aQ+3BGf4HvvegwuwgxdO+di0WEjvuvuxmbrEIdDXA== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XJAZIuC+opJCZViAoQ69M+iRPtMxx4xy3ZpJmp7Lz9o=; b=EA1oZCtR9IktT4Q7TCJ9cVoOLoRweb6Jh4U6ghauZzAOWSpT65RtO3K3ArE7UHA4DMR6fcV0ZdlYIhvnDkAl4Bwx8HL3ILhC+lqOshBXTwCl3A+5Z/nAKF5E3+wVwRO+r6Ssnt/pLIg236HAApxoJu7J7GGmZCVXEUdCV2NJ7EvsKdlDnIxUeiMRWSQyvpAqDYoblwrZZKG2/MAq6JOtRBuVQG0tMEbKYC0wKpT2D1H1dBtBEA4dSaydtOcK1eNbuHodjnflTYD3GTIdPq/eIEgJ/bo5xXuzwh0TFO9w8q4O9L6M6+vi/1e7wN5w7h33kHmXzxlWm3pGhBN4lnDrNg== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::40) by HE1EUR04HT189.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:32 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:32 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:CD075BA98AA3746DFD6663334CD23BBB2BD017A013F9521DF1984C0FEE4331B8; UpperCasedChecksum:4D5AFD885CCBD60E13F218896CF3BB99CF9F2F65286A2AED6128F00DDADA8569; SizeAsReceived:7590; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:33 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:38 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [GkvQrcipm+eAzCXQ/gtKk8Tfa77qPKkE] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:32 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f976bc1d-cbb9-47e3-0209-08d9071246c0 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNUdbPdAvhx5/8x6B2xiI3vbSUlQrMwO2aw+WGhgc5qQ9U5FV7Ff5VJlDByk2VYgb9k7XUSpsyvrjcWwInF9PlH/X3+TGcqlEvMKNYq4acpePDYnWkIDI9BKGAqN8LzMkkiufahtvnbfrO4wtI4oYm9ot/PmxkXV3nv1h+LQpzB+Kloa09MNnUnlg+fDges7pbdub9e6iDTd1F6NskZFhsngvoOk4V7sG+rEYzRUKtK02gXPZi7y6x2BsRKc7WYaHWpQiR1TfJVZPq7J9e1gq7tsP7OarmooQQUdGsfo33NtKTA1gr+wkbPh/EkFLmLMlFO29JJ44Q4a1zmrWtz2o+NOkM1t6bxNYv4n0HIuPD/OBVTLMwBX60zY7sG4WzgZZXon22wmVabeFVGpP+VRWfVEDUlgoJzDZnGkArPgP3QuJWrOXPTC9d7oOhJw/KGYj+KIt7/VUWjBXTqbzq4TxjwVGXe4PrJMbkkpom9nKH2M4hXUGGUmpz7PrYdFTVjMRkIOdxbUl++9PD8qdcf4oLlvdEwhx+Q0wX3KrJVjaUcgr8bFhw4mX3k7NsgURpg8Zcjlt8RNGdZFXvEVHUyNUXOV/9swWhmVAbdJhYZVL+cPfT5JvFn3Sil8/7WZbeHfSUbxOYXAAoHOlB5aMYNCI/9xFebzUP3zOtNNgEjUxx2gPLRLi0gTwyYLjC5GiTFRQAlorkMc2nGRRV4UX386PZevc7m+ZWy9AZw= X-MS-TrafficTypeDiagnostic: HE1EUR04HT189: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hpbAIOI0ZEwiWM9qC3kOeQ2S0GyS4dpfivEmxzQDOB/f0CDOC6x/qalvxE3LhDY0WAnLnTLwRvqRfCX0spKWnEV1EQIq5z249RAZsiuJ0PNX0NAYuwpiJm4bryP2/KC6593c1ZyPpkJVMPieNTsB3iIEe/ftI3iGLkVWyRkrN5Op2oQ5a6mJPa4rp7vH+R9brTgumYVpPFde52HEZtz+a1RhT1c4KlL/QdsBxvpY9FIvKF2svyyxcV+GpGwx9pvon//43NrDaOkYI29KuV64QNMKcsvLtKZt7vciQUzKw7/jBBo97J5aieBgfcqLBPNJAK8PPU05eKiwoUeYHSN9uj716mxaijO2CQbwzfiaYLGZBr4BUPM18xz79VPw01CQ6seaxiXjpbbkFikIx3vK0A== X-MS-Exchange-AntiSpam-MessageData: gL+A405ozMyNioBawhxnWu9+irnvPD7xjh8IlC8cxfZISZN5pnXJDm6HAM96r1Tdy77wjSRP7oeY5C6rhOu+ERrxR76+MVYBIVzdMw7pDAuPBByOeZnoIKDJOiVpIkc8t1IuWRpv6LmlQBZNTZhOyg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f976bc1d-cbb9-47e3-0209-08d9071246c0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:32.9689 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT189 Subject: [FFmpeg-devel] [PATCH 06/14] avcodec/ffv1dec: Reindent after the previous commit X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Zn1VS6OSg0h1 Content-Length: 1508 Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 9a9ee10a4c..ef908a24b7 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -1037,13 +1037,13 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) sizeof(fdst->state_transition)); memcpy(fdst->quant_table, fsrc->quant_table, sizeof(fsrc->quant_table)); - for (i = 0; inum_h_slices * fdst->num_v_slices; i++) { - FFV1Context *fssrc = fsrc->slice_context[i]; - FFV1Context *fsdst = fdst->slice_context[i]; - copy_fields(fsdst, fssrc, fsrc); - } - av_assert0(!fdst->plane[0].state); - av_assert0(!fdst->sample_buffer); + for (i = 0; i < fdst->num_h_slices * fdst->num_v_slices; i++) { + FFV1Context *fssrc = fsrc->slice_context[i]; + FFV1Context *fsdst = fdst->slice_context[i]; + copy_fields(fsdst, fssrc, fsrc); + } + av_assert0(!fdst->plane[0].state); + av_assert0(!fdst->sample_buffer); av_assert1(fdst->max_slice_count == fsrc->max_slice_count); From patchwork Sat Apr 24 11:14:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27251 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2035370yba; Sat, 24 Apr 2021 04:16:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRWhdysqIHZoTHz+Phnsc19TaP3K10VDKz+0oMlgrCj2c2FdNNcOcryEJHWny64s2px3Lq X-Received: by 2002:a17:906:6ce:: with SMTP id v14mr8535605ejb.296.1619263016946; Sat, 24 Apr 2021 04:16:56 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ca21si7781100ejb.227.2021.04.24.04.16.56; Sat, 24 Apr 2021 04:16:56 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=MVgi5LVv; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 589F368A107; Sat, 24 Apr 2021 14:15:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074076.outbound.protection.outlook.com [40.92.74.76]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 72C3B68A044 for ; Sat, 24 Apr 2021 14:15:35 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CDWGS3Aj7GrRJS8ZJ1gqe1ffo2VSeH6qPFgex5uPx1PBVrkETSVzSqy3tWZPyJUrqzdo4cruUgN0sgNRSvJ9dLmrVWKaO1PfLE8Fql1K2J1OayvbGkQRsdDjkgFOpf+b/FaVLZ1ApVqgDiVHInoyT2A31CqyxpuhR0yFz3DlIL7fO8YaqUZOWGv8xlbVeqnRcdwOWkv/XbCw2hKcLcemHTSM2AhGHM970gToCDwDq0/48qHZZsU6XkthTiUKb+V0C5zDetzaAnfRmdq+ZUD3C/L8oZh+ALGRn/sapZ18UHoK4Yq1S1SySlxThKMBgY8laCkWaL0Q0XIrUOrIovQQ/g== 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=k6hskTjc9/aCBLV5tEf/ydY8t9WsOidAKe3z6j1eRk0=; b=ivDWTbv8eJdGMR3ZLN2n67ZLClNh2xg1oZGY/oVViNfkxmZaQRI0hlghXHB9q+ZPmVpOKZCNY1eWxQrnY998B0H8GOIrp4aQjKMhg83/dLueLAavvwcCdkr1n702bnnv1TYS+t2bqR4zROlB3VQRuAXMd6J9kDaHpkMF4f2Nt+bVuiXazg1gWRczRBySKNjMZ6gEXg62hnPnPaY8PIYc7ieGTc4VrAfd6D1u/zTpt7f2jB5VAjT1DlMql3lfykHZaqYfW3MoTyUrY5X4e8tT7DWr08uMUBWDs+vUYpI/4Go27udZLOLZ6Fo/djYH9q7TZBCql+Q3I+MdZ6ntNgEl5w== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k6hskTjc9/aCBLV5tEf/ydY8t9WsOidAKe3z6j1eRk0=; b=MVgi5LVv5aMm4aFW9pbgTNH5yEBwyuudhj+aOJebaaOugpHQzW+WdOSWexC2KIVQKK+o3b0+LNUWvQmVKD+cQA5nOv/f3HAmkLGfNC9J4WvBCUn4xruW4QE+QNzEZvzwA+xWNh/v6814PGkB3gG56WrvB/KCUdYLcY/loXOnOLC9ddM6765ITjku1dMTJt+4ilVXRZ1fQKI7pUiEwX6+u3ahO85FS+mSbrubcxwuvIbT5JBqbgc/oXTqIOHmx9onTGqMisxSF7Ty1++DnRENG8KVyGvfstR7rpOPiEBsuf2afFczXj9QMLK2i4o+Vf5DhmrMfikDLI0gj6wxdFk/9w== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::4c) by HE1EUR04HT022.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:33 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:33 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:78CCA96220F8B76F87362529114DB11E059E993B71612ED86C9D55B77CF090D3; UpperCasedChecksum:05C3F270BB3E379506FD27E136667F08B1FD99439439F2EBA2563A3D502103A9; SizeAsReceived:7586; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:33 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:39 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [5DGc6OjQyu8p4g4SBakY8o1TnxxfYn5e] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-6-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:33 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 2171fdf0-5f9d-44cd-f025-08d907124743 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSHACczraePvIduOTLAdlimZzRrR++AVjywlcTCPiOcYczs/r4tTJg3H69wLkPeRqVTLX2x+jC4ySYq2JPPh5r3Kur38KNvYjWgKJdZWHAZ6Nd/W2gIVrVWI5NfecznHyud6ovV9mIgGo8stQ9kDCn4Paq8jHG6BzQZ+DYUWVcrRJAc2gHaDI8UQStMdVFZO6aoZ7j5uXhdYu/o1PuGmuIxPFnSwF+rl9AxzpR/hy4jVGGgCP1XI4PRZRAbG1/X8pcgr9wEq/ILaSGmklJ52tWah4Sc/NOq+1xjkceIFctVI5FladhtEGG9y0Fp3J7OvUgRINrO8WXt3txzO+uDN5M9Bj9awxVzBbO4GzxUtHdJL54QkYUCyNDUmlnyy4/TomLn516zJaBtWamSs9ybCJHkNf84VeTXWVsfOXQ7A9Qq21H7R4VT/2DZBJnNi8ROQkadlJmL4TargtxBrylBMOq877Tym4h1wc+pX0c8yKKAhsHhCGokygVgAga0/IJOi6NmpP1cZyNBvk6Ehv1czHO9//o+UfUA2b06fmsI/20hg4hnasXMQlQQXuPG9dcQJTL/yPo2d4hA4CfOq08NewGEgpf/TbiARTw+bJdDhifUdX/Gqw8LEyVEsqshwoHgRm91JvThVq0iCT5aItWh6xaSvMCCNlnF9jNpooFkqrJuOzPVTo+UtoVWz4W9z2wu5S3apTRzJZaQ/BtJohOdw3OBu/2RazrAEza2F9OC43CTu1GXnANSir+PDk8B4Wr52Yk= X-MS-TrafficTypeDiagnostic: HE1EUR04HT022: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lEn+2827aHSBCJxaN6hXvjPWN8eXoOuvk7y0anOXq75mnVttdj1YTcC2ynFw15PI/srztzfJMDg3YKNnCW6C2uTBojpi0+NL/pbd0u1bMVbHMiRRyyQC+p37Nx1ICa/f84ujXVeWcWi7OtC3apDxSI8lqHPrOSNY6kXAieMQGhlq9GL35WdjOrJAnozsvnn6MxYtJEca550Xw/9hZ9aLusf6Rpr43YN00yLmyWUJsGlip2jzEIjooTCyU3a/nHccNfmpvAosR3ptHwMzqDuQ5FGDV2mz3WjVZPEnbgJ57H5bRLazE+8UP6ls1Vpo2CrMuakidH6GFTO7T66ACTJcbNwr14GzWV1rkg7L3n60ueJqO+BdGD1O7WuwaUlvInivsLLfgTf9i1fVhgeSovqzEQ== X-MS-Exchange-AntiSpam-MessageData: pKOkUrEF6jN0U2ad/ut9lmaJV+i8kMOJ1pOSFC4R29/q+n3p/ILO5TFwSz+taVW7u4p5ahDCZeD46z5mdzAgBCiPVHfqiiA1g2FoIAFGUFzdaJfkRPp+RWg220JXkE2i9WLiGolvrK5q6eAyWCjnOA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2171fdf0-5f9d-44cd-f025-08d907124743 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:33.8125 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT022 Subject: [FFmpeg-devel] [PATCH 07/14] avcodec/ffv1dec: Don't copy fields unnecessarily X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /LjpWgPyCM6z Content-Length: 3548 Copy slice-only fields only for the slicecontexts and not for the main contexts in update_thread_context(). The converse is true for e.g. key_frame_ok which is only used with the main context; when not doing frame-threaded decoding it is actually only ever set for the main context, so not setting it for the slice contexts when doing frame threading is more consistent. Signed-off-by: Andreas Rheinhardt --- I wonder whether one should use different structures for the main context and the slice contexts. libavcodec/ffv1dec.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index ef908a24b7..45bfe21be5 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -993,8 +993,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac return buf_size; } -static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, - const FFV1Context *fsrc) +static void copy_fields(FFV1Context *fsdst, const FFV1Context *fsrc) { fsdst->version = fsrc->version; fsdst->micro_version = fsrc->micro_version; @@ -1007,18 +1006,8 @@ static void copy_fields(FFV1Context *fsdst, const FFV1Context *fssrc, fsdst->colorspace = fsrc->colorspace; fsdst->ec = fsrc->ec; - fsdst->intra = fsrc->intra; - fsdst->slice_damaged = fssrc->slice_damaged; - fsdst->key_frame_ok = fsrc->key_frame_ok; fsdst->packed_at_lsb = fsrc->packed_at_lsb; - fsdst->slice_count = fsrc->slice_count; - if (fsrc->version<3){ - fsdst->slice_x = fssrc->slice_x; - fsdst->slice_y = fssrc->slice_y; - fsdst->slice_width = fssrc->slice_width; - fsdst->slice_height = fssrc->slice_height; - } } #if HAVE_THREADS @@ -1031,8 +1020,11 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) if (dst == src) return 0; - copy_fields(fdst, fsrc, fsrc); + copy_fields(fdst, fsrc); fdst->use32bit = fsrc->use32bit; + fdst->intra = fsrc->intra; + fdst->key_frame_ok = fsrc->key_frame_ok; + fdst->slice_count = fsrc->slice_count; memcpy(fdst->state_transition, fsrc->state_transition, sizeof(fdst->state_transition)); memcpy(fdst->quant_table, fsrc->quant_table, sizeof(fsrc->quant_table)); @@ -1040,7 +1032,14 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) for (i = 0; i < fdst->num_h_slices * fdst->num_v_slices; i++) { FFV1Context *fssrc = fsrc->slice_context[i]; FFV1Context *fsdst = fdst->slice_context[i]; - copy_fields(fsdst, fssrc, fsrc); + copy_fields(fsdst, fsrc); + fsdst->slice_damaged = fssrc->slice_damaged; + if (fsrc->version < 3) { + fsdst->slice_x = fssrc->slice_x; + fsdst->slice_y = fssrc->slice_y; + fsdst->slice_width = fssrc->slice_width; + fsdst->slice_height = fssrc->slice_height; + } } av_assert0(!fdst->plane[0].state); av_assert0(!fdst->sample_buffer); From patchwork Sat Apr 24 11:14:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27255 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2035501yba; Sat, 24 Apr 2021 04:17:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+PqHEYojq5Vp1b2vP7ZNiIVZXTQjcI7eQr+7lSzFu35+KOQsrIw9d04k16CUe5gts86qQ X-Received: by 2002:a05:6402:51d0:: with SMTP id r16mr9732796edd.52.1619263030276; Sat, 24 Apr 2021 04:17:10 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cz6si8187520edb.335.2021.04.24.04.17.09; Sat, 24 Apr 2021 04:17:10 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=mvsI8MIQ; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B2DF368A112; Sat, 24 Apr 2021 14:15:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075100.outbound.protection.outlook.com [40.92.75.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7DDE268A094 for ; Sat, 24 Apr 2021 14:15:35 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PFn8gtkQbWOkUeRP/KmLZkcMyYmLWEdG21UPPBdzGqXl7UtLNO+C42dkJ+6YELaB0TEpbeYC0Mle2zDM3dp530t37G7T4GdvdswLMW1CckEb1TUDKzAtmsIeS0k3p6s7Ql3ZLgair/Lt1K0FcVwLlBpcTqjMJxgLS1UUyMHxXAowYH4Q1lAJkGW9qJsQNzpgdLUduEB1N+jBbZJTf4E5Q0hAiRyGmj7daVpOgR6kS6Nepgn75cG9a3Mtchl8ydkK3IluEbZZOBVenfS4XM96oaQFKUxKicwQwhnDpNotJLB1VYkL66YtWEoif6d2SD9HGFFAU7GX8G3pdRdcD2GC1Q== 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=yCq9B5PjOwVsIabWbK0tjXkw0r6EyARwBiuOlnitKic=; b=XpmTJxK4TQv80VwGsl6gAktJ39pJmOz7UNlsrX7QGkKKfCvGSZuFyZDlODFKdEE9EbvSzjZaULzKiHKCxA0YxP14fD2FEewFFvHabXw88xA8OaKgIX5WnzKBMXCGFZWF/SXT2+ZfILUcUu7Sk/0QPKGPn80JyOuZs1nZiQVH8/B0iR4GPYbbSpKZ+GTDD3PPpnJUL9caJluR8FLxjm+QtMoAHgjNRLHWxdbGkMLpZ68otSU1UtJLcIq89PJ6hbHJybpweQa76Mp7CmYaYac83U4Tkf1WtFDCPYpGQE38P6RPhGPex9yGTMV8HPpVVcm+Y1p6py0GzIfQBKFkHQ2Mlg== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yCq9B5PjOwVsIabWbK0tjXkw0r6EyARwBiuOlnitKic=; b=mvsI8MIQVM1E+qv8DXKILgyaAPTUo7Bz7rgS+mLVtxvLFztee/VTrpqPqXPpsVCTBdMzS9OnuGU1qAEfpIRbVrIDwTmIoSADOgVlERTr5eN9aj9C8mb86geaGy9+14dPC59tGm/RbHcu64s5wZiyzycgq3JEAQEGnpaVItDpdufFAMJzv80noT3Wvmx7YxhiayPrG2DrFNZcP9FO/MUZJSv5CWKG/nmATNq39kjI8d9rm7TjXv3utrTkqkrrMfE+o7zp5AyLCjqtu6iBTfpCCr/YKuuvepJchTlK4MDmBt5ZCRp8R7LFFqn+rDSEdNtO+5JbeP4alQOLm34UJ1JtQw== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::49) by HE1EUR04HT024.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:34 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:34 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:E09D6766EDF0EB228B2F8A6DEFF9511C31E368007D6E4EC39F4F79A93C2A42CB; UpperCasedChecksum:02876727FED777F5B0BDB263B41612B6BCA3B5418EB3DFA1A43C60B8A850A457; SizeAsReceived:7583; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:34 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:40 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [xBLLLu4Cc5ItWt0bNN9c01U3K60GQYr+] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:33 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 8a3afc36-c135-463e-aba5-08d9071247a0 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNUdbPdAvhx5/8x6B2xiI3vbbLLC1dOt+8o+uuXBXKQ418WOwZhLLT1cJ9zalL/QUh3D4fWpST5YLf3Etpy1mN5Yr08E0dwXRh07zZ5g6OpZfVUU9ckxxRGWmv/i4eJtWEyN/9/bYKFoHlGIU82+BuKIRTK0mX3glkwKeK8j3rTY90jXmq5KQmwQQj7+VVkvcnIH4pJJwVjFeeUH/q5p1bFxNIP+yL3x3FFIvyCmYefcJZdRPvEi+GmD6OUsFAu7F6XmYvHCQ0AqhZHkIvpcRpYU0ZBr1gh8AbeO1RCV63/mzmyI3obEHEWfD3BPtXTsAT2wKrCqpSJ5jxVEDeKxgpp80invVk7AEcxSrvXBFpjKRSb3iOv+5fxxBI0R7c9CKI0I3Z7OA5hcaDUOMmNct4jtggiCx4+w+OJzQqMrMTfaUFdjw83b7uCEb2+F5wma+ICcjf38uc6LsAwsemwXvxYrTh1aJumhtwqGWgFI7AgfO3ZQzMQqFxNTzW653zP+eCVWBqxydhnu/QIVCoQ1q5Tjmh0RFdC9Md9eTT9UPKDAU/oq/wx4ZYBY9Noa0htQHo1pjCUhmkczKSuQulHzrqH2XnzcuO6yWb5S9X/FaOb7uoNOPT1EiD3qgYsdQwBwQMmfuVctIFr9WnnEwabLWVfLGhYBmFFiv8Ms/10p/g0sxGNj33wd9NapUue0b1aBsSHyA2A2ufWzu3vu8lrP3teX3a3mTubqRkY= X-MS-TrafficTypeDiagnostic: HE1EUR04HT024: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yy3n7krGaiKFXeakeAqBLOcsyT3tNTZPR4uCdhNAlsz3993cD7aJCnRXAtr8THsIPtZCk4N2bIuVlF72ZkQBlo95ffWtS3AN9aMYBSqhEAPlar8O/7IqkoBtNIJ9IotI3dwUVcnt9t8tDqWHqy8PgRnNCxciiiT6036ejQgUUc5R9qH1kkG8HRGZv/mb6Wzg+VjV5Yb1GeXrafdv2zKO0WtoPR3ZNgtuyF4CmxkrnTcPllbyKLkku4JO4L7q3SgG9boacwRZZis5GwYpv0PQTrqUFxbOFqbizY6V0Ah6YAoXs6O1Rm7g1Q0ZNY7hYw0Z6YJYvfoE7seDQ3wrtz5dKeww0PeSPZWOWxqm0JST/8pDrON046k/myIekYJViecB/6gXdV85Ij+tyY3QuW8kFA== X-MS-Exchange-AntiSpam-MessageData: fcpqk+PMhrkT5g12BsRJJDqSxvNJyBGG3n/ehcXgArtoNv9agxVB6vMLmCQBXy+oFMVvxCTAot5JgE+vVkC16COeepIFeuf5m8dh3LoMxiA7ShyEjj3WA8opm8Ln/kDWehvGGHLsCJwxNOnolKc03g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a3afc36-c135-463e-aba5-08d9071247a0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:34.3822 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT024 Subject: [FFmpeg-devel] [PATCH 08/14] avcodec/ffv1dec: Check allocations for failure X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: KaBduIPFBkgT Content-Length: 1686 Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 45bfe21be5..791dc073bf 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -259,9 +259,17 @@ static int decode_slice(AVCodecContext *c, void *arg) if (fssrc->ac) { pdst->state = av_malloc_array(CONTEXT_SIZE, psrc->context_count); + if (!pdst->state) { + ret = AVERROR(ENOMEM); + goto fail; + } memcpy(pdst->state, psrc->state, CONTEXT_SIZE * psrc->context_count); } else { pdst->vlc_state = av_malloc_array(sizeof(*pdst->vlc_state), psrc->context_count); + if (!pdst->vlc_state) { + ret = AVERROR(ENOMEM); + goto fail; + } memcpy(pdst->vlc_state, psrc->vlc_state, sizeof(*pdst->vlc_state) * psrc->context_count); } } @@ -343,6 +351,10 @@ static int decode_slice(AVCodecContext *c, void *arg) ff_thread_report_progress(&f->picture, si, 0); return 0; +fail: + fs->slice_damaged = 1; + ff_thread_report_progress(&f->picture, si, 0); + return ret; } static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale) From patchwork Sat Apr 24 11:14:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27249 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2034983yba; Sat, 24 Apr 2021 04:16:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqVrM/Wn9sPatZdk6hP8iY+Y5aNa9I83REqRPmaOzGmnAC14VKTaZbwFHIgAYFmX+ceJWP X-Received: by 2002:aa7:cc15:: with SMTP id q21mr9971953edt.140.1619262979862; Sat, 24 Apr 2021 04:16:19 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z5si8011885ejj.51.2021.04.24.04.16.19; Sat, 24 Apr 2021 04:16:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=YJ82vs9S; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1DDDA689D92; Sat, 24 Apr 2021 14:15:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073067.outbound.protection.outlook.com [40.92.73.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0B291689F4D for ; Sat, 24 Apr 2021 14:15:36 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QDdsuMtzkW0jyfttg2G2usy7IUiHcok2tHSAXsipbGAtdal2k0QK7t96JpRf0umTMknVZIL1xEysXAbGzY9emtxTzFKbzczbt5GOGAuDWJOZWSMjv3Y1VJS4p47ypSn6z6pHYLjh2I/cwjhE9QhrcHVXTsremmXKMIbtnSLp0v6sw3IviwKJa4pM1MswEAGWAvQ8EMh/Ab8K2tqG0GufnRkXj+bw1FiWtfn1nzq5Lz56j5SMLuovqBQeWLYMs8yU5P86Tc6rtAqDpV6E4nLENw5qB7Wc77ZpNzBYWD2vluhebYc4zidmo6ontQizIHe835OccQJhCYHo0ijQtUVcKA== 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=8o5F8ln/C9f244NvxUKlmhNRS8sK6GgdTQcgUp6cZp0=; b=UjzAd6B2m1W3nQCdCPgIhSPS4GsFcIkKbvSED0KjYhWGxSv4ynVMttwx5gMajDk03cJNlSpcJswxfKoG/CtmTYJ2GAAmQo+dXUpo5KCmzvcNU/0aprrhXd4rf+LR7XO7jooWpkGyH+uoaBRGndVHU+iL+1GhrO+9Owb3XnuA/WPlSXeefHHtpfy3w8lpumsm4Vl6vnyhkGyeLZcGYdAVSY/syv70TckxkBU0HMK+EfmP3xX0f8dSz4Du1foi1xuXuKllIKukIbqHylpEt5j7kD4XoIyd/Ybq0oaZs3Ma/QBA6h0Ag1Wc/ClSXtf75iUiNjRlEb8fLyMrMEpvc7RpTA== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8o5F8ln/C9f244NvxUKlmhNRS8sK6GgdTQcgUp6cZp0=; b=YJ82vs9SP0CNTaSeW+K9wEvTLajWmHtfLRkPAzpR3VZpN8GqXPVqm4/itvLCZnX/MpNLFIMFdxWwFUMTSfi5pukVg9LO9F74p/FHGT+jgs0lqo8hg7U7BHd7/x3TSGuPBq1ttpJj9XnIXpq4bAOY/Fsk/40SQuguoaE9/eX4omnXSDNP1sEXsEtwEoEjKAEIEG+tKsye2gQmu8Vns8ga8waDAAKCUOJXjHJMY//cxp452UTw2HWQCYHRGQClaogWpZ5Wmi4JG1w0Ahpx5l4r/o86SDn0wRyVcJBZgG29ktEJ1FOr/u+9Rx6ozS9exD/7P2mAuVPkZ4uNCJcJwr/XTg== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::50) by HE1EUR04HT094.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::348) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:35 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:35 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:B14977674572401B7F08C9D7D12D83F9596132EA3BFA612C972B89BA8D445D74; UpperCasedChecksum:60239E081FB1CFEBD147479DEE73A21D48F2B83C90D6D7ED37DD17D069FC1265; SizeAsReceived:7599; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:41 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [JyCLcqYJf6LsfQMNFF8d7QfQY20t91o7] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:34 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 5797beff-bb76-4a65-c223-08d907124800 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSHACczraePvIduOTLAdlim8w2p235HPiLNiiO9ou6NeiLgkM7spb8v11b7XXX/Y1ZbQ951FF5/9oVpV6YW/kodRA9OWj/DJPmKVR23rXXVfxWlmZyHX5NyukkuEaM8f325f1udHe1mKzdOqr45UyJ2kiBWeIMlLSChM39N+ZcaYDsWti7QvORZKUFKLkEsVhBnxXdRDth6snhP+ATeiKbZAF/yzcV1Lv3n8BP8BN1YMqL/mU6MoPPxcL3r61MZyEpWVsXaqReAQ52b8uP7cdfyue3kH9uX1YYes15bQgqj05PPhpVaX6bEfJImdJJCS+AEKc3rs8vAEIx54BhOe39+Lswn7dM8IPsR9yGPhOI+edcvdjv0GBFqSD3XWc89YNdXZKmeB1Jq/5Y/KPZgFBeAtnFTztEBlsSa9XZUv+XiVnmfhkghy6rcRcwy4/K1HnZ/fweymlup01xyNtIb1UNiX+62+6kl3EjyrkpW8QjVJ8/cSH6AhEqXJK85AMaTXd4zAMCVhBRm4Fa2C4L8S2GRYP35Dhz2rlOb5j03VJiWGnoXxFM4aq9a1mduECaOGSsZ2un8kJ6FQRqE3erlQkVo787Wl1Pw9GJuO/GNxVeR3sfTx2IH6kETtDxUC1LmTqEN6eBKMlMa+UaoWwYxddWNFKTACR6VzmrJeBexgZGiv9twAy7G0XcLzmcqkrFBaNi/v1D0FXKB/r50aLt6+T6AHlDG0+rN9mnIKWCp3NfGsBSGugy19YeVRB8P9fJyEcI= X-MS-TrafficTypeDiagnostic: HE1EUR04HT094: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tbUD2wqyUsiRQaQ1WRMSBZRTJ9Y0+rVgjUkm0G5JK9NWj60hoVuXVqDdqAfMYNwVlZymBMZhLUr0sNDmQBIR64B2tGfHIeegJIF/MS8i2wwLQdtjnW4PoEdU+cxEQOiSvp0DBbDpvWyr7Zn473+wUSAYtjyUFUG3rLeGU+/LASGEyd6/ZK/oXyY4+8FGFdjhfD6IEIuoCYHqaOpPJIi3cQ4hDRC2EyWlMqi54wI4QJwK8MWgEFLDpUN7fvhUABJy1KFmNjgLimJ+5uWzbfeNqLwBvOofdwKLTWAwh31U5/Wl6smMp3zKTC0ZEgcwfZ8GrT52DZoFN+4c9TsWOBDQKicrwRINySldOP5AjnETqfnuzpG70OAmEhfh1XVjYkCO6PWHdljMhg7EZWMzUb/EHg== X-MS-Exchange-AntiSpam-MessageData: vRED0o9sE/NmBIJPBD6gjTqZB488F9+dSbfJgd/0vVrBIj5/JTxWtWerNLnRGDalv3jIjPI7uNugzx2BgwkYU1wVODQtXc/4LLSzuZ6XmuyYJr0JtBY+f1Km5rYX4NtIuqYkGEC0pxn7ATr7Z3WN9w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5797beff-bb76-4a65-c223-08d907124800 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:35.0659 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT094 Subject: [FFmpeg-devel] [PATCH 09/14] avcodec/ffv1dec: Fix segfault with frame threading upon error X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Slmjizl4bjxx Content-Length: 1275 It is possible for the source state to be NULL, namely if an error happened in the src thread and it never even reached the point of decoding the slices; or if the allocation of src's states failed. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 791dc073bf..bddfd8e2fb 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -256,7 +256,10 @@ static int decode_slice(AVCodecContext *c, void *arg) memcpy(pdst, psrc, sizeof(*pdst)); pdst->state = NULL; pdst->vlc_state = NULL; - + if (fssrc->ac && !psrc->state || !fssrc->ac && !psrc->vlc_state) { + ret = AVERROR_INVALIDDATA; + goto fail; + } if (fssrc->ac) { pdst->state = av_malloc_array(CONTEXT_SIZE, psrc->context_count); if (!pdst->state) { From patchwork Sat Apr 24 11:14:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27248 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2035046yba; Sat, 24 Apr 2021 04:16:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0O7mJuqomOQ07esD19+DWGrSAp6gt7FbGMy7dIQsUP9b4roYGfqeBAcFRK38Tkh+8TKp6 X-Received: by 2002:a17:906:b1d4:: with SMTP id bv20mr8762361ejb.46.1619262986392; Sat, 24 Apr 2021 04:16:26 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a42si1283863edf.319.2021.04.24.04.16.26; Sat, 24 Apr 2021 04:16:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=Y07iUCOg; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9EE8868A0BF; Sat, 24 Apr 2021 14:15:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075109.outbound.protection.outlook.com [40.92.75.109]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0D4BB689FF0 for ; Sat, 24 Apr 2021 14:15:36 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gCTaq6te8LbpLQdWkBJovvgBk0R3a0XgXa2Up3Sr+pxl3Z5UXDQ8oDw/nuwJkuJVN8GEwMuYIiUfs9/fic9qUlzVmPpSDyv7HIeKgiXWQKtSBmXKLGkL7dnCYAYEAOzaGT3GWdhoDp+MJjNQYb8YqL6wSPk5G2shRKzP8rkOBGy7Ieb4EIPAaxMHK3SzlEZI43eKEXOQkEeaa0Qfm5wcZXxUjH62jRowj+eyBj/TmhHcw6wbJp4ND5bmVdp8Wem5nns5R/LFOIAx2FOJ5HeZIi+2UPHUHE5DxbZxVLFTJRn6Ak4FJAH3BOT6Wtb98rfzTVPt12XGcOpTj+x0xSbL7Q== 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=wp/iwrYGjJn3ASZEE1xJ4bXlqriR5+lv1erVsrrda2I=; b=C2FuZTonapPSU/JSEijrHK6X4GAT26tqQvUwBBf7eh4qaLB/W2H923MZ01OuRZ3Fvg6pQPSGCufM6iUlc0x0Mn3s/nIwLQT9w4l1HBVJdKO1OT5i4WLdckCa2OAgYostey4keAOoPLJpc1Tndl9AmTaOg/xbpJ6zKv6V+OlbldriMSfihHVYUBHLCTuOtCCO4RcgDL6HrReysm7iuLjbTtm7k0F8FqfFYggp29vqYiI0OEi20/88H8kbFV/l41X3ne2LCl3vlVft9ZHqGIaX7JtIaCXiHnZ0jujAU8PJ/tPa9YvtykI+BJ650dKUyt0pyF4vx3ELjfK3/VvchT8w6Q== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wp/iwrYGjJn3ASZEE1xJ4bXlqriR5+lv1erVsrrda2I=; b=Y07iUCOgLcqQKTP1maCiGgT7pQd3owG2XE6UbN+evvKDcY5yrNOU/YGVcL1iO+JTAyEZiiWh1OPKnmt0vYLSabW8UZc6eLp0nSs9afAjXnWlJpuRZBwgNsIpW0py0e6N6U/ZEtgeQAHePdO12a2S2fELJJOgLa8jrkUYRw8LA1NxTQq3iRGiDZW8rU+siiJIX652tX9jilJrLAdOHEpuvZfzPd+ZXJpIVSzBR5mdwL1XhFjrVBTN2L+C6qzLlJbEEClC6+547mCYqQnAFk64rQrq8pfd/zOTTqVR3e2dBWtag6DIIl6OE8+yg28cxBLUpjUJwLG+ff3dkaJNJfg1tQ== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::43) by HE1EUR04HT059.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::327) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:35 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:35 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:305C5AA66263904491E4BB12F0B4F10B5561FF55F5662B7DB105365AB5FDD78F; UpperCasedChecksum:506A48E56449E3665A53CDAED8A61D3A86C17559B096E3C2AF0E9B061832D0B7; SizeAsReceived:7610; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:42 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [KX50GwTdsQEZUGmP/TDoil3Eueoks7Cg] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-9-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:35 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 26035645-96c5-46a0-229f-08d90712485a X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSHACczraePvIduOTLAdlimBYlWkNNy2iqW0aTgmD869I6+yJCKI013o4XEFsckgr611FxPfOtfCXqeu7sPkvWR1qP1aZKSNQDpTB2w0g/OI/W6Qcn2AvVdIO1cX0x9YtTmmuZH16wnUDJhbyR8nHb912W/+1Qbqmz5iNw+dq23ghyWD6pQsy/HQTANAsj20/SLulD5gpDW65jkKld8Spbeg1gumjyilWuWi/fOLbtpFIwG4xIgzzZBbgfm2zemLBQsQu32G2bNcXiByXlr3BMfFoDq+gjbH2q1eB2/oZHPXq/mtmMZ14DCn459x8asKQNLGNJO+6LOBE/fuUqlXR5q//SUAJeXkab2mfTAwKG5xF8MRzu8geAbttDmhwOP39KzFbROI8NrZ33ESBuLUqnUsR2/Bu5Iu+KGAQt0L3YXDxIK7loEAsAgHQ4ON8t4wJCAXvqnOOnA3f4iRXNlp5pemt/niBIravMDyvpu1WoIGXXEdhelUz+mvHN+6yZy/OsSuprvqgmv6IpDjjMdv5OqM5o1irILUgKtjLNg8gucIh24nmZoosZZzHZ9BvXe2WAMYG6ICUiPKhkRZ+MoFO4yl8+iiFwGQ8kRdE0GhxeMlc/9xYnyyC7chKMq6iKy2YGljsZfBrJ70xcSlrSK5aLvHFDSF3ususCqSf+qBoISDqu2VUQS/N9oUOp5ZXVebLzBD2DbZbfrQyMuhlkxw8lnWOOadx3U4Hy1WVcjpddpyjujbDRrUlePtlwMyTgSwrc= X-MS-TrafficTypeDiagnostic: HE1EUR04HT059: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XsNXgqhodMXSyAVNGg3aZwgZEYhHDvSJkl2F8l5V5l7DneJQY8yj3EGW0Qs3XHiT1BJcGUKwoFi/rZV2Cxtihens52Y5M3KnHKLB/B7q1yBiNtmBgvdydorWGemhUO1KbY5xc1iS1ZyZPXQc9YSDKGtQP8C2O12Gs9yNcoV23XOZ88SEoIvxXUYyBdeKW7anyjHsmJHajWv7sz4OjXziVthJlqgGJT1TdpWjx+7LsYY8/lDjemq+VFgHNsS4klYpVBwW5S8Zx8xGV+G1v3OW2w53m7hbVlhwZErsq1bkWUoeTE/EWI13oAA0kjVpA+7i73pneUfQaQbMxOwpD1g1aiHMpV84PFQamCMADGoT56HOK744XfsHtkslJq0nA8HzVEw7dmKKaSsC4OinXmVk5w== X-MS-Exchange-AntiSpam-MessageData: 1A3zZW5q4k9rJj+/li2c+H35X8WIien42BvSLgNsNs5BMc+EYyv0aHc+Ybfx2RbOpo6/mo73JYjUN+16mhtCw8m2+KRmPts6vHpoT6pGHHECc3JYNN3Sq6oD83L5yOpIA5+AZ/KIFN8LhwxUh4ogUw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26035645-96c5-46a0-229f-08d90712485a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:35.6427 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT059 Subject: [FFmpeg-devel] [PATCH 10/14] avcodec/ffv1dec: Treat all slices as damaged if frame is fully discarded X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Zpk62h/fEITa Content-Length: 2742 In this case each slice's context is damaged, so decoding future frames will fail until the next keyframe; furthermore, in case of frame threading, the current thread's decoding state is not updated based upon the earlier frame's decoding state, so that the damaged frames produced by frame threaded decoding do not coincide with the result of received by non-multithreaded decoding/slice-threaded decoding. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index bddfd8e2fb..c9583db60a 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -870,9 +870,27 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac } p->key_frame = 0; } + buf_p = buf + buf_size; + for (i = f->slice_count - 1; i >= 0; i--) { + int trailer = 3 + 5*!!f->ec; + int v; + + if (i || f->version > 2) { + if (trailer > buf_p - buf || + buf_p - c->bytestream_start < (v = AV_RB24(buf_p-trailer) + trailer)) { + f->key_frame_ok = 0; + av_log(avctx, AV_LOG_ERROR, "Slice pointer chain broken\n"); + return AVERROR_INVALIDDATA; + } + buf_p -= v; + } + } - if ((ret = ff_thread_get_buffer(avctx, &f->picture, AV_GET_BUFFER_FLAG_REF)) < 0) + ret = ff_thread_get_buffer(avctx, &f->picture, AV_GET_BUFFER_FLAG_REF); + if (ret < 0) { + f->key_frame_ok = 0; return ret; + } if (avctx->debug & FF_DEBUG_PICT_INFO) av_log(avctx, AV_LOG_DEBUG, "ver:%d keyframe:%d coder:%d ec:%d slices:%d bps:%d\n", @@ -887,14 +905,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac int v; if (i || f->version > 2) { - if (trailer > buf_p - buf) v = INT_MAX; - else v = AV_RB24(buf_p-trailer) + trailer; + v = AV_RB24(buf_p-trailer) + trailer; } else v = buf_p - c->bytestream_start; - if (buf_p - c->bytestream_start < v) { - av_log(avctx, AV_LOG_ERROR, "Slice pointer chain broken\n"); - ff_thread_report_progress(&f->picture, INT_MAX, 0); - return AVERROR_INVALIDDATA; - } buf_p -= v; if (f->ec) { From patchwork Sat Apr 24 11:14:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27276 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2034869yba; Sat, 24 Apr 2021 04:16:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlNccD5n41s86uS81Q04NcveN7F+3JpuTFrvMWBL2IAvTNtB/YJvqHmyLp7av89xsznA3x X-Received: by 2002:a05:6402:1cb9:: with SMTP id cz25mr9705809edb.163.1619262967202; Sat, 24 Apr 2021 04:16:07 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dm17si7465216edb.190.2021.04.24.04.16.06; Sat, 24 Apr 2021 04:16:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=JXJpnL7Z; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B42A468A046; Sat, 24 Apr 2021 14:15:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073083.outbound.protection.outlook.com [40.92.73.83]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CD105689F4D for ; Sat, 24 Apr 2021 14:15:37 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ln2U9zE+3k0WcA3ZeufUaUoA0U7jIB4qrNh0kqk/ftHi90vhs1hu5Rsn7yhtOZ0EpyEjF+FvgB+qJqeH6K9g2jfXmFj+VciQA/9oiKX1Eem4OTHoytZ7O9MuTLGWhg94CgZRmSsL+9VAs0Y7NhVslsM01eRZEN4MPspyRhbWnL0i2osIkR77OC8LkW4WQ4CyuFPIYZSbFRlcunRzJBVf9Ruf+6e7cQVAszZ8oSRDggOwTDRBUE0etrt523E3Fod/nGulmgDbInDBUCfH47xepHRGUYNrs2z/uNajRnSEvR/zyQ4X4ORL5kjWIRgC9Eq7GWXhIMei4gMeX5ovazOlEA== 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=Rs9aZML7G4/pLUiPHzskK75NezF+QkLqY4ZWIAO6TB8=; b=SudP8EaDjzcEflGy8k4sOjOaRIkv5QA2B1ASa2zkFeADSkO/vmHPuk1itNuz9YQ6kXXtmohuudi53KHADOAItwoYxk5usVj5eb8a5zjQpj+D/MnH6UJX7iKuaST7h8iaw9AxBBdYK69Xx+MgMUnGMr/AoejwgRNd4VE+aF92pQlCTtwUk9uLQkPYUYSFfUiVaFMisygtle4dfQ+/s/xDzkw+0iv+ffoZjkn/DkLj4eOgfc2ekQyjcR0zYmx3paL4LRcY0g5XMxA990UUZz5jvKSh/1IIzOx5SDoNk3L0CG8IXJojFq7mIZZWzbKWtoWbIFob/qJFM2BFMkzctDBAPg== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rs9aZML7G4/pLUiPHzskK75NezF+QkLqY4ZWIAO6TB8=; b=JXJpnL7ZLtKz1inO8P0fICPx6bc2ucod173rl+8d1XKT+VfomJ+m8dEa8DE1QO4U3JiuA0jkoUDYPq0nJhK30hYsMWh1HoPpHUm2lxqGxtoi2Q7tyNZ6CoutSSO+Xv2L8Or5KvCLUnp2qPKH/hUOHrsh9hlmcKn5oTQLfLLsKpW2TnAqOM22zgNsrRiWisVkEMqKUdaVaWBaiTKu447VT25vonv+haTQdfsZQ2umU2d9s5W+cTBOkGcAdBvVtRloolY2vC32DLi8wedntHtY9S5NnbTuVctrFvl+77wR8rCBzZDBwcWKhOGth4eqBBuGY0ihKYwGmkPhGR9IIMwEJw== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::51) by HE1EUR04HT122.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::362) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:36 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:36 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:89460F8A6C394DD9245DAA2B2765BF08CDB3BD3D5E99A89B5BACB9F348A01B97; UpperCasedChecksum:D0C4F0783CE81E3FB86D99CAEFA985752372C4ECEC23B55746448E260FEA2546; SizeAsReceived:7593; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:36 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:43 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [o1cEK/r6lGCLQdcxXhifcqFbbwcmWJ7V] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-10-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:35 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: a428fe4c-b3d8-474e-5338-08d9071248b7 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UL2UDcFXhKBVDdW3S05RF0ZpKXZzuzZ2TeLJYmequqXBGF7rcOvburfh+SmjhYZzLqpw0yHVg5ISB6faUfGK94sWvIUWV8oF+K+Z1SprxgQtgKTfeVln9YydqLv2FrSCs6N/8UOpYsAOyGayczxG2OR/fEeepXAKMqJ7ffxoNuPYeCG3CAclRfz4V5Rw3YHLcnS9nu/haNShmnLel+pWCuTrOWtMolJj+G86VdVqplA+NU5JlFEa4x+2OrktySUlzFnkIbdRJ3/2n6Uk72oTDs04arw4RbaEqDp/U+Wp3YPXOxZHOt8g/sQTd9pXcoI6vxuSlknDdO5ezvi/ADSt4K4n2xLvFzc4/ntS2G5VFElfhidnUG59UqZE66zzIf9sm3qMMi2CyzB3ZrgWFmHpnYae1lAAaB9B2KMEHXkqZCBtDCEWCqfikexwiHKpPgDeK0OgTginKO4W5yPDKBwmr2QW2ry0x/XBys/5K9XluhzULS/XIxH4ggevq/dRS2Z+jycgQk7/PgqB1nKcZUZGg0ejAtAJpTsyAPX9S4/SRxtf0M2esMYgSv+WbMgG4C34UvjVMlVTugbueKt7Wab7+6rJpdhVYH17Ddu9uKfyo0kLGRsSw1B0OM5vV1WeGD+/AE16C1BXMMrcee2BCkA4Tm+LbjbMIYPkVYcc3/LneN/h6K2iKZgEjSaPK9s7LZopImpCJPEAD5Rfg== X-MS-TrafficTypeDiagnostic: HE1EUR04HT122: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +CNGjDXabgeH+an3GX1VnROKvuVtB1cCE/Hy0yMfMnvJyfKlLIVdWogi/4ryJGjE1xLpnk/jcsOsyigWTpGtnvYaLHzttgUQbUp3gp3MgaCS89QANSlPdu1oZjqWT2LborHelhHRgshkTQ1UwryYwDrX8Rzth1f37SKTEVjlr0zlrX29dKqd1MMiHCL/jQGGciOLDLkfOx2mVfvi0BSpsKwZpFmeki+9fQ/5x2YidfrMiLSSCHKJgryiwd7jh1it9LcXesnonRvv048WDCsWIueMQZWW7XXUcNoWkOT4q4fj4LCTBjKHNA0Tyafu7rqD6JpRzb9JiVq4PphjHEMRKU+BBgZjj3XUWNeU0o0w69ydO01kq1FI/9752B/CKo3YLSOvQxXxDMAvVe7m7Jo3UQ== X-MS-Exchange-AntiSpam-MessageData: 3lixqxnTwPBQmUDwx7nqh3Ld+dJSPOqY8TFADknTR21uSNMndS67qGtH7rB0CL1XrNChoJWuZ6vsgA3eD49k1xCKH5ooWmW8RNpIOMucSLxcvtINzrdac5Olua8t9F3rtM+8g8+GP2zEULRFn/t0Ow== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a428fe4c-b3d8-474e-5338-08d9071248b7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:36.2184 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT122 Subject: [FFmpeg-devel] [PATCH 11/14] avcodec/ffv1dec: Fix race when updating slice_damaged X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: pEASVd2zYNQy Content-Length: 2441 A slice is marked as damaged when its checksums indicate an error or if it is not a keyframe and the same slice of the preceding frame was damaged. These checksums are only evaluated after ff_thread_finish_setup() has been called and therefore setting them actually constitutes a data race when using frame threading, because the decoder's update_thread_context copies it. This is undefined behaviour, but in practice it works: If the src slice is damaged, but its preceding slice is not, then it is indeed uncertain whether the dst slice will already be marked as damaged in update_thread_context(); but decoding the slice only begins after the src slice has been completely decoded in which case the dst slice will be marked as damaged if the src slice is so marked. Yet it is still a data race; fixing it is easy: Don't copy slice_damaged in update_thread_context; instead just reset it there and only set it when it is known whether the src slice is damaged or not, i.e. after the src slice has been decoded. This fixes all ffv1-FATE-tests with TSAN when frame-threading is used. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index c9583db60a..c16fc81927 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -1060,7 +1060,12 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) FFV1Context *fssrc = fsrc->slice_context[i]; FFV1Context *fsdst = fdst->slice_context[i]; copy_fields(fsdst, fsrc); - fsdst->slice_damaged = fssrc->slice_damaged; + /* Reset fsdst->slice_damaged here. decode_frame() will set it + * if the slice crc indicates an error and decode_slice() will + * set it after the same slice from the previous frame has + * been decoded if said slice has it set. Copying the field + * here would be a race. */ + fsdst->slice_damaged = 0; if (fsrc->version < 3) { fsdst->slice_x = fssrc->slice_x; fsdst->slice_y = fssrc->slice_y; From patchwork Sat Apr 24 11:14:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27272 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2035158yba; Sat, 24 Apr 2021 04:16:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4akFHWXDhhA70N7JqeWGDo42NLIYrBq1hKS0lB+C4fpMP5S36GkvyMp0Roc7w6r9YGpCb X-Received: by 2002:a17:906:b191:: with SMTP id w17mr8814455ejy.200.1619262997496; Sat, 24 Apr 2021 04:16:37 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a3si8999723ejd.575.2021.04.24.04.16.37; Sat, 24 Apr 2021 04:16:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=JI7CepbP; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9703D68A0D5; Sat, 24 Apr 2021 14:15:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075028.outbound.protection.outlook.com [40.92.75.28]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 907AF689D6E for ; Sat, 24 Apr 2021 14:15:37 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n08J/20GeUtKqGxixV++8/OuUGhDHjrlVOv89/X3pJ28yufmd8v+UcAAZSej6Xi27VDbPDfpwl/dk0YPwvsGlbviUFc7TEiUi4lxk/yCcKUXjmsNOl5kokp3qT4prr/tSbILz6EmPwWJBO0Fb4zSDL9MuqigGjO0fomMYqnabjj7oAo8BYp38RbYmAu89jI+DlX71DlZm8ROpkOTCHX/eV7eYqFUwTmCsZI5qCj6H/mkpb27WtZcCTWCQJHXBbUET0CkzSev3Ga25bAAn28BAdw90FlfnrQLHkORrvLMMFpGnTUIOyQhJxx8WL/lHxm3xX0LZGDX6APlOXIBU+nEPw== 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=VQ9wIojGXhBo8IW1nyVmguKiI/5eXdsne+VVRDB664A=; b=Syam7SB9N3Mqd1QgW9GLNWwIHl3RjKwHgzDeW/L6wO8zhyweJnof3jjbXdYlT/bzgwPFLJh1oMijj8nP0GaEGCKy1w/SM6mYjWm+/13q6+L4HpuJ+JrKwdvPEa3/6VSraGlE8fiyn93K1QLVBesY6LVetzWagv2cppDZMSXJUXVbIf3lM6pV5Nm3u2Z/4s3QUpqxoikfNLR36huQja7l6lOTx4IQm7v1c2/cdEkp44Si5eAgFqwXXXFAvVZQh/MxSj1aJW6tx4sss12EaYVfByNV5qEAJLQXTEq+icbwCx8dB2PKGhefoS5srn1h1h97rr1a3O/mH1zBJQgMqJ1IUA== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VQ9wIojGXhBo8IW1nyVmguKiI/5eXdsne+VVRDB664A=; b=JI7CepbPQrtzh3QpEiVZdbf9SwtG39cpKSbZ29ncMPGsFslYnOOrZTkFiWFVSypDn0KcowIUNme6K5nyh5LyOeUKxnCr+TU5bYqvz67Tmt/cm+z/ZcbVO5bPrbaZfgL4w8ytN14nIMXYkmbhJ7mh15EWkO8ijdnmTXF9CeuquIQwLC3oCLnfX9NgqpwAy8fPQPnLLbQWYjGSIQxWnKwgEP8Bv3e1Qv7kIyE0bdVNTTp+zXgRU2RMcFS5C0qFzBTrL+GY9/ky/xnyQ3/GA4bv3zu4d8q2dAAGvvco5e8NUT1XblMaaBrq7WO9c8kABfxanbMyuVytwJUvankPkF9vjw== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::43) by HE1EUR04HT105.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:36 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:36 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:958056F30EA2C1153013DF27AC2BDB62B3D118F36407CB2578B30B61548E7ED9; UpperCasedChecksum:20330939E809E3DA7B06EE3CC6005AE20D56EC591A146A9CBDA6CBB318EE609F; SizeAsReceived:7591; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:36 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:44 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [lfAUh8VirtTvE5wtRl0392YqMo+oVpSV] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-11-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:36 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 08d0cec7-5d2f-4572-2009-08d907124915 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UL2UDcFXhKBVDdW3S05RF0ZF5AWGEuf0z0CRf02cH/E+09OM7dbm6KTG81TV2XJi878SStxaNvMZEYjmCAomRKm0RGSG+qzB2fxmrobMzzrJWIIa+Xx3OfIUKVrybCBTlALqdZIiNguM0i4tiQ2UTGyEHRsnN87hIVzos106xp3c6mGD7tyPja7n6tpclbTaVA2wW4r3ZbGg2Gq8/+E3OyBWsbN8BLjYA8gVigLh9ifwxd4QuZda33drHqbL4fYsohykRDQy0ehcABvpfpDeHd7/THROFccr/eCsyVF7gBKUilICGmnt/kNT52av+SiszLlkF1/kMMqvA3rwm++HW9nkc2p86cJ+SMxG8UjDzdpjbaAxmMuKmjngSXtufS48JsX56b4IsJbFTnGD29QhifcYUrbD0uOE1HIgrBmy9kOFd/d3bqKMVHtwUD6X3zkB+WBLAgb/t2VccHJD1RflafbeT+tXBR4Zq/1PGmY0s0tI3GwocYS99SPk2RnpQhSku27AhoV5bYE/t+Y6PdWyAKnH2h4qvso8pde8/HIJYAw+eVa+Hvh2nUSy4PTI3mruYZsWdKry57Aor6BL+VLxbW+2PsR9bjp+X9t66MG2Bvq8RQLM1kPJvaO/9ax/AfHHTwGc708DxD0WOcWMiCnO4adHdDVYhZ+CNI5vYpwDG63GXlnUVP8/OHH+bCXxGEmkFDsiDjVaPlG5w== X-MS-TrafficTypeDiagnostic: HE1EUR04HT105: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PIW2p3WJb/DAOfIbc/cEeZK4Rr6RvOqdrf9VKZJ4RkRXnlyqwZoxDm6BzLLUPb0EhcNzQUZhwIBWl5I7in28nfYfUMlkKSRo6NuRQ8QGJGsiQKcISz7rQG+kUGosFop0w8FJNjxaNPtEyhiI2nGoBCLGo1VWUql505kKaD5udKhqTXAIKr3kMMui39I1gR6SKtJ2p2Nwx/uGt6hNCy1Zq4SYe3Nd5TjS2YHLjlCxZMbNhJcDRtStsQrGNjnBXGW+BSfzAYtmfUCoDO76a2CEHU656hAXsXr5uwKPnMncWHToz1iuK4e6K97GkoaRKVJBmqkCBJUoL5v/zn23w+yWBJV8FpVZ5ew4pxRDKFZXvVxgtC7wI5Em76fAFMdG9JShd8twoUAstGGAteEVPyD3fw== X-MS-Exchange-AntiSpam-MessageData: irBUIPrmJv5RFYwFifXXKqaJxn344byD8f+jhVn+jDB6sE2T4wLUWmnAzwfbwpLjGKOVQC03ww3NzRieJwMFUi7wu4tHv0D5uCyUUvH+FQ+MC104vR48cgZ1fdCjWj/FUx1oAxuNyTpu255rzb1pAQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08d0cec7-5d2f-4572-2009-08d907124915 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:36.8591 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT105 Subject: [FFmpeg-devel] [PATCH 12/14] avcodec/ffv1, ffv1dec: Store index of slice context X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ieY2EHChiGk0 Content-Length: 2502 instead of searching the index again and again each time a slice is decoded. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1.c | 3 ++- libavcodec/ffv1.h | 1 + libavcodec/ffv1dec.c | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 47bb032876..8e7542f918 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -131,10 +131,11 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) if (!fs) goto memfail; - f->slice_context[i++] = fs; + f->slice_context[i] = fs; memcpy(fs, f, sizeof(*fs)); memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2)); + fs->slice_index = i++; fs->slice_width = sxe - sxs; fs->slice_height = sye - sys; fs->slice_x = sxs; diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index f5ac8090bd..7f97b2c6f7 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -127,6 +127,7 @@ typedef struct FFV1Context { int quant_table_count; struct FFV1Context *slice_context[MAX_SLICES]; + int slice_index; int slice_count; int max_slice_count; int num_v_slices; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index c16fc81927..060efc25ab 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -230,19 +230,17 @@ static int decode_slice(AVCodecContext *c, void *arg) int width, height, x, y, ret; const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step; AVFrame * const p = f->cur; - int i, si; + int i, si = fs->slice_index; - for( si=0; fs != f->slice_context[si]; si ++) - ; + av_assert1(si >= 0 && si < MAX_SLICES && f->slice_context[si] == fs); if(f->fsrc && !p->key_frame) ff_thread_await_progress(&f->last_picture, si, 0); if(f->fsrc && !p->key_frame) { FFV1Context *fssrc = f->fsrc->slice_context[si]; - FFV1Context *fsdst = f->slice_context[si]; + FFV1Context *fsdst = fs; av_assert1(fsdst->plane_count == fssrc->plane_count); - av_assert1(fsdst == fs); if (!p->key_frame) fsdst->slice_damaged |= fssrc->slice_damaged; From patchwork Sat Apr 24 11:14:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27259 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2035298yba; Sat, 24 Apr 2021 04:16:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzEo6M1PgCLjJWOQ9/sQQx002YuvBxxtVeOPZj/RAOubBgZXNK2eDOAkngRFuajqRrJJpp X-Received: by 2002:a05:6402:42c3:: with SMTP id i3mr9806079edc.270.1619263010947; Sat, 24 Apr 2021 04:16:50 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g20si7413002edp.268.2021.04.24.04.16.50; Sat, 24 Apr 2021 04:16:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=HbE+OJSf; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E388C68A0F3; Sat, 24 Apr 2021 14:15:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075028.outbound.protection.outlook.com [40.92.75.28]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B9317689D6E for ; Sat, 24 Apr 2021 14:15:39 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HUn6RuDcJpj7HhJ4j5W60dzTO9G7uk3PieBwFwTnukroH9mIf8PTNpMAZ9OYUNl1d1OnQrGZ0rrE84+FVKfgtjtz2hV4OZxLJvexP3+dPqpoUXreibzX7lE/wg/ING3FNJeTgDyKZ4nRy0FFVRyOk5wNwDVsSohmK3hdZOaGzwzfQTXcwSYcwAqAdMwmtoxdQZJI4hdAPzCD+ahtEfi7ukaMicRd4AM/jNYMICFEP6urBjNIPqBN91dj1tL0qWfO1G51PrioymY8ItWjJBlmSDQNU4NMpudODN6uITObbb62hVryNCTwApKOLsod0nMqwWFKQNaGXci2yeqnyWUuBw== 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=NDTcyXD/OgnVItQFiHj6FyVVhaMVQyhhMtiy3r8TH8I=; b=ikNmcgmDCjIzsUj8g67JOGbEAPPqjKNg0nwBWYjF+Wci16A5aekOzf6+DBTwxTNtK/92mLgm4fccm9OCd8NkxEIvH72jwHGOODrNBl83dCwsNCh1qP6JCy2y2kYNZpVShMo+cRClsHUKFNRGf43ryqZKctWSh834SnMfBYpduRAgF92LuFJe36v5MbC0h0/cvGN/qWyMOP+3xBiHTtMRComIgA2td4O/B7YC3F/psm3bfMnj230Wntt9Fw7KjZWt/G0ZBzl2dhLJfeUyB5jhWhsb0AGT50GF3yNsMRPADGjvOUiMzSETHjwqSySUlVR1WEoyUg3v7+yE6IO1umtATw== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NDTcyXD/OgnVItQFiHj6FyVVhaMVQyhhMtiy3r8TH8I=; b=HbE+OJSf8QNoK7E9PhHxe0f9u4sVfWKCRvGPUUeLKPfn0gbxial1iVCCRTotrQ65RIWRcI99c1CRPYIiP+ZuGUVUODl2yWui/mGEqoZ0QpaDgE1oW6ti2034HVWO8Jkfe8+4Ee0ufuPACoRo5vqSM7EJxp77aCmoICx7wQ+s1BmuVg8g40I89JdIRG974cnEPqvmHuCDzxchXuLmQPHDfAuggsirAAxn+MPJinLK6zQAo7qLmL2YCJ0N27A2LwH6+xwmoWfwZcWt/xaP+lFow+BFcd6BjoO6S1WzyuDRj1BsZiXinyfjIWT+j0AcvN3GzlISb08k/IoOWiBF8OJ5MA== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::43) by HE1EUR04HT105.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:37 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:37 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:0F4A4A60C6C0B8AC4C07D27A043E72400AACB93B020F42A35F38D58B1DF1EFC6; UpperCasedChecksum:FA09930D6E8618FBDB384DC210240165E90152B865F4D1DF94BAD7EBCDD92A2E; SizeAsReceived:7581; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:45 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [yiA2yFPdcluQ8N9getTGikGzxop7KUg9] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-12-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:37 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3c6c6b07-d140-4a65-31c9-08d907124980 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNUdbPdAvhx5/8x6B2xiI3vbmReKMNocgKGhC2gqRs9eRPL1YEXpIPACCm9+TcsNn2GsGMTjabW8vIlfmGjhhwwTgD1S1gKZZ4hFP+u+8s6FCEDH8y3GoHBCnv3SCR033SEsThS/F15XhYfWTrl0mK3nMMx2Mrv31xgWT8Q5WO3l3MRG2lr2+M+a1L9MUUVDMLpw/pZmWGpljYWfjsVHCZI1LtkvvzSot25DVmTnL2GXKqJIPQRUnSrGUW2Oz1bnyeJQ55P12e+5JRWB7F76XFVKlrQ0ZjBZyZgropDdU/UREoP9ZIVAYTrfV/poRSeQfkW32GdGtFy5B0wRop/BA82zgtbQhW4C9wJt5mpsxgweE2FEAOfhyoCbvLOzw4sJbwg/ACFGtF7PNzpdPl4UA2IRxysv/618PpNpvUkx37a3B5xiZrT0TEx9iwHymc5YCPahbKSy6o7ziYZGMyf6hZKhcbIKzar8IEvaKLAUH882/zOuiick/cyzTeZbhPtqTOJjD1bYeQ1pLAUJ+EBP1BnZniMzV4uCyLoB70UUbCc0b5ZDW3yXv9NaJ7Q9mWFNmkxz2xxW4Ir+FzV9uQSqPm2Xk8HINeHYJQgXYMl/9GPoMEj6rk5M+i2Vm7QHXgMP2tI54vVUKbtjqOSgoz124xImYHBsi96dnKtwFmUllEEeDefFueAPhJ49XXkMgKkLtJvt6+CvMlGL0zjFE6urQOi5gh4AzaBx3Oc= X-MS-TrafficTypeDiagnostic: HE1EUR04HT105: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m7KoOgL/hNhfeSmnx9LBMqIRMOG9KMt4XZ4poX0zwHxauVvdco4++PX2+HeAStlflVNDfiSKYrHOGyewRcG857wEhsLGtLLANn3SfsNe5ZegcTM1Aaqg7wdhWLSwpRiJV6KkGGM3cfhcMVKv+fm/YPzEqvWDCTWvx13yYhjBUCfwPaRiZr/3HbOPT3i6A7C7XJzSto25y8l6FNxhDI1LGAC3Ecoo0+JTAvifAfBlu6QzWw8GneGX5F8dj3pL/D5I52FMEHdcWTi9POHbrtMX6LNv7BDdIrSYRIDBkRyvJalvkl4eu0E+FO5uUikT8YA4ciVfu9muOP74gWCN8smPVdCNAecmQZdRbyPFjJO8i9886RWa2EBrNzwoj53WBs0heuoNukkW6ta9pQLhFWbqFA== X-MS-Exchange-AntiSpam-MessageData: +1f4QgI7NfsqbSMAL+BAdVlBGlYjVr+8XMuLa6td4Or4Wp4xPt6XSgfIv3XyA5dZATryV7sAKhB0J1UGl1GbWs5uCrjGxIJh8iiYn/PJSqIBOkWvPCyXOZuBVM+a9O95xtX8Tf5XFtltWJ6g4wx9HA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c6c6b07-d140-4a65-31c9-08d907124980 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:37.5928 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT105 Subject: [FFmpeg-devel] [PATCH 13/14] avcodec/ffv1dec: Combine identical checks X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: D85th2fg6klT Content-Length: 1316 Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 060efc25ab..9a755937e6 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -234,16 +234,14 @@ static int decode_slice(AVCodecContext *c, void *arg) av_assert1(si >= 0 && si < MAX_SLICES && f->slice_context[si] == fs); - if(f->fsrc && !p->key_frame) - ff_thread_await_progress(&f->last_picture, si, 0); - if(f->fsrc && !p->key_frame) { FFV1Context *fssrc = f->fsrc->slice_context[si]; FFV1Context *fsdst = fs; + av_assert1(fsdst->plane_count == fssrc->plane_count); + ff_thread_await_progress(&f->last_picture, si, 0); - if (!p->key_frame) - fsdst->slice_damaged |= fssrc->slice_damaged; + fsdst->slice_damaged |= fssrc->slice_damaged; for (i = 0; i < f->plane_count; i++) { PlaneContext *psrc = &fssrc->plane[i]; From patchwork Sat Apr 24 11:14:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27252 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp2035561yba; Sat, 24 Apr 2021 04:17:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnqWfdhq5sFWC5q7llv0po+Yd0E6tPZ8iFbsZiA5OfEDhYl8YCW5f1EiFqDRJPJW82rA/+ X-Received: by 2002:aa7:db9a:: with SMTP id u26mr9635267edt.292.1619263035942; Sat, 24 Apr 2021 04:17:15 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id nd10si7139304ejc.600.2021.04.24.04.17.15; Sat, 24 Apr 2021 04:17:15 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=nrfB3tDl; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C9F968A141; Sat, 24 Apr 2021 14:15:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074067.outbound.protection.outlook.com [40.92.74.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C79B168A044 for ; Sat, 24 Apr 2021 14:15:39 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nqxk1kUHOhSgzC4g/yESf42tDomkMjeZetVepDqqrQTDugE1DwyGEIZaiSAmkbBZFa8HSQxl8mIGv3Uo3JnfSOUjBZvRZjwt63yGZuA9Uq8c/zzfxyw+4pUfrgkXAc1JK9gg/upmTTmanQbctT1wGN/Lc7o4xVVMVPSvMMJxqX6HmVKC53iEx3bET47D3XtZEfd1uPrGc8e3c9Bpazy6Sje77FY3UpFUa/VM/J5LSu+6geQnOaWQOjG8Phab44ZtC9U7FEFqqzSmS1Vr5aXjpqYF6O5BtjqiW1j5NpboyVdKuFcPvREy/5ooabgL1DR5hiHroVlqPDMhyGgAirGWwA== 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=g1e33MFFOZ6w1TmCU3ys/MatqPJwmdfANPE9YunIfCg=; b=b6SOKVfdXtcGz+6JsXiwl6azYaMsrii4RDDxedMXN4P7BZkc5ZupN/Gv1+czNkaN9Rfq/gtofvxrEmFLB1ZbkMj+TYhoownASv64Hfq1wmKDnc3r2yNDupuvKE3tEjuo5+jQc9u+xGbVgGFA8tYa2L1NYnjRQVrK6k3t+8ILjZuYSM8pb4ptUhq2j4frQFeH2rLA5qD/dAr/k+D6YKvt6lqKopCwkudoi3+3Mx3xMZ3tJRfoYkesW3/VttQaC8qOG+h6rV1bTtkhJHqxBZb7+NUpOySMElLqR7mZDeMACt78bedkHwLUBsu4HAWGoC2skb51OOBU1p76uOLIPRYX3A== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g1e33MFFOZ6w1TmCU3ys/MatqPJwmdfANPE9YunIfCg=; b=nrfB3tDlnxUUAdqbA+lZHrG7pILOC42xZh8JBFsnhcDoXLi3JMCqElrCd6Tb4S/4RIoZWy7cqyL05XqH5szXxAePfgoPoTiPAvsjTFLcb/sWRMZcq1hmWvHUjbP4mA5T4wHSuIFg+6ze5kNojfP9QL2zhiZgIH3u4sH68YNNFRHoHddGVKdIgM7BFGaDcSlGm3M8EZbr6/zaZ71JwHKoXo0O/g2FArATKvNkJtQPaqgHhQu0m98zMV4JF/Scu65hXK2n7816Ahbo/LEVM24pGYHRGx3z8onJ8+M4yyOe+VUDGxv3LvvAvNeVpaKvVMJAvfiwfD7zMKSUNXV/foO5iQ== Received: from HE1EUR04FT042.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::4a) by HE1EUR04HT211.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sat, 24 Apr 2021 11:15:38 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04FT042.mail.protection.outlook.com (2a01:111:e400:7e0d::159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:38 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:950EEB6111B6091940DD26D75076CA21A474BB4A1754D8B1CE758277BD48EF5D; UpperCasedChecksum:FF8FB14A1E568A33E928884766DC44844EC897AFF238457E1E2BEF2680CA1DC8; SizeAsReceived:7593; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.025; Sat, 24 Apr 2021 11:15:38 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Apr 2021 13:14:46 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [zmRWpLXkwXuvnwTEcpcpn1CWPLsj0v6y] X-ClientProxiedBy: ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210424111446.30338-13-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0160.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:41::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sat, 24 Apr 2021 11:15:37 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 390241c0-b478-4b13-6a93-08d9071249eb X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSHACczraePvIduOTLAdlim0sDX9Akmx2PcNGAJt4A/NrFeeWumQExBhpW8hZMxlPtern4GgOVlhEYvospualXpiF0pY9CcPQE13QZWIkC50uP6brmDKCV7xqhYs893GjmE8mP+2EJum5iKVztl17bzfuoTkYJxCzW8gf3U51FBAjxg9a48JI6qA3SRmdz2qDthYXag/nff8QwDa5uZIdfb4d59BsD172LP/1nAJuP87s2gAIhgc9KYRotN86EgdFek2K2wS/ScH9qMnIpbzMntz21jAuz3LuvSzk/kqTNM8qjIOA/8rRc1rdPFB/LS+jdlRgH1/mHM9I1mBASvyqxvww3YrXxy0EQTuWLa6Y1LIUq1sqXcAm6Pj5GyExoNngKzkEFZJjmGmSz1HVK7WmZp7LvjjVQMpRKV/LWBGXl9RiibN3xGDYXeBCepGyrkCcM7jCJQ/HMRGUjjK0BtmNVICLdB3Ec/tuQUrGOPbtnspj5Ixn80u8fy17njgmxOYnxIM+z4p7WTARrwtZvycuc2fbZzG+K25cGKC7xP7+BL9s/Qmk4Rirh5VRHRgroWup8SXwCIgmaf0vaH/lLFgJvUhHzYAuWMCwtgFqfFX6vY9aZYFIWtECch2TNBswmKFKvAnXimIsGvBcFhK5Gam3j7Xf/f3ozieq+QBDQiTSwaSncbMT6WNyIg4siMNEIO0DiJMsasAM4lNHBaOnt+qQnakm9uDqwQwdsUQGgOsyHLyCq2HmrcAeS5ihy7vwIJmiU= X-MS-TrafficTypeDiagnostic: HE1EUR04HT211: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BEpa+AVLcd2xriVfKCDF4UwKCTzfZAWJthOWGCTH+s5XPUPrYwiNmAeR2EzXwJJktLmtYL72B3jfPZV4XygvHvaC9vTzfTSfWjDEJMoqYTg5ZTa45koHu01jVjWJgew5z8VD9SRso+FX7UAVSCr1aKhhBGX3AJ1nXeP7NUuGpmRy6tM0QgXwGlYNUC4Qi4335/RUrwszt8LRRcmNOW+hJ+n0umKuCl4UWAn+Qt7kohuPPqK6nyWaEwY7JmWID0T0LBAt7fi3YwaLaxlwcbQ4imYtU3og/FBa5fSTw4lPlu3QMlUBKhtBQ+F0uvH0+Mn+wg2FtaoOi0idpZpMc9qsa3Ykj2fbGXMwyfqA1F6hv3fzoLb26ypgFjwKNOwxmSDGpx1j6/WmFE+HqmFbX22WSQ== X-MS-Exchange-AntiSpam-MessageData: GVI1lsi6XyDx4FCZ0iX6229tjJPoeCWJI9q+FdBRDTEjCCDnp8KO1hbZbp9QhBp6G51WxRuErIKqNmMl01qucQAY0fZdl5s/YtqAy6o5PgCWE50ZsY/ISlhAuOPAXrOZ+J4osHfeYnAB1TmOZEwCDQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 390241c0-b478-4b13-6a93-08d9071249eb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2021 11:15:38.2995 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT042.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT211 Subject: [FFmpeg-devel] [PATCH 14/14] avcodec/ffv1: Use av_memdup() instead of av_mallocz()+memcpy() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 17PdcXuoET1+ Content-Length: 1414 Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 8e7542f918..a5f5449602 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -120,19 +120,18 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) av_assert0(max_slice_count > 0); for (i = 0; i < max_slice_count;) { + FFV1Context *fs = av_memdup(f, sizeof(*fs)); int sx = i % f->num_h_slices; int sy = i / f->num_h_slices; int sxs = f->avctx->width * sx / f->num_h_slices; int sxe = f->avctx->width * (sx + 1) / f->num_h_slices; int sys = f->avctx->height * sy / f->num_v_slices; int sye = f->avctx->height * (sy + 1) / f->num_v_slices; - FFV1Context *fs = av_mallocz(sizeof(*fs)); if (!fs) goto memfail; f->slice_context[i] = fs; - memcpy(fs, f, sizeof(*fs)); memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2)); fs->slice_index = i++;