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
6e8bf6db
Commit
6e8bf6db
authored
Dec 22, 2011
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add bytestream2_tell() and bytestream2_seek() functions
parent
f907615f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
bytestream.h
libavcodec/bytestream.h
+30
-1
No files found.
libavcodec/bytestream.h
View file @
6e8bf6db
...
...
@@ -27,7 +27,7 @@
#include "libavutil/intreadwrite.h"
typedef
struct
{
const
uint8_t
*
buffer
,
*
buffer_end
;
const
uint8_t
*
buffer
,
*
buffer_end
,
*
buffer_start
;
}
GetByteContext
;
#define DEF_T(type, name, bytes, read, write) \
...
...
@@ -79,6 +79,7 @@ static av_always_inline void bytestream2_init(GetByteContext *g,
const
uint8_t
*
buf
,
int
buf_size
)
{
g
->
buffer
=
buf
;
g
->
buffer_start
=
buf
;
g
->
buffer_end
=
buf
+
buf_size
;
}
...
...
@@ -93,6 +94,34 @@ static av_always_inline void bytestream2_skip(GetByteContext *g,
g
->
buffer
+=
FFMIN
(
g
->
buffer_end
-
g
->
buffer
,
size
);
}
static
av_always_inline
int
bytestream2_tell
(
GetByteContext
*
g
)
{
return
(
int
)(
g
->
buffer
-
g
->
buffer_start
);
}
static
av_always_inline
int
bytestream2_seek
(
GetByteContext
*
g
,
int
offset
,
int
whence
)
{
switch
(
whence
)
{
case
SEEK_CUR
:
offset
=
av_clip
(
offset
,
-
(
g
->
buffer
-
g
->
buffer_start
),
g
->
buffer_end
-
g
->
buffer
);
g
->
buffer
+=
offset
;
break
;
case
SEEK_END
:
offset
=
av_clip
(
offset
,
-
(
g
->
buffer_end
-
g
->
buffer_start
),
0
);
g
->
buffer
=
g
->
buffer_end
+
offset
;
break
;
case
SEEK_SET
:
offset
=
av_clip
(
offset
,
0
,
g
->
buffer_end
-
g
->
buffer_start
);
g
->
buffer
=
g
->
buffer_start
+
offset
;
break
;
default
:
return
AVERROR
(
EINVAL
);
}
return
bytestream2_tell
(
g
);
}
static
av_always_inline
unsigned
int
bytestream2_get_buffer
(
GetByteContext
*
g
,
uint8_t
*
dst
,
unsigned
int
size
)
...
...
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