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
b6c2c589
Commit
b6c2c589
authored
Dec 23, 2018
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/rangecoder: Add and test ff_rac_check_termination()
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
20b10ba8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
rangecoder.c
libavcodec/rangecoder.c
+19
-0
rangecoder.h
libavcodec/rangecoder.h
+9
-0
rangecoder.c
libavcodec/tests/rangecoder.c
+5
-2
No files found.
libavcodec/rangecoder.c
View file @
b6c2c589
...
...
@@ -121,3 +121,22 @@ int ff_rac_terminate(RangeCoder *c, int version)
return
c
->
bytestream
-
c
->
bytestream_start
;
}
int
ff_rac_check_termination
(
RangeCoder
*
c
,
int
version
)
{
if
(
version
==
1
)
{
RangeCoder
tmp
=
*
c
;
get_rac
(
c
,
(
uint8_t
[])
{
129
});
if
(
c
->
bytestream
==
tmp
.
bytestream
&&
c
->
bytestream
>
c
->
bytestream_start
)
tmp
.
low
-=
*--
tmp
.
bytestream
;
tmp
.
bytestream_end
=
tmp
.
bytestream
;
if
(
get_rac
(
&
tmp
,
(
uint8_t
[])
{
129
}))
return
AVERROR_INVALIDDATA
;
}
else
{
if
(
c
->
bytestream_end
!=
c
->
bytestream
)
return
AVERROR_INVALIDDATA
;
}
return
0
;
}
libavcodec/rangecoder.h
View file @
b6c2c589
...
...
@@ -57,6 +57,15 @@ void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size);
*/
int
ff_rac_terminate
(
RangeCoder
*
c
,
int
version
);
/**
* Check if at the current position there is a valid looking termination
* @param version version 0 requires the decoder to know the data size in bytes
* version 1 needs about 1 bit more space but does not need to
* carry the size from encoder to decoder
* @returns negative AVERROR code on error or non negative.
*/
int
ff_rac_check_termination
(
RangeCoder
*
c
,
int
version
);
void
ff_build_rac_states
(
RangeCoder
*
c
,
int
factor
,
int
max_p
);
static
inline
void
renorm_encoder
(
RangeCoder
*
c
)
...
...
libavcodec/tests/rangecoder.c
View file @
b6c2c589
...
...
@@ -60,8 +60,11 @@ int main(void)
av_log
(
NULL
,
AV_LOG_ERROR
,
"rac failure at %d pass %d version %d
\n
"
,
i
,
p
,
version
);
return
1
;
}
if
(
version
)
get_rac
(
&
c
,
(
uint8_t
[])
{
129
});
if
(
ff_rac_check_termination
(
&
c
,
version
)
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"rac failure at termination pass %d version %d
\n
"
,
p
,
version
);
return
1
;
}
if
(
c
.
bytestream
-
c
.
bytestream_start
-
actual_length
!=
version
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"rac failure at pass %d version %d
\n
"
,
p
,
version
);
return
1
;
...
...
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