From patchwork Sun Mar 6 22:32:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 34627 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp971614nkx; Sun, 6 Mar 2022 14:33:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJymoHJXAEkDhSjtpLC0GcC/auL6f+kxhHJygzkLt2mcUGiPj0aViIZ4J/Dc//4HBlFRQURP X-Received: by 2002:aa7:c64d:0:b0:415:eb27:4 with SMTP id z13-20020aa7c64d000000b00415eb270004mr8603697edr.365.1646605997147; Sun, 06 Mar 2022 14:33:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646605997; cv=none; d=google.com; s=arc-20160816; b=Cr2pPuL2DhRpL3mrefllFy110Rh2gcJKyBtplWh+d6EapX54SykOdD0LwqybLTX85I Lig1+RSD66bImPfwrN9yMxSkQS5Va9xsA5mXshFk9qlPBcEG/YMp9xySOtvdyTYaDERs /agKqniA9M2GAKxHPyKmEX0cdJrPwAfrx6C/KR/A8+f9tfD934ydtv1xAsQMneSh4tAK SC3ZlwK8Yr6oT8I3jM3ZbmMUzoJHzEY3JO7GfDoC2FPHXV55e2zGU8VJId4V3PptcYLW 6RD1QvM0vSSiHZeVmtE4wb5jhCNTFYNWzu5deSlCiiGMmK1yYJ17fiYQ/tMd7M3w2xgR VZOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=xWxzfmQSHI0jxkZYztuaophLtoI7uEQo6lvFUGmX4Rg=; b=FROEC7jbHkBqe/T2D36Qlz0SIMndN43Xf/3LpznHsY6DEjEdsKU9r1bYYDerd/eAya B4SFiO1B2E8R8I0KT2W6dCXhWIncyFlHdDuOfHTE1dfKxKa1CJctn40M8lJJ14Bf9Pq6 aIJZkFGEdyJnIChBkXIyIIssg2lIeo9IpbFKtgukvCU7Y3reFSgNHJPY6zHLPn3qLDLT Ys/iPOQuRFcQBluG6mCLdz207TaDWsdPZPrlNPvj4diN8GAeCxys1mcHDWeEjM1CguE6 uJYMpawlOjmyEFLVf3UQ66sWVekY87HvPVMvmR0Wi+2rtBlMzh9WC3lOuII7sbEWx9U4 aG9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=FxVWdP2B; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gs13-20020a1709072d0d00b006db08718ce3si3165238ejc.378.2022.03.06.14.33.16; Sun, 06 Mar 2022 14:33:17 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=FxVWdP2B; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C386C68980E; Mon, 7 Mar 2022 00:33:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F15E268A7DD for ; Mon, 7 Mar 2022 00:33:05 +0200 (EET) Received: by mail-lf1-f51.google.com with SMTP id j15so23233198lfe.11 for ; Sun, 06 Mar 2022 14:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=XqLui3LkwCOt0j7wADTwjeY7sOqizlweAV2189SIM/I=; b=FxVWdP2BXQZeIz4wJLq7eiCM286WUyDGeU7OZfBRy/vCgzdbBusdCSZPZAOPNQT7bw OlCnTKLzmPH9yDlOdOgIx+bJkV0Jf5TcpNUSK8alEuXl1PCY6KFyGodOn5jmYzWtmjgv pDslXSzz/EuKNCTDvi2azyPCjTf+tCBvooMqy2mTifBl/pywQhSvd1cvEv3Fb0FpAKhM KO7pO8XcgJT8pXp3r6j+5NSO4+TRjVDULGJFy/WNkZDPEW8jnpPjywGcsvMw5HRNb/Ul O8oprFjz4f6u9PUh0OYcSDvXLJu7ArJQBqX1/qh/XtcXrxTSDrFeiXcNuvJ1Opv+cqVs Y/Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=XqLui3LkwCOt0j7wADTwjeY7sOqizlweAV2189SIM/I=; b=6JvfNLtDkU67jm2T64OlqlRa/bwFbfhugDCfGekj+0DG4HnkStWStrqJh+I0PCcpGS veC6Gk3hnxtN2MQe5sHHfm5kxJMf/1+jJGL3EkZG0yanY/5tVAapEJp//4n3pyW32GiO 3h40xYcrkiF1iP+e7ec18ya/6GzxFa78LGx7e66u2EEuwoMGCNuWL/nbjj6TMxNAWWka JQNkjfL/ony6cDN+pn6bI4nKfsmSOpzf58cH32DSPDH1/EG9YKuinS6pBB1Q8A55QB6c otHuyBv1k11wH0IC8oGvItno8P1Ag1BPgTk3IS5zh7HP26xbrr6QEn6ONh4eI77kqyB8 +HnA== X-Gm-Message-State: AOAM530u4XaEqfa+FhTkvsvzTYBchj0sKyg1HluXlp8xRjCYJFcBFNdA Fmqxzx/DZITIyZ2MmsdhHQj6y3sA3iE= X-Received: by 2002:a05:6512:3a86:b0:448:1aae:915d with SMTP id q6-20020a0565123a8600b004481aae915dmr6155293lfu.258.1646605984763; Sun, 06 Mar 2022 14:33:04 -0800 (PST) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id k15-20020a2eb74f000000b00247e266ed2esm731019ljo.138.2022.03.06.14.33.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Mar 2022 14:33:04 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Mar 2022 00:32:59 +0200 Message-Id: <20220306223259.9491-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] mlp_parser: fetch a new timestamp when major sync is found 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GFLsPu2GCXS+ From: Hendrik Leppkes Decoding can only start on a major sync and the parser discards any data received until that point. Therefore, previously received timestamps are no longer relevant to the data being returned from the parser. Additionally, adds a test which remuxes an existing TrueHD sample with the first keyframe dropped using copyinkf, and then demuxes this remux with ffprobe. Previously this would have pushed the first random access point packet out as pts=1, even though it would have contained the data received from packet containing pts=13. With this fix, the first data received from the parser properly contains the pts of the packet in which it was contained. Fixes #9428 Co-authored-by: Jan Ekström --- libavcodec/mlp_parser.c | 1 + tests/fate/truehd.mak | 12 ++++++++++++ tests/ref/fate/truehd-parser-timestamps | 26 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/ref/fate/truehd-parser-timestamps diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c index 9fea7db955..70d7b3f601 100644 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@ -96,6 +96,7 @@ static int mlp_parse(AVCodecParserContext *s, return ret; } + s->fetch_timestamp = 1; return i - 7; } diff --git a/tests/fate/truehd.mak b/tests/fate/truehd.mak index 7da8c93cff..6f451cc327 100644 --- a/tests/fate/truehd.mak +++ b/tests/fate/truehd.mak @@ -13,5 +13,17 @@ fate-truehd-core-bsf: CMD = md5pipe -i $(TARGET_SAMPLES)/truehd/atmos.thd -c:a c fate-truehd-core-bsf: CMP = oneline fate-truehd-core-bsf: REF = 3aa5d0c7825051f3657b71fd6135183b +# Tests that the result from reading a copyinkf remux with the first random +# access point dropped will receive the correct timestamp for the first packet, +# which is not the packet of the first packet read. +FATE_TRUEHD-$(call ALLYES, FILE_PROTOCOL PIPE_PROTOCOL TRUEHD_DEMUXER \ + MLP_PARSER MATROSKA_MUXER NOISE_BSF) \ + += fate-truehd-parser-timestamps +fate-truehd-parser-timestamps: CMD = stream_remux "truehd" \ + "$(TARGET_SAMPLES)/lossless-audio/truehd_5.1.raw" "matroska" \ + "-map 0:a -copyinkf -bsf:a noise=drop=not\(n\)*key -t 0.030" \ + "-c copy -copyts" +fate-truehd-parser-timestamps: CMP = diff + FATE_SAMPLES_AUDIO += $(FATE_TRUEHD-yes) fate-truehd: $(FATE_TRUEHD-yes) diff --git a/tests/ref/fate/truehd-parser-timestamps b/tests/ref/fate/truehd-parser-timestamps new file mode 100644 index 0000000000..94d5a05640 --- /dev/null +++ b/tests/ref/fate/truehd-parser-timestamps @@ -0,0 +1,26 @@ +#tb 0: 1/1000 +#media_type 0: audio +#codec_id 0: truehd +#sample_rate 0: 48000 +#channel_layout 0: 60f +#channel_layout_name 0: 5.1(side) +0, 13, 13, 1, 368, 0x256aaaad +0, 14, 14, 1, 190, 0x7b975b90, F=0x0 +0, 15, 15, 1, 178, 0xfdc85dc0, F=0x0 +0, 16, 16, 1, 184, 0x3a605a1c, F=0x0 +0, 17, 17, 1, 184, 0xf00e5aef, F=0x0 +0, 18, 18, 1, 186, 0x95125c74, F=0x0 +0, 18, 18, 1, 184, 0xc6ae624e, F=0x0 +0, 19, 19, 1, 186, 0x5f9e5de9, F=0x0 +0, 20, 20, 1, 188, 0x80135cc7, F=0x0 +0, 21, 21, 1, 188, 0x10dc5a3d, F=0x0 +0, 22, 22, 1, 188, 0x63ff5980, F=0x0 +0, 23, 23, 1, 198, 0x42265ec5, F=0x0 +0, 23, 23, 1, 210, 0x4d2f6d78, F=0x0 +0, 24, 24, 1, 202, 0x44b6654f, F=0x0 +0, 25, 25, 1, 192, 0x098e6271, F=0x0 +0, 26, 26, 1, 194, 0x090f691d, F=0x0 +0, 27, 27, 1, 382, 0x88b0ac79 +0, 28, 28, 1, 196, 0xf0765d20, F=0x0 +0, 28, 28, 1, 188, 0x72c65e8d, F=0x0 +0, 29, 29, 1, 186, 0x913a5fcb, F=0x0