From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 36E574B73B for ; Wed, 12 Jun 2024 13:54:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4611568DA12; Wed, 12 Jun 2024 16:54:00 +0300 (EEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2084.outbound.protection.outlook.com [40.92.91.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0C0D168D9E9 for ; Wed, 12 Jun 2024 16:53:54 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RMTSSn7YFfNTjq0Har9124NYJe4G2SWf96EXrJdqZ2sIapZJkzmbBpGhkXCUe6I56sgGCiSqdekLz4hr7JDhfIByT9938cDKB8f3C0OSQFkFDTm41TZt+p1wP1GqYS3ltFoTw9K3LHcfDB463VihaBXtyRnMMN2kKsw32rbjZeOAx1OVQS2/e9H5SMYzwEDq6njIpL4lMkXSDjLqzjyy6oEHpn/1CHlWB4TaRsGgXw669oH8Zj4HMSpkLWPrfQoAghmu0oPccrtrarGoaIrs9ta89sYMWNYgxDZmZpj11lNubNZvW0ehvjzOD0zW0uZtwpBQWY/IwjR0eP4aCNftzQ== 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=6dcQow+MHc64efnNJTEtxZICJma4MAiCUvNSKOMrH7U=; b=msVR9Xizhu7MnM6itfMhqeQvr57gwsrzvluuVFZ027pjNsqYzsgcuFwUx3XNJQs8DmgQdiFcwTYnZ4cn/VPLaWrjKRqzZZH8nMk+C8PYoEimVLGh262D+BO97jgUbBrthZiQlVfdhZ6nH+CXhtSjpqm47xBrggumpNNwqKgi5j3CdGCkEC4DGCjdV/jzcHwHTkwt/ZaM83B2z7lyLrZ5+hvvsszp7iybumjLZ++hKTsymADez7WuVQWFewYJJoYljUEbKIQVC5NRZpLFoHkOFE50SP8Epo8naWV7PKyQceFKurHZeOS/ot3W3gnCmvy6AzqurhN5YwiKNAVUq34oAA== 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=6dcQow+MHc64efnNJTEtxZICJma4MAiCUvNSKOMrH7U=; b=NCiQfoS0QCKNcU5UMcmUiJpoFmY7EiFx/FcLTIGyx9g1lowCYLSoddkZNgz56LF55nJXOdD13adSgqbZ0wHVJTafP8Cpi4XouQ10YgWHloE9mG6mzVEphADDWfOH8GEaNv1TKV0dvqmZmFUI7S3GYY8TERXtee8kh+Hr1Uop+M+rEgCy9p0k61jxDWxXXWZOmOKitqMMvVKBIfL3pfybfN+UHMQ2KnStG6HVgaxowsM3vopyCsGSSyGxN7Baas9lE6EIwhIQ/fcNQh2QDQ5Gh824YfyI2qHAgP43aHiFEuAo/qW9I4sfcNv6lz9+J2gB03m2shiK/9BXalfIiTeJWw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0204.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:37b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Wed, 12 Jun 2024 13:53:52 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::d6a1:e3af:a5f1:b614]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::d6a1:e3af:a5f1:b614%3]) with mapi id 15.20.7633.036; Wed, 12 Jun 2024 13:53:52 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jun 2024 15:48:29 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [dd1FGMgbL5rIa8pv9USlnYT1lFSPDdnItjZb5qb4Nl4=] X-ClientProxiedBy: ZR0P278CA0189.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::6) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240612134853.2102377-32-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0204:EE_ X-MS-Office365-Filtering-Correlation-Id: 099ac3db-6f8a-478f-b173-08dc8ae71807 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199020|440099020|3412199017|1710799020; X-Microsoft-Antispam-Message-Info: pavGN3KyW87N9wrTNPvPxHibd6nITorPOxi1O5IbBhOunGuA1O+o5sIPiZW7zoMTM3bkOaEcN6VrIM2BVUVtV+7CwCV9KJvk+bK0jW4Z4XSx3DUGB9m6fI4OjhmcLYpzIPcmqGTDbSmFSojqWHPJt/0NNRmC8A0y5ZIkOAnX49/eTWjJ0OgX5XdSmzol8yXZAV6KzcMkEFqbrB8Ny/yGYFEwRG32Pk/arW3i3euDKpfsogJtd18lNB+WCf6HqODOzpjSQicaOC+NWgs1XwQI6HO6UqmZw3+p43qanRJYUJYTk2dFXQtPlQumhzz0794F/fr1IJrCCintvoArOJF88+5/GYIi9mPRmTTyFeHd7BXxh99EvNOpjyg2kHRfomG10sx8zuz2O+suOoNBkShmYHNMfuMiRGxDaHWTWscMUPdtUKP41MmOPt3ZAMselSg0nb/ipOZOGJHkcbrGwSaCjEgq3ZH6j4KjdiXk25pfKS/Lqx3SbosISx1mDwnxBuxYcdHBfHZrQln3vesbsVwg+1gMXuPGNB1NKD5Z0KZZBLUpCyjLqqGS8Wo9bLQJR94vlbKDkRpxcp9iN9O3sO6SYWHkkNtzvT7+x1a2oAoPSvaopfLJI1NaeJvmSUJxaNOr X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?q1VIqpYtUDwUWoiJyQ4rPyipQv2lRghYcuclnuttfgn2ouCwvHdo1hjbidaQ?= =?us-ascii?Q?uJAsD7DG3dfdoTbnKAkFsOdH1dgqXZS2tEzNlWCOcdfFvQrN/MvjQyOIVBeQ?= =?us-ascii?Q?hGoL45BIuHOIYifh8J7sqDMwJTsnQVPNFNQOoyEOGWVr20KUmzO8Zsg0kqKc?= =?us-ascii?Q?HLGCK3UVUq/R9sc2bzGtLsCLuTulS+crye9nqkn1Ekj5z0YpLMsgUyRaQLOu?= =?us-ascii?Q?zdOYFauqhedIem8dlPiAIMHx07vp9RqJ5kr9Tz85LuOj3Z6bTE5PNuoLZ+f6?= =?us-ascii?Q?LkPN05wzqNULpYqZMs/SUYNbC5meGIOS016XEWfc7xq94fpywmp9H75KcDKs?= =?us-ascii?Q?XWqV9tCYRA3aS1wdEhGiICw/k8sSu84MHuTvEQGplfuwCeJqzzyUHhky4Ume?= =?us-ascii?Q?k/88t5vVNtZDllfLU7dmndE0XbdmR7S23x5nsD83nIUc2aZ1sRCyFh/hkUSy?= =?us-ascii?Q?8tgviI1K82bB+s4AxMRENi7C66Yswm7zhVGAP44/Xe26v+lq0Wg8MV/xLHrR?= =?us-ascii?Q?fdfoQ9rRKlcXIydp/uEpWcZz3pfLfBR0ufWePi5L4ybfxVaX3f7CxxxjdE6b?= =?us-ascii?Q?olTYaFuYbO1jzvau/wguar4UB1GbBK2S3hBj2zKDkMTVEtLJygkuRaP1YxUr?= =?us-ascii?Q?OT2fd7hgRGSZLJ2y5wSs/bvwbHWpAxNpWCTYjBdqufU6xZQHRtM28b2AvuDw?= =?us-ascii?Q?DRWqf7HhxOqSYvZpH2s1tHvBu1V7emAA8B5oc8wpcfvVFoDZSm7S6/6N9TfI?= =?us-ascii?Q?8bLUJa5AcvsujQGvFaK1qrXT9IH6uIBoEvYBCcZIduop5KonnVWvNxtGqgKp?= =?us-ascii?Q?o6Gptd1PuH3Kd3Zyd+OvKLlv9SVCQWJeB1moul5Kv48M8G1hVWEiEdS0ojgw?= =?us-ascii?Q?me13rwuKOfWwlT8ceMqNCRAW9j0Ceo0nEbob6duZJYL/GkGcIl3iAilrfQ3A?= =?us-ascii?Q?x0TMV5bAuCOWfvJ8QLGEc4uaAtYSoCx3lQrUwaSKtKkqQPa1b7FmTbEplJ37?= =?us-ascii?Q?+hWWj/a//2RNMG54/BbbhQYZqE3mxB5uo8vGe4KTWHytFaMANKpkZ3xA85Qk?= =?us-ascii?Q?GB4/MFo+BB7OU+uBT8NB2HgQEtTRaGt2sn7BzZQc9nruLYcMsLCuyyz3ra2U?= =?us-ascii?Q?Isl0RJOo9wZj0WeZHOwCC5B3EEyJcNm7Gxmsceh26Z51raJdSyuzBvzaAI1e?= =?us-ascii?Q?b4vfyuja6g+A5Do8rbopa1+d+w01g9KDkF+WJRqqxSY8v6Uej8UCK6GUXHlb?= =?us-ascii?Q?ZK9HdDyBejx8cttK4SCZMJNtKwSkGa42XiyfDBw1EA=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 099ac3db-6f8a-478f-b173-08dc8ae71807 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2024 13:53:52.6731 (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: AS8P250MB0204 Subject: [FFmpeg-devel] [PATCH 33/57] avcodec/mpv_reconstruct_mb_template: Don't unnecessarily copy data 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: There is no reason to use a temporary buffer as destination for the new macroblock before copying it into its proper place. (History: 3994623df2efd2749631c3492184dd8d4ffa9d1b changed the precursor of ff_mpv_reconstruct_mb() to always decode to the first row of macroblocks for B pictures when a draw_horiz_band callback is set (they are exported to the caller via said callback and each row overwrites the previously decoded row; this was probably intended as a cache-optimization). Later b68ab2609c67d07b6f12ed65125d76bf9a054479 changed this to the current form in which a scratchpad buffer is used when decoding B-pictures without draw_horiz_band callback, followed by copying the block from the scratchpad buffer to the actual destination. I do not know what the aim of this was. When thinking of it as a cache optimization, it makes sense to not use it when the aforementioned draw_horiz_band optimization is in effect, because then the destination row can be presumed to be hot already. But then it makes no sense to restrict this optimization to B-frames.) Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegpicture.h | 1 - libavcodec/mpv_reconstruct_mb_template.c | 23 ++--------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h index 86504fe8ca..d3f39bbae6 100644 --- a/libavcodec/mpegpicture.h +++ b/libavcodec/mpegpicture.h @@ -35,7 +35,6 @@ typedef struct ScratchpadContext { uint8_t *obmc_scratchpad; union { uint8_t *scratchpad_buf; ///< the other *_scratchpad point into this buffer - uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision }; int linesize; ///< linesize that the buffers in this context have been allocated for diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c index 6ad353ddfd..e39b3d0e73 100644 --- a/libavcodec/mpv_reconstruct_mb_template.c +++ b/libavcodec/mpv_reconstruct_mb_template.c @@ -80,11 +80,10 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], s->avctx->mb_decision != FF_MB_DECISION_RD)) // FIXME precalc #endif /* IS_ENCODER */ { - uint8_t *dest_y, *dest_cb, *dest_cr; + uint8_t *dest_y = s->dest[0], *dest_cb = s->dest[1], *dest_cr = s->dest[2]; int dct_linesize, dct_offset; const int linesize = s->cur_pic.linesize[0]; //not s->linesize as this would be wrong for field pics const int uvlinesize = s->cur_pic.linesize[1]; - const int readable = IS_ENCODER || lowres_flag || s->pict_type != AV_PICTURE_TYPE_B; const int block_size = lowres_flag ? 8 >> s->avctx->lowres : 8; /* avoid copy if macroblock skipped in last frame too */ @@ -106,16 +105,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], dct_linesize = linesize << s->interlaced_dct; dct_offset = s->interlaced_dct ? linesize : linesize * block_size; - if (readable) { - dest_y = s->dest[0]; - dest_cb = s->dest[1]; - dest_cr = s->dest[2]; - } else { - dest_y = s->sc.b_scratchpad; - dest_cb = s->sc.b_scratchpad + 16 * linesize; - dest_cr = s->sc.b_scratchpad + 32 * linesize; - } - if (!s->mb_intra) { /* motion handling */ /* decoding or more than one mb_type (MC was already done otherwise) */ @@ -169,7 +158,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || s->avctx->skip_idct >= AVDISCARD_ALL) - goto skip_idct; + return; } /* add dct residue */ @@ -288,14 +277,6 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], } } //gray } - } -skip_idct: - if (!readable) { - s->hdsp.put_pixels_tab[0][0](s->dest[0], dest_y, linesize, 16); - if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { - s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize, 16 >> s->chroma_y_shift); - s->hdsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize, 16 >> s->chroma_y_shift); - } #endif /* !IS_ENCODER */ } } -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".