aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-19 14:00:32 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-19 14:00:39 +0100
commit5440d4b68b6af942ea460f0eb391b7f2442b5f50 (patch)
treeaec11df5505179d4e597589791d110bf3053c6fa
parentb5448e66b0b88da95a3c8f08a2b2d416049585a5 (diff)
parent30a041887f89cd97c372ad6a516da6e012f2c88b (diff)
downloadffmpeg-5440d4b68b6af942ea460f0eb391b7f2442b5f50.tar.gz
Merge commit '30a041887f89cd97c372ad6a516da6e012f2c88b'
* commit '30a041887f89cd97c372ad6a516da6e012f2c88b': ismindex: Calculate the pts duration of trun atoms, not the dts duration Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--tools/ismindex.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/ismindex.c b/tools/ismindex.c
index 47a148ccf6..8636c966e8 100644
--- a/tools/ismindex.c
+++ b/tools/ismindex.c
@@ -230,10 +230,12 @@ fail:
static int64_t read_trun_duration(AVIOContext *in, int default_duration,
int64_t end)
{
- int64_t ret = 0;
+ int64_t dts = 0;
int64_t pos;
int flags, i;
int entries;
+ int64_t first_pts = 0;
+ int64_t max_pts = 0;
avio_r8(in); /* version */
flags = avio_rb24(in);
if (default_duration <= 0 && !(flags & MOV_TRUN_SAMPLE_DURATION)) {
@@ -248,19 +250,23 @@ static int64_t read_trun_duration(AVIOContext *in, int default_duration,
pos = avio_tell(in);
for (i = 0; i < entries && pos < end; i++) {
int sample_duration = default_duration;
+ int64_t pts = dts;
if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(in);
if (flags & MOV_TRUN_SAMPLE_SIZE) avio_rb32(in);
if (flags & MOV_TRUN_SAMPLE_FLAGS) avio_rb32(in);
- if (flags & MOV_TRUN_SAMPLE_CTS) avio_rb32(in);
+ if (flags & MOV_TRUN_SAMPLE_CTS) pts += avio_rb32(in);
if (sample_duration < 0) {
fprintf(stderr, "Negative sample duration %d\n", sample_duration);
return -1;
}
- ret += sample_duration;
+ if (i == 0)
+ first_pts = pts;
+ max_pts = FFMAX(max_pts, pts + sample_duration);
+ dts += sample_duration;
pos = avio_tell(in);
}
- return ret;
+ return max_pts - first_pts;
}
static int64_t read_moof_duration(AVIOContext *in, int64_t offset)