Skip to content

Commit

Permalink
style: Minor improvements to code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor-pelykh committed Jun 28, 2024
1 parent 9f32ea1 commit 2f97c64
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
24 changes: 16 additions & 8 deletions src/formats/jpeg/jpeg-quantize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,22 @@ export abstract class JpegQuantize {
const p = dataIn;

// IDCT constants (20.12 fixed point format)
const cos1 = 4017; // cos(pi/16)*4096
const sin1 = 799; // sin(pi/16)*4096
const cos3 = 3406; // cos(3*pi/16)*4096
const sin3 = 2276; // sin(3*pi/16)*4096
const cos6 = 1567; // cos(6*pi/16)*4096
const sin6 = 3784; // sin(6*pi/16)*4096
const sqrt2 = 5793; // sqrt(2)*4096
const sqrt102 = 2896; // sqrt(2) / 2
// cos(pi/16)*4096
const cos1 = 4017;
// sin(pi/16)*4096
const sin1 = 799;
// cos(3*pi/16)*4096
const cos3 = 3406;
// sin(3*pi/16)*4096
const sin3 = 2276;
// cos(6*pi/16)*4096
const cos6 = 1567;
// sin(6*pi/16)*4096
const sin6 = 3784;
// sqrt(2)*4096
const sqrt2 = 5793;
// sqrt(2) / 2
const sqrt102 = 2896;

// de-quantize
for (let i = 0; i < 64; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/formats/webp/vp8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1325,10 +1325,10 @@ export class VP8 {
InputBuffer.from(topDst, (2 * x - 1) * 4)
);
this.yuvToRgba(
topY.get(2 * x - 0),
topY.get(2 * x),
uv1 & 0xff,
uv1 >>> 16,
InputBuffer.from(topDst, (2 * x - 0) * 4)
InputBuffer.from(topDst, 2 * x * 4)
);

if (bottomY !== undefined) {
Expand Down
7 changes: 1 addition & 6 deletions src/formats/webp/webp-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,7 @@ export class WebPFilters {
*/
private static gradientPredictor(a: number, b: number, c: number): number {
const g = a + b - c;
return (g & ~0xff) === 0
? g
: g < 0
? 0
: // clip to 8bit
255;
return (g & ~0xff) === 0 ? g : g < 0 ? 0 : 255;
}

/**
Expand Down

0 comments on commit 2f97c64

Please sign in to comment.