From patchwork Mon Jul 31 13:38:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 43049 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba09:b0:130:ccc6:6c4b with SMTP id fa9csp119513pzb; Mon, 31 Jul 2023 06:38:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlFK2H1B8QEdaD0pc53SNKXHAzOj2PTV2N4SuWpR7zZFbjbCP6cYc+Ql1i6Y9LB75vW+d8J5 X-Received: by 2002:a05:6402:1055:b0:522:4d1b:3acf with SMTP id e21-20020a056402105500b005224d1b3acfmr8084356edu.37.1690810713200; Mon, 31 Jul 2023 06:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690810713; cv=none; d=google.com; s=arc-20160816; b=yxECnU655Hwa49C/PZp0ZIbk+YgUMP3np257dAV7KHUyLc9d4OJ86nW9jMpC3/Nvhg Gl57chy0sqMQ56LHNFLhDNg0U2cqz/weBnHNrQD5HrkO0liKqQYa1bFjXB4r8kWunH1y L0zvVqbWZpmTjZHtYu7jllzDs7varrA/46bZE6Trivgy0kpNPF94jkYIEwo62wxiI6fp UZ+vBepmH/eOG5ri2u/gB7ZrnTvDFD1vNW7FT90od3yfauR1TalINwDPE0E5SzSNwYI+ rN0tIzT0wHY2uwyxwnsNODdbtA+TrmOkUJZUjQY0n5NFQ5sJWD2rzZOJphr9l6Wd+SiO noDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=bQzyDAHUAaQhAx3Xhwjtv8NOaXxM0TI0NcVMieaivcg=; fh=DKzdJpyueDOox6ShoNYUi750QZs6R2naOS9+hcsrM90=; b=0mp6Sydtf8h+JY/9zAs5gNdmvykfzhKO0ch95o+P7eIMDVztSuT1cHKsKrEEumiu0I rF1Ml/U154Usmqmdw9kuJu6EWcy60imSkYfjcVnB6TbwV9/i+dPAHXKUQhb8yTr2KIS4 T9Fnog+41kSKT/0dF/TmXTfKVix+o217V9qNUL/8/gaE2GXei9mw0apPDuYVmCtn19uC wEhQCBaSdCWxMMO1I4E44KjhoYMj6cXEqn86BO34fPC4ZnNAQw9vEJFg4tfoyHLLfmS6 yo2RQ8WTNDJGWCMFGCXcgF5QwA0pZNRBp10087POh+DmtSwmD9WZMspU47Px4cRLBw3F yyDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ltnglobal-com.20221208.gappssmtp.com header.s=20221208 header.b="ck/aQfM4"; 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 w8-20020aa7cb48000000b005227bab0331si3066928edt.139.2023.07.31.06.38.32; Mon, 31 Jul 2023 06:38:33 -0700 (PDT) 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=@ltnglobal-com.20221208.gappssmtp.com header.s=20221208 header.b="ck/aQfM4"; 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 03B5168C158; Mon, 31 Jul 2023 16:38:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3DEBC68BEE5 for ; Mon, 31 Jul 2023 16:38:13 +0300 (EEST) Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-76754b9eac0so377047185a.0 for ; Mon, 31 Jul 2023 06:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20221208.gappssmtp.com; s=20221208; t=1690810691; x=1691415491; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=NIa8U61D4HjMO2dR5ME9+bwUAki8APBvAR/q5qBzgps=; b=ck/aQfM40XhoGib1/Ye662bna0mHRjQ57ixjd1ekcgJQRUBcdA9Uht80ipQik2bc41 TK3+jAXvaCz96Q/LyKVjq5wqHhnphlSyX0C9tyl784ird5zW0ZxujdE0mbt3zcdfzNLV Tr49CQTGQQvhiHPqYNkURIaRWDlmp4D+Y4/7LHsKzpMajdUO5tQdJEmPGRGtvW8E0viw nCOHBTIAzIbLAw/SHQIm7HXL1NovjGF7xfjcOOWskiv3WwVHyJjS2xL57YCejlWuT/Sf qvkrrYfbkdQIoQFw04NbNuAl/7OErQKH3dUpqtWqaB1huIDI0mLvMbuuSniZP816JRE5 30KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690810691; x=1691415491; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NIa8U61D4HjMO2dR5ME9+bwUAki8APBvAR/q5qBzgps=; b=Ol1ANP+mWnHTIvDzAOsDSJf2/IYBamyJzmKeeDL1zzREoap503lSi7NJHGnV3KnFws wTRunsuUV7OlM1Ob4w9Ik42WDwXASg09UQjoA51w+bIHBUSzBdt52OATpmokbQG9Z8uR FjJ0nx/Fu6o+Ldbc9sYgKWyn3v1ijujZAKxNAawUJ451FKnxCfsjjBb5ewghjwCf1e4y sKYQ8+pcqu2XmatFoyot/wXIY+50VjU66JC3upDGaYU7yS0X5kJM86oz+VKLTt3Yvyit L1NQpA/qR3xF/snNBmrl/smIazMbuoCXEGpbZrIcc09sEuEphB5xIuTIcGQdDjkcXjHB Ja7g== X-Gm-Message-State: ABy/qLazVHkzr581qSZGo+SPqfWAYjGzjR1UO0REHFJvhuFT0oe4LdMh Pval/4OjCdtolYaWPfDPHE8kzprmQXxLQt87WIU= X-Received: by 2002:a05:620a:1914:b0:76c:add6:f84a with SMTP id bj20-20020a05620a191400b0076cadd6f84amr4196052qkb.35.1690810691322; Mon, 31 Jul 2023 06:38:11 -0700 (PDT) Received: from ltnt-nyc-580testdevin.livetimenet.com (pool-71-105-132-214.nycmny.fios.verizon.net. [71.105.132.214]) by smtp.gmail.com with ESMTPSA id o9-20020a05620a110900b0076c84240467sm2504235qkk.52.2023.07.31.06.38.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jul 2023 06:38:10 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 Jul 2023 09:38:03 -0400 Message-Id: <1690810686-4723-2-git-send-email-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1690810686-4723-1-git-send-email-dheitmueller@ltnglobal.com> References: <1690810686-4723-1-git-send-email-dheitmueller@ltnglobal.com> Subject: [FFmpeg-devel] [PATCH v4 1/4] avcodec: Add new side data type to contain original PTS value 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: Devin Heitmueller MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ZPdTZsvHPlZ8 In order to properly process SCTE-35 packets, we need the original PTS value from the demux (i.e. not mangled by the application or reclocked for the output). This allows us to set the pts_adjustment field in an BSF on the output side. Introduce a new side data type to store the original PTS. Signed-off-by: Devin Heitmueller --- libavcodec/defs.h | 12 ++++++++++++ libavcodec/packet.h | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/libavcodec/defs.h b/libavcodec/defs.h index fbe3254..ff50d25 100644 --- a/libavcodec/defs.h +++ b/libavcodec/defs.h @@ -28,6 +28,7 @@ #include #include +#include "libavutil/rational.h" /** * @ingroup lavc_decoding @@ -119,6 +120,17 @@ typedef struct AVPanScan { } AVPanScan; /** + * Original Transport Timestamp. Provides the original timestamp + * of the packet as specified by the libavformat source This allows that + * data to be used in calculations even if the clocks have been + * rebased or otherwise modified. + */ +typedef struct AVTransportTimestamp { + int64_t pts; + AVRational time_base; +} AVTransportTimestamp; + +/** * This structure describes the bitrate properties of an encoded bitstream. It * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD * parameters for H.264/HEVC. diff --git a/libavcodec/packet.h b/libavcodec/packet.h index f28e7e7..8b650a8 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -300,6 +300,17 @@ enum AVPacketSideDataType { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, /** + * Provides the original PTS when passed through the demux. This can + * be used to offset any subsequent changes made by the caller to + * adjust PTS values (such as pts_offset). We need this for SCTE-35, + * since by the time the packets reach the output the PTS values have + * already been re-written, and we cannot calculate pre-roll values + * using the PTS values embedded in the packet content + * Format for this data can be found in AVTransportTimestamp struct + */ + AV_PKT_DATA_TRANSPORT_TIMESTAMP, + + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may * change when new side data types are added.