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
7fb6c922
Commit
7fb6c922
authored
Feb 24, 2012
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc: free the output packet when encoding failed or produced no output.
parent
e42e9b0e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
avcodec.h
libavcodec/avcodec.h
+8
-0
utils.c
libavcodec/utils.c
+8
-0
No files found.
libavcodec/avcodec.h
View file @
7fb6c922
...
@@ -3788,6 +3788,10 @@ int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
...
@@ -3788,6 +3788,10 @@ int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
* avpkt->data is NULL, the encoder will allocate it.
* avpkt->data is NULL, the encoder will allocate it.
* The encoder will set avpkt->size to the size of the
* The encoder will set avpkt->size to the size of the
* output packet.
* output packet.
*
* If this function fails or produces no output, avpkt will be
* freed using av_free_packet() (i.e. avpkt->destruct will be
* called to free the user supplied buffer).
* @param[in] frame AVFrame containing the raw audio data to be encoded.
* @param[in] frame AVFrame containing the raw audio data to be encoded.
* May be NULL when flushing an encoder that has the
* May be NULL when flushing an encoder that has the
* CODEC_CAP_DELAY capability set.
* CODEC_CAP_DELAY capability set.
...
@@ -3870,6 +3874,10 @@ int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
...
@@ -3870,6 +3874,10 @@ int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
* The encoder will set avpkt->size to the size of the
* The encoder will set avpkt->size to the size of the
* output packet. The returned data (if any) belongs to the
* output packet. The returned data (if any) belongs to the
* caller, he is responsible for freeing it.
* caller, he is responsible for freeing it.
*
* If this function fails or produces no output, avpkt will be
* freed using av_free_packet() (i.e. avpkt->destruct will be
* called to free the user supplied buffer).
* @param[in] frame AVFrame containing the raw video data to be encoded.
* @param[in] frame AVFrame containing the raw video data to be encoded.
* May be NULL when flushing an encoder that has the
* May be NULL when flushing an encoder that has the
* CODEC_CAP_DELAY capability set.
* CODEC_CAP_DELAY capability set.
...
...
libavcodec/utils.c
View file @
7fb6c922
...
@@ -864,6 +864,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
...
@@ -864,6 +864,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
*
got_packet_ptr
=
0
;
*
got_packet_ptr
=
0
;
if
(
!
(
avctx
->
codec
->
capabilities
&
CODEC_CAP_DELAY
)
&&
!
frame
)
{
if
(
!
(
avctx
->
codec
->
capabilities
&
CODEC_CAP_DELAY
)
&&
!
frame
)
{
av_free_packet
(
avpkt
);
av_init_packet
(
avpkt
);
av_init_packet
(
avpkt
);
avpkt
->
size
=
0
;
avpkt
->
size
=
0
;
return
0
;
return
0
;
...
@@ -962,6 +963,9 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
...
@@ -962,6 +963,9 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
if
(
!
ret
)
if
(
!
ret
)
avctx
->
frame_number
++
;
avctx
->
frame_number
++
;
if
(
ret
<
0
||
!*
got_packet_ptr
)
av_free_packet
(
avpkt
);
/* NOTE: if we add any audio encoders which output non-keyframe packets,
/* NOTE: if we add any audio encoders which output non-keyframe packets,
this needs to be moved to the encoders, but for now we can do it
this needs to be moved to the encoders, but for now we can do it
here to simplify things */
here to simplify things */
...
@@ -1095,6 +1099,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
...
@@ -1095,6 +1099,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
*
got_packet_ptr
=
0
;
*
got_packet_ptr
=
0
;
if
(
!
(
avctx
->
codec
->
capabilities
&
CODEC_CAP_DELAY
)
&&
!
frame
)
{
if
(
!
(
avctx
->
codec
->
capabilities
&
CODEC_CAP_DELAY
)
&&
!
frame
)
{
av_free_packet
(
avpkt
);
av_init_packet
(
avpkt
);
av_init_packet
(
avpkt
);
avpkt
->
size
=
0
;
avpkt
->
size
=
0
;
return
0
;
return
0
;
...
@@ -1121,6 +1126,9 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
...
@@ -1121,6 +1126,9 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
avctx
->
frame_number
++
;
avctx
->
frame_number
++
;
}
}
if
(
ret
<
0
||
!*
got_packet_ptr
)
av_free_packet
(
avpkt
);
emms_c
();
emms_c
();
return
ret
;
return
ret
;
}
}
...
...
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