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 250B349BEF for ; Mon, 4 Mar 2024 18:07:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6CDD868D4CE; Mon, 4 Mar 2024 20:07:14 +0200 (EET) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BB4F68D362 for ; Mon, 4 Mar 2024 20:07:07 +0200 (EET) Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5ce2aada130so4214473a12.1 for ; Mon, 04 Mar 2024 10:07:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709575625; x=1710180425; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jQG475u1UYaFAcurlIG6Vs4Zvx9vqPmzxpkVU/qKI2w=; b=fFsYASqBeHkNgMrYp1VnO/g9sGWqfoyQEoAqV9CqEHUbwBOeUvpU60E3Fy5Q47FqJL l0+A243oYyIji+GOr+kqC8nLdCMumXwhw3QSrbBdTUxiQPu/g4nLHxOoZnPeMCv2PQgL SizOyLkjPeJRgyb6/cEX8VX7GES45IScBNH4zQ4B0R+q7uxhEEhEcqnmlPQbzIfmz8qH B4zXG/tCUQ4DfUouc1xBY/OX13HSlE9oaZRIzmHbLSq21qSmkQbh02HhPUh+29RUalK1 o/s6P3kkfB5EXe6Lgau57PRgA5LRN1Y7xnrNxdPQWSA8lwZ5iWsHLhGzcmEFhd2sX4h7 xLRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709575625; x=1710180425; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jQG475u1UYaFAcurlIG6Vs4Zvx9vqPmzxpkVU/qKI2w=; b=CGLFQTNtBvE3LJq2EMm9r9MclbsXKkL5KwxkWrrwmiS+Wq7JY0XEHvXHUFAbLkBwb3 sfxCzqhBGz2jjn4E9stDQAzutVGbVOQTqEIyzfqtLxKCZhewnK3fvUOXBLfj4qfJSASe L79RJ5Rzl9Of7MSgA7IiuCMo1/abn2ijO34JyGNwnSQwUD3t7SbEvrTa4IP8evn6i00R LomTiIwBmsVOUXVHI9b2L1x/GCSeerSpXzMggP9mZ61SMLAzoUjyJsYiUH0W6w3CJtCm BjmSf2NeUQPtLLk0mIzGyPFFyGs+AznbApEIf3nywyK+rxZqGKj4LToNRzTqHhJHIoVm BnEQ== X-Gm-Message-State: AOJu0YzVjEXH+tzo3PmsG/sFIReTJU8z4RNe75gQa+64CKLgVzxzxdEX armeSEDawlHbulSE9rt29F5fmOLEeq6B9Lb/ewMTos1BAdgpCXfUHPVrs7RG X-Google-Smtp-Source: AGHT+IHMVhdjehdYY89TYt5AYlPX4sytf5DnR17en2zkPY2X6R+Kp1M1NvAnOBF+gzFiLe6NPGFZ5g== X-Received: by 2002:a17:90a:f007:b0:29b:1c83:4e06 with SMTP id bt7-20020a17090af00700b0029b1c834e06mr6970961pjb.36.1709575624874; Mon, 04 Mar 2024 10:07:04 -0800 (PST) Received: from localhost.localdomain ([190.194.169.124]) by smtp.gmail.com with ESMTPSA id gx15-20020a17090b124f00b00298ca46547fsm8089145pjb.36.2024.03.04.10.07.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 10:07:04 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 15:06:13 -0300 Message-ID: <20240304180613.7280-4-jamrial@gmail.com> X-Mailer: git-send-email 2.44.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: From: Anton Khirnov These fields are documented to be non-public and are only used in decode.c Signed-off-by: James Almer --- 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 035f08a8e0..fb0612ed26 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1860,16 +1860,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 6579c9cbbf..c20b2ebdb3 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) @@ -240,24 +245,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 @@ -575,6 +580,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; @@ -630,7 +636,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); @@ -1672,6 +1678,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, @@ -1719,10 +1726,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) @@ -1801,8 +1808,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.44.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".