diff mbox series

[FFmpeg-devel,v2,1/5] avcodec: Add new side data type to contain original PTS value

Message ID 1688408109-14381-2-git-send-email-dheitmueller@ltnglobal.com
State New
Headers show
Series Add passthrough support for SCTE-35 | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch

Commit Message

Devin Heitmueller July 3, 2023, 6:15 p.m. UTC
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@ltnglobal.com>
---
 libavcodec/defs.h   | 12 ++++++++++++
 libavcodec/packet.h | 11 +++++++++++
 2 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/defs.h b/libavcodec/defs.h
index deadfe7..173020f 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
@@ -131,6 +132,17 @@  typedef struct AVBarData {
 } AVBarData;
 
 /**
+ * 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 bdad21e..6c39a45 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -306,6 +306,17 @@  enum AVPacketSideDataType {
     AV_PKT_DATA_BARDATA,
 
     /**
+     * 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.