Commit 2d74dea8 authored by Harald Axmann's avatar Harald Axmann Committed by Michael Niedermayer

lavf: Provide a monotonic timestamp to the outside world

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 388241ef
...@@ -629,6 +629,13 @@ typedef struct AVIndexEntry { ...@@ -629,6 +629,13 @@ typedef struct AVIndexEntry {
*/ */
#define AV_DISPOSITION_ATTACHED_PIC 0x0400 #define AV_DISPOSITION_ATTACHED_PIC 0x0400
/**
* Options for behavior on timestamp wrap detection.
*/
#define AV_PTS_WRAP_IGNORE 0 ///< ignore the wrap
#define AV_PTS_WRAP_ADD_OFFSET 1 ///< add the format specific offset on wrap detection
#define AV_PTS_WRAP_SUB_OFFSET -1 ///< subtract the format specific offset on wrap detection
/** /**
* Stream structure. * Stream structure.
* New fields can be added to the end with minor version bumps. * New fields can be added to the end with minor version bumps.
...@@ -847,6 +854,23 @@ typedef struct AVStream { ...@@ -847,6 +854,23 @@ typedef struct AVStream {
*/ */
int64_t mux_ts_offset; int64_t mux_ts_offset;
/**
* Internal data to check for wrapping of the time stamp
*/
int64_t pts_wrap_reference;
/**
* Options for behavior, when a wrap is detected.
*
* Defined by AV_PTS_WRAP_ values.
*
* If correction is enabled, there are two possibilities:
* If the first time stamp is near the wrap point, the wrap offset
* will be subtracted, which will create negative time stamps.
* Otherwise the offset will be added.
*/
int pts_wrap_behavior;
} AVStream; } AVStream;
#define AV_PROGRAM_RUNNING 1 #define AV_PROGRAM_RUNNING 1
...@@ -878,6 +902,9 @@ typedef struct AVProgram { ...@@ -878,6 +902,9 @@ typedef struct AVProgram {
*/ */
int64_t start_time; int64_t start_time;
int64_t end_time; int64_t end_time;
int64_t pts_wrap_reference; ///< reference dts for wrap detection
int pts_wrap_behavior; ///< behavior on wrap detection
} AVProgram; } AVProgram;
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
...@@ -1169,6 +1196,13 @@ typedef struct AVFormatContext { ...@@ -1169,6 +1196,13 @@ typedef struct AVFormatContext {
*/ */
unsigned int skip_initial_bytes; unsigned int skip_initial_bytes;
/**
* Correct single timestamp overflows
* - encoding: unused
* - decoding: Set by user via AVOPtions (NO direct access)
*/
unsigned int correct_ts_overflow;
/***************************************************************** /*****************************************************************
* All fields below this line are not part of the public API. They * All fields below this line are not part of the public API. They
* may not be used outside of libavformat and can be changed and * may not be used outside of libavformat and can be changed and
......
...@@ -73,6 +73,7 @@ static const AVOption options[]={ ...@@ -73,6 +73,7 @@ static const AVOption options[]={
{"use_wallclock_as_timestamps", "use wallclock as timestamps", OFFSET(use_wallclock_as_timestamps), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX-1, D}, {"use_wallclock_as_timestamps", "use wallclock as timestamps", OFFSET(use_wallclock_as_timestamps), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX-1, D},
{"avoid_negative_ts", "shift timestamps to make them positive. 1 enables, 0 disables, default of -1 enables when required by target format.", OFFSET(avoid_negative_ts), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, E}, {"avoid_negative_ts", "shift timestamps to make them positive. 1 enables, 0 disables, default of -1 enables when required by target format.", OFFSET(avoid_negative_ts), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, E},
{"skip_initial_bytes", "skip initial bytes", OFFSET(skip_initial_bytes), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX-1, D}, {"skip_initial_bytes", "skip initial bytes", OFFSET(skip_initial_bytes), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX-1, D},
{"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D},
{NULL}, {NULL},
}; };
......
This diff is collapsed.
#tb 0: 1/50 #tb 0: 1/50
0, 0, 0, 1, 221184, 0xf48c94f6 0, 80, 80, 1, 221184, 0xf48c94f6
0, 2, 2, 1, 221184, 0x89b625b2 0, 82, 82, 1, 221184, 0x89b625b2
0, 3, 3, 1, 221184, 0x37e04714 0, 83, 83, 1, 221184, 0x37e04714
0, 4, 4, 1, 221184, 0x4f4c5224 0, 84, 84, 1, 221184, 0x4f4c5224
0, 5, 5, 1, 221184, 0x9193c9f1 0, 85, 85, 1, 221184, 0x9193c9f1
0, 6, 6, 1, 221184, 0x5d1a6197 0, 86, 86, 1, 221184, 0x5d1a6197
0, 7, 7, 1, 221184, 0x40cd51e7 0, 87, 87, 1, 221184, 0x40cd51e7
0, 8, 8, 1, 221184, 0xb2c1a729 0, 88, 88, 1, 221184, 0xb2c1a729
0, 10, 10, 1, 221184, 0x998d6144 0, 90, 90, 1, 221184, 0x998d6144
0, 11, 11, 1, 221184, 0xf5d52311 0, 91, 91, 1, 221184, 0xf5d52311
0, 12, 12, 1, 221184, 0xea9dd6bf 0, 92, 92, 1, 221184, 0xea9dd6bf
0, 13, 13, 1, 221184, 0x0e2ed854 0, 93, 93, 1, 221184, 0x0e2ed854
0, 14, 14, 1, 221184, 0xe295ba58 0, 94, 94, 1, 221184, 0xe295ba58
0, 15, 15, 1, 221184, 0x8aedbb69 0, 95, 95, 1, 221184, 0x8aedbb69
0, 16, 16, 1, 221184, 0x253c9aaa 0, 96, 96, 1, 221184, 0x253c9aaa
0, 17, 17, 1, 221184, 0x5eaf9fb1 0, 97, 97, 1, 221184, 0x5eaf9fb1
0, 18, 18, 1, 221184, 0xcdb5a0cb 0, 98, 98, 1, 221184, 0xcdb5a0cb
0, 19, 19, 1, 221184, 0xcdb5a0cb 0, 99, 99, 1, 221184, 0xcdb5a0cb
0, 20, 20, 1, 221184, 0x23f89994 0, 100, 100, 1, 221184, 0x23f89994
0, 21, 21, 1, 221184, 0x23f89994 0, 101, 101, 1, 221184, 0x23f89994
0, 22, 22, 1, 221184, 0x10dc98d6 0, 102, 102, 1, 221184, 0x10dc98d6
0, 23, 23, 1, 221184, 0x799b9d98 0, 103, 103, 1, 221184, 0x799b9d98
0, 24, 24, 1, 221184, 0xb226996c 0, 104, 104, 1, 221184, 0xb226996c
0, 25, 25, 1, 221184, 0x0ac59a42 0, 105, 105, 1, 221184, 0x0ac59a42
0, 26, 26, 1, 221184, 0x87c2a654 0, 106, 106, 1, 221184, 0x87c2a654
0, 27, 27, 1, 221184, 0xf4c1a711 0, 107, 107, 1, 221184, 0xf4c1a711
0, 28, 28, 1, 221184, 0xf60fa72e 0, 108, 108, 1, 221184, 0xf60fa72e
0, 29, 29, 1, 221184, 0xc8f8b6fc 0, 109, 109, 1, 221184, 0xc8f8b6fc
0, 30, 30, 1, 221184, 0xd709b813 0, 110, 110, 1, 221184, 0xd709b813
0, 31, 31, 1, 221184, 0x5fdfb76b 0, 111, 111, 1, 221184, 0x5fdfb76b
0, 32, 32, 1, 221184, 0x5798b0aa 0, 112, 112, 1, 221184, 0x5798b0aa
0, 33, 33, 1, 221184, 0xf572b1c3 0, 113, 113, 1, 221184, 0xf572b1c3
0, 34, 34, 1, 221184, 0x14b0afdf 0, 114, 114, 1, 221184, 0x14b0afdf
0, 35, 35, 1, 221184, 0x0a66b5b8 0, 115, 115, 1, 221184, 0x0a66b5b8
0, 36, 36, 1, 221184, 0xe316c620 0, 116, 116, 1, 221184, 0xe316c620
0, 37, 37, 1, 221184, 0xbc76c5c2 0, 117, 117, 1, 221184, 0xbc76c5c2
0, 38, 38, 1, 221184, 0x77c7c5e5 0, 118, 118, 1, 221184, 0x77c7c5e5
0, 39, 39, 1, 221184, 0xfc7ac63e 0, 119, 119, 1, 221184, 0xfc7ac63e
0, 40, 40, 1, 221184, 0x05a29ffe 0, 120, 120, 1, 221184, 0x05a29ffe
0, 41, 41, 1, 221184, 0x9bffbf6c 0, 121, 121, 1, 221184, 0x9bffbf6c
0, 42, 42, 1, 221184, 0x3c55be40 0, 122, 122, 1, 221184, 0x3c55be40
0, 43, 43, 1, 221184, 0x6f46c14e 0, 123, 123, 1, 221184, 0x6f46c14e
0, 44, 44, 1, 221184, 0x9cf4ae70 0, 124, 124, 1, 221184, 0x9cf4ae70
0, 45, 45, 1, 221184, 0xf205b2f8 0, 125, 125, 1, 221184, 0xf205b2f8
0, 46, 46, 1, 221184, 0x7180aff8 0, 126, 126, 1, 221184, 0x7180aff8
0, 47, 47, 1, 221184, 0x125eaffe 0, 127, 127, 1, 221184, 0x125eaffe
0, 48, 48, 1, 221184, 0x6970a32d 0, 128, 128, 1, 221184, 0x6970a32d
0, 49, 49, 1, 221184, 0xaea79f62 0, 129, 129, 1, 221184, 0xaea79f62
0, 50, 50, 1, 221184, 0x48d2a093 0, 130, 130, 1, 221184, 0x48d2a093
0, 51, 51, 1, 221184, 0x10a59eb5 0, 131, 131, 1, 221184, 0x10a59eb5
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment