From patchwork Mon Nov 7 01:49: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: 39221 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp1849025pzb; Sun, 6 Nov 2022 17:49:41 -0800 (PST) X-Google-Smtp-Source: AMsMyM56MJJjN1SMbqdLklBb4H6cxFYfAbRvOND6Tg0AqVKWwIZn9GIX9QeohOgGNnPDVUU1yD3b X-Received: by 2002:aa7:c054:0:b0:453:98c6:f6c4 with SMTP id k20-20020aa7c054000000b0045398c6f6c4mr48012584edo.2.1667785781329; Sun, 06 Nov 2022 17:49:41 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id tz14-20020a170907c78e00b0078d8f2658e3si5684548ejc.833.2022.11.06.17.49.36; Sun, 06 Nov 2022 17:49:41 -0800 (PST) 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=mu8n1Fxu; 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 B0B8268BA14; Mon, 7 Nov 2022 03:49:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-oln040092066039.outbound.protection.outlook.com [40.92.66.39]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 234C268BA0F for ; Mon, 7 Nov 2022 03:49:28 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TkVs6Id8VaVCDmq+9TXXgwfuTH/ni9l5t+mcVGVp5AH4yL34f91kYMjeD7AnOGJ5jAzcNe2M7xAJ3lsZjqB5vk9pZYgJRNE3cgMcek8PA/QzXorU3DDZUevfZk4243cqDuiHtbmKIzIuIEpD8oiXat4E/kcouqTaLs27u1RdNI/n/XIXKutLyiKg3PzayglHEWh54fd0+OGX6mtgjBzDctnYkRw0vAO9Kt+fy8n/mjnRMYeVTv/OJiZiDxCxu5veTrtdZC/55Yhm/CKNK86f1N3J9e7sr4Wll715zUlNUtnzzGozomf2U2RuvQpcbchMYRu5PFdfP3vPyMwCNNB9jQ== 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=Nr7S3Xassax7oWQL0c7ClXh/MsCDtRiJYYMQtrAL11g=; b=fbJjti0LE07fggP/lSUSgW096yAwTmKwMyP6RLc2KHh0Eh7Potff5HnSLdpECfc4u3oFb1WayVmcF5CNpKjciYdZIfS5OtQEKPWFndmZX4IxVFHEa4Daur3TlQhK8/7RB8+Fl5T9mulvrPSV4Rl63a3UKNhR3aEL5NoSZLngXJ+nVjIvRDvr67ORniFdBXlSOJb40xgiwNKQrg013WoUcN89n5f+XhrOlKQNtZlOHTlzUc3nY1GN7P90bmwGjpzT1Z5OU61ryOsKHb0qgvgvXE/NvgrUnpMFLjZlEUmVZ2jxi8ERRgVlPXPyexZb7lj0owdvPKUoI03Oso+mvDbaCg== 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=Nr7S3Xassax7oWQL0c7ClXh/MsCDtRiJYYMQtrAL11g=; b=mu8n1Fxu5L5Wsd4M45EkQXVXfzGFmsUsq7VT3dZU3rECccfcplsNp7XlhEw+KpU7s7SYG4A6ERPIaqdFmNS5vwLrhXccX75p3oSDKErSC+fp+2DgR7fFiKWr4fGnfXLtnOJDLDJecGFLNzE+tOcKYgmht58J0hEeSQ+q9xZnsofkqa4Yx4ZGOWSfqaDFBIapBt3q8UbZHK2Q+9TRVTl669dXABMFBmoWLL72sdlyZhXq4betKiA+vYTVODslniu1DDHKvgZa7B4F72rViItv/QkbXeWRWlZS1aSeNre27HmIeaQuP0dQTbj150FYd7SGEyDyA294XZ1TLu6AZfxvKQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by GV2P250MB0923.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:7a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.25; Mon, 7 Nov 2022 01:49:26 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::c323:d08c:85d0:dafe]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::c323:d08c:85d0:dafe%4]) with mapi id 15.20.5791.026; Mon, 7 Nov 2022 01:49:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Nov 2022 02:49:20 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [+5dtojCKkGMl+wZOtz7VEBvnKH8MI9xNOQ7SllvNx/M=] X-ClientProxiedBy: FR0P281CA0009.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:15::14) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221107014922.1503434-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|GV2P250MB0923:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c573c07-eeae-48db-80f0-08dac0624d13 X-MS-Exchange-SLBlob-MailProps: EgT5Wr3QDKzGUuNZsc+Ci/JW2wubyroTFKoQbCd1YdZfgAuemnp4cNydgmdioeBi0HD0pLplRJYKacppsGgCsztPtFE2iHcb1gbp69y7MfE0zPUpQhXV3MIhWu6zdqIm2iT69nif3afCRZ5g6liewhhchPPTINTsJVsde9kDrF0PxzckSCkeeyvSag6uTU0AEwHCiwjOOC1jPSXgYDgJYEZqOs8+7ghYcemTlIxexQvK2N6JWVz30jlmvqQMSL1AXbpeE8Gk55TI3jmOQQ+XxujsglTJxl0OhhHvuKHCG3vWEVvQ2W/nT85E46O49LYPcyaTuQs4n5W3lPFw1jVSZoyBh7jf6daPugatqfF8RIJM3c2UIfx88fGsX/TSkp6V0m87ADf5TnGl4BIQleXjSkFq4kjjiC5ljbwyVyqqnNtKfaVlgJpN7JvDHGVfjQ/jkKoCQHr2L5BGEm5U50aY+Q1SdrqmAMPxAmDHR2qGP+m680O+UkYY/9zQ3GpJ3cJH/cLUvIRKT4cRpETme4y3svzvrvj7prVndwMYlNzxeqSSgl68UTbijFCliLhawllKo15LScFOJh0/oN1n4T1mVwiJXm8iFl/nqT/c5oqmBuLrC1NtcraNbSXgAQmOX8G4nSQn9ihL2vxFCaupTjw9yeToVtgboeP+LpMFjldMfC/8ND6JFm6QZwY/3pcx+MCh4zkrene+Ps9dlQDKhJwJpibTJb6boHgthvRB1HffrQ4= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zfk+7yUFmmGoi0VyW1PjbiylJwiD6p7CYwx9EDILKL5ZI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ource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2022 01:49:26.0360 (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: GV2P250MB0923 Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/clearvideo: Redo updating predicition 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: x/YTdpN4Z0Sf This is in preparation for further commits. Signed-off-by: Andreas Rheinhardt --- libavcodec/clearvideo.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index 6ea3d7b6a2..11ae6ca9ad 100644 --- a/libavcodec/clearvideo.c +++ b/libavcodec/clearvideo.c @@ -296,7 +296,7 @@ static int copyadd_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src, return 0; } -static MV mvi_predict(MVInfo *mvi, int mb_x, int mb_y, MV diff) +static MV *mvi_predict(MVInfo *mvi, int mb_x, int mb_y) { MV res, pred_mv; int left_mv, right_mv, top_mv, bot_mv; @@ -336,10 +336,16 @@ static MV mvi_predict(MVInfo *mvi, int mb_x, int mb_y, MV diff) res.y = bot_mv; } - mvi->mv[mvi->mb_stride + mb_x].x = res.x + diff.x; - mvi->mv[mvi->mb_stride + mb_x].y = res.y + diff.y; + mvi->mv[mvi->mb_stride + mb_x].x = res.x; + mvi->mv[mvi->mb_stride + mb_x].y = res.y; - return res; + return &mvi->mv[mvi->mb_stride + mb_x]; +} + +static void mvi_update_prediction(MV *mv, MV diff) +{ + mv->x += diff.x; + mv->y += diff.y; } static void mvi_reset(MVInfo *mvi, int mb_w, int mb_h, int mb_size) @@ -575,11 +581,13 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe, for (j = 0; j < c->pmb_height; j++) { for (i = 0; i < c->pmb_width; i++) { + MV *mvp, mv; if (get_bits_left(&c->gb) <= 0) return AVERROR_INVALIDDATA; - if (get_bits1(&c->gb)) { - MV mv = mvi_predict(&c->mvi, i, j, zero_mv); + mvp = mvi_predict(&c->mvi, i, j); + mv = *mvp; + if (get_bits1(&c->gb)) { for (plane = 0; plane < 3; plane++) { int16_t x = plane == 0 ? i << c->tile_shift : i << (c->tile_shift - 1); int16_t y = plane == 0 ? j << c->tile_shift : j << (c->tile_shift - 1); @@ -596,15 +604,15 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int y = j << c->tile_shift; int size = 1 << c->tile_shift; TileInfo *tile; - MV mv, cmv; + MV cmv; tile = decode_tile_info(&c->gb, &lev[0]); // Y if (!tile) return AVERROR(ENOMEM); - mv = mvi_predict(&c->mvi, i, j, tile->mv); ret = restore_tree(avctx, c->pic, c->prev, 0, x, y, size, tile, mv); if (ret < 0) mb_ret = ret; + mvi_update_prediction(mvp, tile->mv); x = i << (c->tile_shift - 1); y = j << (c->tile_shift - 1); size = 1 << (c->tile_shift - 1);