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
41d8555f
Commit
41d8555f
authored
Mar 03, 2011
by
Reimar Döffinger
Committed by
Ronald S. Bultje
Mar 04, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avio: add avio_get_str()
Signed-off-by:
Ronald S. Bultje
<
rsbultje@gmail.com
>
parent
fd085bc0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
avio.h
libavformat/avio.h
+14
-0
aviobuf.c
libavformat/aviobuf.c
+17
-0
No files found.
libavformat/avio.h
View file @
41d8555f
...
...
@@ -525,6 +525,20 @@ unsigned int avio_rl24(AVIOContext *s);
unsigned
int
avio_rl32
(
AVIOContext
*
s
);
uint64_t
avio_rl64
(
AVIOContext
*
s
);
/**
* Read a string from pb into buf. The reading will terminate when either
* a NULL character was encountered, maxlen bytes have been read, or nothing
* more can be read from pb. The result is guaranteed to be NULL-terminated, it
* will be truncated if buf is too small.
* Note that the string is not interpreted or validated in any way, it
* might get truncated in the middle of a sequence for multi-byte encodings.
*
* @return number of bytes read (is always <= maxlen).
* If reading ends on EOF or error, the return value will be one more than
* bytes actually read.
*/
int
avio_get_str
(
AVIOContext
*
pb
,
int
maxlen
,
char
*
buf
,
int
buflen
);
/**
* Read a UTF-16 string from pb and convert it to UTF-8.
* The reading will terminate when either a null or invalid character was
...
...
libavformat/aviobuf.c
View file @
41d8555f
...
...
@@ -705,6 +705,23 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen)
return
i
;
}
int
avio_get_str
(
AVIOContext
*
s
,
int
maxlen
,
char
*
buf
,
int
buflen
)
{
int
i
;
// reserve 1 byte for terminating 0
buflen
=
FFMIN
(
buflen
-
1
,
maxlen
);
for
(
i
=
0
;
i
<
buflen
;
i
++
)
if
(
!
(
buf
[
i
]
=
avio_r8
(
s
)))
return
i
+
1
;
if
(
buflen
)
buf
[
i
]
=
0
;
for
(;
i
<
maxlen
;
i
++
)
if
(
!
avio_r8
(
s
))
return
i
+
1
;
return
maxlen
;
}
#define GET_STR16(type, read) \
int avio_get_str16 ##type(AVIOContext *pb, int maxlen, char *buf, int buflen)\
{\
...
...
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