summaryrefslogtreecommitdiff
path: root/tools/ismindex.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-16 12:38:59 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-16 12:45:01 +0200
commita9b613b60e5108692d329c5779e1cc7488cadf0d (patch)
treefb200c10c53451dfc8ae1d94208d8a5f9740d24d /tools/ismindex.c
parent293a8e426fc05db44ac8952a1f62b254e9362f3f (diff)
parent979932378ae3fbf452e312eb759cc7ce175f78de (diff)
downloadffmpeg-a9b613b60e5108692d329c5779e1cc7488cadf0d.tar.gz
Merge commit '979932378ae3fbf452e312eb759cc7ce175f78de'
* commit '979932378ae3fbf452e312eb759cc7ce175f78de': ismindex: use tfhd default duration if no sample duration Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'tools/ismindex.c')
-rw-r--r--tools/ismindex.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/ismindex.c b/tools/ismindex.c
index 274223decc..3e5304635f 100644
--- a/tools/ismindex.c
+++ b/tools/ismindex.c
@@ -227,7 +227,8 @@ fail:
return ret;
}
-static int64_t read_trun_duration(AVIOContext *in, int64_t end)
+static int64_t read_trun_duration(AVIOContext *in, int default_duration,
+ int64_t end)
{
int64_t ret = 0;
int64_t pos;
@@ -235,7 +236,7 @@ static int64_t read_trun_duration(AVIOContext *in, int64_t end)
int entries;
avio_r8(in); /* version */
flags = avio_rb24(in);
- if (!(flags & MOV_TRUN_SAMPLE_DURATION)) {
+ if (default_duration <= 0 && !(flags & MOV_TRUN_SAMPLE_DURATION)) {
fprintf(stderr, "No sample duration in trun flags\n");
return -1;
}
@@ -246,7 +247,7 @@ static int64_t read_trun_duration(AVIOContext *in, int64_t end)
pos = avio_tell(in);
for (i = 0; i < entries && pos < end; i++) {
- int sample_duration = 0;
+ int sample_duration = default_duration;
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);
@@ -267,6 +268,7 @@ static int64_t read_moof_duration(AVIOContext *in, int64_t offset)
int64_t ret = -1;
int32_t moof_size, size, tag;
int64_t pos = 0;
+ int default_duration = 0;
avio_seek(in, offset, SEEK_SET);
moof_size = avio_rb32(in);
@@ -284,8 +286,21 @@ static int64_t read_moof_duration(AVIOContext *in, int64_t offset)
pos = avio_tell(in);
size = avio_rb32(in);
tag = avio_rb32(in);
+ if (tag == MKBETAG('t', 'f', 'h', 'd')) {
+ int flags = 0;
+ avio_r8(in); /* version */
+ flags = avio_rb24(in);
+ avio_rb32(in); /* track_id */
+ if (flags & MOV_TFHD_BASE_DATA_OFFSET)
+ avio_rb64(in);
+ if (flags & MOV_TFHD_STSD_ID)
+ avio_rb32(in);
+ if (flags & MOV_TFHD_DEFAULT_DURATION)
+ default_duration = avio_rb32(in);
+ }
if (tag == MKBETAG('t', 'r', 'u', 'n')) {
- return read_trun_duration(in, pos + size);
+ return read_trun_duration(in, default_duration,
+ pos + size);
}
avio_seek(in, pos + size, SEEK_SET);
}