From patchwork Sat Aug 10 20:55:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 14381 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 024B6448E81 for ; Sat, 10 Aug 2019 23:56:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C9CFD68AAC3; Sat, 10 Aug 2019 23:56:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D80B68A324 for ; Sat, 10 Aug 2019 23:56:03 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D44D6E3719; Sat, 10 Aug 2019 22:56:02 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0W2QrDCjccQ5; Sat, 10 Aug 2019 22:56:01 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D85A6E3715; Sat, 10 Aug 2019 22:56:00 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 10 Aug 2019 22:55:57 +0200 Message-Id: <20190810205557.23642-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCHv2 3/3] avformat/avio: remove 4k limit from avio_printf 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" We do this by switching to AVBPrint. v2: Also set IO context error flag in case of ENOMEM. Signed-off-by: Marton Balint --- doc/APIchanges | 3 +++ libavformat/avio.h | 5 ++++- libavformat/aviobuf.c | 16 +++++++++++----- libavformat/version.h | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 0b19fb067d..fe36c34b90 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2019-08-xx - xxxxxxxxxx - lavf 58.31.101 - avio.h + 4K limit removed from avio_printf. + 2019-08-xx - xxxxxxxxxx - lavf 58.31.100 - avio.h Add avio_print_n_strings and avio_print. diff --git a/libavformat/avio.h b/libavformat/avio.h index 0c622f44bd..f3a35004d2 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -571,7 +571,10 @@ int64_t avio_size(AVIOContext *s); */ int avio_feof(AVIOContext *s); -/** @warning Writes up to 4 KiB per call */ +/** + * Writes a formatted string to the context. + * @return number of bytes written, < 0 on error. + */ int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); /** diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 4a37a13d7a..2a0f033c45 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1215,14 +1215,20 @@ int avio_closep(AVIOContext **s) int avio_printf(AVIOContext *s, const char *fmt, ...) { va_list ap; - char buf[4096]; /* update doc entry in avio.h if changed */ - int ret; + AVBPrint bp; + av_bprint_init(&bp, 0, INT_MAX); va_start(ap, fmt); - ret = vsnprintf(buf, sizeof(buf), fmt, ap); + av_vbprintf(&bp, fmt, ap); va_end(ap); - avio_write(s, buf, strlen(buf)); - return ret; + if (!av_bprint_is_complete(&bp)) { + av_bprint_finalize(&bp, NULL); + s->error = AVERROR(ENOMEM); + return AVERROR(ENOMEM); + } + avio_write(s, bp.str, bp.len); + av_bprint_finalize(&bp, NULL); + return bp.len; } void avio_print_n_strings(AVIOContext *s, int nb_strings, ...) diff --git a/libavformat/version.h b/libavformat/version.h index feceaedc08..9814db8633 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -33,7 +33,7 @@ // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 #define LIBAVFORMAT_VERSION_MINOR 31 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \