[FFmpeg-devel] [PATCH v4 1/4] avcodec: Add new side data type to contain original PTS value
Devin Heitmueller
devin.heitmueller at ltnglobal.com
Mon Jul 31 16:38:03 EEST 2023
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 <dheitmueller at ltnglobal.com>
---
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 <stdint.h>
#include <stdlib.h>
+#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.
--
1.8.3.1
More information about the ffmpeg-devel
mailing list