Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
4af5310d
Commit
4af5310d
authored
Jan 20, 2013
by
Diego Biurrun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_bits/put_bits: K&R formatting cosmetics
Signed-off-by:
Diego Biurrun
<
diego@biurrun.de
>
parent
570a4a01
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
39 deletions
+42
-39
get_bits.h
libavcodec/get_bits.h
+0
-0
put_bits.h
libavcodec/put_bits.h
+42
-39
No files found.
libavcodec/get_bits.h
View file @
4af5310d
This diff is collapsed.
Click to expand it.
libavcodec/put_bits.h
View file @
4af5310d
...
...
@@ -29,6 +29,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include "libavutil/bswap.h"
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
...
...
@@ -49,19 +50,20 @@ typedef struct PutBitContext {
* @param buffer the buffer where to put bits
* @param buffer_size the size in bytes of buffer
*/
static
inline
void
init_put_bits
(
PutBitContext
*
s
,
uint8_t
*
buffer
,
int
buffer_size
)
static
inline
void
init_put_bits
(
PutBitContext
*
s
,
uint8_t
*
buffer
,
int
buffer_size
)
{
if
(
buffer_size
<
0
)
{
if
(
buffer_size
<
0
)
{
buffer_size
=
0
;
buffer
=
NULL
;
buffer
=
NULL
;
}
s
->
size_in_bits
=
8
*
buffer_size
;
s
->
buf
=
buffer
;
s
->
buf_end
=
s
->
buf
+
buffer_size
;
s
->
buf_ptr
=
s
->
buf
;
s
->
bit_left
=
32
;
s
->
bit_buf
=
0
;
s
->
size_in_bits
=
8
*
buffer_size
;
s
->
buf
=
buffer
;
s
->
buf_end
=
s
->
buf
+
buffer_size
;
s
->
buf_ptr
=
s
->
buf
;
s
->
bit_left
=
32
;
s
->
bit_buf
=
0
;
}
/**
...
...
@@ -79,21 +81,21 @@ static inline void flush_put_bits(PutBitContext *s)
{
#ifndef BITSTREAM_WRITER_LE
if
(
s
->
bit_left
<
32
)
s
->
bit_buf
<<=
s
->
bit_left
;
s
->
bit_buf
<<=
s
->
bit_left
;
#endif
while
(
s
->
bit_left
<
32
)
{
/* XXX: should test end of buffer */
#ifdef BITSTREAM_WRITER_LE
*
s
->
buf_ptr
++
=
s
->
bit_buf
;
s
->
bit_buf
>>=
8
;
*
s
->
buf_ptr
++
=
s
->
bit_buf
;
s
->
bit_buf
>>=
8
;
#else
*
s
->
buf_ptr
++
=
s
->
bit_buf
>>
24
;
s
->
bit_buf
<<=
8
;
*
s
->
buf_ptr
++
=
s
->
bit_buf
>>
24
;
s
->
bit_buf
<<=
8
;
#endif
s
->
bit_left
+=
8
;
s
->
bit_left
+=
8
;
}
s
->
bit_left
=
32
;
s
->
bit_buf
=
0
;
s
->
bit_left
=
32
;
s
->
bit_buf
=
0
;
}
#ifdef BITSTREAM_WRITER_LE
...
...
@@ -111,7 +113,8 @@ void avpriv_align_put_bits(PutBitContext *s);
*
* @param terminate_string 0-terminates the written string if value is 1
*/
void
avpriv_put_string
(
PutBitContext
*
pb
,
const
char
*
string
,
int
terminate_string
);
void
avpriv_put_string
(
PutBitContext
*
pb
,
const
char
*
string
,
int
terminate_string
);
/**
* Copy the content of src to the bitstream.
...
...
@@ -132,7 +135,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
assert
(
n
<=
31
&&
value
<
(
1U
<<
n
));
bit_buf
=
s
->
bit_buf
;
bit_buf
=
s
->
bit_buf
;
bit_left
=
s
->
bit_left
;
/* XXX: optimize */
...
...
@@ -140,26 +143,26 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
bit_buf
|=
value
<<
(
32
-
bit_left
);
if
(
n
>=
bit_left
)
{
AV_WL32
(
s
->
buf_ptr
,
bit_buf
);
s
->
buf_ptr
+=
4
;
bit_buf
=
(
bit_left
==
32
)
?
0
:
value
>>
bit_left
;
bit_left
+=
32
;
s
->
buf_ptr
+=
4
;
bit_buf
=
(
bit_left
==
32
)
?
0
:
value
>>
bit_left
;
bit_left
+=
32
;
}
bit_left
-=
n
;
bit_left
-=
n
;
#else
if
(
n
<
bit_left
)
{
bit_buf
=
(
bit_buf
<<
n
)
|
value
;
bit_left
-=
n
;
bit_buf
=
(
bit_buf
<<
n
)
|
value
;
bit_left
-=
n
;
}
else
{
bit_buf
<<=
bit_left
;
bit_buf
|=
value
>>
(
n
-
bit_left
);
bit_buf
<<=
bit_left
;
bit_buf
|=
value
>>
(
n
-
bit_left
);
AV_WB32
(
s
->
buf_ptr
,
bit_buf
);
s
->
buf_ptr
+=
4
;
bit_left
+=
32
-
n
;
bit_buf
=
value
;
s
->
buf_ptr
+=
4
;
bit_left
+=
32
-
n
;
bit_buf
=
value
;
}
#endif
s
->
bit_buf
=
bit_buf
;
s
->
bit_buf
=
bit_buf
;
s
->
bit_left
=
bit_left
;
}
...
...
@@ -167,7 +170,7 @@ static inline void put_sbits(PutBitContext *pb, int n, int32_t value)
{
assert
(
n
>=
0
&&
n
<=
31
);
put_bits
(
pb
,
n
,
value
&
((
1
<<
n
)
-
1
));
put_bits
(
pb
,
n
,
value
&
((
1
<<
n
)
-
1
));
}
/**
...
...
@@ -190,9 +193,9 @@ static void av_unused put_bits32(PutBitContext *s, uint32_t value)
* Return the pointer to the byte where the bitstream writer will put
* the next bit.
*/
static
inline
uint8_t
*
put_bits_ptr
(
PutBitContext
*
s
)
static
inline
uint8_t
*
put_bits_ptr
(
PutBitContext
*
s
)
{
return
s
->
buf_ptr
;
return
s
->
buf_ptr
;
}
/**
...
...
@@ -201,9 +204,9 @@ static inline uint8_t* put_bits_ptr(PutBitContext *s)
*/
static
inline
void
skip_put_bytes
(
PutBitContext
*
s
,
int
n
)
{
assert
((
put_bits_count
(
s
)
&
7
)
==
0
);
assert
(
s
->
bit_left
==
32
);
s
->
buf_ptr
+=
n
;
assert
((
put_bits_count
(
s
)
&
7
)
==
0
);
assert
(
s
->
bit_left
==
32
);
s
->
buf_ptr
+=
n
;
}
/**
...
...
@@ -214,7 +217,7 @@ static inline void skip_put_bytes(PutBitContext *s, int n)
static
inline
void
skip_put_bits
(
PutBitContext
*
s
,
int
n
)
{
s
->
bit_left
-=
n
;
s
->
buf_ptr
-=
4
*
(
s
->
bit_left
>>
5
);
s
->
buf_ptr
-=
4
*
(
s
->
bit_left
>>
5
);
s
->
bit_left
&=
31
;
}
...
...
@@ -225,7 +228,7 @@ static inline void skip_put_bits(PutBitContext *s, int n)
*/
static
inline
void
set_put_bits_buffer_size
(
PutBitContext
*
s
,
int
size
)
{
s
->
buf_end
=
s
->
buf
+
size
;
s
->
buf_end
=
s
->
buf
+
size
;
}
#endif
/* AVCODEC_PUT_BITS_H */
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