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
4d7c71c3
Commit
4d7c71c3
authored
Nov 08, 2011
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for OOM after av_mallocz() in ff_interleave_add_packet().
Fixes a crash with the sample from Ubuntu bug #869125.
parent
8a3f9764
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
audiointerleave.c
libavformat/audiointerleave.c
+10
-3
internal.h
libavformat/internal.h
+2
-1
utils.c
libavformat/utils.c
+8
-3
No files found.
libavformat/audiointerleave.c
View file @
4d7c71c3
...
@@ -113,10 +113,13 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
...
@@ -113,10 +113,13 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
}
}
av_fifo_generic_write
(
aic
->
fifo
,
pkt
->
data
,
pkt
->
size
,
NULL
);
av_fifo_generic_write
(
aic
->
fifo
,
pkt
->
data
,
pkt
->
size
,
NULL
);
}
else
{
}
else
{
int
ret
;
// rewrite pts and dts to be decoded time line position
// rewrite pts and dts to be decoded time line position
pkt
->
pts
=
pkt
->
dts
=
aic
->
dts
;
pkt
->
pts
=
pkt
->
dts
=
aic
->
dts
;
aic
->
dts
+=
pkt
->
duration
;
aic
->
dts
+=
pkt
->
duration
;
ff_interleave_add_packet
(
s
,
pkt
,
compare_ts
);
ret
=
ff_interleave_add_packet
(
s
,
pkt
,
compare_ts
);
if
(
ret
<
0
)
return
ret
;
}
}
pkt
=
NULL
;
pkt
=
NULL
;
}
}
...
@@ -125,8 +128,12 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
...
@@ -125,8 +128,12 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
AVStream
*
st
=
s
->
streams
[
i
];
AVStream
*
st
=
s
->
streams
[
i
];
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
AVPacket
new_pkt
;
AVPacket
new_pkt
;
while
(
ff_interleave_new_audio_packet
(
s
,
&
new_pkt
,
i
,
flush
))
int
ret
;
ff_interleave_add_packet
(
s
,
&
new_pkt
,
compare_ts
);
while
(
ff_interleave_new_audio_packet
(
s
,
&
new_pkt
,
i
,
flush
))
{
ret
=
ff_interleave_add_packet
(
s
,
&
new_pkt
,
compare_ts
);
if
(
ret
<
0
)
return
ret
;
}
}
}
}
}
...
...
libavformat/internal.h
View file @
4d7c71c3
...
@@ -71,8 +71,9 @@ void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i
...
@@ -71,8 +71,9 @@ void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i
/**
/**
* Add packet to AVFormatContext->packet_buffer list, determining its
* Add packet to AVFormatContext->packet_buffer list, determining its
* interleaved position using compare() function argument.
* interleaved position using compare() function argument.
* @return 0, or < 0 on error
*/
*/
void
ff_interleave_add_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
,
int
ff_interleave_add_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
,
int
(
*
compare
)(
AVFormatContext
*
,
AVPacket
*
,
AVPacket
*
));
int
(
*
compare
)(
AVFormatContext
*
,
AVPacket
*
,
AVPacket
*
));
void
ff_read_frame_flush
(
AVFormatContext
*
s
);
void
ff_read_frame_flush
(
AVFormatContext
*
s
);
...
...
libavformat/utils.c
View file @
4d7c71c3
...
@@ -3262,12 +3262,14 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
...
@@ -3262,12 +3262,14 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
return
ret
;
return
ret
;
}
}
void
ff_interleave_add_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
,
int
ff_interleave_add_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
,
int
(
*
compare
)(
AVFormatContext
*
,
AVPacket
*
,
AVPacket
*
))
int
(
*
compare
)(
AVFormatContext
*
,
AVPacket
*
,
AVPacket
*
))
{
{
AVPacketList
**
next_point
,
*
this_pktl
;
AVPacketList
**
next_point
,
*
this_pktl
;
this_pktl
=
av_mallocz
(
sizeof
(
AVPacketList
));
this_pktl
=
av_mallocz
(
sizeof
(
AVPacketList
));
if
(
!
this_pktl
)
return
AVERROR
(
ENOMEM
);
this_pktl
->
pkt
=
*
pkt
;
this_pktl
->
pkt
=
*
pkt
;
pkt
->
destruct
=
NULL
;
// do not free original but only the copy
pkt
->
destruct
=
NULL
;
// do not free original but only the copy
av_dup_packet
(
&
this_pktl
->
pkt
);
// duplicate the packet if it uses non-alloced memory
av_dup_packet
(
&
this_pktl
->
pkt
);
// duplicate the packet if it uses non-alloced memory
...
@@ -3296,6 +3298,7 @@ next_non_null:
...
@@ -3296,6 +3298,7 @@ next_non_null:
s
->
streams
[
pkt
->
stream_index
]
->
last_in_packet_buffer
=
s
->
streams
[
pkt
->
stream_index
]
->
last_in_packet_buffer
=
*
next_point
=
this_pktl
;
*
next_point
=
this_pktl
;
return
0
;
}
}
static
int
ff_interleave_compare_dts
(
AVFormatContext
*
s
,
AVPacket
*
next
,
AVPacket
*
pkt
)
static
int
ff_interleave_compare_dts
(
AVFormatContext
*
s
,
AVPacket
*
next
,
AVPacket
*
pkt
)
...
@@ -3314,10 +3317,12 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk
...
@@ -3314,10 +3317,12 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk
AVPacketList
*
pktl
;
AVPacketList
*
pktl
;
int
stream_count
=
0
,
noninterleaved_count
=
0
;
int
stream_count
=
0
,
noninterleaved_count
=
0
;
int64_t
delta_dts_max
=
0
;
int64_t
delta_dts_max
=
0
;
int
i
;
int
i
,
ret
;
if
(
pkt
){
if
(
pkt
){
ff_interleave_add_packet
(
s
,
pkt
,
ff_interleave_compare_dts
);
ret
=
ff_interleave_add_packet
(
s
,
pkt
,
ff_interleave_compare_dts
);
if
(
ret
<
0
)
return
ret
;
}
}
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
...
...
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