[vlc-commits] demux: mp4: split/store in sidx timescale and set timescale
Francois Cartegnie
git at videolan.org
Sun Oct 11 16:50:48 CEST 2020
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Oct 8 12:44:31 2020 +0200| [a0238a476e45509867a7376e6865c8497217e8b3] | committer: Francois Cartegnie
demux: mp4: split/store in sidx timescale and set timescale
(cherry picked from commit 7a07508abc4e0613a76cd5e8e4f95ddca627efe0)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=a0238a476e45509867a7376e6865c8497217e8b3
---
modules/demux/adaptive/playlist/SegmentInformation.cpp | 12 ++++--------
modules/demux/adaptive/playlist/SegmentInformation.hpp | 4 ++--
modules/demux/dash/mp4/IndexReader.cpp | 8 +++++---
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.cpp b/modules/demux/adaptive/playlist/SegmentInformation.cpp
index a5af675ee9..344e155c78 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.cpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.cpp
@@ -601,7 +601,6 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
getSegments(INFOTYPE_MEDIA, seglist);
size_t prevstart = 0;
stime_t prevtime = 0;
- const Timescale timescale = inheritTimescale();
SplitPoint split = {0,0,0};
std::vector<SplitPoint>::const_iterator splitIt;
@@ -611,22 +610,19 @@ void SegmentInformation::SplitUsingIndex(std::vector<SplitPoint> &splitlist)
if(splitIt != splitlist.begin())
{
/* do previous splitpoint */
- const stime_t duration = timescale.ToScaled(split.duration);
- insertIntoSegment(seglist, prevstart, split.offset - 1, prevtime, duration);
+ insertIntoSegment(seglist, prevstart, split.offset - 1, prevtime, split.duration);
}
prevstart = split.offset;
- prevtime = timescale.ToScaled(split.time);
+ prevtime = split.time;
}
if(splitlist.size() == 1)
{
- const stime_t duration = timescale.ToScaled(split.duration);
- insertIntoSegment(seglist, prevstart, 0, prevtime, duration);
+ insertIntoSegment(seglist, prevstart, 0, prevtime, split.duration);
}
else if(splitlist.size() > 1)
{
- const stime_t duration = timescale.ToScaled(split.duration);
- insertIntoSegment(seglist, prevstart, split.offset - 1, prevtime, duration);
+ insertIntoSegment(seglist, prevstart, split.offset - 1, prevtime, split.duration);
}
}
diff --git a/modules/demux/adaptive/playlist/SegmentInformation.hpp b/modules/demux/adaptive/playlist/SegmentInformation.hpp
index f95c90b9cf..b8f817e3e6 100644
--- a/modules/demux/adaptive/playlist/SegmentInformation.hpp
+++ b/modules/demux/adaptive/playlist/SegmentInformation.hpp
@@ -59,8 +59,8 @@ namespace adaptive
{
public:
size_t offset;
- mtime_t time;
- mtime_t duration;
+ stime_t time;
+ stime_t duration;
};
void SplitUsingIndex(std::vector<SplitPoint>&);
diff --git a/modules/demux/dash/mp4/IndexReader.cpp b/modules/demux/dash/mp4/IndexReader.cpp
index d539d22d8e..5dc8089a6d 100644
--- a/modules/demux/dash/mp4/IndexReader.cpp
+++ b/modules/demux/dash/mp4/IndexReader.cpp
@@ -48,14 +48,16 @@ bool IndexReader::parseIndex(block_t *p_block, BaseRepresentation *rep, uint64_t
/* sidx refers to offsets from end of sidx pos in the file + first offset */
point.offset = sidx->i_first_offset + i_fileoffset + sidxbox->i_pos + sidxbox->i_size;
point.time = 0;
- for(uint16_t i=0; i<sidx->i_reference_count && sidx->i_timescale; i++)
+ if(!sidx->i_timescale)
+ return false;
+ for(uint16_t i=0; i<sidx->i_reference_count; i++)
{
splitlist.push_back(point);
point.offset += sidx->p_items[i].i_referenced_size;
- point.duration = CLOCK_FREQ * sidx->p_items[i].i_subsegment_duration /
- sidx->i_timescale;
+ point.duration = sidx->p_items[i].i_subsegment_duration;
point.time += point.duration;
}
+ rep->setTimescale(Timescale(sidx->i_timescale));
rep->SplitUsingIndex(splitlist);
rep->getPlaylist()->debug();
}
More information about the vlc-commits
mailing list