Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
dav1d
Commits
b4e6377a
Commit
b4e6377a
authored
Feb 08, 2019
by
Vittorio Giovara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_bits: Factor out leb parsing to dav1d_get_uleb128()
parent
c45f6b37
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
10 deletions
+24
-10
src/getbits.c
src/getbits.c
+21
-0
src/getbits.h
src/getbits.h
+1
-0
src/obu.c
src/obu.c
+2
-10
No files found.
src/getbits.c
View file @
b4e6377a
...
...
@@ -79,6 +79,27 @@ int dav1d_get_sbits(GetBits *const c, const unsigned n) {
return
res
>>
shift
;
}
unsigned
dav1d_get_uleb128
(
GetBits
*
c
)
{
unsigned
val
=
0
,
more
,
i
=
0
;
do
{
more
=
dav1d_get_bits
(
c
,
1
);
unsigned
bits
=
dav1d_get_bits
(
c
,
7
);
if
(
i
<=
3
||
(
i
==
4
&&
bits
<
(
1
<<
4
)))
val
|=
bits
<<
(
i
*
7
);
else
if
(
bits
)
{
c
->
error
=
1
;
return
0
;
}
if
(
more
&&
++
i
==
8
)
{
c
->
error
=
1
;
return
0
;
}
}
while
(
more
);
return
val
;
}
unsigned
dav1d_get_uniform
(
GetBits
*
const
c
,
const
unsigned
max
)
{
// Output in range [0..max-1]
// max must be > 1, or else nothing is read from the bitstream
...
...
src/getbits.h
View file @
b4e6377a
...
...
@@ -41,6 +41,7 @@ typedef struct GetBits {
void
dav1d_init_get_bits
(
GetBits
*
c
,
const
uint8_t
*
data
,
size_t
sz
);
unsigned
dav1d_get_bits
(
GetBits
*
c
,
unsigned
n
);
int
dav1d_get_sbits
(
GetBits
*
c
,
unsigned
n
);
unsigned
dav1d_get_uleb128
(
GetBits
*
c
);
// Output in range 0..max-1
unsigned
dav1d_get_uniform
(
GetBits
*
c
,
unsigned
max
);
...
...
src/obu.c
View file @
b4e6377a
...
...
@@ -1187,17 +1187,9 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, int global) {
}
// obu length field
unsigned
len
=
0
,
more
,
i
=
0
;
unsigned
len
=
0
;
if
(
has_length_field
)
do
{
more
=
dav1d_get_bits
(
&
gb
,
1
);
unsigned
bits
=
dav1d_get_bits
(
&
gb
,
7
);
if
(
i
<=
3
||
(
i
==
4
&&
bits
<
(
1
<<
4
)))
len
|=
bits
<<
(
i
*
7
);
else
if
(
bits
)
goto
error
;
if
(
more
&&
++
i
==
8
)
goto
error
;
}
while
(
more
);
len
=
dav1d_get_uleb128
(
&
gb
);
else
len
=
(
int
)
in
->
sz
-
1
-
has_extension
;
if
(
gb
.
error
)
goto
error
;
...
...
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