From patchwork Sat Sep 10 01:07:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 37821 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp1245672pzh; Fri, 9 Sep 2022 18:08:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR4rrE3C8hR4j1hE2KEy53Cjs16Lx3Q9HGPF8T3wR8GQC8ysdQOUWZBVYsEfgwO909+YyRvT X-Received: by 2002:a05:6402:40cb:b0:451:2b71:9940 with SMTP id z11-20020a05640240cb00b004512b719940mr2880517edb.237.1662772130483; Fri, 09 Sep 2022 18:08: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 nb21-20020a1709071c9500b00730c028231esi2013533ejc.120.2022.09.09.18.08.50; Fri, 09 Sep 2022 18:08: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=IMhI9mXQ; 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 BA5D968BB36; Sat, 10 Sep 2022 04:08:04 +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-oln040092074104.outbound.protection.outlook.com [40.92.74.104]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A88F268BB21 for ; Sat, 10 Sep 2022 04:08:01 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ae8eKfzsFu9vLMqUmLRnjrRcqaUe7NF3xDLclreo+F3tumaQk/KIZgAVuAgEBvFlEEHP6BNkziaYZLPytSR/+IP9Du6ZcWouxdijmHM7xRDJQegzyo/LNpoNTl011uSWN0h0ipjVrEClcU+dRQEx9ZqvGEdFl03o+93i0PSJyT6KvHSyKOesehSV14vhj1aNYwiD/KMKQU3JxlzkZiIKhkczll8lGBZk4YmCn+QPF4rJc7wHSDtgsobC94NIEYvxE/14AZDzm3ksFc5mURXsct8OGbZ3ckt/anl1GosFKxZ60kN6keYV7w3DWcTndG74JgaKE5VSb0smQnaCBfJNJw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y4vYhNyW1sn7kyYqx9kOc/HeQLDQfNPeg+PuJQX0cVU=; b=U3R4t/Isq+cU0OVrZQPp+M7xkNgm2NEUIDl9cwyK2RXNrZtAn0hnxxDATeGdSuwgaENCSIs8JctRNQszrJEHyReC3iHcpVOKlTGJc9I3UOIwnQEgs1WUr7oF4uZP89sbsvCKMr1hp/KpUB6o6D8kUCA44SnqNQVYKsoU544KReTxCEOLyINNV9dSaff98CWCH5IN4uU8a5OsSXa0CtwoIewbriB5dzm2Eni3vuwDu1D3J6XIWuI6DGZ7SAfcPBUiQ2/dZBk6ZQBH1IBnBYBXvKK6Dnj/aUn7l0PwC8J5E27iXLvhOk6omeK8a24+bvzAcr8im2XZc0sPGoOG2fpaXw== 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=y4vYhNyW1sn7kyYqx9kOc/HeQLDQfNPeg+PuJQX0cVU=; b=IMhI9mXQgkr0l9RLTte6LfGfw+TKId0fxjdp21Xg8fT3O9fhm+G/cVFDoW6Xi7FFeaxh28wuMqqONKtMuQKRHTfP/QRJxOTrvDXD1rmT14SUDGp3VkZ/66zEjQqjlCiyZJ19dgW4+GtYCT8eSqyweoldWK60RhnXt/qnOgCXCAaRkzQx0sNpNDEXQhzAyDmIPaNdGmK9nidRZsJxoMJ3Dexnh3UEcjn4yaOp6n6Q7hVmkerfxWYLDzNfkOhOlZNzt9vNpIWhXItPdFXoKzUhySslMvg8YY+c8Fg1pYCdZpuc2Sxepai5vDAJr3blsEyg2hsdM0ED6eEU9PWjlW6qcA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0242.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Sat, 10 Sep 2022 01:08:00 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::611e:1608:45cb:b58a]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::611e:1608:45cb:b58a%4]) with mapi id 15.20.5612.019; Sat, 10 Sep 2022 01:08:00 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 10 Sep 2022 03:07:20 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [LZDELizYE3rzeYVKvE1BNOzpS2N3aeJUYbT61/CrDB4=] X-ClientProxiedBy: FR0P281CA0102.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::18) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20220910010729.2961339-8-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0242:EE_ X-MS-Office365-Filtering-Correlation-Id: df58fb2f-1607-4916-f85b-08da92c8e755 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9Xmqc989vEjNQgjm661f4SJJ4uYCt9TKY/H5ERn2HEyO4slLcGpBHeZFq1Ol8+SPgJAzm3jBx59ORFdctK4Q1uKhWzzyXNuufBDlgAb8Z2B2xF9OWFTmVVNVnkjB8T3PbcbOn4SvLI/sYohdZn9vZylL1WNW5yZ3phR083ugFmHzpfaakh6IWqQZ10wVWtjB2wzBAtJGTpJ2BgsykG4CHVqJ4tJQvvJVhzgz/WnZwST0QrZ4SomY2OBWZtVeUjn40ZhW2J6f+JMeuqxqfEjreHNIqr/myYyZfm3YBgEtEpWJgFNZMbV+uRDznuf03lBym9wiRnJjDNAFTfI+XEKvlafELX6bf4BYXemzW80ZwRFRoxqgg3UkRarMu39NtgGR6o4IN/IACf5vK1VLZzfWmjfXvzHoqH7GQnqWJ4EZFzxHDkfsToLt8AwqlkHI5Tyf15yChQ3Bns/oeoUez5K5ALlrnZMGn9K57SbA8gAawVAU2E7rGtFokj3EZPXPafB6JY0yQaukugmeowaOAQKtCi5+/ZG+wly+ZRA4TL0PB70XP4EVSm8MIhdOo4JeHadh81/2cPlv97aiKJEqeAcjPCNZtIt11HQjWCtZVH41WGTM0HOFk0Ewa/yMUeBQqVJcQMZRIl6PZMyP/P0kcLI/Wm5+mhGioYM48mUYjTFaEbpbHO5bWT7uD2TefQqKxFeJCmPzhjYyA5xAQOEmqgg9N+13ExYHx9cWOAVb0gGWZpc/NJxL75PXwDFnUjhbDmIGV4IM= X-Microsoft-Antispam: BCL:0; X-Microsoft-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/aoqxFmdev30nsNJCQS7+Dhj7uvF4Cp/iHJ6zNcqIYGXUEocllDFGy6b7lnLud8OHZ9RQqztDwmTs1HhpoSfMj3stJV2JGktzkZckXQqxY/Utr0Js/WognubBIIhXfc+7fXM212LiA+Rs8lRqfI+dDbxqPoOB9VOyTjYZJzMrp+dFo/+lqyRe6ltXsI7MmfgAFZ3VugpugP6exHwO6wGRarCfLHMn8boPHYZEfZz5UBAL/h52qJKeDn2x4RFdyV5g+FyjDHf/aplfy6HZE87LfOLe+TbvKZYrk+U6OwUS39vIQCTUDXnL466YJXrkmEMmrNvjFYR9FdimXzb+fSMTPRh6HbUt6JidWGCbWEBKuDPYqVNCoBjwty+i9wlpYZPJW2z+YY1xR+aTWAtUgNev494WsNKmJSEdLquZwmdZDi5T0mmOpILu8i4x6RZZc++lK8puupV1IXxLNLBENk6ZjGKz5C+brzyJPMLajL+Goh8Gtno/Mcwiuxt6rn9ov+Qx370DNkySn+y4LsEuS7x8DuI5JhNLpX8Am3DCRHDYNPHv2YHZVIF2D4UTF2H9y6T8wym/6Nn+odLRNUj/yuimjCQyDikHdznl392FeTYySpkXbeqJ6SZxOOxsNdxjwefBSZZhuoNXZ1yEhEGu9d9UWSs+9MyxXnpxn+L7VXLWP6q8XzxhXdbfr5GfVY2Rz9Bw9uGs5jtkYn9vDkGxMRGqJ75uck7pcT9vgkoUzVt8adRJ/nO0SEeZ3rFppojJ6LJTsNIlwEVz3kKpCUzOmxYuigK6VL+S1iKg+giobLiHcji/OUisvVsownQksxYpePRDS7DAte8z13BoABMFPqWcQ2JyDipdCzNj7v4gD0jUYfOP4Dvzl24BMWRL55EN6taSdRhT/qnMTUodlPa1mfmuUnbYaAyAYacm/AbH8Xzjhr6Wlgy488qHpyE0aDQqtTNas8JxCyTtIRZUDoPxQwCFyoDetbPBDFrQzHmGyKp X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: df58fb2f-1607-4916-f85b-08da92c8e755 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2022 01:08:00.0507 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0242 Subject: [FFmpeg-devel] [PATCH 09/18] avcodec/vp8: Disable slice-thread synchronization code for VP7 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: z089Ldk4UvCJ The VP7 decoder is not slice-threaded; by its design, VP7 only allows at most two slice threads per frame and if it were ever implemented, it would likely need custom synchronization code anyway, so disable the current code for it. Signed-off-by: Andreas Rheinhardt --- libavcodec/vp8.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index f5c05cd84f..dd3d38d342 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -2440,7 +2440,7 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void if (vpx_rac_is_end(c)) return AVERROR_INVALIDDATA; // Wait for previous thread to read mb_x+2, and reach mb_y-1. - if (prev_td != td) { + if (!is_vp7 && prev_td != td) { if (threadnr != 0) { check_thread_pos(td, prev_td, mb_x + (is_vp7 ? 2 : 1), @@ -2508,11 +2508,9 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void td->mv_bounds.mv_min.x -= 64; td->mv_bounds.mv_max.x -= 64; - if (mb_x == s->mb_width + 1) { - update_pos(td, mb_y, s->mb_width + 3); - } else { - update_pos(td, mb_y, mb_x); - } + if (!is_vp7) + update_pos(td, mb_y, mb_x == s->mb_width + 1 ? + s->mb_width + 3 : mb_x); } return 0; } @@ -2561,10 +2559,10 @@ static av_always_inline void filter_mb_row(AVCodecContext *avctx, void *tdata, for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb++) { VP8FilterStrength *f = &td->filter_strength[mb_x]; - if (prev_td != td) + if (!is_vp7 && prev_td != td) check_thread_pos(td, prev_td, (mb_x + 1) + (s->mb_width + 3), mb_y - 1); - if (next_td != td) + if (!is_vp7 && next_td != td) if (next_td != &s->thread_data[0]) check_thread_pos(td, next_td, mb_x + 1, mb_y + 1); @@ -2585,7 +2583,8 @@ static av_always_inline void filter_mb_row(AVCodecContext *avctx, void *tdata, dst[1] += 8; dst[2] += 8; - update_pos(td, mb_y, (s->mb_width + 3) + mb_x); + if (!is_vp7) + update_pos(td, mb_y, (s->mb_width + 3) + mb_x); } } @@ -2618,12 +2617,14 @@ int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr, for (mb_y = jobnr; mb_y < s->mb_height; mb_y += num_jobs) { ret = s->decode_mb_row_no_filter(avctx, tdata, jobnr, threadnr, mb_y); if (ret < 0) { - update_pos(td, s->mb_height, INT_MAX & 0xFFFF); + if (!is_vp7) + update_pos(td, s->mb_height, INT_MAX & 0xFFFF); return ret; } if (s->deblock_filter) s->filter_mb_row(avctx, tdata, jobnr, threadnr, mb_y); - update_pos(td, mb_y, INT_MAX & 0xFFFF); + if (!is_vp7) + update_pos(td, mb_y, INT_MAX & 0xFFFF); td->mv_bounds.mv_min.y -= 64 * num_jobs; td->mv_bounds.mv_max.y -= 64 * num_jobs; @@ -2802,17 +2803,18 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, s->prev_frame = prev_frame; s->mv_bounds.mv_min.y = -MARGIN; s->mv_bounds.mv_max.y = ((s->mb_height - 1) << 6) + MARGIN; - for (i = 0; i < MAX_THREADS; i++) { - VP8ThreadData *td = &s->thread_data[i]; - atomic_init(&td->thread_mb_pos, 0); - atomic_init(&td->wait_mb_pos, INT_MAX); - } - if (is_vp7) + if (is_vp7) { avctx->execute2(avctx, vp7_decode_mb_row_sliced, s->thread_data, NULL, num_jobs); - else + } else { + for (unsigned i = 0; i < MAX_THREADS; i++) { + VP8ThreadData *td = &s->thread_data[i]; + atomic_init(&td->thread_mb_pos, 0); + atomic_init(&td->wait_mb_pos, INT_MAX); + } avctx->execute2(avctx, vp8_decode_mb_row_sliced, s->thread_data, NULL, num_jobs); + } } ff_thread_report_progress(&curframe->tf, INT_MAX, 0);