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
Steve Lhomme
VLC
Commits
66f3469f
Commit
66f3469f
authored
Dec 14, 2015
by
François Cartegnie
🤞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_bits: add bs_remain()
parent
4bdb1e99
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
0 deletions
+100
-0
include/vlc_bits.h
include/vlc_bits.h
+8
-0
test/Makefile.am
test/Makefile.am
+3
-0
test/src/misc/bits.c
test/src/misc/bits.c
+89
-0
No files found.
include/vlc_bits.h
View file @
66f3469f
...
...
@@ -62,6 +62,14 @@ static inline int bs_pos( const bs_t *s )
return
(
8
*
(
s
->
p
-
s
->
p_start
)
+
8
-
s
->
i_left
);
}
static
inline
int
bs_remain
(
const
bs_t
*
s
)
{
if
(
s
->
p
>=
s
->
p_end
)
return
0
;
else
return
(
8
*
(
s
->
p_end
-
s
->
p
)
-
8
+
s
->
i_left
);
}
static
inline
int
bs_eof
(
const
bs_t
*
s
)
{
return
(
s
->
p
>=
s
->
p_end
?
1
:
0
);
...
...
test/Makefile.am
View file @
66f3469f
...
...
@@ -22,6 +22,7 @@ check_PROGRAMS = \
test_src_misc_variables
\
test_src_crypto_update
\
test_src_input_stream
\
test_src_misc_bits
\
$(NULL)
check_SCRIPTS
=
\
...
...
@@ -86,6 +87,8 @@ test_src_input_stream_LDADD = $(LIBVLCCORE) $(LIBVLC)
test_src_input_stream_net_SOURCES
=
src/input/stream.c
test_src_input_stream_net_CFLAGS
=
$(AM_CFLAGS)
-DTEST_NET
test_src_input_stream_net_LDADD
=
$(LIBVLCCORE)
$(LIBVLC)
test_src_misc_bits_SOURCES
=
src/misc/bits.c
test_src_misc_bits_LDADD
=
$(LIBVLC)
checkall
:
$(MAKE)
check_PROGRAMS
=
"
$(check_PROGRAMS)
$(EXTRA_PROGRAMS)
"
check
...
...
test/src/misc/bits.c
0 → 100644
View file @
66f3469f
/*****************************************************************************
* bits.c test bitstream reader
*****************************************************************************
* Copyright (C) 2015 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "../../libvlc/test.h"
#include <vlc_bits.h>
#include <assert.h>
int
main
(
void
)
{
test_init
();
uint8_t
z
[
2
];
bs_t
bs
;
bs_init
(
&
bs
,
NULL
,
0
);
assert
(
bs_remain
(
&
bs
)
==
0
);
assert
(
bs_pos
(
&
bs
)
==
0
);
bs_init
(
&
bs
,
&
z
,
0
);
assert
(
bs_remain
(
&
bs
)
==
0
);
assert
(
bs_pos
(
&
bs
)
==
0
);
bs_init
(
&
bs
,
&
z
,
1
);
assert
(
bs_remain
(
&
bs
)
==
8
);
assert
(
bs_pos
(
&
bs
)
==
0
);
bs_skip
(
&
bs
,
3
);
assert
(
bs_remain
(
&
bs
)
==
5
);
assert
(
bs_pos
(
&
bs
)
==
3
);
bs_init
(
&
bs
,
&
z
,
2
);
assert
(
bs_remain
(
&
bs
)
==
16
);
bs_write
(
&
bs
,
1
,
0
);
assert
(
bs_remain
(
&
bs
)
==
16
);
bs_read1
(
&
bs
);
assert
(
bs_remain
(
&
bs
)
==
15
);
assert
(
bs_pos
(
&
bs
)
==
1
);
bs_read
(
&
bs
,
7
);
assert
(
bs_remain
(
&
bs
)
==
8
);
assert
(
bs_pos
(
&
bs
)
==
8
);
bs_read1
(
&
bs
);
assert
(
bs_remain
(
&
bs
)
==
7
);
assert
(
bs_pos
(
&
bs
)
==
9
);
bs_align
(
&
bs
);
assert
(
bs_remain
(
&
bs
)
==
0
);
assert
(
bs_pos
(
&
bs
)
==
16
);
z
[
0
]
=
0xAA
;
z
[
1
]
=
0x55
;
bs_init
(
&
bs
,
&
z
,
2
);
assert
(
bs_read
(
&
bs
,
4
)
==
0x0A
);
assert
(
bs_read
(
&
bs
,
12
)
==
((
0x0A
<<
8
)
|
0x55
)
);
z
[
0
]
=
0x15
;
z
[
1
]
=
0x23
;
bs_init
(
&
bs
,
&
z
,
2
);
assert
(
bs_read_ue
(
&
bs
)
==
0x09
);
assert
(
bs_remain
(
&
bs
)
==
9
);
assert
(
bs_read1
(
&
bs
)
==
1
);
assert
(
bs_read_se
(
&
bs
)
==
2
);
assert
(
bs_remain
(
&
bs
)
==
3
);
assert
(
bs_read_se
(
&
bs
)
==
-
1
);
assert
(
bs_eof
(
&
bs
)
);
return
0
;
}
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