Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
libaec
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mathis Rosenhauer
libaec
Commits
7c60bf8e
Commit
7c60bf8e
authored
Oct 02, 2012
by
Mathis Rosenhauer
Committed by
Thomas Jahns
Feb 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib functions for simple buffer encoding/decoding
parent
58fe035a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
55 deletions
+96
-55
src/decode.c
src/decode.c
+13
-0
src/encode.c
src/encode.c
+15
-0
src/libaec.h
src/libaec.h
+51
-35
src/sz_compat.c
src/sz_compat.c
+11
-18
src/szlib.h
src/szlib.h
+6
-2
No files found.
src/decode.c
View file @
7c60bf8e
...
...
@@ -607,3 +607,16 @@ int aec_decode(struct aec_stream *strm, int flush)
req_buffer:
return
AEC_OK
;
}
int
aec_buf_decode
(
struct
aec_stream
*
strm
)
{
int
status
;
status
=
aec_decode_init
(
strm
);
if
(
status
!=
AEC_OK
)
return
status
;
status
=
aec_decode
(
strm
,
AEC_FLUSH
);
aec_decode_end
(
strm
);
return
status
;
}
src/encode.c
View file @
7c60bf8e
...
...
@@ -737,3 +737,18 @@ int aec_encode_end(struct aec_stream *strm)
free
(
state
);
return
AEC_OK
;
}
int
aec_buf_encode
(
struct
aec_stream
*
strm
)
{
int
status
;
status
=
aec_encode_init
(
strm
);
if
(
status
!=
AEC_OK
)
return
status
;
status
=
aec_encode
(
strm
,
AEC_FLUSH
);
if
(
strm
->
avail_in
>
0
||
strm
->
avail_out
==
0
)
status
=
AEC_DATA_ERROR
;
aec_encode_end
(
strm
);
return
status
;
}
src/libaec.h
View file @
7c60bf8e
...
...
@@ -7,30 +7,41 @@ struct internal_state;
struct
aec_stream
{
const
unsigned
char
*
next_in
;
size_t
avail_in
;
/* number of bytes available at
* next_in */
size_t
total_in
;
/* total number of input bytes read so
* far */
size_t
avail_in
;
/* number of bytes available at
* next_in
*/
size_t
total_in
;
/* total number of input bytes read so
* far
*/
unsigned
char
*
next_out
;
size_t
avail_out
;
/* remaining free space at next_out */
size_t
total_out
;
/* total number of bytes output so far */
int
bit_per_sample
;
/* resolution in bits per sample (n =
* 1,..., 32) */
int
block_size
;
/* block size in samples */
int
rsi
;
/* Reference sample interval, the number of
blocks between consecutive reference
samples. */
size_t
avail_out
;
/* remaining free space at next_out */
size_t
total_out
;
/* total number of bytes output so far */
int
bit_per_sample
;
/* resolution in bits per sample (n =
* 1, ..., 32)
*/
int
block_size
;
/* block size in samples */
int
rsi
;
/* Reference sample interval, the number
* of _blocks_ between consecutive
* reference samples (up to 4096).
*/
int
flags
;
struct
internal_state
*
state
;
};
/* Coder flags */
#define AEC_DATA_UNSIGNED 0
#define AEC_DATA_SIGNED 1
#define AEC_DATA_3BYTE 2
/* 24 bit samples coded in 3 bytes */
#define AEC_DATA_LSB 0
#define AEC_DATA_MSB 16
/* Sample data description flags */
#define AEC_DATA_UNSIGNED 0
/* Samples are unsigned integers (default) */
#define AEC_DATA_SIGNED 1
/* Samples are signed. Telling libaec
* this results in a slightly better
* compression ratio.
*/
#define AEC_DATA_3BYTE 2
/* 24 bit samples are coded in 3 bytes */
#define AEC_DATA_MSB 16
/* Samples are stored with their most
* significant bit first. This has
* nothing to do with the endianness
* of the host.
*/
#define AEC_DATA_LSB 0
/* Samples are stored LSB first (default) */
#define AEC_DATA_PREPROCESS 32
/* Set if preprocessor should be used */
/* Return codes of library functions */
...
...
@@ -41,27 +52,32 @@ struct aec_stream {
#define AEC_MEM_ERROR (-4)
/* Options for flushing */
#define AEC_NO_FLUSH 0
/* Do not enforce output flushing. More
* input may be provided with later
* calls. So far only relevant for
* encoding.
*/
#define AEC_FLUSH 1
/* Flush output and end encoding. The last
* call to aec_encode() must set AEC_FLUSH to
* drain all output.
*
* It is not possible to continue encoding
* of the same stream after it has been
* flushed because the last byte may be
* padded with fill bits.
*/
#define AEC_NO_FLUSH 0
/* Do not enforce output
* flushing. More input may be
* provided with later calls. So far
* only relevant for encoding.
*/
#define AEC_FLUSH 1
/* Flush output and end encoding. The
* last call to aec_encode() must set
* AEC_FLUSH to drain all output.
*
* It is not possible to continue
* encoding of the same stream after it
* has been flushed because the last byte
* may be padded with fill bits.
*/
/* Streaming encoding and decoding functions */
int
aec_encode_init
(
struct
aec_stream
*
strm
);
int
aec_encode
(
struct
aec_stream
*
strm
,
int
flush
);
int
aec_encode_end
(
struct
aec_stream
*
strm
);
int
aec_decode_init
(
struct
aec_stream
*
strm
);
int
aec_decode
(
struct
aec_stream
*
strm
,
int
flush
);
int
aec_decode_end
(
struct
aec_stream
*
strm
);
int
aec_encode_init
(
struct
aec_stream
*
strm
);
int
aec_
encode
(
struct
aec_stream
*
strm
,
int
flush
);
int
aec_
encode_end
(
struct
aec_stream
*
strm
);
/* Utility functions for encoding or decoding a memory buffer. */
int
aec_
buffer_encode
(
struct
aec_stream
*
strm
);
int
aec_
buffer_decode
(
struct
aec_stream
*
strm
);
#endif
/* LIBAEC_H */
src/sz_compat.c
View file @
7c60bf8e
#include <stdio.h>
#include <stddef.h>
#include "szlib.h"
#include "libaec.h"
int
SZ_BufftoBuffCompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
)
int
SZ_BufftoBuffCompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
)
{
int
status
;
struct
aec_stream
strm
;
...
...
@@ -16,21 +19,17 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen, const void *source, size_
strm
.
next_out
=
dest
;
strm
.
next_in
=
source
;
if
((
status
=
aec_encode_init
(
&
strm
))
!=
AEC_OK
)
return
status
;
if
((
status
=
aec_encode
(
&
strm
,
AEC_FLUSH
))
!=
AEC_OK
)
status
=
aec_buf_encode
(
&
strm
);
if
(
status
!=
AEC_OK
)
return
status
;
*
destLen
=
strm
.
total_out
;
if
((
status
=
aec_encode_end
(
&
strm
))
!=
AEC_OK
)
return
status
;
return
SZ_OK
;
}
int
SZ_BufftoBuffDecompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
)
int
SZ_BufftoBuffDecompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
)
{
int
status
;
struct
aec_stream
strm
;
...
...
@@ -44,16 +43,10 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, const void *source, siz
strm
.
next_out
=
dest
;
strm
.
next_in
=
source
;
if
((
status
=
aec_decode_init
(
&
strm
))
!=
AEC_OK
)
return
status
;
if
((
status
=
aec_decode
(
&
strm
,
AEC_FLUSH
))
!=
AEC_OK
)
status
=
aec_buf_decode
(
&
strm
);
if
(
status
!=
AEC_OK
)
return
status
;
*
destLen
=
strm
.
total_out
;
if
((
status
=
aec_decode_end
(
&
strm
))
!=
AEC_OK
)
return
status
;
return
SZ_OK
;
}
src/szlib.h
View file @
7c60bf8e
...
...
@@ -22,7 +22,11 @@ typedef struct SZ_com_t_s
int
pixels_per_scanline
;
}
SZ_com_t
;
int
SZ_BufftoBuffCompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
);
int
SZ_BufftoBuffDecompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
);
int
SZ_BufftoBuffCompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
);
int
SZ_BufftoBuffDecompress
(
void
*
dest
,
size_t
*
destLen
,
const
void
*
source
,
size_t
sourceLen
,
SZ_com_t
*
param
);
#endif
/* SZLIB_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment