Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
libaec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Mathis Rosenhauer
libaec
Commits
4f989501
Commit
4f989501
authored
12 years ago
by
Mathis Rosenhauer
Committed by
Thomas Jahns
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Interleaving for 32 and 64 bit in sz compatibility
parent
51bf2653
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sz_compat.c
+60
-5
60 additions, 5 deletions
src/sz_compat.c
src/test_szcomp.c
+8
-4
8 additions, 4 deletions
src/test_szcomp.c
with
68 additions
and
9 deletions
src/sz_compat.c
+
60
−
5
View file @
4f989501
#include
<stdio.h>
#include
<stddef.h>
#include
<string.h>
#include
<stdlib.h>
#include
"szlib.h"
#include
"libaec.h"
...
...
@@ -21,26 +23,62 @@ static int convert_options(int sz_opts)
return
opts
;
}
static
void
interleave_buffer
(
unsigned
char
*
dest
,
unsigned
char
*
src
,
size_t
n
,
int
wordsize
)
{
size_t
i
,
j
;
for
(
i
=
0
;
i
<
n
/
wordsize
;
i
++
)
for
(
j
=
0
;
j
<
wordsize
;
j
++
)
dest
[
j
*
(
n
/
wordsize
)
+
i
]
=
src
[
i
*
wordsize
+
j
];
}
static
void
deinterleave_buffer
(
unsigned
char
*
dest
,
unsigned
char
*
src
,
size_t
n
,
int
wordsize
)
{
size_t
i
,
j
;
for
(
i
=
0
;
i
<
n
/
wordsize
;
i
++
)
for
(
j
=
0
;
j
<
wordsize
;
j
++
)
dest
[
i
*
wordsize
+
j
]
=
src
[
j
*
(
n
/
wordsize
)
+
i
];
}
int
SZ_BufftoBuffCompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
)
{
int
status
;
struct
aec_stream
strm
;
unsigned
char
*
buf
;
if
(
param
->
bits_per_pixel
==
32
||
param
->
bits_per_pixel
==
64
)
{
buf
=
(
unsigned
char
*
)
malloc
(
sourceLen
);
if
(
buf
==
NULL
)
return
SZ_MEM_ERROR
;
interleave_buffer
(
buf
,
source
,
sourceLen
,
param
->
bits_per_pixel
/
8
);
strm
.
bit_per_sample
=
8
;
strm
.
next_in
=
buf
;
}
else
{
strm
.
next_in
=
source
;
strm
.
bit_per_sample
=
param
->
bits_per_pixel
;
}
strm
.
bit_per_sample
=
param
->
bits_per_pixel
;
strm
.
avail_in
=
sourceLen
;
strm
.
block_size
=
param
->
pixels_per_block
;
strm
.
rsi
=
param
->
pixels_per_scanline
/
param
->
pixels_per_block
;
strm
.
flags
=
convert_options
(
param
->
options_mask
);
strm
.
avail_in
=
sourceLen
;
strm
.
avail_out
=
*
destLen
;
strm
.
next_out
=
dest
;
strm
.
next_in
=
source
;
status
=
aec_buffer_encode
(
&
strm
);
if
(
status
!=
AEC_OK
)
return
status
;
if
(
param
->
bits_per_pixel
==
32
||
param
->
bits_per_pixel
==
64
)
{
free
(
buf
);
}
*
destLen
=
strm
.
total_out
;
return
SZ_OK
;
}
...
...
@@ -51,14 +89,25 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
{
int
status
;
struct
aec_stream
strm
;
unsigned
char
*
buf
;
if
(
param
->
bits_per_pixel
==
32
||
param
->
bits_per_pixel
==
64
)
{
buf
=
(
unsigned
char
*
)
malloc
(
*
destLen
);
if
(
buf
==
NULL
)
return
SZ_MEM_ERROR
;
strm
.
bit_per_sample
=
8
;
strm
.
next_out
=
buf
;
}
else
{
strm
.
next_out
=
dest
;
strm
.
bit_per_sample
=
param
->
bits_per_pixel
;
}
strm
.
bit_per_sample
=
param
->
bits_per_pixel
;
strm
.
block_size
=
param
->
pixels_per_block
;
strm
.
rsi
=
param
->
pixels_per_scanline
/
param
->
pixels_per_block
;
strm
.
flags
=
convert_options
(
param
->
options_mask
);
strm
.
avail_in
=
sourceLen
;
strm
.
avail_out
=
*
destLen
;
strm
.
next_out
=
dest
;
strm
.
next_in
=
source
;
status
=
aec_buffer_decode
(
&
strm
);
...
...
@@ -66,6 +115,12 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
return
status
;
*
destLen
=
strm
.
total_out
;
if
(
param
->
bits_per_pixel
==
32
||
param
->
bits_per_pixel
==
64
)
{
deinterleave_buffer
(
dest
,
buf
,
*
destLen
,
param
->
bits_per_pixel
/
8
);
free
(
buf
);
}
return
SZ_OK
;
}
...
...
This diff is collapsed.
Click to expand it.
src/test_szcomp.c
+
8
−
4
View file @
4f989501
...
...
@@ -4,7 +4,9 @@
#include
<string.h>
#include
"szlib.h"
#define OPTIONS_MASK (SZ_RAW_OPTION_MASK | SZ_MSB_OPTION_MASK | SZ_NN_OPTION_MASK)
#define OPTIONS_MASK (SZ_RAW_OPTION_MASK \
| SZ_MSB_OPTION_MASK \
| SZ_NN_OPTION_MASK)
#define PIXELS_PER_BLOCK (8)
#define PIXELS_PER_SCANLINE (PIXELS_PER_BLOCK*128)
...
...
@@ -22,7 +24,7 @@ int main(int argc, char *argv[])
return
1
;
}
sz_param
.
options_mask
=
OPTIONS_MASK
;
sz_param
.
bits_per_pixel
=
1
6
;
sz_param
.
bits_per_pixel
=
6
4
;
sz_param
.
pixels_per_block
=
PIXELS_PER_BLOCK
;
sz_param
.
pixels_per_scanline
=
PIXELS_PER_SCANLINE
;
...
...
@@ -43,12 +45,14 @@ int main(int argc, char *argv[])
sourceLen
=
fread
(
source
,
1
,
sourceLen
,
fp
);
status
=
SZ_BufftoBuffCompress
(
dest
,
&
destLen
,
source
,
sourceLen
,
&
sz_param
);
status
=
SZ_BufftoBuffCompress
(
dest
,
&
destLen
,
source
,
sourceLen
,
&
sz_param
);
if
(
status
!=
SZ_OK
)
return
status
;
dest1Len
=
sourceLen
;
status
=
SZ_BufftoBuffDecompress
(
dest1
,
&
dest1Len
,
dest
,
destLen
,
&
sz_param
);
status
=
SZ_BufftoBuffDecompress
(
dest1
,
&
dest1Len
,
dest
,
destLen
,
&
sz_param
);
if
(
status
!=
SZ_OK
)
return
status
;
...
...
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