From patchwork Mon Mar 4 17:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 46783 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d808:b0:19e:cdac:8cce with SMTP id iv8csp139312pzb; Mon, 4 Mar 2024 09:32:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV1gKBlocoJ5DZO3Tn6synV9HQKZl41OsI1uTXyaZJxj9T2SugDG2eXEhMBHl1UZDrIw0tXM/gRM8DPk6GZCRY5xncJ//1afyjmfA== X-Google-Smtp-Source: AGHT+IGrK6D2F4EPdLmxJABnLBk5pkTSFTAIVnCn2heHycUg45asDBrnUtU9hXvh8v2/rE6NC9ip X-Received: by 2002:a17:906:4818:b0:a45:2fc4:f25d with SMTP id w24-20020a170906481800b00a452fc4f25dmr2573154ejq.12.1709573565409; Mon, 04 Mar 2024 09:32:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709573565; cv=none; d=google.com; s=arc-20160816; b=motugRdjmteI8XMU8n6B58MSw8fDTMZPgfpyB/rRSWCbqDW239LZoVcNS55SvcH16b jk3sEEI3FxyHGTQFbgeum/ia3mXDHYX6QypYEgr/ynCGl5FjIvGWanXZzJOYM+k0eb92 xEA8K1jRNzpQFlfwAKUGIffzAUv9SSjvPqti6QSwUxS/eDMaoOdIXHZNgRcMcDid3LUM EdjZWOpVLwgan3C1akTiiUNj2mWp7muqxugwPAEiCVQNd9Wb2Fkp+G7JI+J2Lk5bj0JK X9HMS4qhn3sCVxgI1TCJdRhmfnGgcOQfVja7BjxLFewV3L2NGNWkSQ7vxTYAICgC4EUj T3nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=y0U4RzHmT1U0POGvR0/mOSWwvRz7S7Y/J3bd42+sieA=; fh=zgMS+X4RExv2k7fU8QdWClnqVJdqO/9UbUuBS5xxJDs=; b=O5DZfaZYxfpEzDrQYEJSV5ypJ+jILLIH0hgqgJUpPv2JmGdKSAZE8Juvn1Ea6jwv5j MKUa3PO/gBQUna0ec2iHOpaZ1T8xeZfkpMQrLNr+SbQPz5UNRFDrY2iR0Wfaa+ZLkLww mJ+l7DHQ4ONxnRDpOSo/+Us046AHo67vcNVtKmyksWUbprELSVgEsy4QJVylp/oOVB2j SPIfArbitkbC7Nb4ikigUdH5shXhZun6QhD9S8yeLe69sT3pT/VKRAzwLuBJE8P2E2f/ rxOhrT8skni/pDvocDkXqri7eZ11ldI6ofqjEIdN3TRLYuZc5Pn6rQ2ExDPbRFRm99mL yRyw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h4-20020a1709063b4400b00a4432e5bd60si4102415ejf.848.2024.03.04.09.32.44; Mon, 04 Mar 2024 09:32:45 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CDCCB68D113; Mon, 4 Mar 2024 19:32:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from srv-infra-2.infra.inf.glb.tvvideoms.com (www.inf.tvvideoms.com [213.205.126.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4F4FA68D44E for ; Mon, 4 Mar 2024 19:32:24 +0200 (EET) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-2.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id 3389B40526; Mon, 4 Mar 2024 17:32:23 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Mar 2024 18:32:15 +0100 Message-Id: <20240304173219.1877658-2-nicolas.gaullier@cji.paris> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240304173219.1877658-1-nicolas.gaullier@cji.paris> References: <20240304173219.1877658-1-nicolas.gaullier@cji.paris> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/5] avcodec/parser: merge packets from the same frame 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 Cc: Nicolas Gaullier Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +ke8IV3dUCJP The mpegts demuxer splits packets according to its max_packet_size. This currently fills the AVCodecParserContext s->cur_frame_* arrays with kind of 'empty' entries: no pts/dts. This patch merges these entries, so the parser behaviour is independent from the demuxer settings. This patch is required for the following patch which will fetch 'past' timestamps from past cur_frames. Signed-off-by: Nicolas Gaullier --- libavcodec/parser.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/parser.c b/libavcodec/parser.c index efc28b8918..90461075fd 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -142,6 +142,8 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, memset(dummy_buf, 0, sizeof(dummy_buf)); buf = dummy_buf; } else if (s->cur_offset + buf_size != s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */ + if (pos != s->cur_frame_pos[s->cur_frame_start_index] || pos <= 0 || + pts != AV_NOPTS_VALUE || dts != AV_NOPTS_VALUE ) { /* add a new packet descriptor */ i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1); s->cur_frame_start_index = i; @@ -150,6 +152,9 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, s->cur_frame_pts[i] = pts; s->cur_frame_dts[i] = dts; s->cur_frame_pos[i] = pos; + } else { + s->cur_frame_end[s->cur_frame_start_index] = s->cur_offset + buf_size; + } } if (s->fetch_timestamp) {