From patchwork Fri May 12 20:22:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Levinson X-Patchwork-Id: 3665 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp488741vsd; Fri, 12 May 2017 13:22:51 -0700 (PDT) X-Received: by 10.28.52.9 with SMTP id b9mr3562002wma.11.1494620571789; Fri, 12 May 2017 13:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494620571; cv=none; d=google.com; s=arc-20160816; b=JkdXT3CKwqFv6uLgH8+Qgrm3lySzHZCAtrzB2EyiGrvOYo3mRGohq6iy2YhW3/uBMV kpsMo4MtTBcRNW/DeKGln9SMG4zBPAxLQfVa2c+qfLoCpoo/xo9WkENfJzHyKjgiugAo rLOG9K8qR6ONnPvH+0qsNa3qAk87ZzWw28/ySB0qIPsKd51s3Wmwh1AXxZjWIK2Zgvaq OYQm/LzuO1ogZiomkz4Diw+HWMkuGHipJcRpNORq7arbOQp6MJS/yYnaGNNLO0qT8FGo mfDHCBNBUH4XNSxRqEBKv2GhfFX8/ppCult4hTRO3z/NcWx0toAMHLICfvzq3V/TIyzf REbg== 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=qhjlDL7DiqukfOL14NuDjw2k7duAANAknJXyvG3s7+hLfwc/1hL+NHWsfpsog42SiJ SHMpkAi8bP/q0gee65qvfgJqYJqnyAoAGVdtCUd6wwfUZ54ExEgTcIFhsOq8MKFxT1fh Hu0YO1bEVMDg5ll677OdJmTgtFJzPGuiXdGa6ZgVZxqhVRgH7cjJgP5EqJp8ZmtPotC4 DrCOL0foGQjWcRt/TINHp2Etl8JmdSNJY44d/cx7QdAy+nfyhE0hrs2fxFIkSCVVGeqW lj/vQdScS5TlG8Ftasa8R56oT5OMdcSLRGZ2Xl0Ec0L17b5L2Ih2BK9WkUA12zdMXyIP 0WBQ== 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 l22si4372335wrl.241.2017.05.12.13.22.51; Fri, 12 May 2017 13:22:51 -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 3D91E68836D; Fri, 12 May 2017 23:22:41 +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 D4413680457 for ; Fri, 12 May 2017 23:22:34 +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 D1AAF7340344 for ; Fri, 12 May 2017 13:22:41 -0700 (PDT) To: FFmpeg development discussions and patches From: Aaron Levinson Message-ID: Date: Fri, 12 May 2017 13:22:41 -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; }