From patchwork Fri Oct 9 13:04:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 22780 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 5444D44A971 for ; Fri, 9 Oct 2020 16:06:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2B47968B9B2; Fri, 9 Oct 2020 16:06:39 +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 6340B68B683 for ; Fri, 9 Oct 2020 16:06:33 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail.red.khirnov.net (Postfix) with ESMTP id D9989296258 for ; Fri, 9 Oct 2020 15:06:32 +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 fGKcBkeKbwLg for ; Fri, 9 Oct 2020 15:06:30 +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 61C36296256 for ; Fri, 9 Oct 2020 15:06:30 +0200 (CEST) Received: by libav.daenerys.khirnov.net (Postfix, from userid 1000) id 88CE020E00C0; Fri, 9 Oct 2020 15:06:26 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Oct 2020 15:04:16 +0200 Message-Id: <20201009130430.602-4-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 04/18] lavf: move AVStream.pts_reorder_error[_count] 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 | 6 ------ libavformat/internal.h | 6 ++++++ libavformat/utils.c | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 7da67d961d..3d7fe4aadf 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1162,12 +1162,6 @@ typedef struct AVStream { */ int update_initial_durations_done; - /** - * Internal data to generate dts from pts - */ - int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; - uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index c9eca1babb..95cb5b5d60 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -225,6 +225,12 @@ struct AVStreamInternal { } *info; + /** + * Internal data to generate dts from pts + */ + int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; + uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; + /** * Internal data to analyze DTS and detect faulty mpeg streams */ diff --git a/libavformat/utils.c b/libavformat/utils.c index 04f2b24b72..3c4d13e1c1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1027,8 +1027,8 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t if (dts == AV_NOPTS_VALUE) { int64_t best_score = INT64_MAX; for (i = 0; ipts_reorder_error_count[i]) { - int64_t score = st->pts_reorder_error[i] / st->pts_reorder_error_count[i]; + if (st->internal->pts_reorder_error_count[i]) { + int64_t score = st->internal->pts_reorder_error[i] / st->internal->pts_reorder_error_count[i]; if (score < best_score) { best_score = score; dts = pts_buffer[i]; @@ -1039,13 +1039,13 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t for (i = 0; ipts_reorder_error[i]; - diff = FFMAX(diff, st->pts_reorder_error[i]); - st->pts_reorder_error[i] = diff; - st->pts_reorder_error_count[i]++; - if (st->pts_reorder_error_count[i] > 250) { - st->pts_reorder_error[i] >>= 1; - st->pts_reorder_error_count[i] >>= 1; + + (uint64_t)st->internal->pts_reorder_error[i]; + diff = FFMAX(diff, st->internal->pts_reorder_error[i]); + st->internal->pts_reorder_error[i] = diff; + st->internal->pts_reorder_error_count[i]++; + if (st->internal->pts_reorder_error_count[i] > 250) { + st->internal->pts_reorder_error[i] >>= 1; + st->internal->pts_reorder_error_count[i] >>= 1; } } }