From patchwork Fri May 12 20:26:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Levinson X-Patchwork-Id: 3666 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp489953vsd; Fri, 12 May 2017 13:26:40 -0700 (PDT) X-Received: by 10.28.31.135 with SMTP id f129mr3645346wmf.78.1494620799937; Fri, 12 May 2017 13:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494620799; cv=none; d=google.com; s=arc-20160816; b=hgKFVmOJitq92fBN3P2JhMH2YRJayXov0cfT6lJ1SVTn//YpjVOIDjlWantsEXpDAk E8QahQD50YWMXPyiAK6sg/Y4bgk92xnG/Oyum3urh9bIKXw4LG2hx4fzajvOmC45eIhW 6Ytv9GSmvdk9x3KB1bxRawS3j4GLmaZ6cPjuO85wpxD+HDnPJbuQEBOpzgHCGzIAyUSF IlUbvb8F826ARsG/RHIlJ4b7NffcSI4EXEnSG4y7Vafoy3QzFeQ3456WGfixndsLlSfk Dd+X4dnyRB8BvoR5Vb7+e7paU6tIgYqBtBeDsNshMqqDnXzusV+4KY011YFl+YneOhNR IZdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:user-agent:date:message-id:from:to :delivered-to:arc-authentication-results; bh=abSElsB6xp2fP+NvFXkKlce6FQOYSW76TEkNsn4Rxws=; b=JFLI4POtWVAN7XUwA+eopyZEQdc3OByH3AjtYgW9cJq5uLRzMMptMCzNrOi5s5xhQY JPFibR+X/BjPTIVwM7PQd3dnlrbI6g3ooYSTXFcK+D+q58EfH37zOiQNZFvRKRRNld1f N2/ktSN0pAO1hvITd1aSNPt9RJZrRLhd2soG3RQLOW9DqWqUcZwaFh70jjRuRiaRndKP uM+46HB3dTmDikGE0Z2yh1svKwyg3ea3zDqXudV+zNRZa0RBtKyJgChUNK3VacmzFsGR 4cQLwputdnM3lTY/AXYPIz1OZj/vmE2eKSVZ3u/rFRjg+3EV3cQtqfcD3EReq/vzxNDn MT9w== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m185si3178059wmg.72.2017.05.12.13.26.39; Fri, 12 May 2017 13:26:39 -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 5622E688396; Fri, 12 May 2017 23:26:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from white.spiritone.com (white.spiritone.com [216.99.193.38]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B735680457 for ; Fri, 12 May 2017 23:26:22 +0300 (EEST) Received: from [192.168.3.101] (184-100-204-251.ptld.qwest.net [184.100.204.251]) by white.spiritone.com (Postfix) with ESMTPSA id 2C9297340525 for ; Fri, 12 May 2017 13:26:29 -0700 (PDT) To: FFmpeg development discussions and patches From: Aaron Levinson Message-ID: Date: Fri, 12 May 2017 13:26:28 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] ffmpeg: Separated check_init_output_file() from init_output_stream() 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" Purpose: Separated the call to check_init_output_file() from init_output_stream(), and now check_init_output_file() is called by the parent after calling init_output_stream(). Additionally, moved some static function declarations to the beginning of the file. Signed-off-by: Aaron Levinson --- ffmpeg.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index e798d92277..3cd45ba665 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -141,6 +141,9 @@ AVIOContext *progress_avio = NULL; static uint8_t *subtitle_out; +static int init_output_stream(OutputStream *ost, char *error, int error_len); +static int check_init_output_file(OutputFile *of, int file_index); + InputStream **input_streams = NULL; int nb_input_streams = 0; InputFile **input_files = NULL; @@ -1400,8 +1403,6 @@ static void do_video_stats(OutputStream *ost, int frame_size) } } -static int init_output_stream(OutputStream *ost, char *error, int error_len); - static void finish_output_stream(OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; @@ -1446,6 +1447,10 @@ static int reap_filters(int flush) ost->file_index, ost->index, error); exit_program(1); } + + ret = check_init_output_file(of, ost->file_index); + if (ret < 0) + exit_program(1); } if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) { @@ -1894,6 +1899,10 @@ static void flush_encoders(void) ost->file_index, ost->index, error); exit_program(1); } + + ret = check_init_output_file(of, ost->file_index); + if (ret < 0) + exit_program(1); } if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) @@ -3564,10 +3573,6 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) ost->initialized = 1; - ret = check_init_output_file(output_files[ost->file_index], ost->file_index); - if (ret < 0) - return ret; - return ret; } @@ -3629,11 +3634,17 @@ static int transcode_init(void) /* open each encoder */ for (i = 0; i < nb_output_streams; i++) { + ost = output_streams[i]; // skip streams fed from filtergraphs until we have a frame for them - if (output_streams[i]->filter) + if (ost->filter) continue; - ret = init_output_stream(output_streams[i], error, sizeof(error)); + ret = init_output_stream(ost, error, sizeof(error)); + if (ret < 0) + goto dump_format; + + ret = check_init_output_file(output_files[ost->file_index], + ost->file_index); if (ret < 0) goto dump_format; }