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
0d712409
Commit
0d712409
authored
Dec 01, 2004
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fifo_realloc()
Originally committed as revision 3726 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
61f4aa96
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
7 deletions
+34
-7
avformat.h
libavformat/avformat.h
+1
-0
mpeg.c
libavformat/mpeg.c
+2
-6
utils.c
libavformat/utils.c
+31
-1
No files found.
libavformat/avformat.h
View file @
0d712409
...
...
@@ -546,6 +546,7 @@ int fifo_size(FifoBuffer *f, uint8_t *rptr);
int
fifo_read
(
FifoBuffer
*
f
,
uint8_t
*
buf
,
int
buf_size
,
uint8_t
**
rptr_ptr
);
void
fifo_write
(
FifoBuffer
*
f
,
uint8_t
*
buf
,
int
size
,
uint8_t
**
wptr_ptr
);
int
put_fifo
(
ByteIOContext
*
pb
,
FifoBuffer
*
f
,
int
buf_size
,
uint8_t
**
rptr_ptr
);
void
fifo_realloc
(
FifoBuffer
*
f
,
int
size
);
/* media file input */
AVInputFormat
*
av_find_input_format
(
const
char
*
short_name
);
...
...
libavformat/mpeg.c
View file @
0d712409
...
...
@@ -391,7 +391,7 @@ static int mpeg_mux_init(AVFormatContext *ctx)
default:
return
-
1
;
}
fifo_init
(
&
stream
->
fifo
,
2
*
stream
->
max_buffer_size
+
100
*
MAX_PAYLOAD_SIZE
);
//FIXME think about the size maybe dynamically realloc
fifo_init
(
&
stream
->
fifo
,
16
);
stream
->
next_packet
=
&
stream
->
premux_packet
;
}
bitrate
=
0
;
...
...
@@ -1172,11 +1172,6 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
stream
->
predecode_packet
=
pkt_desc
;
stream
->
next_packet
=
&
pkt_desc
->
next
;
if
(
stream
->
fifo
.
end
-
stream
->
fifo
.
buffer
-
fifo_size
(
&
stream
->
fifo
,
stream
->
fifo
.
rptr
)
<
size
){
av_log
(
ctx
,
AV_LOG_ERROR
,
"fifo overflow
\n
"
);
return
-
1
;
}
if
(
s
->
is_dvd
){
if
(
is_iframe
)
{
stream
->
fifo_iframe_ptr
=
stream
->
fifo
.
wptr
;
...
...
@@ -1186,6 +1181,7 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
}
}
fifo_realloc
(
&
stream
->
fifo
,
fifo_size
(
&
stream
->
fifo
,
NULL
)
+
size
+
1
);
fifo_write
(
&
stream
->
fifo
,
buf
,
size
,
&
stream
->
fifo
.
wptr
);
for
(;;){
...
...
libavformat/utils.c
View file @
0d712409
...
...
@@ -232,6 +232,9 @@ void fifo_free(FifoBuffer *f)
int
fifo_size
(
FifoBuffer
*
f
,
uint8_t
*
rptr
)
{
int
size
;
if
(
!
rptr
)
rptr
=
f
->
rptr
;
if
(
f
->
wptr
>=
rptr
)
{
size
=
f
->
wptr
-
rptr
;
...
...
@@ -244,9 +247,13 @@ int fifo_size(FifoBuffer *f, uint8_t *rptr)
/* get data from the fifo (return -1 if not enough data) */
int
fifo_read
(
FifoBuffer
*
f
,
uint8_t
*
buf
,
int
buf_size
,
uint8_t
**
rptr_ptr
)
{
uint8_t
*
rptr
=
*
rptr_ptr
;
uint8_t
*
rptr
;
int
size
,
len
;
if
(
!
rptr_ptr
)
rptr_ptr
=
&
f
->
rptr
;
rptr
=
*
rptr_ptr
;
if
(
f
->
wptr
>=
rptr
)
{
size
=
f
->
wptr
-
rptr
;
}
else
{
...
...
@@ -270,11 +277,34 @@ int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr)
return
0
;
}
void
fifo_realloc
(
FifoBuffer
*
f
,
int
new_size
){
int
old_size
=
f
->
end
-
f
->
buffer
;
if
(
old_size
<
new_size
){
uint8_t
*
old
=
f
->
buffer
;
f
->
buffer
=
av_realloc
(
f
->
buffer
,
new_size
);
f
->
rptr
+=
f
->
buffer
-
old
;
f
->
wptr
+=
f
->
buffer
-
old
;
if
(
f
->
wptr
<
f
->
rptr
){
memmove
(
f
->
rptr
+
new_size
-
old_size
,
f
->
rptr
,
f
->
buffer
+
old_size
-
f
->
rptr
);
f
->
rptr
+=
new_size
-
old_size
;
}
f
->
end
=
f
->
buffer
+
new_size
;
}
}
void
fifo_write
(
FifoBuffer
*
f
,
uint8_t
*
buf
,
int
size
,
uint8_t
**
wptr_ptr
)
{
int
len
;
uint8_t
*
wptr
;
if
(
!
wptr_ptr
)
wptr_ptr
=
&
f
->
wptr
;
wptr
=
*
wptr_ptr
;
while
(
size
>
0
)
{
len
=
f
->
end
-
wptr
;
if
(
len
>
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