Permalink
Browse files

Add functions for converting between pre- and post-cutlist frame numb…

…ers.

Refs #8631.  These functions are not actually used anywhere yet.
  • Loading branch information...
stichnot committed Apr 12, 2012
1 parent 6114ecd commit 769059b1f85af7963574cff0d14c74e387ab2422
Showing with 76 additions and 0 deletions.
  1. +60 −0 mythtv/libs/libmythtv/deletemap.cpp
  2. +10 −0 mythtv/libs/libmythtv/deletemap.h
  3. +6 −0 mythtv/libs/libmythtv/mythplayer.h
@@ -839,3 +839,63 @@ bool DeleteMap::IsSaved(void) const
return currentMap == savedMap;
}
+
+uint64_t DeleteMap::TranslatePositionAbsToRel(const frm_dir_map_t &deleteMap,
+ uint64_t absPosition)
+{
+ uint64_t subtraction = 0;
+ uint64_t startOfCutRegion = 0;
+ frm_dir_map_t::const_iterator i;
+ bool withinCut = false;
+ bool first = true;
+ for (i = deleteMap.constBegin(); i != deleteMap.constEnd(); ++i)
+ {
+ if (first)
+ withinCut = (i.value() == MARK_CUT_END);
+ first = false;
+ if (i.key() > absPosition)
+ break;
+ if (i.value() == MARK_CUT_START && !withinCut)
+ {
+ withinCut = true;
+ startOfCutRegion = i.key();
+ }
+ else if (i.value() == MARK_CUT_END && withinCut)
+ {
+ withinCut = false;
+ subtraction += (i.key() - startOfCutRegion);
+ }
+ }
+ if (withinCut)
+ subtraction += (absPosition - startOfCutRegion);
+ return absPosition - subtraction;
+}
+
+uint64_t DeleteMap::TranslatePositionRelToAbs(const frm_dir_map_t &deleteMap,
+ uint64_t relPosition)
+{
+ uint64_t addition = 0;
+ uint64_t startOfCutRegion = 0;
+ frm_dir_map_t::const_iterator i;
+ bool withinCut = false;
+ bool first = true;
+ for (i = deleteMap.constBegin(); i != deleteMap.constEnd(); ++i)
+ {
+ if (first)
+ withinCut = (i.value() == MARK_CUT_END);
+ first = false;
+ if (i.value() == MARK_CUT_START && !withinCut)
+ {
+ withinCut = true;
+ startOfCutRegion = i.key();
+ if (relPosition + addition <= startOfCutRegion)
+ break;
+ }
+ else if (i.value() == MARK_CUT_END && withinCut)
+ {
+ withinCut = false;
+ addition += (i.key() - startOfCutRegion);
+ }
+ }
+ return relPosition + addition;
+}
@@ -66,6 +66,16 @@ class MTV_PUBLIC DeleteMap
bool IsTemporaryMark(uint64_t frame) const;
bool HasTemporaryMark(void) const;
uint64_t GetLastFrame(uint64_t total) const;
+ uint64_t TranslatePositionAbsToRel(uint64_t absPosition) const {
+ return TranslatePositionAbsToRel(m_deleteMap, absPosition);
+ }
+ uint64_t TranslatePositionRelToAbs(uint64_t relPosition) const {
+ return TranslatePositionRelToAbs(m_deleteMap, relPosition);
+ }
+ static uint64_t TranslatePositionAbsToRel(const frm_dir_map_t &deleteMap,
+ uint64_t absPosition);
+ static uint64_t TranslatePositionRelToAbs(const frm_dir_map_t &deleteMap,
+ uint64_t relPosition);
void TrackerReset(uint64_t frame, uint64_t total);
bool TrackerWantsToJump(uint64_t frame, uint64_t total, uint64_t &to);
@@ -381,6 +381,12 @@ class MTV_PUBLIC MythPlayer
virtual long long CalcMaxFFTime(long long ff, bool setjump = true) const;
long long CalcRWTime(long long rw) const;
virtual void calcSliderPos(osdInfo &info, bool paddedFields = false);
+ uint64_t TranslatePositionAbsToRel(uint64_t absPosition) {
+ return deleteMap.TranslatePositionAbsToRel(absPosition);
+ }
+ uint64_t TranslatePositionRelToAbs(uint64_t relPosition) {
+ return deleteMap.TranslatePositionRelToAbs(relPosition);
+ }
// Commercial stuff
void SetAutoCommercialSkip(CommSkipMode autoskip)

0 comments on commit 769059b

Please sign in to comment.