From patchwork Fri Mar 1 13:39:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Gaullier X-Patchwork-Id: 46684 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp1268906pzb; Fri, 1 Mar 2024 05:40:07 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX+8kbffvh9fd1ViocHvXP+SFhKYUgLniysMihWZ8mJl3FOIt+0kBIlVQfiB2Ck2unQVHixIQA6CVd0Z7626l+mTRqqmb1jtSnmFw== X-Google-Smtp-Source: AGHT+IE0WFZwM4ifP1IZBLSnx6c9Djk12zCZfmi+bPb2g//7J3nWFavsw4Pr9lttEpd0I/X7gA9M X-Received: by 2002:a05:6402:222a:b0:564:71:ccf0 with SMTP id cr10-20020a056402222a00b005640071ccf0mr1463846edb.2.1709300407646; Fri, 01 Mar 2024 05:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709300407; cv=none; d=google.com; s=arc-20160816; b=u03fKiDNQstFrGotTcwGGgnOX4KnUUmnPewTXIOcc7S1dOeFgNYIm+7OUcWuhyGk4e yLh5Y4pVuDEAb/h8dV4YrWNGcaX4DF1YxCjC/CzYmfmMfOxrFTaSPu5+pMTzZLOjjASr vctxrMnT8TXdOt+OYTen+JhKkGKzCefOvlIYtoKH+BmHnsgg/1yqCzyUJUTSF9kM2TGc hAt9Yq9vnPfVvJOEx59JK/D1HMP4Rz0v6jcwJMpW7TiRGQx3WgxoF4JWkaKqDjN0UGVm OK1Csdh9SZwyeO/zk3TWbcH4IRnTzMs/GO13nE85JeAXA09+fJSfHnRbn1/A3RroM3t9 kKKQ== 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=57naAmacJ8T5ia41JnnLNMUVgU+rMzwOf1Pwnv22ZVE=; fh=zgMS+X4RExv2k7fU8QdWClnqVJdqO/9UbUuBS5xxJDs=; b=D54ArnYF//WcPDMNH6Gqm5P+91XsjCKejgQOi6Zg8VE+oq/cpbWNetiJbuKTZ9KDct 416YO0q+3G7faHqO7haU6BZbff1d6mTEjv6jB1h4eFt0Ohx/7ePdl5CUBCIeJkhuQWFx F+7IJk2eDYAJY0CtPY6ejkjT4EdsGncy49NQwaWCkzXkk8wmZyNG8Ek/8q1ld9/2gqE9 VKJK/OYMjxF/feI5ffnbFZ1hVz0W5qBMqNqtoASoPydLYDvQM+D2uJzHX8ECPkQ/8cUk Sh3KbwOpuOaeb4Ew6D3Er0WiYyiRRquws696Tt2VAOoynIiiLiowLo6eTzK/R5cKZ9EY b46A==; 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 a19-20020aa7cf13000000b0056651d886d0si1497467edy.687.2024.03.01.05.40.07; Fri, 01 Mar 2024 05:40:07 -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 B087968D27F; Fri, 1 Mar 2024 15:39:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from srv-infra-1.infra.inf.glb.tvvideoms.com (www.inf.tvvideoms.com [213.205.126.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B3EB68D253 for ; Fri, 1 Mar 2024 15:39:26 +0200 (EET) Received: from cji.paris (unknown [172.16.3.159]) by srv-infra-1.infra.inf.glb.tvvideoms.com (Postfix) with ESMTP id B830320746; Fri, 1 Mar 2024 13:39:25 +0000 (UTC) From: Nicolas Gaullier To: ffmpeg-devel@ffmpeg.org Date: Fri, 1 Mar 2024 14:39:19 +0100 Message-Id: <20240301133923.1132924-2-nicolas.gaullier@cji.paris> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240301133923.1132924-1-nicolas.gaullier@cji.paris> References: <20240301133923.1132924-1-nicolas.gaullier@cji.paris> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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: uKU4wK87CpHB 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/parser.c b/libavcodec/parser.c index efc28b8918..249f81d4bb 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -142,6 +142,7 @@ 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 ) { /* 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 +151,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) {