From patchwork Fri Jan 6 21:14:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 2089 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp6006047vsb; Fri, 6 Jan 2017 13:15:13 -0800 (PST) X-Received: by 10.194.90.135 with SMTP id bw7mr58627492wjb.34.1483737313602; Fri, 06 Jan 2017 13:15:13 -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 k3si3579789wme.130.2017.01.06.13.15.12; Fri, 06 Jan 2017 13:15:13 -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=@hotmail.com; 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 dis=NONE) header.from=hotmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8EBEB68A331; Fri, 6 Jan 2017 23:15:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from SNT004-OMC4S26.hotmail.com (snt004-omc4s26.hotmail.com [65.55.90.229]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7215F68A2BF for ; Fri, 6 Jan 2017 23:14:57 +0200 (EET) Received: from NAM01-BY2-obe.outbound.protection.outlook.com ([65.55.90.201]) by SNT004-OMC4S26.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Fri, 6 Jan 2017 13:15:01 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KAUvvGKUW4GhJ6EDM/78g+zq3VRVhm/JhAJ0LGF6xLI=; b=lvTMOAdAtlgyXfrAmsnfKU67GP4PqUm7tW1/PgpboaN0fu7rqLMNlF+QXH/W3nXCr54VmFLIoPMXW1M2ebX4EwAeKuMu84KFxikQj+aCJC+t5V7Bt9U/XITXH731wvVw4s8CH/tvrZ3odHt1ZSD3VT6oIKY2Rquxqlt9mQ4ITp1kluwHJbeQXK5PPP9CXs2503+8c9iUIR8uEWRvrpnuge7i+XHSnEpkggTrBw0IWO6L7eoxbSS+unJtwJTofZELhqsB8ZHplk++iG+tpvE/b7lpkr4XYx/mEomybjkt4FS7F982ZouaCE+RM9bwApM8qByZGpFlTVY9Lz6T+MmOyQ== Received: from BN3NAM01FT044.eop-nam01.prod.protection.outlook.com (10.152.66.53) by BN3NAM01HT019.eop-nam01.prod.protection.outlook.com (10.152.66.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.8; Fri, 6 Jan 2017 21:15:00 +0000 Received: from MWHPR13MB1678.namprd13.prod.outlook.com (10.152.66.53) by BN3NAM01FT044.mail.protection.outlook.com (10.152.66.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.8 via Frontend Transport; Fri, 6 Jan 2017 21:15:00 +0000 Received: from MWHPR13MB1678.namprd13.prod.outlook.com ([10.171.144.16]) by MWHPR13MB1678.namprd13.prod.outlook.com ([10.171.144.16]) with mapi id 15.01.0829.007; Fri, 6 Jan 2017 21:14:59 +0000 From: Soft Works To: FFmpeg development discussions and patches Thread-Topic: [FFmpeg-devel] [PATCH 1/2] libavformat/avio: Add avio_get_dyn_buf function Thread-Index: AQHSaA1x3atr5gelLkWdP1Iufavt56Er8x2N Date: Fri, 6 Jan 2017 21:14:59 +0000 Message-ID: References: , <20170106110900.GJ4749@nb4> In-Reply-To: <20170106110900.GJ4749@nb4> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: authentication-results: ffmpeg.org; dkim=none (message not signed) header.d=none; ffmpeg.org; dmarc=none action=none header.from=hotmail.com; x-incomingtopheadermarker: OriginalChecksum:C8372F3888A3362D63F9D048EC8904FA9CBFF9AB4486D211935AA3B22D6AA309; UpperCasedChecksum:2FE9D3FF10274D9587E42A427B83C0DC7A8658F0653A8C6A111EC3E074FA2F22; SizeAsReceived:7661; Count:39 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [lhGp+bJCKKhNAaQ8RtFpkBj+Sr2Qb+QG] x-incomingheadercount: 39 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; BN3NAM01HT019; 7:CJPoFg1I6aqZ6WjizFPLEsl/8toO4GgUxTPHLE/pPX+x2lOOfVogrWsmIM45m5Z69HFnxVa42p5+iFWlN8dMr5IeDhCunUYgMTobAjzEXU4OJXPxsBq4UkAJIiIkR3h3WDX7Cccys2PMgE/xANeSs3W8WmucEi9UJKhmoFqpmeTIjvPGAJVWywYe/+Im9m5fEYbyDdV1dvcM7a6bcmk5U71fax7thqmnBtoJ6lrNhem5qavtq+HnG+Tn5l1T8x9pED9hY6nQhgNaA7EMVJTI/JX9aWD6PWow2aLwbw7DleF80ZnMSgMOcYZqcIaCXrmdRa8l+jIDmFWsuFyr0Vh4868z68bOfXJCbMBJOxu5fGLlm3vJOQ1diUuL5wFCF19H2WoaXnNmilG4GbWWYZMY89mLDJKYK1jAA2kBkpZbCE6Dzj3bZEHaNbC140+ANor5B++ql9BdzUl+AtN8fUMYww== x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3NAM01HT019; H:MWHPR13MB1678.namprd13.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 814f87ca-3a84-4a35-e1b5-08d4367912c2 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(1601124038)(1603103113)(1603101340)(1601125047)(1701031023); SRVR:BN3NAM01HT019; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444111334)(444112120)(432015012)(102415395)(82015046); SRVR:BN3NAM01HT019; BCL:0; PCL:0; RULEID:; SRVR:BN3NAM01HT019; x-forefront-prvs: 01792087B6 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2017 21:14:59.7625 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3NAM01HT019 X-OriginalArrivalTime: 06 Jan 2017 21:15:01.0804 (UTC) FILETIME=[F16266C0:01D26861] Subject: Re: [FFmpeg-devel] [PATCH 1/2] libavformat/avio: Add avio_get_dyn_buf function 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" [PATCH] libavformat/avio: Add avio_get_dyn_buf function Revision #2: Bumb version and add APIchanges entry This commit adds the avio_get_dyn_buf function which allows accessing the content of a DynBuffer without destroying it. This is required in matroskaenc for preliminary writing (correct) mkv headers. Context for this change is fixing regression bug #5977. --- doc/APIchanges | 3 +++ libavformat/avio.h | 12 ++++++++++++ libavformat/aviobuf.c | 17 +++++++++++++++++ libavformat/version.h | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index fbeae7a..3279563 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-01-06 - xxxxxxx - lavf 57.62.100- avio.h + Add avio_get_dyn_buf() + 2016-12-10 - xxxxxxx - lavu xx.xx.100- imgutils.h Add av_image_check_size2() diff --git a/libavformat/avio.h b/libavformat/avio.h index b1ce1d1..f2b9a6f 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -704,6 +704,18 @@ int avio_closep(AVIOContext **s); int avio_open_dyn_buf(AVIOContext **s); /** + * Return the written size and a pointer to the buffer. + * The AVIOContext stream is left intact. + * The buffer must NOT be freed. + * No padding is added to the buffer. + * + * @param s IO context + * @param pbuffer pointer to a byte buffer + * @return the length of the byte buffer + */ +int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer); + +/** * Return the written size and a pointer to the buffer. The buffer * must be freed with av_free(). * Padding of AV_INPUT_BUFFER_PADDING_SIZE is added to the buffer. diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 134d627..bf7e5f8 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1277,6 +1277,23 @@ int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) return url_open_dyn_buf_internal(s, max_packet_size); } +int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer) +{ + DynBuffer *d; + + if (!s) { + *pbuffer = NULL; + return 0; + } + + avio_flush(s); + + d = s->opaque; + *pbuffer = d->buffer; + + return d->size; +} + int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { DynBuffer *d; diff --git a/libavformat/version.h b/libavformat/version.h index 65e6a4c..21cc8a9 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 57 -#define LIBAVFORMAT_VERSION_MINOR 61 +#define LIBAVFORMAT_VERSION_MINOR 62 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \