From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A920846C03 for ; Mon, 4 Mar 2024 15:11:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D068768D403; Mon, 4 Mar 2024 17:11:26 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A3DDD68D3E2 for ; Mon, 4 Mar 2024 17:11:20 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=qt20Jwd4; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id D38F04D3D for ; Mon, 4 Mar 2024 16:11:19 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id McbRjpn9cjBs for ; Mon, 4 Mar 2024 16:11:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1709565078; bh=+XAycaF/94BZRXUlfAp9HPtk/0XJu47PfGCg3bLvO9k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qt20Jwd44JsNz+yUbWnRNvJzA9XeAxSCa5Rx5tR86pQsea1ovz0vR4IieQSkNRn/2 bIktOvKujnr0ggY6YII233gbBFKWh5b718dpJ5pZVtLsGWO2zGm4B5b8FWNrf6cOcj H92pXxPUgG5q2zhf+OQnjMJzr/o16zMqM7XcCPH7KKdhQKQqQ2/vBzFK0SLm1+5+1K jbEMWnw7A2B0abSRRLadT4WUkgY31d9WxF0sanQJPgV0j/WvQQ6Q5K5iF26khd8fIq VYtjVSTJpvImiceOMNQpc4ggiCShA4TME/3m93fOyTrQlj9+UbIk78eelGSrz8oktO 4f8a0qi/4lPag== Received: from libav.khirnov.net (libav.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.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id C43C810B9 for ; Mon, 4 Mar 2024 16:11:18 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9CD203A0357 for ; Mon, 4 Mar 2024 16:11:18 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 16:11:08 +0100 Message-ID: <20240304151108.6808-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240125134425.374-1-jamrial@gmail.com> References: <20240125134425.374-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc: move AVCodecContext.pts_correction* to DecodeContext X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: These fields are documented to be non-public and are only used in decode.c --- libavcodec/avcodec.h | 10 ---------- libavcodec/decode.c | 37 ++++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 43859251cc..0578c5d525 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1827,16 +1827,6 @@ typedef struct AVCodecContext { */ const struct AVCodecDescriptor *codec_descriptor; - /** - * Current statistics for PTS correction. - * - decoding: maintained and used by libavcodec, not intended to be used by user apps - * - encoding: unused - */ - int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far - int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far - int64_t pts_correction_last_pts; /// PTS of the last frame - int64_t pts_correction_last_dts; /// DTS of the last frame - /** * Character encoding of the input subtitles file. * - decoding: set by user diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 7c67b18bc4..c2b4266b78 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -60,6 +60,11 @@ typedef struct DecodeContext { * The caller has submitted a NULL packet on input. */ int draining_started; + + int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far + int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far + int64_t pts_correction_last_pts; /// PTS of the last frame + int64_t pts_correction_last_dts; /// DTS of the last frame } DecodeContext; static DecodeContext *decode_ctx(AVCodecInternal *avci) @@ -273,24 +278,24 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt) * @param dts the dts field of the decoded AVPacket * @return one of the input values, may be AV_NOPTS_VALUE */ -static int64_t guess_correct_pts(AVCodecContext *ctx, +static int64_t guess_correct_pts(DecodeContext *dc, int64_t reordered_pts, int64_t dts) { int64_t pts = AV_NOPTS_VALUE; if (dts != AV_NOPTS_VALUE) { - ctx->pts_correction_num_faulty_dts += dts <= ctx->pts_correction_last_dts; - ctx->pts_correction_last_dts = dts; + dc->pts_correction_num_faulty_dts += dts <= dc->pts_correction_last_dts; + dc->pts_correction_last_dts = dts; } else if (reordered_pts != AV_NOPTS_VALUE) - ctx->pts_correction_last_dts = reordered_pts; + dc->pts_correction_last_dts = reordered_pts; if (reordered_pts != AV_NOPTS_VALUE) { - ctx->pts_correction_num_faulty_pts += reordered_pts <= ctx->pts_correction_last_pts; - ctx->pts_correction_last_pts = reordered_pts; + dc->pts_correction_num_faulty_pts += reordered_pts <= dc->pts_correction_last_pts; + dc->pts_correction_last_pts = reordered_pts; } else if(dts != AV_NOPTS_VALUE) - ctx->pts_correction_last_pts = dts; + dc->pts_correction_last_pts = dts; - if ((ctx->pts_correction_num_faulty_pts<=ctx->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE) + if ((dc->pts_correction_num_faulty_pts<=dc->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE) && reordered_pts != AV_NOPTS_VALUE) pts = reordered_pts; else @@ -617,6 +622,7 @@ static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame) static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) { AVCodecInternal *avci = avctx->internal; + DecodeContext *dc = decode_ctx(avci); const FFCodec *const codec = ffcodec(avctx->codec); int ret, ok; @@ -672,7 +678,7 @@ FF_DISABLE_DEPRECATION_WARNINGS frame->top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST); FF_ENABLE_DEPRECATION_WARNINGS #endif - frame->best_effort_timestamp = guess_correct_pts(avctx, + frame->best_effort_timestamp = guess_correct_pts(dc, frame->pts, frame->pkt_dts); @@ -1744,6 +1750,7 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) int ff_decode_preinit(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; + DecodeContext *dc = decode_ctx(avci); int ret = 0; /* if the decoder init function was already called previously, @@ -1791,10 +1798,10 @@ int ff_decode_preinit(AVCodecContext *avctx) } } - avctx->pts_correction_num_faulty_pts = - avctx->pts_correction_num_faulty_dts = 0; - avctx->pts_correction_last_pts = - avctx->pts_correction_last_dts = INT64_MIN; + dc->pts_correction_num_faulty_pts = + dc->pts_correction_num_faulty_dts = 0; + dc->pts_correction_last_pts = + dc->pts_correction_last_dts = INT64_MIN; if ( !CONFIG_GRAY && avctx->flags & AV_CODEC_FLAG_GRAY && avctx->codec_descriptor->type == AVMEDIA_TYPE_VIDEO) @@ -1873,8 +1880,8 @@ void ff_decode_flush_buffers(AVCodecContext *avctx) av_packet_unref(avci->last_pkt_props); av_packet_unref(avci->in_pkt); - avctx->pts_correction_last_pts = - avctx->pts_correction_last_dts = INT64_MIN; + dc->pts_correction_last_pts = + dc->pts_correction_last_dts = INT64_MIN; av_bsf_flush(avci->bsf); -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".