From patchwork Wed Aug 3 18:55:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 78 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp839999vsd; Wed, 3 Aug 2016 11:58:43 -0700 (PDT) X-Received: by 10.28.130.208 with SMTP id e199mr72391385wmd.14.1470250722957; Wed, 03 Aug 2016 11:58:42 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s70si28122900wme.140.2016.08.03.11.58.42; Wed, 03 Aug 2016 11:58:42 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8FC5568A21F; Wed, 3 Aug 2016 21:58:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe04-2.mx.upcmail.net (vie01a-dmta-pe04-2.mx.upcmail.net [62.179.121.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7B31D68A21C for ; Wed, 3 Aug 2016 21:58:12 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1bV1Mw-0004kb-3A for ffmpeg-devel@ffmpeg.org; Wed, 03 Aug 2016 20:58:18 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id SiyG1t00t0S5wYM01iyHVk; Wed, 03 Aug 2016 20:58:18 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 3 Aug 2016 20:55:21 +0200 Message-Id: <20160803185523.27767-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.9.2 Subject: [FFmpeg-devel] [PATCH 1/3] avformat: Add av_get_frame_filename2() and AV_FRAME_FILENAME_FLAGS_MULTIPLE 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This will be used to allow writing file sequences using the tee output onto multiple places in parallel Signed-off-by: Michael Niedermayer --- libavformat/avformat.h | 7 +++++++ libavformat/utils.c | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index b9fbb06..d8a6cf3 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2720,6 +2720,9 @@ void av_dump_format(AVFormatContext *ic, const char *url, int is_output); + +#define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1 ///< Allow multiple %d + /** * Return in 'buf' the path with '%d' replaced by a number. * @@ -2730,8 +2733,12 @@ void av_dump_format(AVFormatContext *ic, * @param buf_size destination buffer size * @param path numbered sequence string * @param number frame number + * @param flags AV_FRAME_FILENAME_FLAGS_* * @return 0 if OK, -1 on format error */ +int av_get_frame_filename2(char *buf, int buf_size, + const char *path, int number, int flags); + int av_get_frame_filename(char *buf, int buf_size, const char *path, int number); diff --git a/libavformat/utils.c b/libavformat/utils.c index 5a902ea..6b7609e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -4315,7 +4315,7 @@ uint64_t ff_ntp_time(void) return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US; } -int av_get_frame_filename(char *buf, int buf_size, const char *path, int number) +int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags) { const char *p; char *q, buf1[20], c; @@ -4340,7 +4340,7 @@ int av_get_frame_filename(char *buf, int buf_size, const char *path, int number) case '%': goto addchar; case 'd': - if (percentd_found) + if (!(flags & AV_FRAME_FILENAME_FLAGS_MULTIPLE) && percentd_found) goto fail; percentd_found = 1; if (number < 0) @@ -4370,6 +4370,11 @@ fail: return -1; } +int av_get_frame_filename(char *buf, int buf_size, const char *path, int number) +{ + return av_get_frame_filename2(buf, buf_size, path, number, 0); +} + void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size,