Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
c0853697
Commit
c0853697
authored
Oct 18, 2012
by
Diego Biurrun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil/lzo: K&R formatting cosmetics
parent
c9ef4321
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
43 deletions
+53
-43
lzo.c
libavutil/lzo.c
+53
-43
No files found.
libavutil/lzo.c
View file @
c0853697
...
...
@@ -29,6 +29,7 @@
#define OUTBUF_PADDED 1
/// Define if we may read up to 8 bytes beyond the input buffer.
#define INBUF_PADDED 1
typedef
struct
LZOContext
{
const
uint8_t
*
in
,
*
in_end
;
uint8_t
*
out_start
,
*
out
,
*
out_end
;
...
...
@@ -39,7 +40,8 @@ typedef struct LZOContext {
* @brief Reads one byte from the input buffer, avoiding an overrun.
* @return byte read
*/
static
inline
int
get_byte
(
LZOContext
*
c
)
{
static
inline
int
get_byte
(
LZOContext
*
c
)
{
if
(
c
->
in
<
c
->
in_end
)
return
*
c
->
in
++
;
c
->
error
|=
AV_LZO_INPUT_DEPLETED
;
...
...
@@ -58,10 +60,12 @@ static inline int get_byte(LZOContext *c) {
* @param mask bits used from x
* @return decoded length value
*/
static
inline
int
get_len
(
LZOContext
*
c
,
int
x
,
int
mask
)
{
static
inline
int
get_len
(
LZOContext
*
c
,
int
x
,
int
mask
)
{
int
cnt
=
x
&
mask
;
if
(
!
cnt
)
{
while
(
!
(
x
=
get_byte
(
c
)))
cnt
+=
255
;
while
(
!
(
x
=
get_byte
(
c
)))
cnt
+=
255
;
cnt
+=
mask
+
x
;
}
return
cnt
;
...
...
@@ -84,7 +88,8 @@ static inline int get_len(LZOContext *c, int x, int mask) {
* @brief Copies bytes from input to output buffer with checking.
* @param cnt number of bytes to copy, must be >= 0
*/
static
inline
void
copy
(
LZOContext
*
c
,
int
cnt
)
{
static
inline
void
copy
(
LZOContext
*
c
,
int
cnt
)
{
register
const
uint8_t
*
src
=
c
->
in
;
register
uint8_t
*
dst
=
c
->
out
;
if
(
cnt
>
c
->
in_end
-
src
)
{
...
...
@@ -117,7 +122,8 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt);
* cnt > back is valid, this will copy the bytes we just copied,
* thus creating a repeating pattern with a period length of back.
*/
static
inline
void
copy_backptr
(
LZOContext
*
c
,
int
back
,
int
cnt
)
{
static
inline
void
copy_backptr
(
LZOContext
*
c
,
int
back
,
int
cnt
)
{
register
const
uint8_t
*
src
=
&
c
->
out
[
-
back
];
register
uint8_t
*
dst
=
c
->
out
;
if
(
src
<
c
->
out_start
||
src
>
dst
)
{
...
...
@@ -132,7 +138,8 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) {
c
->
out
=
dst
+
cnt
;
}
static
inline
void
memcpy_backptr
(
uint8_t
*
dst
,
int
back
,
int
cnt
)
{
static
inline
void
memcpy_backptr
(
uint8_t
*
dst
,
int
back
,
int
cnt
)
{
const
uint8_t
*
src
=
&
dst
[
-
back
];
if
(
back
==
1
)
{
memset
(
dst
,
*
src
,
cnt
);
...
...
@@ -166,12 +173,14 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) {
}
}
void
av_memcpy_backptr
(
uint8_t
*
dst
,
int
back
,
int
cnt
)
{
void
av_memcpy_backptr
(
uint8_t
*
dst
,
int
back
,
int
cnt
)
{
memcpy_backptr
(
dst
,
back
,
cnt
);
}
int
av_lzo1x_decode
(
void
*
out
,
int
*
outlen
,
const
void
*
in
,
int
*
inlen
)
{
int
state
=
0
;
int
av_lzo1x_decode
(
void
*
out
,
int
*
outlen
,
const
void
*
in
,
int
*
inlen
)
{
int
state
=
0
;
int
x
;
LZOContext
c
;
if
(
!*
outlen
||
!*
inlen
)
{
...
...
@@ -185,13 +194,14 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) {
c
.
in
=
in
;
c
.
in_end
=
(
const
uint8_t
*
)
in
+
*
inlen
;
c
.
out
=
c
.
out_start
=
out
;
c
.
out_end
=
(
uint8_t
*
)
out
+
*
outlen
;
c
.
out_end
=
(
uint8_t
*
)
out
+
*
outlen
;
c
.
error
=
0
;
x
=
GETB
(
c
);
if
(
x
>
17
)
{
copy
(
&
c
,
x
-
17
);
x
=
GETB
(
c
);
if
(
x
<
16
)
c
.
error
|=
AV_LZO_ERROR
;
if
(
x
<
16
)
c
.
error
|=
AV_LZO_ERROR
;
}
if
(
c
.
in
>
c
.
in_end
)
c
.
error
|=
AV_LZO_INPUT_DEPLETED
;
...
...
@@ -216,7 +226,7 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) {
break
;
}
}
}
else
if
(
!
state
)
{
}
else
if
(
!
state
)
{
cnt
=
get_len
(
&
c
,
x
,
15
);
copy
(
&
c
,
cnt
+
3
);
x
=
GETB
(
c
);
...
...
@@ -229,7 +239,7 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) {
back
=
(
GETB
(
c
)
<<
2
)
+
(
x
>>
2
)
+
1
;
}
copy_backptr
(
&
c
,
back
,
cnt
+
2
);
state
=
state
=
cnt
=
x
&
3
;
copy
(
&
c
,
cnt
);
x
=
GETB
(
c
);
...
...
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