mirror of https://github.com/SixLabors/ImageSharp
2 changed files with 132 additions and 0 deletions
@ -0,0 +1,67 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jxl.Ac; |
|||
|
|||
internal enum JxlAcStrategyType : ushort |
|||
{ |
|||
// Regular block size DCT
|
|||
DCT = 0, |
|||
|
|||
// Encode pixels without transforming
|
|||
IDENTITY = 1, |
|||
|
|||
// Use 2-by-2 DCT
|
|||
DCT2X2 = 2, |
|||
|
|||
// Use 4-by-4 DCT
|
|||
DCT4X4 = 3, |
|||
|
|||
// Use 16-by-16 DCT
|
|||
DCT16X16 = 4, |
|||
|
|||
// Use 32-by-32 DCT
|
|||
DCT32X32 = 5, |
|||
|
|||
// Use 16-by-8 DCT
|
|||
DCT16X8 = 6, |
|||
|
|||
// Use 8-by-16 DCT
|
|||
DCT8X16 = 7, |
|||
|
|||
// Use 32-by-8 DCT
|
|||
DCT32X8 = 8, |
|||
|
|||
// Use 8-by-32 DCT
|
|||
DCT8X32 = 9, |
|||
|
|||
// Use 32-by-16 DCT
|
|||
DCT32X16 = 10, |
|||
|
|||
// Use 16-by-32 DCT
|
|||
DCT16X32 = 11, |
|||
|
|||
// 4x8 and 8x4 DCT
|
|||
DCT4X8 = 12, |
|||
DCT8X4 = 13, |
|||
|
|||
// Corner-DCT.
|
|||
AFV0 = 14, |
|||
|
|||
AFV1 = 15, |
|||
AFV2 = 16, |
|||
AFV3 = 17, |
|||
|
|||
// Larger DCTs
|
|||
DCT64X64 = 18, |
|||
DCT64X32 = 19, |
|||
DCT32X64 = 20, |
|||
|
|||
// No transforms smaller than 64x64 are allowed below.
|
|||
DCT128X128 = 21, |
|||
DCT128X64 = 22, |
|||
DCT64X128 = 23, |
|||
DCT256X256 = 24, |
|||
DCT256X128 = 25, |
|||
DCT128X256 = 26 |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jxl; |
|||
|
|||
internal struct JxlFrameDimensions |
|||
{ |
|||
public const int BlockDimensions = 8; |
|||
public const int DctBlockSize = BlockDimensions * BlockDimensions; |
|||
public const int GroupDimensions = 256; |
|||
public const int GroupDimensionsInBlocks = GroupDimensions / BlockDimensions; |
|||
|
|||
public int XSize; |
|||
public int YSize; |
|||
public int XSizeUpsampled; |
|||
public int YSizeUpsampled; |
|||
public int XSizeUpsampledPadded; |
|||
public int YSizeUpsampledPadded; |
|||
public int XSizePadded; |
|||
public int YSizePadded; |
|||
public int XSizeBlocks; |
|||
public int YSizeBlocks; |
|||
public int XSizeGroups; |
|||
public int YSizeGroups; |
|||
public int XSizeDcGroups; |
|||
public int YSizeDcGroups; |
|||
public int NumGroups; |
|||
public int NumDcGroups; |
|||
public int GroupDimension; |
|||
public int DcGroupDimension; |
|||
|
|||
public JxlFrameDimensions(int xSizePixel, int ySizePixel, int groupSizeShift, int maxHorizontalShift, int maxVerticalShift, bool modularMode, int upsampling) |
|||
{ |
|||
this.GroupDimension = (GroupDimensions >> 1) << groupSizeShift; |
|||
this.DcGroupDimension = this.GroupDimension * BlockDimensions; |
|||
this.XSizeUpsampled = xSizePixel; |
|||
this.YSizeUpsampled = ySizePixel; |
|||
this.XSize = DivCeil(xSizePixel, upsampling); |
|||
this.YSize = DivCeil(ySizePixel, upsampling); |
|||
this.XSizeBlocks = DivCeil(this.XSize, BlockDimensions << maxHorizontalShift) << maxHorizontalShift; |
|||
this.YSizeBlocks = DivCeil(this.YSize, BlockDimensions << maxVerticalShift) << maxVerticalShift; |
|||
this.XSizePadded = this.XSizeBlocks * BlockDimensions; |
|||
this.YSizePadded = this.YSizeBlocks * BlockDimensions; |
|||
|
|||
if (modularMode) |
|||
{ |
|||
this.XSizePadded = this.XSize; |
|||
this.YSizePadded = this.YSize; |
|||
} |
|||
|
|||
this.XSizeUpsampledPadded = this.XSizePadded * upsampling; |
|||
this.YSizeUpsampledPadded = this.YSizePadded * upsampling; |
|||
this.XSizeGroups = DivCeil(this.XSize, GroupDimensions); |
|||
this.YSizeGroups = DivCeil(this.YSize, GroupDimensions); |
|||
this.XSizeDcGroups = DivCeil(this.XSizeBlocks, GroupDimensions); |
|||
this.YSizeDcGroups = DivCeil(this.YSizeBlocks, GroupDimensions); |
|||
this.NumGroups = this.XSizeGroups * this.YSizeGroups; |
|||
this.NumDcGroups = this.XSizeDcGroups * this.YSizeDcGroups; |
|||
} |
|||
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
private static int DivCeil(int x, int y) => x / y; |
|||
} |
|||
Loading…
Reference in new issue