forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for issue video-dev#2336: Remove misplaced timescale normalizing …
…in delta computation (video-dev#2354) Remove a misplaced scale normalization in a timestamp delta compuation in the mp4-remuxer when checking for sample gaps and overlapping.e
- Loading branch information
Showing
2 changed files
with
73 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const MPEG_TS_CLOCK_FREQ_HZ = 90000; | ||
|
||
export function toTimescaleFromScale (value, destScale: number, srcScale: number = 1, round: boolean = false): number { | ||
return toTimescaleFromBase(value, destScale, 1 / srcScale); | ||
} | ||
|
||
export function toTimescaleFromBase (value, destScale: number, srcBase: number = 1, round: boolean = false): number { | ||
const result = value * destScale * srcBase; // equivalent to `(value * scale) / (1 / base)` | ||
return round ? Math.round(result) : result; | ||
} | ||
|
||
export function toMsFromMpegTsClock (value: number, round: boolean = false): number { | ||
return toTimescaleFromBase(value, 1000, 1 / MPEG_TS_CLOCK_FREQ_HZ, round); | ||
} | ||
|
||
export function toMpegTsClockFromTimescale (value: number, srcScale: number = 1): number { | ||
return toTimescaleFromBase(value, MPEG_TS_CLOCK_FREQ_HZ, 1 / srcScale); | ||
} |