From patchwork Tue Jun 25 06:47:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Siddall X-Patchwork-Id: 13693 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 91BC644873D for ; Tue, 25 Jun 2019 09:47:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6754A68977D; Tue, 25 Jun 2019 09:47:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-oln040092002076.outbound.protection.outlook.com [40.92.2.76]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 49C0B680328 for ; Tue, 25 Jun 2019 09:47:32 +0300 (EEST) Received: from SN1NAM01FT048.eop-nam01.prod.protection.outlook.com (10.152.64.53) by SN1NAM01HT078.eop-nam01.prod.protection.outlook.com (10.152.65.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2008.13; Tue, 25 Jun 2019 06:47:30 +0000 Received: from DM6PR14MB2633.namprd14.prod.outlook.com (10.152.64.53) by SN1NAM01FT048.mail.protection.outlook.com (10.152.64.249) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.13 via Frontend Transport; Tue, 25 Jun 2019 06:47:30 +0000 Received: from DM6PR14MB2633.namprd14.prod.outlook.com ([fe80::ec20:1622:7a1e:2253]) by DM6PR14MB2633.namprd14.prod.outlook.com ([fe80::ec20:1622:7a1e:2253%5]) with mapi id 15.20.2008.017; Tue, 25 Jun 2019 06:47:30 +0000 From: Jacob Siddall To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v2] avformat/rtpdec_rfc4175: Fix incorrect copy_offset calculation Thread-Index: AQHVKyHcCLfFFM/ktUSpQLJOZnC6Zw== Date: Tue, 25 Jun 2019 06:47:30 +0000 Message-ID: References: <20190622082008.GP3118@michaelspb> In-Reply-To: <20190622082008.GP3118@michaelspb> Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MEXPR01CA0107.ausprd01.prod.outlook.com (2603:10c6:200:2c::16) To DM6PR14MB2633.namprd14.prod.outlook.com (2603:10b6:5:11d::15) x-incomingtopheadermarker: OriginalChecksum:AFA4B1E20B0726EDE70FB4D6C61ABCE2F47DB94A9622DFB982DCAAFA4F193E5A; UpperCasedChecksum:B98BE0651A10515283CA3673C7B241237D5B626BF018D4BA582B6E26C90B4CE8; SizeAsReceived:7406; Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-tmn: [yftxGSqskapbaJP8k2G04bXtvg1yW7vh] x-microsoft-original-message-id: <20190625064652.31441-1-kobe@live.com.au> x-ms-publictraffictype: Email x-incomingheadercount: 50 x-eopattributedmessage: 0 x-ms-exchange-slblob-mailprops: pt8ZUcDWjMU4N6H0Wpqa9/tckY//xJHQMWUoJSLUEs04sEzFOrTMnVXctB/vQFc8ru74c7kQmc0ISnkGHGuuv52TUqbX93/mwXPrKDvsHmaY25lvTznl63933Mrm2NO76oCToXuY4BwF9vPzxH3CNoUV8z2tys8vddW5E9kfnNxxCVqH3M4awFvVKpuwl9crcIwD3PfelFdhk5GdbOsFMzg7JNHmKJ5fLE9266MnhZGTH0Ea3orvCHtDrU/v/gIn6a++9+X4X8K2vlxPPXRDHeNGmw/9drVb44jMJaK1DrEUIDjfCBwcfi7TT5ZaMt+RohOspCHcbfWf8UVnlwq88gRzrdJWogx1ucz2tHmpL4vaPeT8cqlL0/sHcx6Td6SKasVNPYLIH/wqPAbdVIS+WS5mB5DrwAw3gEQ8nY9Z/AavQWtmLf00nGZBVtsYr43qgaPPBI2mVbdZIGSRV9kiRNZsVKkrKo+WesrWfbr+4mOSq4dD+VSjAEcDO6PQCKFcRUx8rEH7pkpVZc7lvBDc67TBS0frsJuVbk9qA5sGvB8hRqjWjtJnVyht2lFlVLNEx+dLLWmUlLxzkabyx7hd6kDCPX/2nWzL+jnPZewGQ6gdBgJASwqMzCEQLdNyyZCvrsPyyjhnRnjsoPczPo6QZ9mS2yzQ7BfrV9ln8pixqybAeI/6G5lTeyro/DTHRE1cAMSBwyZ5eQGcM0xLQCZSMHA3zOZ70MGAyqoe35LezI2TnQmbGNqz9nRZLsdQFvSe3MXlsdchT/jiwK0ZhxK6EwCJEOGlm3JtyfcyVM/NlXujfJYegfCZigRe0l5fkQFmgWDFwi/j3QvGKHKIsCpeAQaGe6PFj6yxf2n+9c8CBIpojKP9x9S6iXlQLlqFcgw4OKlyXQeZvDkmOEXjmlE+yKLkqKtfaemy3AnFNGT0A3dNAffdycEwgf5SF5xQZGN4 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(5050001)(7020095)(20181119110)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(201702181274)(2017031322404)(2017031323274)(2017031324274)(1601125500)(1603101475)(1701031045); SRVR:SN1NAM01HT078; x-ms-traffictypediagnostic: SN1NAM01HT078: x-ms-exchange-purlcount: 1 x-microsoft-antispam-message-info: FNq9ci9l1fPUfb79tt1A4ZCBU4wBeuwipuYjAs6ToxSJbyM65jKLN63n1PzxADX8JaDXA+v8RMeVxThpoleOYzmcx1ETRhc8SGl3NtmQTKJ4WVPv3S0d51i+HAY4UVHMiVR8DBJu7QkGCyL1j0im+0Yhfm6SLx8Fr1TM33JgMrepLiliBgB+EaMB+4jt/tY6 MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: eb8bb641-15a0-41a8-a03b-08d6f938fd95 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jun 2019 06:47:30.3191 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM01HT078 Subject: [FFmpeg-devel] [PATCH v2] avformat/rtpdec_rfc4175: Fix incorrect copy_offset calculation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Jacob Siddall Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The previous calculation code did not account for the fact that the copy_offset for the start of the frame array is at index 0, yet the scan line number from the rfc4175 RTP header starts at 1. This caused 2 issues to appear: - The first scan line was being copied into the array where the second scan line should be. This caused the resulting video to have a green line at the top of it. - Since the packet containing the last scan line would fail the calculation, the packet with the RTP marker would not be processed which caused a log message saying "Missed previous RTP marker" to be outputted for each frame. Signed-off-by: Jacob Siddall --- Changes in v2: - Don't handle packet if the line number is less than 1 Section 12 in the VSF technical recommendation TR-03 specifies that the video scan line numbers should start at 1. http://www.videoservicesforum.org/download/technical_recommendations/VSF_TR-03_2015-11-12.pdf libavformat/rtpdec_rfc4175.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c index e9c62c1..490db87 100644 --- a/libavformat/rtpdec_rfc4175.c +++ b/libavformat/rtpdec_rfc4175.c @@ -205,8 +205,11 @@ static int rfc4175_handle_packet(AVFormatContext *ctx, PayloadContext *data, if (length > payload_len) length = payload_len; + if (line < 1) + return AVERROR_INVALIDDATA; + /* prevent ill-formed packets to write after buffer's end */ - copy_offset = (line * data->width + offset) * data->pgroup / data->xinc; + copy_offset = ((line - 1) * data->width + offset) * data->pgroup / data->xinc; if (copy_offset + length > data->frame_size) return AVERROR_INVALIDDATA;