From patchwork Thu Jun 27 06:06:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Siddall X-Patchwork-Id: 13715 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 2CFEA4496BF for ; Thu, 27 Jun 2019 09:06:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 09A3468A326; Thu, 27 Jun 2019 09:06:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-oln040092009107.outbound.protection.outlook.com [40.92.9.107]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBAE1689909 for ; Thu, 27 Jun 2019 09:06:26 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=testarcselector01; d=microsoft.com; cv=none; b=MrxE95Os3XfdPSJHccHa3h2OGNq01mQEpMALMFxcQJ1WQl3nqGC9oiMxdpWZND9DfOYmFn1iWTMNrEhqOGCqloNvUzkwomwZ1nwknbSpZtKbp830nuRAIR4ntUDjfWNz6c2Qwbgsp7TUrFWshmzPfN0/gW2Ky+rlH4S3XO/OrNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=testarcselector01; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0MHoYmgijDZWjGEY1t05HdHKtKMnZFRPqU2+9NVyS54=; b=ZsN6ZdjTc6o4r3B6Zr4pFGyCWeqUCwjuRH0JRIcS7m4mTb9qdfH/LZi6YqxYUV0lDE+C0IXnFluaV8iILg8LWONxBp6vnVrMQ3GNa1WcJ5S2pAoiKPV6x2Ox4UTbazx0pgErhE6nplkzobq3CkdefMsuc8yTBAEruMx6ghzTuVY= ARC-Authentication-Results: i=1; test.office365.com 1;spf=none;dmarc=none;dkim=none;arc=none Received: from SN1NAM04FT050.eop-NAM04.prod.protection.outlook.com (10.152.88.53) by SN1NAM04HT016.eop-NAM04.prod.protection.outlook.com (10.152.89.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2008.13; Thu, 27 Jun 2019 06:06:22 +0000 Received: from DM6PR14MB2633.namprd14.prod.outlook.com (10.152.88.53) by SN1NAM04FT050.mail.protection.outlook.com (10.152.89.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2032.15 via Frontend Transport; Thu, 27 Jun 2019 06:06:22 +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.018; Thu, 27 Jun 2019 06:06:22 +0000 From: Jacob Siddall To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v3] avformat/rtpdec_rfc4175: Fix incorrect copy_offset calculation Thread-Index: AQHVLK5yWfw9vqKsgUqKTt1rL73Y6Q== Date: Thu, 27 Jun 2019 06:06:22 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MEAPR01CA0110.ausprd01.prod.outlook.com (2603:10c6:220:60::26) To DM6PR14MB2633.namprd14.prod.outlook.com (2603:10b6:5:11d::15) x-incomingtopheadermarker: OriginalChecksum:F60F21FD63A513545E3AB229886A89ADC2504B271F5734589E89C547D4F1D711; UpperCasedChecksum:C68036458B486A368ABA27F4E33595E59E243959A3C58D1A9F27E02C3E60A416; SizeAsReceived:7502; Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-tmn: [6JvZ0yqJ+jRmiY74d58mu8XH8aUxRPBR] x-microsoft-original-message-id: <20190627060543.11239-1-kobe@live.com.au> x-ms-publictraffictype: Email x-incomingheadercount: 50 x-eopattributedmessage: 0 x-ms-exchange-slblob-mailprops: pt8ZUcDWjMWur6sCEe76QxzGrFFiw274+KWyOk8/sJGN9yKvStFRoZOWujXJ96beB9hjPfMBMXb7AhrB9twRgylZ5+XenZ+HUhj4Wft9vq2K3VWlCJ+sQFFFAXAcdquiAR1hAzg+r+3wRIRNANAOvYQc3exOOFeMOeyVNFDwwxaKNv783+jXjUJAOC5rfNGSgYi7/RWlS3BApGlOui9KIjOwO4TE5F2NH9o6aMNMyQ7KeSpZIAkgKeY7mU2Hnv4Oeskcdd50rME/D6UgjHDTOS6q3duhWEXN0AgYe5rKOG2zxksU9j8M+jbmml6b8aWGOwbvMlP5wfVtOK0UJvnITON1srdXzWh/QlIRsWEzkC9ZtFrgi5i/o30NnHqwTxic9v24drAE+FmC0pz29fZJNpa0V4VeAJkIdqcFi/PkD6XMrAQOb4uulzS4o8b1Flxqf+KH/lVeWjOOgNDqwHYZ5DicSVc3BBoGVrg60SMmc82CNIWKG30wbdWA5RqjTaxUFRh9sU+bhl9xhJ5PrfRWllhVJGALtxrMB7a0OSSAZu9fmIOOp3nM31Y/I8ztIR+zyp4O0I9hEShvDvin1kAxbAwLkRoJMHF6zUVPHz/kZRmf4yDONTztMcZ9PfkSCVS5wXcrQRW1IDgAcFAKvM4Tgf0cX0s5NmSVdhjX/JkiZOoZywJIomSD5eywTS+40hu2Pra2Qzy1n3g6XoCVZLX02oCXwTKhIa6gC7a2TDnSqLopvcLocT4aWxNCUXH4IihajVCZ5AKRtvFBGw3Bqsd3qtGtvGkJggMzkoIkGRWRw+75jwm6SoscSnEP9Fe8Roayk39zU5fvt9tg1ESNEiNWmGzwqQOVz1GzTUpAuoEAjKo9ItJ4KpeYDAyZMdOOwumGN/SEr6b1A5q/sjJIQRy3n3jhripJn7R6O8S75aOFDZPumBYh4EVaooPfGUa2b73D 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:SN1NAM04HT016; x-ms-traffictypediagnostic: SN1NAM04HT016: x-ms-exchange-purlcount: 1 x-microsoft-antispam-message-info: DMmPsBDlQqKTEsGu6iai/BSr69FcYIaLaDVzNqJymXBUlsW/jK9d5R6iqb2bvhP4bKrqGDs+XCknyG3MHPh+iF5nfl3mPJq5+TFlYAcxZdYRjMK2wX3WBV9ziCbM3DdHZIYsThUQkFQGzYrTH+QqfvfDW1T+hpvaU0jyWh1Kq/qBkAEWyCmDgwpKOzRuWL42 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: 7cba2ff6-a45a-4b5a-0851-08d6fac59444 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jun 2019 06:06:22.7109 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM04HT016 Subject: [FFmpeg-devel] [PATCH v3] 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 Changes in v3: - Changed the commit hash abbreviation in the patch file diff to be 10 characters in length rather than 7. This was causing the patch file to fail when it was applied. 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 e9c62c1389..490db87520 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;