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
9305bdc6
Commit
9305bdc6
authored
Aug 30, 2018
by
James Almer
Committed by
Paul B Mahol
Aug 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/get_bits: actually make cached reader correctly disabled
parent
6b1b5af0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
25 deletions
+29
-25
get_bits.h
libavcodec/get_bits.h
+22
-18
golomb.h
libavcodec/golomb.h
+7
-7
No files found.
libavcodec/get_bits.h
View file @
9305bdc6
...
...
@@ -54,9 +54,13 @@
#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
#endif
#ifndef CACHED_BITSTREAM_READER
#define CACHED_BITSTREAM_READER 0
#endif
typedef
struct
GetBitContext
{
const
uint8_t
*
buffer
,
*
buffer_end
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
uint64_t
cache
;
unsigned
bits_left
;
#endif
...
...
@@ -116,7 +120,7 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
* For examples see get_bits, show_bits, skip_bits, get_vlc.
*/
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
# define MIN_CACHE_BITS 64
#elif defined LONG_BITSTREAM_READER
# define MIN_CACHE_BITS 32
...
...
@@ -124,7 +128,7 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
# define MIN_CACHE_BITS 25
#endif
#if
ndef
CACHED_BITSTREAM_READER
#if
!
CACHED_BITSTREAM_READER
#define OPEN_READER_NOSIZE(name, gb) \
unsigned int name ## _index = (gb)->index; \
...
...
@@ -214,14 +218,14 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
static
inline
int
get_bits_count
(
const
GetBitContext
*
s
)
{
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
return
s
->
index
-
s
->
bits_left
;
#else
return
s
->
index
;
#endif
}
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
static
inline
void
refill_32
(
GetBitContext
*
s
)
{
#if !UNCHECKED_BITSTREAM_READER
...
...
@@ -288,7 +292,7 @@ static inline unsigned show_val(const GetBitContext *s, unsigned n)
*/
static
inline
void
skip_bits_long
(
GetBitContext
*
s
,
int
n
)
{
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
skip_bits
(
s
,
n
);
#else
#if UNCHECKED_BITSTREAM_READER
...
...
@@ -299,7 +303,7 @@ static inline void skip_bits_long(GetBitContext *s, int n)
#endif
}
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
static
inline
void
skip_remaining
(
GetBitContext
*
s
,
unsigned
n
)
{
#ifdef BITSTREAM_READER_LE
...
...
@@ -318,7 +322,7 @@ static inline void skip_remaining(GetBitContext *s, unsigned n)
*/
static
inline
int
get_xbits
(
GetBitContext
*
s
,
int
n
)
{
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
int32_t
cache
=
show_bits
(
s
,
32
);
int
sign
=
~
cache
>>
31
;
skip_remaining
(
s
,
n
);
...
...
@@ -338,7 +342,7 @@ static inline int get_xbits(GetBitContext *s, int n)
#endif
}
#if
ndef
CACHED_BITSTREAM_READER
#if
!
CACHED_BITSTREAM_READER
static
inline
int
get_xbits_le
(
GetBitContext
*
s
,
int
n
)
{
register
int
sign
;
...
...
@@ -357,7 +361,7 @@ static inline int get_xbits_le(GetBitContext *s, int n)
static
inline
int
get_sbits
(
GetBitContext
*
s
,
int
n
)
{
register
int
tmp
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
av_assert2
(
n
>
0
&&
n
<=
25
);
tmp
=
sign_extend
(
get_bits
(
s
,
n
),
n
);
#else
...
...
@@ -377,7 +381,7 @@ static inline int get_sbits(GetBitContext *s, int n)
static
inline
unsigned
int
get_bits
(
GetBitContext
*
s
,
int
n
)
{
register
int
tmp
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
av_assert2
(
n
>
0
&&
n
<=
32
);
if
(
n
>
s
->
bits_left
)
{
...
...
@@ -412,7 +416,7 @@ static av_always_inline int get_bitsz(GetBitContext *s, int n)
static
inline
unsigned
int
get_bits_le
(
GetBitContext
*
s
,
int
n
)
{
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
av_assert2
(
n
>
0
&&
n
<=
32
);
if
(
n
>
s
->
bits_left
)
{
refill_32
(
s
);
...
...
@@ -439,7 +443,7 @@ static inline unsigned int get_bits_le(GetBitContext *s, int n)
static
inline
unsigned
int
show_bits
(
GetBitContext
*
s
,
int
n
)
{
register
int
tmp
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
if
(
n
>
s
->
bits_left
)
refill_32
(
s
);
...
...
@@ -455,7 +459,7 @@ static inline unsigned int show_bits(GetBitContext *s, int n)
static
inline
void
skip_bits
(
GetBitContext
*
s
,
int
n
)
{
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
if
(
n
<
s
->
bits_left
)
skip_remaining
(
s
,
n
);
else
{
...
...
@@ -482,7 +486,7 @@ static inline void skip_bits(GetBitContext *s, int n)
static
inline
unsigned
int
get_bits1
(
GetBitContext
*
s
)
{
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
if
(
!
s
->
bits_left
)
refill_64
(
s
);
...
...
@@ -529,7 +533,7 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n)
av_assert2
(
n
>=
0
&&
n
<=
32
);
if
(
!
n
)
{
return
0
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
}
return
get_bits
(
s
,
n
);
#else
...
...
@@ -628,7 +632,7 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
s
->
buffer_end
=
buffer
+
buffer_size
;
s
->
index
=
0
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
refill_64
(
s
);
#endif
...
...
@@ -758,7 +762,7 @@ static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits,
static
av_always_inline
int
get_vlc2
(
GetBitContext
*
s
,
VLC_TYPE
(
*
table
)[
2
],
int
bits
,
int
max_depth
)
{
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
int
nb_bits
;
unsigned
idx
=
show_bits
(
s
,
bits
);
int
code
=
table
[
idx
][
0
];
...
...
libavcodec/golomb.h
View file @
9305bdc6
...
...
@@ -54,7 +54,7 @@ static inline int get_ue_golomb(GetBitContext *gb)
{
unsigned
int
buf
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
buf
=
show_bits_long
(
gb
,
32
);
if
(
buf
>=
(
1
<<
27
))
{
...
...
@@ -119,7 +119,7 @@ static inline int get_ue_golomb_31(GetBitContext *gb)
{
unsigned
int
buf
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
buf
=
show_bits_long
(
gb
,
32
);
buf
>>=
32
-
9
;
...
...
@@ -142,7 +142,7 @@ static inline unsigned get_interleaved_ue_golomb(GetBitContext *gb)
{
uint32_t
buf
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
buf
=
show_bits_long
(
gb
,
32
);
if
(
buf
&
0xAA800000
)
{
...
...
@@ -238,7 +238,7 @@ static inline int get_se_golomb(GetBitContext *gb)
{
unsigned
int
buf
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
buf
=
show_bits_long
(
gb
,
32
);
if
(
buf
>=
(
1
<<
27
))
{
...
...
@@ -300,7 +300,7 @@ static inline int get_interleaved_se_golomb(GetBitContext *gb)
{
unsigned
int
buf
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
buf
=
show_bits_long
(
gb
,
32
);
if
(
buf
&
0xAA800000
)
{
...
...
@@ -375,7 +375,7 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
unsigned
int
buf
;
int
log
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
buf
=
show_bits_long
(
gb
,
32
);
log
=
av_log2
(
buf
);
...
...
@@ -429,7 +429,7 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit,
unsigned
int
buf
;
int
log
;
#if
def
CACHED_BITSTREAM_READER
#if CACHED_BITSTREAM_READER
buf
=
show_bits_long
(
gb
,
32
);
log
=
av_log2
(
buf
);
...
...
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