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
7c3a8b05
Commit
7c3a8b05
authored
12 years ago
by
Mathis Rosenhauer
Committed by
Thomas Jahns
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
calculate uncompressed length only when it changes
parent
289d4f81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/encode.c
+18
-17
18 additions, 17 deletions
src/encode.c
src/encode.h
+1
-0
1 addition, 0 deletions
src/encode.h
with
19 additions
and
17 deletions
src/encode.c
+
18
−
17
View file @
7c3a8b05
...
@@ -235,6 +235,7 @@ static void preprocess_unsigned(struct aec_stream *strm)
...
@@ -235,6 +235,7 @@ static void preprocess_unsigned(struct aec_stream *strm)
x
++
;
x
++
;
}
}
state
->
ref
=
1
;
state
->
ref
=
1
;
state
->
uncomp_len
=
(
strm
->
block_size
-
1
)
*
strm
->
bits_per_sample
;
}
}
static
void
preprocess_signed
(
struct
aec_stream
*
strm
)
static
void
preprocess_signed
(
struct
aec_stream
*
strm
)
...
@@ -274,6 +275,7 @@ static void preprocess_signed(struct aec_stream *strm)
...
@@ -274,6 +275,7 @@ static void preprocess_signed(struct aec_stream *strm)
d
++
;
d
++
;
}
}
state
->
ref
=
1
;
state
->
ref
=
1
;
state
->
uncomp_len
=
(
strm
->
block_size
-
1
)
*
strm
->
bits_per_sample
;
}
}
static
uint64_t
block_fs
(
struct
aec_stream
*
strm
,
int
k
)
static
uint64_t
block_fs
(
struct
aec_stream
*
strm
,
int
k
)
...
@@ -312,7 +314,7 @@ static uint64_t block_fs(struct aec_stream *strm, int k)
...
@@ -312,7 +314,7 @@ static uint64_t block_fs(struct aec_stream *strm, int k)
return
fs
;
return
fs
;
}
}
static
int
assess_splitting_option
(
struct
aec_stream
*
strm
)
static
u
int
32_t
assess_splitting_option
(
struct
aec_stream
*
strm
)
{
{
/**
/**
Length of CDS encoded with splitting option and optimal k.
Length of CDS encoded with splitting option and optimal k.
...
@@ -395,17 +397,17 @@ static int assess_splitting_option(struct aec_stream *strm)
...
@@ -395,17 +397,17 @@ static int assess_splitting_option(struct aec_stream *strm)
return
len_min
;
return
len_min
;
}
}
static
int
assess_se_option
(
uint64_t
limit
,
struct
aec_stream
*
strm
)
static
u
int
32_t
assess_se_option
(
struct
aec_stream
*
strm
)
{
{
/**
/**
Length of CDS encoded with Second Extension option.
Length of CDS encoded with Second Extension option.
If length is above limit just return UINT
64
_MAX.
If length is above limit just return UINT
32
_MAX.
*/
*/
int
i
;
int
i
;
uint64_t
d
;
uint64_t
d
;
uint
64
_t
len
;
uint
32
_t
len
;
struct
internal_state
*
state
=
strm
->
state
;
struct
internal_state
*
state
=
strm
->
state
;
len
=
1
;
len
=
1
;
...
@@ -414,12 +416,11 @@ static int assess_se_option(uint64_t limit, struct aec_stream *strm)
...
@@ -414,12 +416,11 @@ static int assess_se_option(uint64_t limit, struct aec_stream *strm)
d
=
(
uint64_t
)
state
->
block
[
i
]
d
=
(
uint64_t
)
state
->
block
[
i
]
+
(
uint64_t
)
state
->
block
[
i
+
1
];
+
(
uint64_t
)
state
->
block
[
i
+
1
];
/* we have to worry about overflow here */
/* we have to worry about overflow here */
if
(
d
>
limit
)
{
if
(
d
>
state
->
uncomp_len
)
{
len
=
UINT
64
_MAX
;
len
=
UINT
32
_MAX
;
break
;
break
;
}
else
{
}
else
{
len
+=
d
*
(
d
+
1
)
/
2
len
+=
d
*
(
d
+
1
)
/
2
+
state
->
block
[
i
+
1
];
+
(
uint64_t
)
state
->
block
[
i
+
1
];
}
}
}
}
return
len
;
return
len
;
...
@@ -578,23 +579,20 @@ static int m_select_code_option(struct aec_stream *strm)
...
@@ -578,23 +579,20 @@ static int m_select_code_option(struct aec_stream *strm)
Decide which code option to use.
Decide which code option to use.
*/
*/
uint64_t
uncomp_len
;
uint32_t
split_len
;
uint64_t
split_len
;
uint32_t
se_len
;
uint64_t
se_len
;
struct
internal_state
*
state
=
strm
->
state
;
struct
internal_state
*
state
=
strm
->
state
;
uncomp_len
=
(
strm
->
block_size
-
state
->
ref
)
*
strm
->
bits_per_sample
;
split_len
=
assess_splitting_option
(
strm
);
split_len
=
assess_splitting_option
(
strm
);
se_len
=
assess_se_option
(
split_len
,
strm
);
se_len
=
assess_se_option
(
strm
);
if
(
split_len
<
uncomp_len
)
{
if
(
split_len
<
state
->
uncomp_len
)
{
if
(
split_len
<
se_len
)
if
(
split_len
<
se_len
)
return
m_encode_splitting
(
strm
);
return
m_encode_splitting
(
strm
);
else
else
return
m_encode_se
(
strm
);
return
m_encode_se
(
strm
);
}
else
{
}
else
{
if
(
uncomp_len
<=
se_len
)
if
(
state
->
uncomp_len
<=
se_len
)
return
m_encode_uncomp
(
strm
);
return
m_encode_uncomp
(
strm
);
else
else
return
m_encode_se
(
strm
);
return
m_encode_se
(
strm
);
...
@@ -723,7 +721,10 @@ static int m_get_block(struct aec_stream *strm)
...
@@ -723,7 +721,10 @@ static int m_get_block(struct aec_stream *strm)
state
->
mode
=
m_get_rsi_resumable
;
state
->
mode
=
m_get_rsi_resumable
;
}
}
}
else
{
}
else
{
state
->
ref
=
0
;
if
(
state
->
ref
)
{
state
->
ref
=
0
;
state
->
uncomp_len
=
strm
->
block_size
*
strm
->
bits_per_sample
;
}
state
->
block
+=
strm
->
block_size
;
state
->
block
+=
strm
->
block_size
;
state
->
blocks_avail
--
;
state
->
blocks_avail
--
;
return
m_check_zero_block
(
strm
);
return
m_check_zero_block
(
strm
);
...
...
This diff is collapsed.
Click to expand it.
src/encode.h
+
1
−
0
View file @
7c3a8b05
...
@@ -101,6 +101,7 @@ struct internal_state {
...
@@ -101,6 +101,7 @@ struct internal_state {
int
k
;
/* splitting position */
int
k
;
/* splitting position */
int
kmax
;
/* maximum number for k depending on id_len */
int
kmax
;
/* maximum number for k depending on id_len */
int
flush
;
/* flush option copied from argument */
int
flush
;
/* flush option copied from argument */
uint32_t
uncomp_len
;
/* length of uncompressed CDS */
};
};
#endif
/* ENCODE_H */
#endif
/* ENCODE_H */
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