Ticket #8631: seek_honors_cutlist_v4.patch
| File seek_honors_cutlist_v4.patch, 25.6 KB (added by , 15 years ago) |
|---|
-
themes/default-wide/osd.xml
352 352 <area>770,10,300,30</area> 353 353 <align>right,top</align> 354 354 </textarea> 355 <textarea name=" timedisplay" from="title">355 <textarea name="fulltimedisplay" from="title"> 356 356 <area>10,50,1060,30</area> 357 357 <align>hcenter,bottom</align> 358 358 </textarea> -
libs/libmythtv/deletemap.h
46 46 bool IsTemporaryMark(uint64_t frame); 47 47 bool HasTemporaryMark(void); 48 48 uint64_t GetLastFrame(uint64_t total); 49 uint64_t TranslatePositionAbsToRel(uint64_t absPosition) { 50 return TranslatePositionAbsToRel(m_deleteMap, absPosition); 51 } 52 uint64_t TranslatePositionRelToAbs(uint64_t relPosition) { 53 return TranslatePositionRelToAbs(m_deleteMap, relPosition); 54 } 55 static uint64_t TranslatePositionAbsToRel(const frm_dir_map_t &deleteMap, 56 uint64_t absPosition); 57 static uint64_t TranslatePositionRelToAbs(const frm_dir_map_t &deleteMap, 58 uint64_t relPosition); 49 59 50 60 void TrackerReset(uint64_t frame, uint64_t total); 51 61 bool TrackerWantsToJump(uint64_t frame, uint64_t total, uint64_t &to); -
libs/libmythtv/tv_play.h
418 418 419 419 bool SeekHandleAction(PlayerContext *actx, const QStringList &actions, 420 420 const bool isDVD); 421 void DoSeek(PlayerContext*, float time, const QString &mesg); 421 void DoSeek(PlayerContext*, float time, const QString &mesg, 422 bool timeIsOffset, bool honorCutlist=true); 422 423 bool DoPlayerSeek(PlayerContext*, float time); 423 424 enum ArbSeekWhence { 424 425 ARBSEEK_SET = 0, … … 426 427 ARBSEEK_FORWARD, 427 428 ARBSEEK_END 428 429 }; 429 void DoArbSeek(PlayerContext*, ArbSeekWhence whence );430 void DoArbSeek(PlayerContext*, ArbSeekWhence whence, bool honorCutlist=true); 430 431 void NormalSpeed(PlayerContext*); 431 432 void ChangeSpeed(PlayerContext*, int direction); 432 433 void ToggleTimeStretch(PlayerContext*); -
libs/libmythtv/mythplayer.h
344 344 virtual long long CalcMaxFFTime(long long ff, bool setjump = true) const; 345 345 long long CalcRWTime(long long rw) const; 346 346 virtual void calcSliderPos(osdInfo &info, bool paddedFields = false); 347 uint64_t TranslatePositionAbsToRel(uint64_t absPosition) { 348 return deleteMap.TranslatePositionAbsToRel(absPosition); 349 } 350 uint64_t TranslatePositionRelToAbs(uint64_t relPosition) { 351 return deleteMap.TranslatePositionRelToAbs(relPosition); 352 } 347 353 348 354 // Commercial stuff 349 355 void SetAutoCommercialSkip(CommSkipMode autoskip) … … 521 527 void JumpToProgram(void); 522 528 523 529 void calcSliderPosPriv(osdInfo &info, bool paddedFields, 524 int playbackLen, float secsplayed, bool islive); 530 int playbackLen, float secsplayed, bool islive, 531 bool isRaw); 525 532 526 533 protected: 527 534 DecoderBase *decoder; -
libs/libmythtv/mythdvdplayer.cpp
432 432 // DVD playing non-functional under windows for now 433 433 secsplayed = 0.0f; 434 434 #endif 435 calcSliderPosPriv(info, paddedFields, playbackLen, secsplayed, islive); 435 calcSliderPosPriv(info, paddedFields, playbackLen, secsplayed, islive, false); 436 calcSliderPosPriv(info, paddedFields, playbackLen, secsplayed, islive, true); 436 437 } 437 438 438 439 void MythDVDPlayer::SeekForScreenGrab(uint64_t &number, uint64_t frameNum, -
libs/libmythtv/tv_play.cpp
549 549 "Pause"), "P"); 550 550 REG_KEY("TV Playback", "SEEKFFWD", QT_TRANSLATE_NOOP("MythControls", 551 551 "Fast Forward"), "Right"); 552 REG_KEY("TV Playback", "SEEKFFWDNOCUTLIST", QT_TRANSLATE_NOOP("MythControls", 553 "Fast Forward ignoring cutlist"), ""); 552 554 REG_KEY("TV Playback", "SEEKRWND", QT_TRANSLATE_NOOP("MythControls", 553 555 "Rewind"), "Left"); 556 REG_KEY("TV Playback", "SEEKRWNDNOCUTLIST", QT_TRANSLATE_NOOP("MythControls", 557 "Rewind ignoring cutlist"), ""); 554 558 REG_KEY("TV Playback", "ARBSEEK", QT_TRANSLATE_NOOP("MythControls", 555 559 "Arbitrary Seek"), "*"); 560 REG_KEY("TV Playback", "ARBSEEKNOCUTLIST", QT_TRANSLATE_NOOP("MythControls", 561 "Arbitrary Seek ignoring cutlist"), ""); 556 562 REG_KEY("TV Playback", "CHANNELUP", QT_TRANSLATE_NOOP("MythControls", 557 563 "Channel up"), "Up"); 558 564 REG_KEY("TV Playback", "CHANNELDOWN", QT_TRANSLATE_NOOP("MythControls", … … 563 569 "Switch to the previous channel"), "H"); 564 570 REG_KEY("TV Playback", "JUMPFFWD", QT_TRANSLATE_NOOP("MythControls", 565 571 "Jump ahead"), "PgDown"); 572 REG_KEY("TV Playback", "JUMPFFWDNOCUTLIST", QT_TRANSLATE_NOOP("MythControls", 573 "Jump ahead ignoring cutlist"), ""); 566 574 REG_KEY("TV Playback", "JUMPRWND", QT_TRANSLATE_NOOP("MythControls", 567 575 "Jump back"), "PgUp"); 576 REG_KEY("TV Playback", "JUMPRWNDNOCUTLIST", QT_TRANSLATE_NOOP("MythControls", 577 "Jump back ignoring cutlist"), ""); 578 REG_KEY("TV Playback", "INFONOCUTLIST", QT_TRANSLATE_NOOP("MythControls", 579 "Info ignoring cutlist"), ""); 568 580 REG_KEY("TV Playback", "JUMPBKMRK", QT_TRANSLATE_NOOP("MythControls", 569 581 "Jump to bookmark"), "K"); 570 582 REG_KEY("TV Playback", "FFWDSTICKY", QT_TRANSLATE_NOOP("MythControls", … … 3997 4009 ctx->buffer->DVD()->MoveButtonDown(); 3998 4010 } 3999 4011 else if (has_action("LEFT", actions) || 4000 has_action("SEEKRWND", actions)) 4012 has_action("SEEKRWND", actions) || 4013 has_action("SEEKRWNDNOCUTLIST", actions)) 4001 4014 { 4002 4015 ctx->buffer->DVD()->MoveButtonLeft(); 4003 4016 } 4004 4017 else if (has_action("RIGHT", actions) || 4005 has_action("SEEKFFWD", actions)) 4018 has_action("SEEKFFWD", actions) || 4019 has_action("SEEKFFWDNOCUTLIST", actions)) 4006 4020 { 4007 4021 ctx->buffer->DVD()->MoveButtonRight(); 4008 4022 } … … 4189 4203 } 4190 4204 } 4191 4205 } 4192 else if (has_action("JUMPRWND", actions)) 4206 else if (has_action("JUMPRWND", actions) || 4207 has_action("JUMPRWNDNOCUTLIST", actions)) 4193 4208 { 4194 4209 if (isDVD) 4195 4210 DVDJumpBack(ctx); 4196 4211 else if (GetNumChapters(ctx) > 0) 4197 4212 DoJumpChapter(ctx, -1); 4198 4213 else 4199 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back")); 4214 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back"), 4215 true, has_action("JUMPRWND", actions)); 4200 4216 } 4201 else if (has_action("JUMPFFWD", actions)) 4217 else if (has_action("JUMPFFWD", actions) || 4218 has_action("JUMPFFWDNOCUTLIST", actions)) 4202 4219 { 4203 4220 if (isDVD) 4204 4221 DVDJumpForward(ctx); 4205 4222 else if (GetNumChapters(ctx) > 0) 4206 4223 DoJumpChapter(ctx, 9999); 4207 4224 else 4208 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead")); 4225 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead"), 4226 true, has_action("JUMPFFWD", actions)); 4209 4227 } 4210 4228 else if (has_action("JUMPBKMRK", actions)) 4211 4229 { 4212 4230 ctx->LockDeletePlayer(__FILE__, __LINE__); 4213 long long bookmark = ctx->player->GetBookmark(); 4214 long long curloc = ctx->player->GetFramesPlayed(); 4231 uint64_t bookmark = ctx->player->GetBookmark(); 4215 4232 float mult = 1.0f; 4216 4233 if (ctx->last_framerate) 4217 4234 mult = 1.0f / ctx->last_framerate; 4218 long long seekloc = (long long) ((bookmark - curloc) * mult);4235 float seekloc = ctx->player->TranslatePositionAbsToRel(bookmark) * mult; 4219 4236 ctx->UnlockDeletePlayer(__FILE__, __LINE__); 4220 4237 4221 4238 if (bookmark > ctx->last_framerate) 4222 4239 { 4223 DoSeek(ctx, seekloc, tr("Jump to Bookmark") );4240 DoSeek(ctx, seekloc, tr("Jump to Bookmark"), false); 4224 4241 } 4225 4242 } 4226 4243 else if (has_action("JUMPSTART",actions)) 4227 4244 { 4228 long long seekloc = +1; 4229 ctx->LockDeletePlayer(__FILE__, __LINE__); 4230 if (ctx->player && ctx->last_framerate >= 0.0001f) 4231 { 4232 seekloc = (int64_t) (-1.0 * ctx->player->GetFramesPlayed() / 4233 ctx->last_framerate); 4234 } 4235 ctx->UnlockDeletePlayer(__FILE__, __LINE__); 4236 4237 if (seekloc <= 0) 4238 DoSeek(ctx, seekloc, tr("Jump to Beginning")); 4245 DoSeek(ctx, 0, tr("Jump to Beginning"), false); 4239 4246 } 4240 4247 else if (has_action("CLEAROSD", actions)) 4241 4248 { … … 4382 4389 ChangeTimeStretch(ctx, -1); 4383 4390 else if (has_action("MENU", actions)) 4384 4391 ShowOSDMenu(ctx); 4385 else if (has_action("INFO", actions) )4392 else if (has_action("INFO", actions) || has_action("INFONOCUTLIST", actions)) 4386 4393 { 4387 4394 if (HasQueuedInput()) 4388 4395 { 4389 DoArbSeek(ctx, ARBSEEK_SET );4396 DoArbSeek(ctx, ARBSEEK_SET, !has_action("INFONOCUTLIST", actions)); 4390 4397 } 4391 4398 else 4392 4399 ToggleOSD(ctx, true); … … 4585 4592 else if (GetNumChapters(ctx) > 0) 4586 4593 DoJumpChapter(ctx, -1); 4587 4594 else 4588 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back") );4595 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back"), true); 4589 4596 } 4590 4597 else if (has_action("CHANNELDOWN", actions)) 4591 4598 { … … 4601 4608 else if (GetNumChapters(ctx) > 0) 4602 4609 DoJumpChapter(ctx, 9999); 4603 4610 else 4604 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead") );4611 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead"), true); 4605 4612 } 4606 4613 else if (has_action("DELETE", actions) && !islivetv) 4607 4614 { … … 4826 4833 ctx->UnlockDeletePlayer(__FILE__, __LINE__); 4827 4834 4828 4835 if (tokens[2] == "BEGINNING") 4829 DoSeek(ctx, -fplay, tr("Jump to Beginning")); 4830 else if (tokens[2] == "FORWARD") 4831 DoSeek(ctx, ctx->fftime, tr("Skip Ahead")); 4832 else if (tokens[2] == "BACKWARD") 4833 DoSeek(ctx, -ctx->rewtime, tr("Skip Back")); 4834 else if ((tokens[2] == "POSITION") && (tokens.size() == 4) && 4836 DoSeek(ctx, 0, tr("Jump to Beginning"), false); 4837 else if (tokens[2] == "FORWARD" || tokens[2] == "FORWARDNOCUTLIST") 4838 DoSeek(ctx, ctx->fftime, tr("Skip Ahead"), true, tokens[2] == "FORWARD"); 4839 else if (tokens[2] == "BACKWARD" || tokens[2] == "BACKWARDNOCUTLIST") 4840 DoSeek(ctx, -ctx->rewtime, tr("Skip Back"), true, tokens[2] == "BACKWARD"); 4841 else if ((tokens[2] == "POSITION" || 4842 tokens[2] == "POSITIONNOCUTLIST") && 4843 (tokens.size() == 4) && 4835 4844 (tokens[3].contains(QRegExp("^\\d+$"))) && 4836 4845 ctx->last_framerate) 4837 4846 { 4838 4847 long long rel_frame = tokens[3].toInt(); 4839 rel_frame -= (long long) (fplay * (1.0 / ctx->last_framerate)),4840 DoSeek(ctx, rel_frame, tr("Jump To"));4848 DoSeek(ctx, rel_frame / ctx->last_framerate, tr("Jump To"), 4849 false, tokens[2] == "POSITION"); 4841 4850 } 4842 4851 } 4843 4852 else if (tokens.size() >= 3 && tokens[1] == "VOLUME") … … 5871 5880 const bool isDVD) 5872 5881 { 5873 5882 const int kRewind = 4, kForward = 8, kSticky = 16, kSlippery = 32, 5874 kRelative = 64, kAbsolute = 128, kWhenceMask = 3; 5883 kRelative = 64, kAbsolute = 128, kIgnoreCutlist = 256, 5884 kWhenceMask = 3; 5875 5885 int flags = 0; 5876 5886 if (has_action("SEEKFFWD", actions)) 5877 5887 flags = ARBSEEK_FORWARD | kForward | kSlippery | kRelative; 5888 else if (has_action("SEEKFFWDNOCUTLIST", actions)) 5889 flags = ARBSEEK_FORWARD | kForward | kSlippery | kRelative | kIgnoreCutlist; 5878 5890 else if (has_action("FFWDSTICKY", actions)) 5879 5891 flags = ARBSEEK_END | kForward | kSticky | kAbsolute; 5880 5892 else if (has_action("RIGHT", actions)) 5881 5893 flags = ARBSEEK_FORWARD | kForward | kSticky | kRelative; 5882 5894 else if (has_action("SEEKRWND", actions)) 5883 5895 flags = ARBSEEK_REWIND | kRewind | kSlippery | kRelative; 5896 else if (has_action("SEEKRWNDNOCUTLIST", actions)) 5897 flags = ARBSEEK_REWIND | kRewind | kSlippery | kRelative | kIgnoreCutlist; 5884 5898 else if (has_action("RWNDSTICKY", actions)) 5885 5899 flags = ARBSEEK_SET | kRewind | kSticky | kAbsolute; 5886 5900 else if (has_action("LEFT", actions)) … … 5891 5905 int direction = (flags & kRewind) ? -1 : 1; 5892 5906 if (HasQueuedInput()) 5893 5907 { 5894 DoArbSeek(actx, static_cast<ArbSeekWhence>(flags & kWhenceMask)); 5908 DoArbSeek(actx, static_cast<ArbSeekWhence>(flags & kWhenceMask), 5909 !(flags & kIgnoreCutlist)); 5895 5910 } 5896 5911 else if (actx->paused) 5897 5912 { … … 5901 5916 direction * (1.001 / actx->last_framerate); 5902 5917 QString message = (flags & kRewind) ? QString(tr("Rewind")) : 5903 5918 QString(tr("Forward")); 5904 DoSeek(actx, time, message );5919 DoSeek(actx, time, message, true, !(flags & kIgnoreCutlist)); 5905 5920 } 5906 5921 } 5907 5922 else if (flags & kSticky) … … 5912 5927 { 5913 5928 if (smartForward) 5914 5929 doSmartForward = true; 5915 DoSeek(actx, -actx->rewtime, tr("Skip Back")); 5930 DoSeek(actx, -actx->rewtime, tr("Skip Back"), 5931 true, !(flags & kIgnoreCutlist)); 5916 5932 } 5917 5933 else 5918 5934 { 5919 5935 if (smartForward & doSmartForward) 5920 DoSeek(actx, actx->rewtime, tr("Skip Ahead")); 5936 DoSeek(actx, actx->rewtime, tr("Skip Ahead"), 5937 true, !(flags & kIgnoreCutlist)); 5921 5938 else 5922 DoSeek(actx, actx->fftime, tr("Skip Ahead")); 5939 DoSeek(actx, actx->fftime, tr("Skip Ahead"), 5940 true, !(flags & kIgnoreCutlist)); 5923 5941 } 5924 5942 return true; 5925 5943 } 5926 5944 5927 void TV::DoSeek(PlayerContext *ctx, float time, const QString &mesg) 5945 void TV::DoSeek(PlayerContext *ctx, float time, const QString &mesg, 5946 bool timeIsOffset, bool honorCutlist) 5928 5947 { 5929 5948 bool limitkeys = false; 5930 5949 … … 5938 5957 keyRepeatTimer.start(); 5939 5958 NormalSpeed(ctx); 5940 5959 time += StopFFRew(ctx); 5960 float framerate = ctx->last_framerate; 5961 uint64_t currentFrameAbs = ctx->player->GetFramesPlayed(); 5962 uint64_t currentFrameRel = honorCutlist ? 5963 ctx->player->TranslatePositionAbsToRel(currentFrameAbs) : 5964 currentFrameAbs; 5965 int64_t desiredFrameRel = (timeIsOffset ? currentFrameRel : 0) + 5966 time * framerate + 0.5; 5967 if (desiredFrameRel < 0) 5968 desiredFrameRel = 0; 5969 uint64_t desiredFrameAbs = honorCutlist ? 5970 ctx->player->TranslatePositionRelToAbs(desiredFrameRel) : 5971 desiredFrameRel; 5972 time = ((int64_t)desiredFrameAbs - (int64_t)currentFrameAbs) / framerate; 5941 5973 DoPlayerSeek(ctx, time); 5942 5974 UpdateOSDSeekMessage(ctx, mesg, kOSDTimeout_Med); 5943 5975 } 5944 5976 } 5945 5977 5946 void TV::DoArbSeek(PlayerContext *ctx, ArbSeekWhence whence )5978 void TV::DoArbSeek(PlayerContext *ctx, ArbSeekWhence whence, bool honorCutlist) 5947 5979 { 5948 5980 bool ok = false; 5949 5981 int seek = GetQueuedInputAsInt(&ok); … … 5954 5986 float time = ((seek / 100) * 3600) + ((seek % 100) * 60); 5955 5987 5956 5988 if (whence == ARBSEEK_FORWARD) 5957 DoSeek(ctx, time, tr("Jump Ahead") );5989 DoSeek(ctx, time, tr("Jump Ahead"), true, honorCutlist); 5958 5990 else if (whence == ARBSEEK_REWIND) 5959 DoSeek(ctx, -time, tr("Jump Back") );5991 DoSeek(ctx, -time, tr("Jump Back"), true, honorCutlist); 5960 5992 else 5961 5993 { 5962 5994 ctx->LockDeletePlayer(__FILE__, __LINE__); … … 5968 6000 if (whence == ARBSEEK_END) 5969 6001 time = (ctx->player->CalcMaxFFTime(LONG_MAX, false) / 5970 6002 ctx->last_framerate) - time; 5971 else5972 time = time - (ctx->player->GetFramesPlayed() - 1) /5973 ctx->last_framerate;5974 6003 ctx->UnlockDeletePlayer(__FILE__, __LINE__); 5975 DoSeek(ctx, time, tr("Jump To") );6004 DoSeek(ctx, time, tr("Jump To"), (whence != ARBSEEK_SET), honorCutlist); 5976 6005 } 5977 6006 } 5978 6007 … … 6908 6937 { 6909 6938 commited = true; 6910 6939 if (HasQueuedInput()) 6940 // XXX Should the cutlist be honored? 6911 6941 DoArbSeek(ctx, ARBSEEK_FORWARD); 6912 6942 } 6913 6943 else if (StateIsLiveTV(GetState(ctx))) … … 11501 11531 uint chapterLength = ctx->buffer->DVD()->GetChapterLength(); 11502 11532 if ((titleLength == chapterLength) && chapterLength > 300) 11503 11533 { 11504 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back") );11534 DoSeek(ctx, -ctx->jumptime * 60, tr("Jump Back"), true); 11505 11535 } 11506 11536 else 11507 11537 { … … 11548 11578 (currentTime < (chapterLength - (ctx->jumptime * 60))) && 11549 11579 chapterLength > 300) 11550 11580 { 11551 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead") );11581 DoSeek(ctx, ctx->jumptime * 60, tr("Jump Ahead"), true); 11552 11582 } 11553 11583 else 11554 11584 { -
libs/libmythtv/deletemap.cpp
66 66 } 67 67 } 68 68 69 /** 69 static QString createTimeString(uint64_t frame, uint64_t total, 70 double frame_rate, bool full_resolution) 71 { 72 int secs = (int)(frame / frame_rate); 73 int frames = frame - (int)(secs * frame_rate); 74 int totalSecs = (int)(total / frame_rate); 75 QString timestr; 76 if (totalSecs >= 3600) 77 timestr = QString::number(secs / 3600) + ":"; 78 timestr += QString("%1").arg((secs / 60) % 60, 2, 10, QChar(48)) + 79 QString(":%1").arg(secs % 60, 2, 10, QChar(48)); 80 if (full_resolution) 81 timestr += QString(".%1").arg(frames, 2, 10, QChar(48)); 82 return timestr; 83 } 84 85 /** 70 86 * \brief Show and update the edit mode On Screen Display. The cut regions 71 87 * are only refreshed if the deleteMap has been updated. 72 88 */ … … 84 100 infoMap.detach(); 85 101 ctx->UnlockPlayingInfo(__FILE__, __LINE__); 86 102 87 int secs = (int)(frame / frame_rate);88 int frames = frame - (int)(secs * frame_rate);89 QString timestr = QString::number(secs / 3600) +90 QString(":%1").arg((secs / 60) % 60, 2, 10, QChar(48)) +91 QString(":%1").arg(secs % 60, 2, 10, QChar(48)) +92 QString(".%1").arg(frames, 2, 10, QChar(48));93 94 103 QString cutmarker = " "; 95 104 if (IsInDelete(frame)) 96 105 cutmarker = QObject::tr("cut"); 97 106 107 QString timestr = createTimeString(frame, total, frame_rate, true); 108 uint64_t relTotal = TranslatePositionAbsToRel(total); 109 QString relTimeDisplay = createTimeString(TranslatePositionAbsToRel(frame), 110 relTotal, frame_rate, false); 111 QString relLengthDisplay = createTimeString(relTotal, 112 relTotal, frame_rate, false); 98 113 infoMap["timedisplay"] = timestr; 99 114 infoMap["framedisplay"] = QString::number(frame); 100 115 infoMap["cutindicator"] = cutmarker; 101 116 infoMap["title"] = QObject::tr("Edit"); 102 117 infoMap["seekamount"] = m_seekText;; 118 infoMap["reltimedisplay"] = relTimeDisplay; 119 infoMap["rellengthdisplay"] = relLengthDisplay; 120 infoMap["fulltimedisplay"] = timestr + " (" + 121 QObject::tr("%1 of %2").arg(relTimeDisplay).arg(relLengthDisplay) + ")"; 103 122 104 123 QHash<QString,float> posMap; 105 124 posMap.insert("position", (float)((double)frame/(double)total)); … … 721 740 722 741 return currentMap == savedMap; 723 742 } 743 744 uint64_t DeleteMap::TranslatePositionAbsToRel(const frm_dir_map_t &deleteMap, 745 uint64_t absPosition) 746 { 747 uint64_t subtraction = 0; 748 uint64_t startOfCutRegion = 0; 749 frm_dir_map_t::const_iterator i; 750 bool withinCut = false; 751 bool first = true; 752 for (i = deleteMap.constBegin(); 753 i != deleteMap.constEnd() && i.key() <= absPosition; 754 i++) 755 { 756 if (first) 757 withinCut = (i.value() == MARK_CUT_END); 758 first = false; 759 if (i.value() == MARK_CUT_START && !withinCut) 760 { 761 withinCut = true; 762 startOfCutRegion = i.key(); 763 } 764 else if (i.value() == MARK_CUT_END && withinCut) 765 { 766 withinCut = false; 767 subtraction += (i.key() - startOfCutRegion); 768 } 769 } 770 if (withinCut) 771 subtraction += (absPosition - startOfCutRegion); 772 return absPosition - subtraction; 773 } 774 775 uint64_t DeleteMap::TranslatePositionRelToAbs(const frm_dir_map_t &deleteMap, 776 uint64_t relPosition) 777 { 778 uint64_t addition = 0; 779 uint64_t startOfCutRegion = 0; 780 frm_dir_map_t::const_iterator i; 781 bool withinCut = false; 782 bool first = true; 783 for (i = deleteMap.constBegin(); i != deleteMap.constEnd(); i++) 784 { 785 if (first) 786 withinCut = (i.value() == MARK_CUT_END); 787 first = false; 788 if (i.value() == MARK_CUT_START && !withinCut) 789 { 790 withinCut = true; 791 startOfCutRegion = i.key(); 792 if (relPosition + addition <= startOfCutRegion) 793 break; 794 } 795 else if (i.value() == MARK_CUT_END && withinCut) 796 { 797 withinCut = false; 798 addition += (i.key() - startOfCutRegion); 799 } 800 } 801 return relPosition + addition; 802 } -
libs/libmythtv/mythplayer.cpp
4282 4282 info.values.insert("progbefore", 0); 4283 4283 info.values.insert("progafter", 0); 4284 4284 4285 int playbackLen = (totalDuration > 0) ? totalDuration : totalLength; 4285 int rawPlaybackLen = (totalDuration > 0) ? totalDuration : totalLength; 4286 // XXX- Note that the translated playbackLen uses the frame count 4287 // with respect to a fixed frame rate, rather than the ffmpeg 4288 // display timecode. 4289 int playbackLen = deleteMap.TranslatePositionAbsToRel(totalLength * video_frame_rate) / video_frame_rate; 4286 4290 4287 4291 if (livetv && player_ctx->tvchain) 4288 4292 { … … 4300 4304 islive = true; 4301 4305 } 4302 4306 4303 float secsplayed = (float)(disp_timecode / 1000.f); 4304 calcSliderPosPriv(info, paddedFields, playbackLen, secsplayed, islive); 4307 // XXX- Note that the translated secsplayed uses the frame number 4308 // with respect to a fixed frame rate, rather than the ffmpeg 4309 // display timecode. 4310 float secsplayed = ((float)deleteMap.TranslatePositionAbsToRel(framesPlayed) / video_frame_rate); 4311 calcSliderPosPriv(info, paddedFields, playbackLen, secsplayed, islive, false); 4312 float rawSecsplayed = (float)(disp_timecode / 1000.f); 4313 calcSliderPosPriv(info, paddedFields, rawPlaybackLen, rawSecsplayed, islive, true); 4305 4314 } 4306 4315 4307 4316 void MythPlayer::calcSliderPosPriv(osdInfo &info, bool paddedFields, 4308 4317 int playbackLen, float secsplayed, 4309 bool islive )4318 bool islive, bool isRaw) 4310 4319 { 4320 QString rawPrefix = isRaw ? "raw" : ""; 4311 4321 playbackLen = max(playbackLen, 1); 4312 4322 secsplayed = min((float)playbackLen, max(secsplayed, 0.0f)); 4313 4323 4314 info.values["position"] = (int)(1000.0f * (secsplayed / (float)playbackLen)); 4324 info.values[rawPrefix + "position"] = 4325 (int)(1000.0f * (secsplayed / (float)playbackLen)); 4315 4326 4316 4327 int phours = (int)secsplayed / 3600; 4317 4328 int pmins = ((int)secsplayed - phours * 3600) / 60; … … 4360 4371 } 4361 4372 } 4362 4373 4363 info.text[ "description"] = QObject::tr("%1 of %2").arg(text1).arg(text2);4364 info.text[ "playedtime"] = text1;4365 info.text[ "totaltime"] = text2;4366 info.text[ "remainingtime"] = islive ? QString() : text3;4367 info.text[ "behindtime"] = islive ? text3 : QString();4374 info.text[rawPrefix + "description"] = QObject::tr("%1 of %2").arg(text1).arg(text2); 4375 info.text[rawPrefix + "playedtime"] = text1; 4376 info.text[rawPrefix + "totaltime"] = text2; 4377 info.text[rawPrefix + "remainingtime"] = islive ? QString() : text3; 4378 info.text[rawPrefix + "behindtime"] = islive ? text3 : QString(); 4368 4379 } 4369 4380 4370 4381 int MythPlayer::GetNumChapters() -
libs/libmythtv/osd.cpp
335 335 found = true; 336 336 } 337 337 } 338 if (map.contains("rawposition")) 339 { 340 MythUIProgressBar *bar = dynamic_cast<MythUIProgressBar *> (win->GetChild("rawposition")); 341 if (bar) 342 { 343 bar->SetVisible(true); 344 bar->SetStart(0); 345 bar->SetTotal(1000); 346 bar->SetUsed(map.value("rawposition")); 347 found = true; 348 } 349 } 338 350 339 351 if (found) 340 352 SetExpiry(window, timeout);
