-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Get rid of frames-(m)sec conversion #13288
Conversation
xbmc/Util.h
Outdated
@@ -204,6 +204,13 @@ class CUtil | |||
*/ | |||
static int GetRandomNumber(); | |||
|
|||
static int ConvertSecsToOffset(double secs) { return static_cast<int>(secs * 75); } | |||
static double ConvertOffsetToSecs(int offset) { return offset / 75.0; } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
jenkins build this please |
Let's try again now. |
xbmc/CueDocument.cpp
Outdated
@@ -456,7 +457,7 @@ int CCueDocument::ExtractTimeFromIndex(const std::string &index) | |||
int secs = atoi(time[1].c_str()); | |||
int frames = atoi(time[2].c_str()); | |||
|
|||
return (mins*60 + secs)*75 + frames; | |||
return CUtil::ConvertSecsToOffset(mins*60 + secs) + frames; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
17b77e6
to
3cf2e5f
Compare
@notspiff @FernetMenta the "weird" unit of 75 frames comes from the Cue-sheet standard: see https://en.wikipedia.org/wiki/Cue_sheet_(computing) . |
jenkins build this please |
1 similar comment
jenkins build this please |
once again, jenkins build this please |
at last. Jenkins is good - just the usual OSX test failure... |
@Voyager1 nice! |
Thanks, looks good at a glance. |
Does that include the offset values held in the music DB? If not would it not be best to convert cuesheet values when originally read and saved msec values in the library too? But that would ential converting existing song data and a db bump. I will take that as a separate PR if liked. |
ha - I did not consider the existing ones. As of right now, they are in "frames" but new data will be stored in milliseconds. So existing data will be read as milliseconds thus will be wrong. Another option would be to store in db as "frames", ie. do a conversion upon read/write. But I like your suggestion (much cleaner IMO) and if you feel up to doing the db bump, that would be great! |
@DaveTBlake I just want to clarify that three (not two) columns in the Song table will now be interpreted as milliseconds: iDuration, iStartOffset, iEndOffset. |
I get your thinking @Voyager1 but IMO Song table iDuration needs to remain as seconds. It is something all songs have, and for human use rather than player (which does not take any notice of what the library has anyway) - think track listings on the back of a CD case - and second accuracy is enough. Music from cuesheets is not mainstream, and the only time that iStartOffset, iEndOffset is used. Despite the odd cuesheet standard using frames, I suspect that all offsets are to second accuracy - the example cuesheets I have seem have all been like that, and it seems a natural granularity for music. But in line with use elsewhere we can store as msec, after all they have never been the same unit as iDuration Happy to do the db bump, I can roll it into some other small changes. |
@DaveTBlake my bad... iDuration is (and has been) in seconds so indeed there's no change (I don't know what I was thinking!). Please go ahead with the bump. Next to the version increase, I think you'll just need an UPDATE SQL statement to multiply all iStartOffset and iEndOffset * 1000 / 75 (or * 40/3) |
…ths of sec) and seconds/milliseconds
a556700
to
d1d6fc5
Compare
@DaveTBlake - since I didn't hear back I pushed an additional commit for the db bump. This way we have a complete PR that can be merged and tested. |
jenkins build this please |
Thanks for that @Voyager1, just not sure what I didn't reply to? |
you may have missed my message on slack. Never mind... |
Kodi no longer builds for me after this PR. |
weird because jenkins had built it without issues. That said I think it would be ok to use PRId64 instead because it's the same for an output format specifier. Feel free to PR the fix. thanks! |
it's likely due to interaction with #13336 (system.h removal). |
jenkins told it works on top of #13336 |
…(one more 75 missed)
[video] Fix CGUIWindowVideoBase::GetResumeItemOffset after #13288 (on…
Description
A relatively small change to isolate the repeated conversions between frames (aka 1/75th of a second) and seconds or milliseconds. CFileItem's startOffset and endOffset are expressed in "frames" so there's repeated conversion going on in several places. Plus having the conversion all over the place is error prone.
UPDATE
I've added code to remove the frames conversion and put all offsets in milliseconds. At first sight the code seems to work fine.
Note: the placement of the helper functions is currently CUtil but it's up for comments.
Motivation and Context
see above
How Has This Been Tested?
Code compiles. Some runtime testing done but needs more testing.
Screenshots (if appropriate):
Types of change
Checklist: