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 518194A7D8 for ; Sat, 11 May 2024 20:53:02 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D88268D5BF; Sat, 11 May 2024 23:52:26 +0300 (EEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2051.outbound.protection.outlook.com [40.92.74.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E0BF68D5E0 for ; Sat, 11 May 2024 23:52:24 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ehBZNBdU5z/+uTyya6w3NroQs7h/oLWbJ8wUpNq4Y44Xb/w1O58PtBhs0/xf9cx3cy6A+mnaBHMaRpopnKHH664F23Asm0hYZg9gp1thytIqHfX+75Ia7U1MbCrb9LbJ7Zx/QP7W8eu4eBLmqp0VospY84BVZ/YpZIe7tktuuBuX3279VI82/kVAe5zIQjTOoAqIYNLlPihQxDWWI/aCzcEQXvCHO6ajvmXws39rXJUJQJOYXrgE7TSQZODelAnDK3ZCTbuqfGPETF0W5t3XczbaZYJngbiKKmgOB+YHgcHegwJxRMFwK7afUgS3RqgGm0i8PNX2JNiBWnxokRiI4w== 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=G58UvaailvqdEndIDcGIilSwUKTN0Jw9Gghjg2/Io7w=; b=gwwf11rvEce8inq5Ke0dN/AWnC6Gf9tL3v0z6y6Sqf3/saCLEz5IkVCI0Nri1iBaP5M/l7jijt8btdck/gNmYvNlRvFNXByPKApMeypJUnTG5QyFyqg25a8hJarbgDCsRzqcXRgyOWNcietQ+oEENDck0Bc9AVBH5FrNDAjCGN6ZGRnUiFtNOJKwGJGa+BvsRLorxvKyIamZ5h+GkVx22AxlKfoXbe3IHg37xIaEBmrdMf4AmxppQaRcSS9Za1qersSEmqFJ4VWAQWiV21yTlOyOfpE778IL5f89Vr+4OmLQXjFZxYKT055kQnyim2Gh0fq69W178DKy6Yg2j60Wsg== 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=G58UvaailvqdEndIDcGIilSwUKTN0Jw9Gghjg2/Io7w=; b=VrN18QL9BYj5oR/1A0pkAfbRp6JNIPtJ42E10CiDW9qSWQZSRg7Io7qVk8i6fz5Dl9wufallFTH8AHuUcE+5YVuhs7m2KdAoJ7BbhZqgK+ibKOquBvz+kYz5UcKDqrZjRV9W/w3ZIjSwRgJDgjSrEiQ1O3fv9ujHn/NleUQ1gI/miVKbJgldKs/o7LtPb3XNR/4kPV69xHzRi/L22K8V9CIQO1GsL33gWiqUaUfWCslI5M1bK6yE95hUXe4FhK/glHMzQ2lxo+gcRG6Kep27vJc127Mkx2dEXAym3PrK9i0w/sLCxxnD5jbUJtKNNptZvwBGtPX09+NRvj9Qhfr7dA== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DB9P250MB0449.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:325::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.51; Sat, 11 May 2024 20:52:22 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::d6a1:e3af:a5f1:b614]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::d6a1:e3af:a5f1:b614%7]) with mapi id 15.20.7544.052; Sat, 11 May 2024 20:52:21 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 11 May 2024 22:50:32 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [Wszu9W3AK75ASDIJ0K2uUQsR2/skaP6O+6Rit+SMFb0=] X-ClientProxiedBy: ZR0P278CA0172.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:45::6) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240511205135.2411886-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DB9P250MB0449:EE_ X-MS-Office365-Filtering-Correlation-Id: 93a4b286-bf93-4a0f-6321-08dc71fc410b X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3412199016|440099019|1710799017; X-Microsoft-Antispam-Message-Info: aJHZDbWYleEh328ooNapWltaDzAMage0ZNyVK5tGRY5H36b7R/7UpwIPQ6qsLcV0ydXsx2OmyLzjABsbXdo7fqRqDepLj+xbBDAMQD1uAK+Xl7K+LFs8+zUr09vS3K0+gKruGMBtUH4rnNmKViGC0c/QxIcmBoogA66PRtDIhpHluDfBlmS92A4/4MeXp/nRgcfq4KiIhnQRsTiD7WPNtEKIbyFZno3bMiUOE+sE6wyieRrAIwvhQE25N7+n3iswL4/rwwfzQeF6YA2H727ISMfP5DuY6TlW+fMnZh+oHwduoeNTTqLN0DL289l46u7Q1XyNafPCMA0FZcYcDsbpah98whlkTOk8HUH6+4OpgBxaWBF4iUtvKE7mlQZcBaxtI42k00OniN0NBwA8Wp96ncOVsbFckuxtxy+XM4gdc26nuc0XdYwzdq0XKu7lh8U9aCWy69IIBYwEitnP5WKOxBX/1xHdSI8keZiDFKIYcpggv4cvCkCEaQ9bQuNiTQT6+tKFspNG/TzD1lm+37BxoMAsFEMqpuBBfG9JjXLlR4V0wHMzhqSqgnCfBUx6K4FY9DMRoWnDkbycwXGM/LCTOmFjjT9og5XGgrMFhhPoXDXXH2cUsyJbdp4As0ChCDLY X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?f916jYKjYoyVToep2iAYZEAjRkuYN0c4e6wg+uluDTFBwGW8r1g+qATLa20Y?= =?us-ascii?Q?lbkn2g/qkELTTktNegUCJPP/mlGL5vfBTZI9sxRVy1zs3pmBfkxqOOFq6w6i?= =?us-ascii?Q?6utdc4TbpOGzUkSg1zbtw4FWNbIGS72Fo+sVs0rkVc6UcMqjFv/tvmfwylIi?= =?us-ascii?Q?voWYCcitzezl8NI77dQECNP0p6eCvfRXAIlK9dzje+SGzGuMEKkBOb8/Jod4?= =?us-ascii?Q?P4THeNCFr6kY3pz23XSVRlXKlXBCEjF374Rjk7SxK3h0PyDTnpkCKUsWQUe9?= =?us-ascii?Q?11kNoy67GxbbMAQBt+6Hi7T2Q3tE/2/fRMLCK2myMdi7+uwifKKv01/3jf+j?= =?us-ascii?Q?b1WA8BLHBw2bmuNSM2youT6rrjruBUBrsS73SsYr+Qzd2LY/lHVul83aQj35?= =?us-ascii?Q?sLEn2aQRq4MOSMmV70hUwflofF00xqZYIQmeKiwk4kXcfjKqfULn9uYgbHWn?= =?us-ascii?Q?btlOerxUUQzyPsFdk7NvWrPfdOo8r71DICd378c4THDLta1fpo1qxsKHen6g?= =?us-ascii?Q?haWG9aOkneLxHo7YxNPdoeyTgNtlQgQCZHNkiOaGPVIm2lW+A8h4PrZXcTbv?= =?us-ascii?Q?WOG5C3tlRlggLZMm+uGGjJyIn1IWIZIak4jUX8URHp3J6MFX2prajdseseh4?= =?us-ascii?Q?BcQoM5gHcsifULzrPv9WPAajfEBEFo9hHijZGzWk0KEoEbo1cAMKFLzTK1pL?= =?us-ascii?Q?howO5UglydFUe+DbZXJirVubLSo4lqTv4j1lxoo92Dwh3DRrP5TBCzJRnVPp?= =?us-ascii?Q?Bt1ucKuG62W5FVT+dPAI33vLERS2B0Crt5QtdLeD68QmiPYEaFcjbXjHXbI9?= =?us-ascii?Q?IxlP/Omwez/a4XYxAt51K7nVLL6mIDvi5kLuF1r9Si/0uCdBpwJ3P+8PORp8?= =?us-ascii?Q?Az4FKvo4IxQK/x42eB/fx9piWbRwe+1OFrae1UksY+OxNJAWmc2GwdEJ4cJl?= =?us-ascii?Q?i24aO1si/7MGdM/yDvG4aDm7yR6q9ypzZzgQ+tJe6xoW5L6qsL7jPLFIowOV?= =?us-ascii?Q?1pKj/ElQMQPLf7WgPrws6bc5i/jJNFeRQ/gldHSftppLTR9nl5eprQTbapnS?= =?us-ascii?Q?c2BKGwz9sVOTBsraKVag49822XuznFFHUxRyoGi4AUv5hzDyw4UPd3nQXO4D?= =?us-ascii?Q?EFgdxdC5KBNt4pIBFc4H64J8N0MlS4qe25lZNFnXxyIp1c9PeK21JMp+2g1H?= =?us-ascii?Q?gN0o3aTzYfBjrpKE+lNPLP7Tw1rpvZ1pwJfVJOlyZ35s5n+lHlxvscBpUlTH?= =?us-ascii?Q?InvXe2lw2ybuN82REKf7ZC4GWi2KuDBhbK/BI7GT/A=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93a4b286-bf93-4a0f-6321-08dc71fc410b X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2024 20:52:21.8948 (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: DB9P250MB0449 Subject: [FFmpeg-devel] [PATCH v2 08/71] avcodec/mpegvideo_dec: Sync linesize and uvlinesize between threads 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: linesize and uvlinesize are supposed to be the common linesize of all the Y/UV-planes of all the currently cached pictures. ff_mpeg_update_thread_context() syncs the pictures, yet it did not sync linesize and uvlinesize. This mostly works, because ff_alloc_picture() only accepts new pictures if they coincide with the linesize of the already provided pictures (if any). Yet there is a catch: Linesize changes are accepted when the dimensions change (in which case the cached frames are discarded). So imagine a scenario where all frame threads use the same dimension A until a frame with a different dimension B is encountered in the bitstream, only to be instantly reverted to A in the next picture. If the user changes the linesize of the frames upon the change to dimension B and keeps the linesize thereafter (possible if B > A), ff_alloc_picture() will report an error when frame-threading is in use: The thread decoding B will perform a frame size change and so will the next thread in ff_mpeg_update_thread_context() as well as when decoding its picture. But the next thread will (presuming it is not the same thread that decoded B, i.e. presuming >= 3 threads) not perform a frame size change, because the new frame size coincides with its old frame size, yet the linesize it expects from ff_alloc_picture() is outdated, so that it errors out. It is also possible for the user to use the original linesizes for the frame after the frame that reverted back to A; this will be accepted, yet the assumption that of all pictures are the same will be broken, leading to segfaults. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo_dec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index 31403d9acc..597ffde7f8 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -127,6 +127,9 @@ do {\ UPDATE_PICTURE(last_picture); UPDATE_PICTURE(next_picture); + s->linesize = s1->linesize; + s->uvlinesize = s1->uvlinesize; + #define REBASE_PICTURE(pic, new_ctx, old_ctx) \ ((pic && pic >= old_ctx->picture && \ pic < old_ctx->picture + MAX_PICTURE_COUNT) ? \ -- 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".