From patchwork Wed Aug 14 23:51:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 14511 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 6DB4444A105 for ; Thu, 15 Aug 2019 02:51:49 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 567D468AB70; Thu, 15 Aug 2019 02:51:49 +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 F3F3568AAEA for ; Thu, 15 Aug 2019 02:51:42 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id BE0C4E3827; Thu, 15 Aug 2019 01:51:42 +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 ho2UuHWhZ1js; Thu, 15 Aug 2019 01:51:41 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3E16BE3841; Thu, 15 Aug 2019 01:51:41 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 15 Aug 2019 01:51:29 +0200 Message-Id: <20190814235130.5973-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190814235130.5973-1-cus@passwd.hu> References: <20190814235130.5973-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 3/4] avformat/mpegtsenc: move some code around and simplify a bit 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" PCR does not need to be recalcualted for CBR when inserting a NULL or PCR only packet. Signed-off-by: Marton Balint --- libavformat/mpegtsenc.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 9dee5fa1d0..04da081ac0 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -1221,6 +1221,15 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, } ts->next_pcr = next_pcr; } + if (dts != AV_NOPTS_VALUE && (dts - pcr / 300) > delay) { + /* pcr insert gets priority over null packet insert */ + if (write_pcr) + mpegts_insert_pcr_only(s, st); + else + mpegts_insert_null_packet(s); + /* recalculate write_pcr and possibly retransmit si_info */ + continue; + } } else if (ts_st->pcr_period && dts != AV_NOPTS_VALUE) { pcr = (dts - delay) * 300; if (pcr - ts_st->last_pcr >= ts_st->pcr_period && is_start) { @@ -1229,17 +1238,6 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, } } - if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE && - (dts - get_pcr(ts, s->pb) / 300) > delay) { - /* pcr insert gets priority over null packet insert */ - if (write_pcr) - mpegts_insert_pcr_only(s, st); - else - mpegts_insert_null_packet(s); - /* recalculate write_pcr and possibly retransmit si_info */ - continue; - } - /* prepare packet header */ q = buf; *q++ = 0x47;