Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QcmpCompressionLibrary
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
QcmpCompressionLibrary
Commits
6e2eceac
Commit
6e2eceac
authored
4 years ago
by
Vojtech Moravec
Browse files
Options
Downloads
Patches
Plain Diff
Debugging the new huffman code.
parent
9beec742
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/cz/it4i/qcmp/cli/functions/DebugFunction.java
+35
-18
35 additions, 18 deletions
src/main/java/cz/it4i/qcmp/cli/functions/DebugFunction.java
with
35 additions
and
18 deletions
src/main/java/cz/it4i/qcmp/cli/functions/DebugFunction.java
+
35
−
18
View file @
6e2eceac
package
cz.it4i.qcmp.cli.functions
;
import
cz.it4i.qcmp.cache.QuantizationCacheManager
;
import
cz.it4i.qcmp.cache.VQCacheFile
;
import
cz.it4i.qcmp.cli.CompressionOptionsCLIParser
;
import
cz.it4i.qcmp.cli.CustomFunctionBase
;
import
cz.it4i.qcmp.data.HyperStackDimensions
;
import
cz.it4i.qcmp.io.RawDataIO
;
import
cz.it4i.qcmp.io.loader.IPlaneLoader
;
import
cz.it4i.qcmp.io.loader.PlaneLoaderFactory
;
import
cz.it4i.qcmp.huffman.Huffman
;
import
cz.it4i.qcmp.huffman.HuffmanNode
;
import
cz.it4i.qcmp.io.InBitStream
;
import
cz.it4i.qcmp.io.OutBitStream
;
import
cz.it4i.qcmp.quantization.vector.VQCodebook
;
import
cz.it4i.qcmp.utilities.Utils
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
@SuppressWarnings
(
"ConstantConditions"
)
public
class
DebugFunction
extends
CustomFunctionBase
{
/**
* Base constructor with parsed CLI options.
...
...
@@ -22,27 +28,38 @@ public class DebugFunction extends CustomFunctionBase {
@Override
public
boolean
run
()
{
final
IPlaneLoader
loader
;
try
{
loader
=
PlaneLoaderFactory
.
getPlaneLoaderForInputFile
(
options
.
getInputDataInfo
());
}
catch
(
final
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
final
HyperStackDimensions
dims
=
options
.
getInputDataInfo
().
getDimensions
();
final
int
planeSize
=
Utils
.
multiplyExact
(
dims
.
getWidth
(),
dims
.
getHeight
());
final
int
sliceSize
=
Utils
.
multiplyExact
(
planeSize
,
dims
.
getNumberOfTimepoints
());
try
{
final
VQCodebook
codebook
=
((
VQCacheFile
)
QuantizationCacheManager
.
readCacheFile
(
"D:\\tmp\\codebook.qvc"
)).
getCodebook
();
for
(
int
t
=
12
;
t
<
15
;
t
++)
{
final
int
[]
symbols
=
new
int
[
codebook
.
getCodebookSize
()];
for
(
int
i
=
0
;
i
<
codebook
.
getCodebookSize
();
i
++)
{
symbols
[
i
]
=
i
;
}
RawDataIO
.
write
(
String
.
format
(
"slice_t%d.raw"
,
t
),
loader
.
loadAllPlanesU16Data
(
t
),
false
);
}
final
Huffman
huffman
=
new
Huffman
(
symbols
,
codebook
.
getVectorFrequencies
());
huffman
.
buildHuffmanTree
();
final
int
bitsPerSymbol
=
(
int
)
Utils
.
log2
(
codebook
.
getCodebookSize
());
try
(
final
OutBitStream
bitStream
=
new
OutBitStream
(
new
FileOutputStream
(
"D:\\tmp\\huffman_tree.data"
,
false
),
bitsPerSymbol
,
64
))
{
huffman
.
saveHuffmanTree
(
bitStream
);
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
}
HuffmanNode
readRoot
=
null
;
try
(
final
InBitStream
inBitStream
=
new
InBitStream
(
new
FileInputStream
(
"D:\\tmp\\huffman_tree.data"
),
bitsPerSymbol
,
256
))
{
readRoot
=
Huffman
.
readHuffmanTree
(
inBitStream
);
}
catch
(
final
IOException
ex
)
{
ex
.
printStackTrace
();
}
final
boolean
equal
=
huffman
.
getRoot
().
treeEqual
(
readRoot
);
System
.
out
.
println
(
readRoot
!=
null
);
return
true
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment