Ticket #8631: seek_honors_cutlist.patch
File seek_honors_cutlist.patch, 8.6 KB (added by , 14 years ago) |
---|
-
libs/libmythtv/deletemap.h
44 44 bool IsInDelete(uint64_t frame); 45 45 uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right); 46 46 uint64_t GetLastFrame(uint64_t total); 47 uint64_t TranslatePositionAbsToRel(uint64_t absPosition); 48 uint64_t TranslatePositionRelToAbs(uint64_t relPosition); 47 49 48 50 void TrackerReset(uint64_t frame, uint64_t total); 49 51 bool TrackerWantsToJump(uint64_t frame, uint64_t total, uint64_t &to); -
libs/libmythtv/NuppelVideoPlayer.cpp
3968 3968 info.values.insert("progbefore", 0); 3969 3969 info.values.insert("progafter", 0); 3970 3970 3971 int playbackLen = totalLength;3971 int playbackLen = deleteMap.TranslatePositionAbsToRel(totalLength * video_frame_rate) / video_frame_rate; 3972 3972 3973 3973 if (livetv && player_ctx->tvchain) 3974 3974 { … … 3986 3986 islive = true; 3987 3987 } 3988 3988 3989 float secsplayed = ((float) framesPlayed/ video_frame_rate);3989 float secsplayed = ((float)deleteMap.TranslatePositionAbsToRel(framesPlayed) / video_frame_rate); 3990 3990 calcSliderPosPriv(info, paddedFields, playbackLen, secsplayed, islive); 3991 3991 } 3992 3992 -
libs/libmythtv/tv_play.h
416 416 417 417 bool SeekHandleAction(PlayerContext *actx, const QStringList &actions, 418 418 const bool isDVD); 419 void DoSeek(PlayerContext*, float time, const QString &mesg); 419 void DoSeek(PlayerContext*, float time, const QString &mesg, 420 bool timeIsOffset=true); 420 421 bool DoNVPSeek(PlayerContext*, float time); 421 422 enum ArbSeekWhence { 422 423 ARBSEEK_SET = 0, -
libs/libmythtv/NuppelVideoPlayer.h
233 233 virtual long long CalcMaxFFTime(long long ff, bool setjump = true) const; 234 234 long long CalcRWTime(long long rw) const; 235 235 virtual void calcSliderPos(osdInfo &info, bool paddedFields = false); 236 uint64_t TranslatePositionAbsToRel(uint64_t absPosition) { 237 return deleteMap.TranslatePositionAbsToRel(absPosition); 238 } 239 uint64_t TranslatePositionRelToAbs(uint64_t relPosition) { 240 return deleteMap.TranslatePositionRelToAbs(relPosition); 241 } 236 242 237 243 /// Non-const gets 238 244 OSD *GetOSD(void) { return osd; } -
libs/libmythtv/tv_play.cpp
3983 3983 else if (has_action("JUMPBKMRK", actions)) 3984 3984 { 3985 3985 ctx->LockDeleteNVP(__FILE__, __LINE__); 3986 long long bookmark = ctx->nvp->GetBookmark(); 3987 long long curloc = ctx->nvp->GetFramesPlayed(); 3986 uint64_t bookmark = ctx->nvp->GetBookmark(); 3988 3987 float mult = 1.0f; 3989 3988 if (ctx->last_framerate) 3990 3989 mult = 1.0f / ctx->last_framerate; 3991 long long seekloc = (long long) ((bookmark - curloc) * mult);3990 float seekloc = ctx->nvp->TranslatePositionAbsToRel(bookmark) * mult; 3992 3991 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 3993 3992 3994 3993 if (bookmark > ctx->last_framerate) 3995 3994 { 3996 DoSeek(ctx, seekloc, tr("Jump to Bookmark") );3995 DoSeek(ctx, seekloc, tr("Jump to Bookmark"), false); 3997 3996 } 3998 3997 } 3999 3998 else if (has_action("JUMPSTART",actions)) 4000 3999 { 4001 long long seekloc = +1; 4002 ctx->LockDeleteNVP(__FILE__, __LINE__); 4003 if (ctx->nvp && ctx->last_framerate >= 0.0001f) 4004 { 4005 seekloc = (int64_t) (-1.0 * ctx->nvp->GetFramesPlayed() / 4006 ctx->last_framerate); 4007 } 4008 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 4009 4010 if (seekloc <= 0) 4011 DoSeek(ctx, seekloc, tr("Jump to Beginning")); 4000 DoSeek(ctx, 0, tr("Jump to Beginning"), false); 4012 4001 } 4013 4002 else if (has_action("CLEAROSD", actions)) 4014 4003 { … … 4591 4580 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 4592 4581 4593 4582 if (tokens[2] == "BEGINNING") 4594 DoSeek(ctx, -fplay, tr("Jump to Beginning"));4583 DoSeek(ctx, 0, tr("Jump to Beginning"), false); 4595 4584 else if (tokens[2] == "FORWARD") 4596 4585 DoSeek(ctx, ctx->fftime, tr("Skip Ahead")); 4597 4586 else if (tokens[2] == "BACKWARD") … … 4601 4590 ctx->last_framerate) 4602 4591 { 4603 4592 long long rel_frame = tokens[3].toInt(); 4604 rel_frame -= (long long) (fplay * (1.0 / ctx->last_framerate)), 4605 DoSeek(ctx, rel_frame, tr("Jump To")); 4593 DoSeek(ctx, rel_frame / ctx->last_framerate, tr("Jump To"), false); 4606 4594 } 4607 4595 } 4608 4596 else if (tokens.size() >= 3 && tokens[1] == "QUERY") … … 5637 5625 return true; 5638 5626 } 5639 5627 5640 void TV::DoSeek(PlayerContext *ctx, float time, const QString &mesg) 5628 void TV::DoSeek(PlayerContext *ctx, float time, const QString &mesg, 5629 bool timeIsOffset) 5641 5630 { 5642 5631 bool limitkeys = false; 5643 5632 … … 5651 5640 keyRepeatTimer.start(); 5652 5641 NormalSpeed(ctx); 5653 5642 time += StopFFRew(ctx); 5643 float framerate = ctx->last_framerate; 5644 uint64_t currentFrameAbs = ctx->nvp->GetFramesPlayed(); 5645 uint64_t currentFrameRel = 5646 ctx->nvp->TranslatePositionAbsToRel(currentFrameAbs); 5647 int64_t desiredFrameRel = (timeIsOffset ? currentFrameRel : 0) + 5648 time * framerate + 0.5; 5649 if (desiredFrameRel < 0) 5650 desiredFrameRel = 0; 5651 uint64_t desiredFrameAbs = 5652 ctx->nvp->TranslatePositionRelToAbs(desiredFrameRel); 5653 time = ((int64_t)desiredFrameAbs - (int64_t)currentFrameAbs) / framerate; 5654 5654 DoNVPSeek(ctx, time); 5655 5655 UpdateOSDSeekMessage(ctx, mesg, true); 5656 5656 } … … 5681 5681 if (whence == ARBSEEK_END) 5682 5682 time = (ctx->nvp->CalcMaxFFTime(LONG_MAX, false) / 5683 5683 ctx->last_framerate) - time; 5684 else5685 time = time - (ctx->nvp->GetFramesPlayed() - 1) /5686 ctx->last_framerate;5687 5684 ctx->UnlockDeleteNVP(__FILE__, __LINE__); 5688 DoSeek(ctx, time, tr("Jump To") );5685 DoSeek(ctx, time, tr("Jump To"), (whence != ARBSEEK_SET)); 5689 5686 } 5690 5687 } 5691 5688 -
libs/libmythtv/deletemap.cpp
505 505 result = it.key(); 506 506 return result; 507 507 } 508 509 uint64_t DeleteMap::TranslatePositionAbsToRel(uint64_t absPosition) 510 { 511 uint64_t subtraction = 0; 512 uint64_t startOfCutRegion = 0; 513 frm_dir_map_t::const_iterator i; 514 bool withinCut = false; 515 bool first = true; 516 for (i = m_deleteMap.constBegin(); 517 i != m_deleteMap.constEnd() && i.key() <= absPosition; 518 i++) 519 { 520 if (first) 521 withinCut = (i.value() == MARK_CUT_END); 522 first = false; 523 if (i.value() == MARK_CUT_START && !withinCut) 524 { 525 withinCut = true; 526 startOfCutRegion = i.key(); 527 } 528 else if (i.value() == MARK_CUT_END && withinCut) 529 { 530 withinCut = false; 531 subtraction += (i.key() - startOfCutRegion); 532 } 533 } 534 if (withinCut) 535 subtraction += (absPosition - startOfCutRegion); 536 return absPosition - subtraction; 537 } 538 539 uint64_t DeleteMap::TranslatePositionRelToAbs(uint64_t relPosition) 540 { 541 uint64_t addition = 0; 542 uint64_t startOfCutRegion = 0; 543 frm_dir_map_t::const_iterator i; 544 bool withinCut = false; 545 bool first = true; 546 for (i = m_deleteMap.constBegin(); i != m_deleteMap.constEnd(); i++) 547 { 548 if (first) 549 withinCut = (i.value() == MARK_CUT_END); 550 first = false; 551 if (i.value() == MARK_CUT_START && !withinCut) 552 { 553 withinCut = true; 554 startOfCutRegion = i.key(); 555 if (relPosition + addition <= startOfCutRegion) 556 break; 557 } 558 else if (i.value() == MARK_CUT_END && withinCut) 559 { 560 withinCut = false; 561 addition += (i.key() - startOfCutRegion); 562 } 563 } 564 return relPosition + addition; 565 }