📄 aiccommon.pas
字号:
unit AICCommon;
{ Advanced Image Coding (AIC)
===========================
Common declarations used by various AIC library units }
interface
uses
SysUtils;
const
RowColSize = 8;
BlockSize = RowColSize * RowColSize;
{ The AIC algorithms works with 8x8 blocks of pixels }
AICMinQuality = 1;
{ Mimimum quality for compressing AIC images }
AICMaxQuality = 100;
{ Maximum quality for compressing AIC images }
AICFileID = 'AIC';
{ Every AIC must start with this ID }
AICFileVersion = 10; // 1.0
{ The maximum supported file version, multiplied by 10 }
type
EAICError = class(Exception);
{ Class used for raising AIC related exceptions }
TAICQuality = AICMinQuality..AICMaxQuality;
{ Supported quality levels }
TAICImageFormat = (ifGreyscale,ifColor);
{ AIC supports 8-bit greyscale and 24-bit color images }
TAICChannelType = (ctY,ctCb,ctCr);
{ The types of supported color channels.
ctY: The luminance channel (for greyscale and color images)
ctCb: The chrominance channel in blue direction (color images only)
ctCr: The chrominance channel in red direction (color images only) }
TAICPredictionMode = (pmVert,pmHorz,pmDC,
pmDiagonalDownLeft,pmDiagonalDownRight,
pmVerticalRight,pmHorizontalDown,
pmVerticalLeft, pmHorizontalUp);
{ The supported block prediction modes. See web site for details }
TAICChannel = array of array of Byte;
{ Represents is single component channels as a 2D-array of bytes }
TAICChannels = array[TAICChannelType] of TAICChannel;
{ Represents a full color images with three channels for Y, Cb and Cr
components }
TAICByteBlock = array [0..BlockSize - 1] of Byte;
{ An 8x8 block of bytes, ordered as a one dimensional array, used to
represent blocks of pixel values }
TAICIntBlock = array [0..BlockSize - 1] of Integer;
{ An 8x8 block of integers, ordered as a one dimensional array, used to
represent blocks of DCT coefficients }
TAICFloatBlock = array [0..BlockSize - 1] of Double;
{ An 8x8 block of floating point values, ordered as a one dimensional array,
used to represent quantisation tables and temporary blocks of
DCT coefficients }
TAICQuantTable = TAICFloatBlock;
{ An 8x8 block of quantisation values }
TAICBGR = packed record
{ Represents and interleaved 3-byte value of a pixel in Windows bitmap
format (that is, in BGR-order) }
B, G, R: Byte;
end;
PAICBGR = ^TAICBGR;
TAICFileID = array [0..2] of Char;
{ Every AIC file starts a header with a 3 byte file ID }
TAICFileHeader = packed record
{ Every AIC file starts with this header }
FileID : TAICFileID;
{ A 3-byte file ID, must be 'AIC' }
FileVersion : Byte;
{ The version of the file, multipled by 10 (version 2.3 --> 23) }
ImageWidth : Word;
{ The width of the image }
ImageHeight : Word;
{ The height of the image }
ImageFormat : TAICImageFormat;
{ The format of the image (greyscale or color) }
Quality : TAICQuality;
{ The quality level with which the image is compressed }
end;
var
AICByteClip: array [-1023..1023] of Byte;
{ A helper array to clip values to byte boundaries.
Elements -1023..-1 all have value 0.
Elements 256..1023 all have value 255.
Elements 0..255 have values 0..255 respectively.
Is used by calculations that use rounding and can cause a value to become
less than 0 or greater than 255. By using 'Value := AICByteClip[Value]',
this value is clipped to the 0..255 range }
procedure AICError(const Msg: String);
{ Raise an exception of type EAICError }
implementation
procedure AICError(const Msg: String);
begin
raise EAICError.Create(Msg);
end;
procedure InitializeClipArray;
var
I: Integer;
begin
for I := Low(AICByteClip) to High(AICByteClip) do
if I < 0 then
AICByteClip[I] := 0
else if I > 255 then
AICByteClip[I] := 255
else
AICByteClip[I] := I;
end;
initialization
InitializeClipArray;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -