diff options
| author | caleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu> | 2022-03-12 22:07:48 -0500 |
|---|---|---|
| committer | caleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu> | 2022-03-12 22:07:48 -0500 |
| commit | 39da04dc796b635b43879d285bc9d2c2aabc8761 (patch) | |
| tree | ed72215dafba14fec002c1899e38f466bb6aae7a /webAO/utils/calculateApngLength.js | |
| parent | 1296cecb0690bbe70c109693625cb424297a0b40 (diff) | |
Lint
Diffstat (limited to 'webAO/utils/calculateApngLength.js')
| -rw-r--r-- | webAO/utils/calculateApngLength.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/webAO/utils/calculateApngLength.js b/webAO/utils/calculateApngLength.js index 86c2073..932f581 100644 --- a/webAO/utils/calculateApngLength.js +++ b/webAO/utils/calculateApngLength.js @@ -1,25 +1,25 @@ - /** +/** * Adds up the chunk delays to find out how long a APNG is * @param {data} apngFile the APNG data */ const calculateApngLength = (apngFile) => { const d = new Uint8Array(apngFile); - // https://wiki.mozilla.org/APNG_Specification#.60fcTL.60:_The_Frame_Control_Chunk - let duration = 0; - for (var i = 0; i < d.length; i++) { - // Find fcTL header (66 63 54 4C) - if (d[i] === 0x66 + // https://wiki.mozilla.org/APNG_Specification#.60fcTL.60:_The_Frame_Control_Chunk + let duration = 0; + for (let i = 0; i < d.length; i++) { + // Find fcTL header (66 63 54 4C) + if (d[i] === 0x66 && d[i + 1] === 0x63 && d[i + 2] === 0x54 && d[i + 3] === 0x4C) { - // numerator and denominator - let delay = ((d[i + 21] / d[i + 23]) * 1000) + // numerator and denominator + const delay = ((d[i + 21] / d[i + 23]) * 1000); - // minimum is 100ms - duration += delay < 100 ? 100 : delay; - } - } - console.debug(duration); - return duration * 10; + // minimum is 100ms + duration += delay < 100 ? 100 : delay; + } + } + console.debug(duration); + return duration * 10; }; export default calculateApngLength; |
