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 647E346A38 for ; Mon, 29 Apr 2024 00:36:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A10D168D42D; Mon, 29 Apr 2024 03:35:57 +0300 (EEST) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2092.outbound.protection.outlook.com [40.92.59.92]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4E1B368D418 for ; Mon, 29 Apr 2024 03:35:50 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iXxSUc8622IiCVuEJ3Qwxa7GC5BYcISqA6jTLBT+uU1GZNUktecze8idFfsdxLuDGioNU4XCBpsvOTLtZ7NApVk+Qr3FW2T7FZOtn9mvPyKtUPQECO7uXp5x04vv/weaD5xTLx4C3zbXzd6pJQd8dkCjQiwJP5dyv0y8nVNh0Y+mEzyNiKLPyI0YU69xYzNfvdTcxVtqtYMYHq34PEavYPG3DJ+75pJYbZLSyI4hMUoAU9ipy/9SsSJXTIrTnCTHzG+z188x+zTOjtWdAtiwuRqF9bWvnH5EKv11lzavGJUz5L57NPHURJ8j9r8SsHIaXk8jHk0Op9zyuAx/uh7o/A== 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=nQsbWwcabhJSX9qM7kT2h+Ky1Z5Q5dT5q7QZiYDqq9hFsb1lVpmbG5EDl1CTs3Cy520MBIADT4PfI3fUaeqO86eURQlNjaJbn22RAMYVPGqu5sY9r3Jvts6EIjVuxhVmO4/qMFroy2wNXo1shdHWTtfB5HAGm7UhQOZUMlkhJSaBDEOybrsF4pe9JVahVqwegeVPmRdxdm3wcmZKt5p3bbGp8yV51EbEHbvzCyp5m08hasf/xsEnPwaHw06F73fR+nvCw8R1FWB6Ii/+64KKBRs4qG7Tn/iEgdpvBTMRXWFRuyG/sEdtd6wU7D8ZR0ypMyf+m88cktvS7ukDCBiSAA== 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=SBToF3kwwmmkS2MUDsSZAcQjHHzl7ec2+SukGG2HU6goNN5hP16x6Okjx5G+urEsOAprfOb3KdRFzJ3MLyU39OsUxNugkS2xofkS1RpZ8cHXFto2gooZxcL5RdTPkR8musT/OGVTkm9+5gpW+OgTgOIX3SH0N3aBOe9hefyU8UtSwg6gzS9tswAWIfvFZuKpAA7ufVF6C3R+Y/XjfoS39519TkZc8oKXAiinav91A8N7+wj+ytyUPir9jngZNtAG1utiy3QEsIEedHRwCbCDp2agHKJNgeU3Lh74/WYwLK1TC8ezidjDUFseT2hikCZMj84bGE/TMCgW0qPLo/YifQ== Received: from GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:60::6) by PR3P250MB0068.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:173::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 00:35:44 +0000 Received: from GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM ([fe80::4eb:f54f:b451:34fd]) by GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM ([fe80::4eb:f54f:b451:34fd%4]) with mapi id 15.20.7519.021; Mon, 29 Apr 2024 00:35:44 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Apr 2024 02:35:24 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [TzINNBSWrZ/X9SofT0H/G2iGWyKsgIFAu0E49Yk+u40=] X-ClientProxiedBy: FR2P281CA0080.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9a::13) To GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:60::6) X-Microsoft-Original-Message-ID: <20240429003535.1516058-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0021:EE_|PR3P250MB0068:EE_ X-MS-Office365-Filtering-Correlation-Id: 64447cf5-ab2f-4ca2-b52c-08dc67e44e5b X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|440099019|3412199016|1710799017; X-Microsoft-Antispam-Message-Info: VxLhZZBt8aWkWORMGACkJUNwKhbXFysYGzybScMQtdpOI6Cq463NF/NskBq+Ev/E/QbEh94zbo0W3DwyXyFzynFaEdkQHJOr7ohWw2TEm2b4BLrdDMuqznadHBjyP9vWNDOqyP9baUcE9SVSSrULUQ1/t8x+3zV7YuBViKS4kUxNL0Ceo9LRvlz0NDoqnp+oPU0FK3JgZBsRbSN+6Thk0UPfcuXJpEtP9xdkiFB4gAUGkbeUZmVGaimeLihm4yAUbQkto05kg54JB7LuJeT7cswSsjEmhZa7QTMNndK6EvJ4/0C5hhjnu4fZJ6d3nZp2XVd1hUU60jbXVCaX8OXLImVJpbHZBxciDHoknpLy8FKVF4hjU48aFHAZu5LpJNE4LelHB0GeEMdj4ctyqOE1EE9Qzn4Kf3yXDIs4jYyp1Bh/ivR9FqjXgdImVNh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ascii?Q?IF0ZZ6J1TOpWNEgl+ZbLDN1rwrfTiPkHtLv+x6NO5/g23O6VShbX0g90Qb5l?= =?us-ascii?Q?VriXRgpKCUeZSX2sBYaP2agxEmYW55C8wZPhdMVV36YsW0DM7Opfm1rKvzgw?= =?us-ascii?Q?HJ3nVfp4OxM+wwCYrK9kN/San0LnhPX8DmqgstDtWqboBzSclFfZmY6Jtf4H?= =?us-ascii?Q?z2mtAEQ/hkeyrkfl8+cCyVRknhOk2XwWhuN1oPw6yUeTE79BHIQmNlY8ojpM?= =?us-ascii?Q?jnz6q8evFsiuJCrfNas2pehQ3Hmbfyo3BxxCvXJ42LYG8t+/L6ynUBnkdYm1?= =?us-ascii?Q?dReP4lCKd5j6S5r3ahNQzMj2efSr42kYNt4zc/0yd9jsJ+wNKyH8eAY7j252?= =?us-ascii?Q?9Boxzyrcb012lw9g/LEg/cxbvNXADSzwvTO1QN2an9AQQ9hhjWTQAk8SIK1N?= =?us-ascii?Q?BsDUZ+SDYlswhXLbTMJCLyXUT4UNlW+jZAdU3B57FkVde7FpquMn5zhE8ead?= =?us-ascii?Q?Oi2wSt3vF3Q9GlBjNRnCAgdue+s+3q2C0hI+YJgKwZzMy4E+5aQ4aHElLNGh?= =?us-ascii?Q?+sFM1I0T0U5C3iw1unGpXcydtENsSV13RQ4oHDldaspDEnvNi2FJEs629/++?= =?us-ascii?Q?g9iGloLygWEzZ4fgEcvwSwg9PJhS9stJamzrpW/y1Q=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64447cf5-ab2f-4ca2-b52c-08dc67e44e5b X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 00:35:44.6474 (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: PR3P250MB0068 Subject: [FFmpeg-devel] [PATCH 03/14] 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".