From patchwork Tue Nov 30 18:29:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31850 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp8044791iob; Tue, 30 Nov 2021 10:29:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxaeGeGrOveYy5hMqDgZntcv5iqwcfxfiWnAagsHFK1Yp3MQZjW8bXaCIceLo5UMjEUufeo X-Received: by 2002:a50:ff10:: with SMTP id a16mr913205edu.275.1638296979246; Tue, 30 Nov 2021 10:29:39 -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 de8si24152858ejc.412.2021.11.30.10.29.38; Tue, 30 Nov 2021 10:29:39 -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="QWvfoL/+"; 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 1D86168AA67; Tue, 30 Nov 2021 20:29:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-oln040092065038.outbound.protection.outlook.com [40.92.65.38]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E44A9689738 for ; Tue, 30 Nov 2021 20:29:29 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DRb9M3OuLJ8+wb73/I9wVt4pR+XiKXMXZaN/Kp2LRFrba7Pb59RNrKJ4Paly3OvxUUbcMcvCY89tybSyApBJa6wKjnmR0Hlh/pMNrDNLbfydkhHM/bSq4nakuGan7Abi2z9PpYpnya5Sz1kDnwCNT7D6+rdKpZVfxlDeSjptsBXttLtt8lc0MMIjJGdVHvYE2VOtuOBXZ/sz3BwPgdt8dmMAlLFie0j4Vy4QmHbO+ORdHlKH8shhVDxrdD39TNO93Y5/MxffH4aHna1dyjruS4IqQMsO1QMPrGPgDW8gBbO2ZI97x+uJQMh7C/IfQCrL6gyeVfs2DNTc7AXrxrR0nw== 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=I64KaNechPjj3RXFEO2Ox3Ht9etNEtfw3NGnnBzHPcg=; b=EReA3alnmSrqiZhfHQN9rzEK50TtJ5x1eib1WGzOJgOhvx1MzYfihfJHXO52Hupn3ohn67f7mepHElg+s/DdV3Thz533fN7Crrv5FiDjYmR7Rv7Tnl2eGGZuAue22ZJhhXL62lE9jfBYlWvnMI+SrkDcy2myTK/z9Kg+8U75ZUgnCBary0KLx1SNjTNnnv7ugJ0qcf+PsUtn15OACezpOc8ml6H7uvrel7R4Jhau4bXOPetf1C/I+XJBo5CH4/3YKCtfTWyxZ/4fRhTnhfLDVtyGZhYG0Gqsw8wLZJL8qPbTW83O2porGfRd9/WScfAoLrvaSXiYRJRAcB8U3q2ytg== 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=I64KaNechPjj3RXFEO2Ox3Ht9etNEtfw3NGnnBzHPcg=; b=QWvfoL/+ODJqV8nfrVMvRI2TGRuscPKqSt+evSUhUWlTOIVD6SsuOOzVE8KeBwkSW2q0Dw6ovNr/93qGUDs5qHH+K92WLw0HvYw5lBnKz7irYpN2xQ5Vp8xnQ7iRW0tOiMeBWIcrfvZ6iK5QccZ1F7RqYRpN2c4tbaU6jTug8SR0HU++KEebxbx+UO7AlqGgRl4fIcBmRGuzADo6qZEB/aXnZ5NtIo0f2wA3N5DVVATHVH73hk7Gw5cRUaa3c4S7xJIhC3AIVaGIkX18Zv0/QnR2YNdjUdo4UdueGHj6OFRX/jCnEgfI/jSoEexs7hncnSaoRLjftWh14MuLjnG4iw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR0302MB3192.eurprd03.prod.outlook.com (2603:10a6:209:16::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Tue, 30 Nov 2021 18:29:25 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%9]) with mapi id 15.20.4734.024; Tue, 30 Nov 2021 18:29:25 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 30 Nov 2021 19:29:17 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [GOCzntU1CAeuFp5DH8dIHn7Bn5BuwJUt] X-ClientProxiedBy: AM0PR05CA0090.eurprd05.prod.outlook.com (2603:10a6:208:136::30) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211130182918.79840-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.248.74) by AM0PR05CA0090.eurprd05.prod.outlook.com (2603:10a6:208:136::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.11 via Frontend Transport; Tue, 30 Nov 2021 18:29:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa5f166d-5cc5-4ac0-535c-08d9b42f5636 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQ7g5p8v69jsFHjfPXus47gTsTcQ5FgnMxq11lozcJLW1Q8TnNOpyIhu+2AyN0UszhMq9mtSOtlr7gozAWai6lmlArAmTQFMOY/POjPr8yUobQAfTOeLOURfu1su71KI5+yGL7u4+MtvPKxyhQYF/qtnUx7z4czs2B30kCpZo8uBNPQjp+eFVG27gsP0a8vQOIEsRSItKdGtmu+tNW2wohVgA0Podaxz0G9YuaEUXkLekOOGnFCbelPCOXTF4Vz3fKc3kkB49mV+B90HVXR69Q9I7xWXvuchIp9PMBba5XwrFrQqxuwgNTMkOl9LzgQMaIAp9YRTGao0998UyV6Qg5CW86Om/82Xpj7TqaFbYthc4kSvmnYEEnyMFhR4a5BEgxHLgWY4dL/WwiwhCKVpLEEDaEuMeLtO+sPoTtA6kaMUJgA2xAM2n5E/wP54QxthNuXosnuVOhU9lVpUSptXJTRqYZuqNF1Rl0UO+9YdjDxi5voN0L+y+hpsttQ+2wk8FeHfUU3xnRGZp4wO8gQ6IEsCtutO6SxB3d/qemRVzn/+YD49VfFq+iB+9nIiOVzbK+Q2EjSGuAR+D4rgwvLjKs4BoAR7CDQuNR52UDMuz7cvXUsFcCpsJEF20O87I2vQUid5453N5CMjVOTt150iYW5jFJWIzak2qvyFiO8nQobvcT/+fcmlYnm5/f+YHAdQP5ISyBRAIA6FjjpBV2Ift61yd6TMV+5h6KStogBXsk/cDMdC5L3qMjRw+2JvsA0K10= X-MS-TrafficTypeDiagnostic: AM6PR0302MB3192: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4b79nkh5gQB3hxUVtp2Vz1FqhCmidDH+SjNr8IrWp6NaIe2y/cggYcwKpZFCgBBoSgKsPjHaszo6wfwWbOJEBzG5jAEn3wJ5fnJOIIDZQTKmGJAZTMOC3+hb2a1NiqBiSKxXGnJdzU9VUOhE2J+nyQbPm/bGB6DLHU28HvS7KEvj1dyWsEYbeseG9RJsWIPcu3gCZyVXot7yHGxe4JRS8n6KQDLjnZWv0EktzfRHI7pLGWN8h6bAEzJu3bQy7wWXhtIOL4zyOgHeZ09vfeFtxGQ0bulryZHxOyfMOuIXkxU0jggSAwT6MQLhRiPDASM7+dpHqbiNYBKGBCjcxUJAFKPAwOMwSNskPVIIsTBE5VGxclRbyuO7gxoGzro2pRnCGJHXi2BPmTePNSWDXDSut4tsIWYkghF5vieKKxTrB1xg0FLWmkfsTLTunQzp47oe/F6WPGAw8defqcLDJoTuj2RU+y7oDPMD5KacubydsQtekfpLqa8YanVpoCuX76Hx3RDdqavZoqRelIyaPVKtaEJna4EyHyx2F/gpNk7BH4g8c8j4/18+RC2BDN5YV1wk2/KpLlr2RWGtwsdz3te7Dw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7+586WlWuC8XGF0TYOcXaWWo3v6q9VQI3AMKONohShi+9hLauuMNhVt+6yQSDECQ/OyR/wvJzpE9TCBsU5Boy6xSrGtK9Y/rxxbYSQFar8eWmAmAaN/a2z6+gScU+yUJ8DjQ8eSrjYs0AUgFGNlHPHNy72w776Bf5/9IdTMGgFj2N62Hx47xILtPsRmzVzLEsCm9cI51KJB+iBEx2KAJUwq/J5bmy4/IM2yun75Ns89lE4xV8ATs1MhL3+I49GUagPRsTbsw/xFD7OB+s//C39IVIpcByF3Pr4YAQ3r1idQQFS84wx1muVUpQWp/Gz9DjSHtUoypp1ImIfwm5vic1Y+icIb9p/OSQJ7ZkKSJsYL5+p+gn4CZa8oPCDQ2lNLRAP8W24UT8iiYZUpr2AW+IrxhNHK4yMR2OZnIIWVrOf+mS+Mk59zBQrtO5du7ph10hZawVfxVIOh1Ym2hY86kxzev1ghZ8spB2t+NMeNjqhug8Ge6Aig0BLfN51KcfU0ocaWAA+HqTUFFCMmhVqiZxFWxPmURCjIkTML5RubYTndt4iK34oIatkINkqKzFfORv7w3h2bTErh2ixtbTu2bjFJEqi5ZkFr8PMLhjLQUyBzBJ00gXp/KhdGPzn9NF8Cl9Zp9uXjZLTPn6UWgZs5vzJ1TWqfgdUMRaDDulR9lVehcRQkwvugIg1uGnu6+eJI4aDyxVn8yet9eijjYihEfwiPB2SqCm3Bj/7AIdF5iQMJhkywsj4DKxRuhpCHhgTE6IDJmBWATtCMMjHpKLTKhxUXzYc0nqtBRjdc6G9BrOlsH3i5syPRZffzVrSZtlvE2GwaLUfxGfpPZgiRwac6LK+qiK43cNLblTKpvVa+fPOAo0q1yBlkgzu7ib8KMpMzF/Q+tH6bH3JnW3I1TZYyoICHNIUzuwk8giGG9jqiwVHusUYySan46XynV5nbFUBCBDrb7TFlv2oTVyyy+7SBThg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa5f166d-5cc5-4ac0-535c-08d9b42f5636 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2021 18:29:25.4799 (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: AM6PR0302MB3192 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/h264_redundant_pps_bsf: Support multiple input PPS 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: Nre6P4jSo1jC Up until now, the h264_redundant_pps_bsf stored the initial value of pic_init_qp_minus26 of the most recently encountered PPS; it also modified the slices based upon to assumption that the most recent PPS is the PPS the slice belongs to. Yet this assumption is flawed, as there can be several PPS with different IDs that are visible at any given time. If these have different pic_init_qp_minus26 values, the output can be invalid. Fix this by directly using the pic_init_qp_minus26 value of the input PPS. Signed-off-by: Andreas Rheinhardt --- This BSF is of course still dangerous as long as it deletes certain PPS without checking whether it is really redundant. libavcodec/h264_redundant_pps_bsf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index 4b2831fb04..5efcf5ea5d 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -32,7 +32,6 @@ typedef struct H264RedundantPPSContext { CBSBSFContext common; int global_pic_init_qp; - int current_pic_init_qp; } H264RedundantPPSContext; @@ -50,9 +49,7 @@ static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx, return err; pps = unit->content; - // Record the current value of pic_init_qp in order to fix up - // following slices, then overwrite with the global value. - ctx->current_pic_init_qp = pps->pic_init_qp_minus26 + 26; + // Overwrite pic_init_qp with the global value. pps->pic_init_qp_minus26 = ctx->global_pic_init_qp - 26; // Some PPSs have this set, so it must be set in all of them. @@ -66,10 +63,13 @@ static int h264_redundant_pps_fixup_pps(H264RedundantPPSContext *ctx, static int h264_redundant_pps_fixup_slice(H264RedundantPPSContext *ctx, H264RawSliceHeader *slice) { - int qp; + const CodedBitstreamH264Context *const in = ctx->common.input->priv_data; + const H264RawPPS *const pps = in->pps[slice->pic_parameter_set_id]; - qp = ctx->current_pic_init_qp + slice->slice_qp_delta; - slice->slice_qp_delta = qp - ctx->global_pic_init_qp; + // We modified the PPS's qp value, now offset this by applying + // the negative offset to the slices. + slice->slice_qp_delta += pps->pic_init_qp_minus26 + - (ctx->global_pic_init_qp - 26); return 0; }