summaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-20 22:59:45 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-20 23:43:05 +0200
commitb1fad7ac200d0779a44fc267085d7d46ce2391b9 (patch)
tree8d90c6c835760252979c9739797993f71b36c603 /libavcodec/utils.c
parent439c9760b046caaffceacc08c40692f2e8cb3f03 (diff)
parentd6604b29ef544793479d7fb4e05ef6622bb3e534 (diff)
downloadffmpeg-streaming-b1fad7ac200d0779a44fc267085d7d46ce2391b9.zip
ffmpeg-streaming-b1fad7ac200d0779a44fc267085d7d46ce2391b9.tar.gz
Merge commit 'd6604b29ef544793479d7fb4e05ef6622bb3e534'
* commit 'd6604b29ef544793479d7fb4e05ef6622bb3e534': Gather all coded_frame allocations and free functions to a single place Conflicts: libavcodec/a64multienc.c libavcodec/asvenc.c libavcodec/cljrenc.c libavcodec/dpxenc.c libavcodec/dvenc.c libavcodec/gif.c libavcodec/huffyuvenc.c libavcodec/jpeglsenc.c libavcodec/libopenjpegenc.c libavcodec/libtheoraenc.c libavcodec/libvpxenc.c libavcodec/mpegvideo_enc.c libavcodec/nvenc.c libavcodec/pngenc.c libavcodec/proresenc_kostya.c libavcodec/sunrastenc.c libavcodec/tiffenc.c libavcodec/utils.c libavcodec/utvideoenc.c libavcodec/v210enc.c libavcodec/v410enc.c libavcodec/xbmenc.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 53b01b0..3aa861a 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1529,6 +1529,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if (av_codec_is_encoder(avctx->codec)) {
int i;
+ avctx->coded_frame = av_frame_alloc();
+ if (!avctx->coded_frame) {
+ ret = AVERROR(ENOMEM);
+ goto free_and_end;
+ }
if (avctx->codec->sample_fmts) {
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
@@ -1751,6 +1756,8 @@ free_and_end:
av_opt_free(avctx->priv_data);
av_opt_free(avctx);
+ av_frame_free(&avctx->coded_frame);
+
av_dict_free(&tmp);
av_freep(&avctx->priv_data);
if (avctx->internal) {
@@ -2882,7 +2889,6 @@ av_cold int avcodec_close(AVCodecContext *avctx)
ff_thread_free(avctx);
if (avctx->codec && avctx->codec->close)
avctx->codec->close(avctx);
- avctx->coded_frame = NULL;
avctx->internal->byte_buffer_size = 0;
av_freep(&avctx->internal->byte_buffer);
av_frame_free(&avctx->internal->to_free);
@@ -2901,8 +2907,10 @@ av_cold int avcodec_close(AVCodecContext *avctx)
av_opt_free(avctx->priv_data);
av_opt_free(avctx);
av_freep(&avctx->priv_data);
- if (av_codec_is_encoder(avctx->codec))
+ if (av_codec_is_encoder(avctx->codec)) {
av_freep(&avctx->extradata);
+ av_frame_free(&avctx->coded_frame);
+ }
avctx->codec = NULL;
avctx->active_thread_type = 0;
OpenPOWER on IntegriCloud