From patchwork Thu Nov 8 15:35:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 10953 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 4ABA444D8ED for ; Thu, 8 Nov 2018 17:35:30 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A9223689F89; Thu, 8 Nov 2018 17:35:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F1696689F85 for ; Thu, 8 Nov 2018 17:34:54 +0200 (EET) Received: by mail-pf1-f173.google.com with SMTP id v9-v6so7155467pff.2 for ; Thu, 08 Nov 2018 07:35:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=J8q9TZRg07tCjwbAhm2FzfN8IEQgV5O9F6PBLbgEjYw=; b=hqWTeLFvnYf2B2S1h5tIyAG/GvgdASJEpWho8+7TO/hGlj8jIdpJR+KiuC/Ya1+Uc8 186oitbW9mg8mEGROfICX+3D1JYWcZpqxFEWMPcJ8u1t71RdVecaiYbWQfJyUwQ6S12U Ep9YeOuec7GP3v11/ltNpTobBL3k9iU0HpcN8Ervo6ulk5xdor+GA8dZ5bmY1ke2NBQn Kfw1Rhf9wiB7hUcVSBVcpbqNWu5FAb0Q9nh6I3Zr1HmnQIxs8GbpH0CteYDT+YNrzy7y Y++pJBSGRbxLujmG6N+btp3cY/V5uAhWBF1Ph5oUXqiCOOasAUsflJuRfeVdCeSZvObv EYsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=J8q9TZRg07tCjwbAhm2FzfN8IEQgV5O9F6PBLbgEjYw=; b=J7L5NhjcbyvIDzYdYltqSLJF3WU5KkC8b+LwlEHMU4RfOiuOJqcxqFe5aJZiQXWTPU 3rzK9d3T/yeY1OIPcRQjmk88sGSp4xDoMX3dxeLf3QtCu/MZixa8XFWP8tiTLT8iaBre sPzmDwFEYFvSSlnTXH6Uxk+sbXlh1T8Gk5Tz5PuUN+/99TUgzZW/VFibUULSmHTawyeX hsVvc3crx6jDCJ6OaiACOvVzzUc/Esa9qq1VvA7bvgepqAyxGsGBR456pHG8I1agZOLJ AAn3gkSOn6HEBeUwfTa079Ci1HsOAPG+wnB2/tBS6TieNi1WbJ359epF7n9Gk0DY4sdN vQKA== X-Gm-Message-State: AGRZ1gLK9GPX8nomPrQ9gxtZb6LqgUUCS9CJA6Gf9GRcyBiOFX9JXuvr L0UocQV87++2keXUuZ4lXb7QjFOc X-Google-Smtp-Source: AJdET5c5scra096ozPekupWu8Jh+3nlsl6k4iZeIa+etROcHMhVSokl+9YlvDB7ALkxu78F3028mrA== X-Received: by 2002:a62:1095:: with SMTP id 21-v6mr4909304pfq.227.1541691328309; Thu, 08 Nov 2018 07:35:28 -0800 (PST) Received: from localhost.localdomain ([47.90.47.25]) by smtp.gmail.com with ESMTPSA id n87-v6sm4909901pfb.62.2018.11.08.07.35.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 07:35:27 -0800 (PST) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Nov 2018 23:35:20 +0800 Message-Id: <1541691321-12543-1-git-send-email-mypopydev@gmail.com> X-Mailer: git-send-email 1.7.1 Subject: [FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg: Refine the do_video_out. 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: Jun Zhao MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Jun Zhao --- fftools/ffmpeg.c | 62 ++++++++++++++++++++++++----------------------------- 1 files changed, 28 insertions(+), 34 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index da4259a..e989e7a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1193,33 +1193,27 @@ static void do_video_out(OutputFile *of, } ost->last_dropped = nb_frames == nb0_frames && next_picture; - /* duplicates frame if needed */ - for (i = 0; i < nb_frames; i++) { - AVFrame *in_picture; - av_init_packet(&pkt); - pkt.data = NULL; - pkt.size = 0; - - if (i < nb0_frames && ost->last_frame) { - in_picture = ost->last_frame; - } else - in_picture = next_picture; + /* duplicates frame if needed */ + for (i = 0; i < nb_frames; i++) { + AVFrame *in_picture; + int forced_keyframe = 0; + double pts_time; + av_init_packet(&pkt); + pkt.data = NULL; + pkt.size = 0; - if (!in_picture) - return; + if (i < nb0_frames && ost->last_frame) { + in_picture = ost->last_frame; + } else + in_picture = next_picture; - in_picture->pts = ost->sync_opts; + if (!in_picture) + return; -#if 1 - if (!check_recording_time(ost)) -#else - if (ost->frame_number >= ost->max_frames) -#endif - return; + in_picture->pts = ost->sync_opts; - { - int forced_keyframe = 0; - double pts_time; + if (!check_recording_time(ost)) + return; if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) && ost->top_field_first >= 0) @@ -1328,18 +1322,18 @@ static void do_video_out(OutputFile *of, fprintf(ost->logfile, "%s", enc->stats_out); } } - } - ost->sync_opts++; - /* - * For video, number of frames in == number of packets out. - * But there may be reordering, so we can't throw away frames on encoder - * flush, we need to limit them here, before they go into encoder. - */ - ost->frame_number++; - if (vstats_filename && frame_size) - do_video_stats(ost, frame_size); - } + ost->sync_opts++; + /* + * For video, number of frames in == number of packets out. + * But there may be reordering, so we can't throw away frames on encoder + * flush, we need to limit them here, before they go into encoder. + */ + ost->frame_number++; + + if (vstats_filename && frame_size) + do_video_stats(ost, frame_size); + } if (!ost->last_frame) ost->last_frame = av_frame_alloc();