mirror of
https://github.com/team-charls/charls
synced 2025-03-28 21:03:13 +00:00
Misc refactorings
This commit is contained in:
parent
153bb8bb8f
commit
19d1093fde
208
CharLS.vcproj
208
CharLS.vcproj
@ -108,102 +108,6 @@
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
|
||||
UseOfMFC="0"
|
||||
UseOfATL="0"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
EnableFiberSafeOptimizations="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;JPEGLS_EXPORTS"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="0"
|
||||
StructMemberAlignment="0"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="false"
|
||||
DisableLanguageExtensions="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
CallingConvention="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/charls.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
OptimizeForWindows98="0"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/CharLS.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
@ -294,6 +198,102 @@
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
|
||||
UseOfMFC="0"
|
||||
UseOfATL="0"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
EnableFiberSafeOptimizations="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;JPEGLS_EXPORTS"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="0"
|
||||
StructMemberAlignment="0"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="false"
|
||||
DisableLanguageExtensions="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
CallingConvention="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/charls.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
OptimizeForWindows98="0"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/CharLS.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
@ -418,6 +418,14 @@
|
||||
EnableIntrinsicFunctions="true"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
EnableIntrinsicFunctions="true"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
@ -431,14 +439,6 @@
|
||||
EnableFunctionLevelLinking="false"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
EnableIntrinsicFunctions="true"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
|
13
header.cpp
13
header.cpp
@ -9,6 +9,19 @@
|
||||
#include "encoderstrategy.h"
|
||||
#include <memory>
|
||||
|
||||
//
|
||||
//DRI: Define Restart Interval:
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// - $ff, $dd (DRI)
|
||||
// - length (high byte, low byte), must be = 4
|
||||
// - restart interval (high byte, low byte) in units of MCU blocks,
|
||||
// meaning that every n MCU blocks a RSTn marker can be found.
|
||||
// The first marker will be RST0, then RST1 etc, after RST7
|
||||
// repeating from RST0.
|
||||
|
||||
|
||||
|
||||
|
||||
bool IsDefault(const JlsCustomParameters* pcustom)
|
||||
{
|
||||
|
21
scan.h
21
scan.h
@ -190,8 +190,8 @@ public:
|
||||
void EncodeRunPixels(LONG runLength, bool bEndofline);
|
||||
LONG DoRunMode(LONG ipixel, EncoderStrategy*);
|
||||
|
||||
inlinehint void DoRegular(LONG Qs, SAMPLE&, LONG pred, DecoderStrategy*);
|
||||
inlinehint void DoRegular(LONG Qs, SAMPLE& x, LONG pred, EncoderStrategy*);
|
||||
inlinehint SAMPLE DoRegular(LONG Qs, LONG, LONG pred, DecoderStrategy*);
|
||||
inlinehint SAMPLE DoRegular(LONG Qs, LONG x, LONG pred, EncoderStrategy*);
|
||||
|
||||
void DoLine(SAMPLE* pdummy);
|
||||
void DoLine(Triplet* pdummy);
|
||||
@ -232,7 +232,7 @@ protected:
|
||||
|
||||
|
||||
template<class TRAITS, class STRATEGY>
|
||||
typename void JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, SAMPLE& x, LONG pred, DecoderStrategy*)
|
||||
typename TRAITS::SAMPLE JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, LONG, LONG pred, DecoderStrategy*)
|
||||
{
|
||||
LONG sign = BitWiseSign(Qs);
|
||||
JlsContext& ctx = _contexts[ApplySign(Qs, sign)];
|
||||
@ -255,12 +255,12 @@ typename void JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, SAMPLE& x, LONG pred
|
||||
}
|
||||
ErrVal = ErrVal ^ ((traits.NEAR == 0) ? ctx.GetErrorCorrection(k) : 0);
|
||||
ctx.UpdateVariables(ErrVal, traits.NEAR, traits.RESET);
|
||||
x = traits.ComputeReconstructedSample(Px, ApplySign(ErrVal, sign));
|
||||
return traits.ComputeReconstructedSample(Px, ApplySign(ErrVal, sign));
|
||||
}
|
||||
|
||||
|
||||
template<class TRAITS, class STRATEGY>
|
||||
typename void JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, SAMPLE& x, LONG pred, EncoderStrategy*)
|
||||
typename TRAITS::SAMPLE JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, LONG x, LONG pred, EncoderStrategy*)
|
||||
{
|
||||
LONG sign = BitWiseSign(Qs);
|
||||
JlsContext& ctx = _contexts[ApplySign(Qs, sign)];
|
||||
@ -272,7 +272,7 @@ typename void JlsCodec<TRAITS,STRATEGY>::DoRegular(LONG Qs, SAMPLE& x, LONG pred
|
||||
EncodeMappedValue(k, GetMappedErrVal(ctx.GetErrorCorrection(k | traits.NEAR) ^ ErrVal), traits.LIMIT);
|
||||
ctx.UpdateVariables(ErrVal, traits.NEAR, traits.RESET);
|
||||
ASSERT(traits.IsNear(traits.ComputeReconstructedSample(Px, ApplySign(ErrVal, sign)), x));
|
||||
x = static_cast<SAMPLE>(traits.ComputeReconstructedSample(Px, ApplySign(ErrVal, sign)));
|
||||
return static_cast<SAMPLE>(traits.ComputeReconstructedSample(Px, ApplySign(ErrVal, sign)));
|
||||
}
|
||||
|
||||
|
||||
@ -662,7 +662,7 @@ void JlsCodec<TRAITS,STRATEGY>::DoLine(SAMPLE*)
|
||||
}
|
||||
else
|
||||
{
|
||||
DoRegular(Qs, ptypeCur[ipixel], GetPredictedValue(Ra, Rb, Rc), (STRATEGY*)(NULL));
|
||||
ptypeCur[ipixel] = DoRegular(Qs, ptypeCur[ipixel], GetPredictedValue(Ra, Rb, Rc), (STRATEGY*)(NULL));
|
||||
ipixel++;
|
||||
}
|
||||
}
|
||||
@ -692,9 +692,10 @@ void JlsCodec<TRAITS,STRATEGY>::DoLine(Triplet*)
|
||||
else
|
||||
{
|
||||
Triplet Rx;
|
||||
DoRegular(Qs1, ptypeCur[ipixel].v1, GetPredictedValue(Ra.v1, Rb.v1, Rc.v1), (STRATEGY*)(NULL));
|
||||
DoRegular(Qs2, ptypeCur[ipixel].v2, GetPredictedValue(Ra.v2, Rb.v2, Rc.v2), (STRATEGY*)(NULL));
|
||||
DoRegular(Qs3, ptypeCur[ipixel].v3, GetPredictedValue(Ra.v3, Rb.v3, Rc.v3), (STRATEGY*)(NULL));
|
||||
Rx.v1 = DoRegular(Qs1, ptypeCur[ipixel].v1, GetPredictedValue(Ra.v1, Rb.v1, Rc.v1), (STRATEGY*)(NULL));
|
||||
Rx.v2 = DoRegular(Qs2, ptypeCur[ipixel].v2, GetPredictedValue(Ra.v2, Rb.v2, Rc.v2), (STRATEGY*)(NULL));
|
||||
Rx.v3 = DoRegular(Qs3, ptypeCur[ipixel].v3, GetPredictedValue(Ra.v3, Rb.v3, Rc.v3), (STRATEGY*)(NULL));
|
||||
ptypeCur[ipixel] = Rx;
|
||||
ipixel++;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ void ReadFile(SZC strName, std::vector<BYTE>* pvec, int ioffs = 0)
|
||||
fprintf( stderr, "Could not open %s\n", strName );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
fseek(pfile, 0, SEEK_END);
|
||||
int cbyteFile = ftell(pfile);
|
||||
fseek(pfile, ioffs, SEEK_SET);
|
||||
@ -88,7 +90,7 @@ void SwapBytes(std::vector<BYTE>* rgbyte)
|
||||
|
||||
}
|
||||
|
||||
void TestRoundTrip(const char* strName, const BYTE* rgbyteRaw, Size size, int cbit, int ccomp)
|
||||
void TestRoundTrip(const char* strName, std::vector<BYTE>& rgbyteRaw, Size size, int cbit, int ccomp)
|
||||
{
|
||||
std::vector<BYTE> rgbyteCompressed;
|
||||
rgbyteCompressed.resize(size.cx *size.cy * 4);
|
||||
@ -106,7 +108,7 @@ void TestRoundTrip(const char* strName, const BYTE* rgbyteRaw, Size size, int cb
|
||||
params.ilv = ccomp == 3 ? ILV_SAMPLE : ILV_NONE;
|
||||
|
||||
size_t cbyteCompressed;
|
||||
JpegLsEncode(&rgbyteCompressed[0], rgbyteCompressed.size(), &cbyteCompressed, rgbyteRaw, rgbyteOut.size(), ¶ms);
|
||||
JpegLsEncode(&rgbyteCompressed[0], rgbyteCompressed.size(), &cbyteCompressed, &rgbyteRaw[0], rgbyteOut.size(), ¶ms);
|
||||
|
||||
double dwtimeEncodeComplete = getTime();
|
||||
|
||||
@ -174,7 +176,8 @@ void TestFile(SZC strName, int ioffs, Size size2, int cbit, int ccomp)
|
||||
|
||||
ReadFile(strName, &rgbyteUncompressed, ioffs);
|
||||
|
||||
TestRoundTrip(strName, &rgbyteUncompressed[0], size2, cbit, ccomp);
|
||||
|
||||
TestRoundTrip(strName, rgbyteUncompressed, size2, cbit, ccomp);
|
||||
|
||||
};
|
||||
|
||||
@ -238,7 +241,11 @@ void TestPerformance()
|
||||
Size size1024 = Size(1024, 1024);
|
||||
Size size512 = Size(512, 512);
|
||||
|
||||
// TestFile("test/mars/phoenixmars.ppm", 40, Size(5300,4300), 8, 3);
|
||||
|
||||
// TestFile("test/rgb8bit/artificial.ppm", 17, Size(3072,2048), 8, 3);
|
||||
// TestFile("test/rgb8bit/bridge.ppm", 17, Size(2749,4049), 8, 3);
|
||||
// TestFile("test/rgb8bit/big_building.ppm", 17, Size(7216,5412), 8, 3);
|
||||
|
||||
TestFile("test/desktop.ppm", 40, Size(1280,1024), 8, 3);
|
||||
TestFile("test/MR2_UNC", 1728, size1024, 16, 1);
|
||||
TestFile("test/0015.raw", 0, size1024, 8, 1);
|
||||
@ -263,7 +270,7 @@ void TestNoiseImage()
|
||||
}
|
||||
}
|
||||
|
||||
TestRoundTrip("noise", &rgbyteNoise[0], size2, 7, 1);
|
||||
TestRoundTrip("noise", rgbyteNoise, size2, 7, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -307,6 +314,47 @@ void DecompressFile(SZC strNameEncoded, SZC strNameRaw, int ioffs)
|
||||
}
|
||||
|
||||
|
||||
BYTE palettisedDataH10[] = {
|
||||
0xFF, 0xD8, //Start of image (SOI) marker
|
||||
0xFF, 0xF7, //Start of JPEG-LS frame (SOF 55) marker – marker segment follows
|
||||
0x00, 0x0B, //Length of marker segment = 11 bytes including the length field
|
||||
0x02, //P = Precision = 2 bits per sample
|
||||
0x00, 0x04, //Y = Number of lines = 4
|
||||
0x00, 0x03, //X = Number of columns = 3
|
||||
0x01, //Nf = Number of components in the frame = 1
|
||||
0x01, //C1 = Component ID = 1 (first and only component)
|
||||
0x11, //Sub-sampling: H1 = 1, V1 = 1
|
||||
0x00, //Tq1 = 0 (this field is always 0)
|
||||
|
||||
0xFF, 0xF8, //LSE – JPEG-LS preset parameters marker
|
||||
0x00, 0x11, //Length of marker segment = 17 bytes including the length field
|
||||
0x02, //ID = 2, mapping table
|
||||
0x05, //TID = 5 Table identifier (arbitrary)
|
||||
0x03, //Wt = 3 Width of table entry
|
||||
0xFF, 0xFF, 0xFF, //Entry for index 0
|
||||
0xFF, 0x00, 0x00, //Entry for index 1
|
||||
0x00, 0xFF, 0x00, //Entry for index 2
|
||||
0x00, 0x00, 0xFF, //Entry for index 3
|
||||
|
||||
0xFF, 0xDA, //Start of scan (SOS) marker
|
||||
0x00, 0x08, //Length of marker segment = 8 bytes including the length field
|
||||
0x01, //Ns = Number of components for this scan = 1
|
||||
0x01, //C1 = Component ID = 1
|
||||
0x05, //Tm 1 = Mapping table identifier = 5
|
||||
0x00, //NEAR = 0 (near-lossless max error)
|
||||
0x00, //ILV = 0 (interleave mode = non-interleaved)
|
||||
0x00, //Al = 0, Ah = 0 (no point transform)
|
||||
0xDB, 0x95, 0xF0, //3 bytes of compressed image data
|
||||
0xFF, 0xD9 //End of image (EOI) marker
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const BYTE rgbyte[] = { 0, 0, 90, 74,
|
||||
68, 50, 43, 205,
|
||||
|
Loading…
x
Reference in New Issue
Block a user