From patchwork Fri Oct 9 13:04:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 22787 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 5131144A971 for ; Fri, 9 Oct 2020 16:06:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4110768B9EF; Fri, 9 Oct 2020 16:06:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.red.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3646C68B9C0 for ; Fri, 9 Oct 2020 16:06:40 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id 67669296259 for ; Fri, 9 Oct 2020 15:06:37 +0200 (CEST) Received: from mail.red.khirnov.net ([IPv6:::1]) by localhost (mail.red.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 2Ja0Hzf1K5OL for ; Fri, 9 Oct 2020 15:06:37 +0200 (CEST) Received: from libav.daenerys.khirnov.net (libav.daenerys.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.daenerys.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail.red.khirnov.net (Postfix) with ESMTPS id F2B0A296263 for ; Fri, 9 Oct 2020 15:06:31 +0200 (CEST) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id 0A7CA20E0265; Fri, 9 Oct 2020 15:06:27 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Oct 2020 15:04:29 +0200 Message-Id: <20201009130430.602-17-anton@khirnov.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009130430.602-1-anton@khirnov.net> References: <20201009130430.602-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/18] lavf: move AVStream.last_IP_* to AVStreamInternal 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" Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 4 ++-- libavformat/internal.h | 3 +++ libavformat/nutdec.c | 2 +- libavformat/utils.c | 20 ++++++++++---------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6168062ce1..a01912d654 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1040,10 +1040,10 @@ typedef struct AVStream { */ int64_t first_dts; int64_t cur_dts; - int64_t last_IP_pts; - int last_IP_duration; #if LIBAVFORMAT_VERSION_MAJOR < 59 + int64_t unused12; + int unused13; // kept for ABI compatibility only, do not access in any way int unused10; int unused11; diff --git a/libavformat/internal.h b/libavformat/internal.h index edc8bbae80..a8c8a10d4b 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -357,6 +357,9 @@ struct AVStreamInternal { * Number of frames that have been demuxed during avformat_find_stream_info() */ int codec_info_nb_frames; + + int64_t last_IP_pts; + int last_IP_duration; }; #ifdef __GNUC__ diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 53a052503e..f8c11d270f 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -1086,7 +1086,7 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code) stc->skip_until_key_frame = 0; discard = s->streams[stream_id]->discard; - last_IP_pts = s->streams[stream_id]->last_IP_pts; + last_IP_pts = s->streams[stream_id]->internal->last_IP_pts; if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) || (discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts) || diff --git a/libavformat/utils.c b/libavformat/utils.c index c0ba07d288..8be6400f11 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1316,28 +1316,28 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, /* DTS = decompression timestamp */ /* PTS = presentation timestamp */ if (pkt->dts == AV_NOPTS_VALUE) - pkt->dts = st->last_IP_pts; + pkt->dts = st->internal->last_IP_pts; update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt); if (pkt->dts == AV_NOPTS_VALUE) pkt->dts = st->cur_dts; /* This is tricky: the dts must be incremented by the duration * of the frame we are displaying, i.e. the last I- or P-frame. */ - if (st->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX) - st->last_IP_duration = pkt->duration; + if (st->internal->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX) + st->internal->last_IP_duration = pkt->duration; if (pkt->dts != AV_NOPTS_VALUE) - st->cur_dts = av_sat_add64(pkt->dts, st->last_IP_duration); + st->cur_dts = av_sat_add64(pkt->dts, st->internal->last_IP_duration); if (pkt->dts != AV_NOPTS_VALUE && pkt->pts == AV_NOPTS_VALUE && - st->last_IP_duration > 0 && + st->internal->last_IP_duration > 0 && ((uint64_t)st->cur_dts - (uint64_t)next_dts + 1) <= 2 && next_dts != next_pts && next_pts != AV_NOPTS_VALUE) pkt->pts = next_dts; if ((uint64_t)pkt->duration <= INT32_MAX) - st->last_IP_duration = pkt->duration; - st->last_IP_pts = pkt->pts; + st->internal->last_IP_duration = pkt->duration; + st->internal->last_IP_pts = pkt->pts; /* Cannot compute PTS if not present (we can compute it only * by knowing the future. */ } else if (pkt->pts != AV_NOPTS_VALUE || @@ -1874,7 +1874,7 @@ void ff_read_frame_flush(AVFormatContext *s) av_parser_close(st->internal->parser); st->internal->parser = NULL; } - st->last_IP_pts = AV_NOPTS_VALUE; + st->internal->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; if (st->first_dts == AV_NOPTS_VALUE) st->cur_dts = RELATIVE_TS_BASE; @@ -2863,7 +2863,7 @@ skip_duration_calc: st = ic->streams[i]; st->cur_dts = st->first_dts; - st->last_IP_pts = AV_NOPTS_VALUE; + st->internal->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; for (j = 0; j < MAX_REORDER_DELAY + 1; j++) st->internal->pts_buffer[j] = AV_NOPTS_VALUE; @@ -4523,7 +4523,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->internal->pts_wrap_reference = AV_NOPTS_VALUE; st->internal->pts_wrap_behavior = AV_PTS_WRAP_IGNORE; - st->last_IP_pts = AV_NOPTS_VALUE; + st->internal->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; for (i = 0; i < MAX_REORDER_DELAY + 1; i++) st->internal->pts_buffer[i] = AV_NOPTS_VALUE;