Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
2e80435a
Commit
2e80435a
authored
Jan 29, 2021
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/matroskaenc: use av_packet_alloc() to allocate packets
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
8d78e90a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
matroskaenc.c
libavformat/matroskaenc.c
+11
-10
No files found.
libavformat/matroskaenc.c
View file @
2e80435a
...
...
@@ -137,7 +137,7 @@ typedef struct MatroskaMuxContext {
mkv_cues
cues
;
int64_t
cues_pos
;
AVPacket
cur_audio_pkt
;
AVPacket
*
cur_audio_pkt
;
unsigned
nb_attachments
;
int
have_video
;
...
...
@@ -451,7 +451,7 @@ static void mkv_deinit(AVFormatContext *s)
{
MatroskaMuxContext
*
mkv
=
s
->
priv_data
;
av_packet_
unref
(
&
mkv
->
cur_audio_pkt
);
av_packet_
free
(
&
mkv
->
cur_audio_pkt
);
ffio_free_dyn_buf
(
&
mkv
->
cluster_bc
);
ffio_free_dyn_buf
(
&
mkv
->
info
.
bc
);
...
...
@@ -1933,8 +1933,6 @@ static int mkv_write_header(AVFormatContext *s)
mkv
->
reserve_cues_space
=
-
1
;
}
av_init_packet
(
&
mkv
->
cur_audio_pkt
);
mkv
->
cur_audio_pkt
.
size
=
0
;
mkv
->
cluster_pos
=
-
1
;
// start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
...
...
@@ -2431,9 +2429,9 @@ static int mkv_write_packet(AVFormatContext *s, const AVPacket *pkt)
keyframe
&&
(
mkv
->
have_video
?
codec_type
==
AVMEDIA_TYPE_VIDEO
:
1
)
?
AVIO_DATA_MARKER_SYNC_POINT
:
AVIO_DATA_MARKER_BOUNDARY_POINT
);
// check if we have an audio packet cached
if
(
mkv
->
cur_audio_pkt
.
size
>
0
)
{
ret
=
mkv_write_packet_internal
(
s
,
&
mkv
->
cur_audio_pkt
);
av_packet_unref
(
&
mkv
->
cur_audio_pkt
);
if
(
mkv
->
cur_audio_pkt
->
size
>
0
)
{
ret
=
mkv_write_packet_internal
(
s
,
mkv
->
cur_audio_pkt
);
av_packet_unref
(
mkv
->
cur_audio_pkt
);
if
(
ret
<
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Could not write cached audio packet ret:%d
\n
"
,
ret
);
...
...
@@ -2445,7 +2443,7 @@ static int mkv_write_packet(AVFormatContext *s, const AVPacket *pkt)
// keyframe's timecode is contained in the same cluster for WebM
if
(
codec_type
==
AVMEDIA_TYPE_AUDIO
)
{
if
(
pkt
->
size
>
0
)
ret
=
av_packet_ref
(
&
mkv
->
cur_audio_pkt
,
pkt
);
ret
=
av_packet_ref
(
mkv
->
cur_audio_pkt
,
pkt
);
}
else
ret
=
mkv_write_packet_internal
(
s
,
pkt
);
return
ret
;
...
...
@@ -2477,8 +2475,8 @@ static int mkv_write_trailer(AVFormatContext *s)
int
ret
,
ret2
=
0
;
// check if we have an audio packet cached
if
(
mkv
->
cur_audio_pkt
.
size
>
0
)
{
ret
=
mkv_write_packet_internal
(
s
,
&
mkv
->
cur_audio_pkt
);
if
(
mkv
->
cur_audio_pkt
->
size
>
0
)
{
ret
=
mkv_write_packet_internal
(
s
,
mkv
->
cur_audio_pkt
);
if
(
ret
<
0
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Could not write cached audio packet ret:%d
\n
"
,
ret
);
...
...
@@ -2702,6 +2700,9 @@ static int mkv_init(struct AVFormatContext *s)
}
else
mkv
->
mode
=
MODE_MATROSKAv2
;
mkv
->
cur_audio_pkt
=
av_packet_alloc
();
if
(
!
mkv
->
cur_audio_pkt
)
return
AVERROR
(
ENOMEM
);
mkv
->
tracks
=
av_mallocz_array
(
s
->
nb_streams
,
sizeof
(
*
mkv
->
tracks
));
if
(
!
mkv
->
tracks
)
return
AVERROR
(
ENOMEM
);
...
...
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