summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/aliaspixenc.c16
-rw-r--r--libavcodec/asvenc.c6
-rw-r--r--libavcodec/avuienc.c13
-rw-r--r--libavcodec/bmpenc.c11
-rw-r--r--libavcodec/dnxhdenc.c6
-rw-r--r--libavcodec/dvenc.c11
-rw-r--r--libavcodec/ffv1enc.c5
-rw-r--r--libavcodec/flashsvenc.c8
-rw-r--r--libavcodec/gif.c7
-rw-r--r--libavcodec/huffyuvenc.c5
-rw-r--r--libavcodec/jpeglsenc.c11
-rw-r--r--libavcodec/lclenc.c6
-rw-r--r--libavcodec/libopenjpegenc.c8
-rw-r--r--libavcodec/libschroedingerenc.c6
-rw-r--r--libavcodec/libspeexenc.c4
-rw-r--r--libavcodec/libtheoraenc.c6
-rw-r--r--libavcodec/libutvideoenc.cpp2
-rw-r--r--libavcodec/libvpxenc.c7
-rw-r--r--libavcodec/libx264.c6
-rw-r--r--libavcodec/libx265.c8
-rw-r--r--libavcodec/libxavs.c6
-rw-r--r--libavcodec/libxvid.c4
-rw-r--r--libavcodec/ljpegenc.c5
-rw-r--r--libavcodec/mpegvideo_enc.c3
-rw-r--r--libavcodec/nvenc.c10
-rw-r--r--libavcodec/pamenc.c11
-rw-r--r--libavcodec/pcxenc.c11
-rw-r--r--libavcodec/pngenc.c5
-rw-r--r--libavcodec/pnmenc.c14
-rw-r--r--libavcodec/proresenc_anatoliy.c4
-rw-r--r--libavcodec/proresenc_kostya.c5
-rw-r--r--libavcodec/qsvenc.c6
-rw-r--r--libavcodec/qtrleenc.c8
-rw-r--r--libavcodec/r210enc.c22
-rw-r--r--libavcodec/rawenc.c11
-rw-r--r--libavcodec/roqvideoenc.c4
-rw-r--r--libavcodec/sgienc.c11
-rw-r--r--libavcodec/snowenc.c6
-rw-r--r--libavcodec/sunrastenc.c7
-rw-r--r--libavcodec/svq1enc.c4
-rw-r--r--libavcodec/targaenc.c11
-rw-r--r--libavcodec/tiffenc.c6
-rw-r--r--libavcodec/utils.c12
-rw-r--r--libavcodec/utvideoenc.c9
-rw-r--r--libavcodec/v210enc.c12
-rw-r--r--libavcodec/v308enc.c9
-rw-r--r--libavcodec/v408enc.c8
-rw-r--r--libavcodec/v410enc.c15
-rw-r--r--libavcodec/xfaceenc.c5
-rw-r--r--libavcodec/y41penc.c8
-rw-r--r--libavcodec/yuv4enc.c9
-rw-r--r--libavcodec/zmbvenc.c8
52 files changed, 20 insertions, 401 deletions
diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c
index 1fcea08415..6aede994e5 100644
--- a/libavcodec/aliaspixenc.c
+++ b/libavcodec/aliaspixenc.c
@@ -27,14 +27,6 @@
#define ALIAS_HEADER_SIZE 10
-static av_cold int encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
- return 0;
-}
-
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
@@ -114,20 +106,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
-static av_cold int encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_alias_pix_encoder = {
.name = "alias_pix",
.long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_ALIAS_PIX,
- .init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_BGR24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
},
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index d78fa47ed4..5decde34ee 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -363,8 +363,7 @@ AVCodec ff_asv1_encoder = {
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE },
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
- FF_CODEC_CAP_INIT_CLEANUP,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};
#endif
@@ -379,7 +378,6 @@ AVCodec ff_asv2_encoder = {
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE },
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
- FF_CODEC_CAP_INIT_CLEANUP,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};
#endif
diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c
index b32f433b29..acfe7bcee3 100644
--- a/libavcodec/avuienc.c
+++ b/libavcodec/avuienc.c
@@ -44,11 +44,6 @@ static av_cold int avui_encode_init(AVCodecContext *avctx)
AV_WB32(avctx->extradata + 48, avctx->height);
memcpy(avctx->extradata + 52, "\0\0\0\x1\0\0\0\x20\0\0\0\x2", 12);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
- return AVERROR(ENOMEM);
- }
return 0;
}
@@ -99,13 +94,6 @@ static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
-static av_cold int avui_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
-
- return 0;
-}
-
AVCodec ff_avui_encoder = {
.name = "avui",
.long_name = NULL_IF_CONFIG_SMALL("Avid Meridien Uncompressed"),
@@ -113,7 +101,6 @@ AVCodec ff_avui_encoder = {
.id = AV_CODEC_ID_AVUI,
.init = avui_encode_init,
.encode2 = avui_encode_frame,
- .close = avui_encode_close,
.capabilities = CODEC_CAP_EXPERIMENTAL,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_UYVY422, AV_PIX_FMT_NONE },
};
diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
index 2a1956dc4a..2772315120 100644
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -60,10 +60,6 @@ static av_cold int bmp_encode_init(AVCodecContext *avctx){
return AVERROR(EINVAL);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
return 0;
}
@@ -163,12 +159,6 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
-static av_cold int bmp_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_bmp_encoder = {
.name = "bmp",
.long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"),
@@ -176,7 +166,6 @@ AVCodec ff_bmp_encoder = {
.id = AV_CODEC_ID_BMP,
.init = bmp_encode_init,
.encode2 = bmp_encode_frame,
- .close = bmp_encode_close,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_BGRA, AV_PIX_FMT_BGR24,
AV_PIX_FMT_RGB565, AV_PIX_FMT_RGB555, AV_PIX_FMT_RGB444,
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index c034485a5e..bbb0065f8a 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -388,10 +388,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale,
ctx->m.mb_num * sizeof(uint8_t), fail);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->key_frame = 1;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
@@ -1138,8 +1134,6 @@ static av_cold int dnxhd_encode_end(AVCodecContext *avctx)
for (i = 1; i < avctx->thread_count; i++)
av_freep(&ctx->thread[i]);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 9ce72732f3..cc5678ca91 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -65,10 +65,6 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
return ret;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
dv_vlc_map_tableinit();
memset(&fdsp,0, sizeof(fdsp));
@@ -743,12 +739,6 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
return 0;
}
-static int dvvideo_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_dvvideo_encoder = {
.name = "dvvideo",
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
@@ -757,7 +747,6 @@ AVCodec ff_dvvideo_encoder = {
.priv_data_size = sizeof(DVVideoContext),
.init = dvvideo_encode_init,
.encode2 = dvvideo_encode_frame,
- .close = dvvideo_encode_close,
.capabilities = CODEC_CAP_SLICE_THREADS | CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P,
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 02e7f0753d..b1380ec209 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -853,10 +853,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
if ((ret = ffv1_allocate_initial_states(s)) < 0)
return ret;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
if (!s->transparency)
@@ -1332,7 +1328,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int encode_close(AVCodecContext *avctx)
{
- av_frame_free(&avctx->coded_frame);
ffv1_close(avctx);
return 0;
}
diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
index f56a995895..5c1f7ad526 100644
--- a/libavcodec/flashsvenc.c
+++ b/libavcodec/flashsvenc.c
@@ -98,8 +98,6 @@ static av_cold int flashsv_encode_end(AVCodecContext *avctx)
av_freep(&s->previous_frame);
av_freep(&s->tmpblock);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
@@ -131,12 +129,6 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- flashsv_encode_end(avctx);
- return AVERROR(ENOMEM);
- }
-
return 0;
}
diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index cf5d438a72..d92a0bcb4e 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -221,11 +221,6 @@ static av_cold int gif_encode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "GIF does not support resolutions above 65535x65535\n");
return AVERROR(EINVAL);
}
-
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
@@ -320,8 +315,6 @@ static int gif_encode_close(AVCodecContext *avctx)
{
GIFContext *s = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
-
av_freep(&s->lzw);
av_freep(&s->buf);
av_frame_free(&s->last_frame);
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 22e2cb86e3..a860f83758 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -228,8 +228,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
s->version = 2;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->extradata || !avctx->coded_frame)
+ if (!avctx->extradata)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
@@ -1037,8 +1036,6 @@ static av_cold int encode_end(AVCodecContext *avctx)
av_freep(&avctx->extradata);
av_freep(&avctx->stats_out);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index d2749101ed..60a7427091 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -412,18 +412,8 @@ memfail:
return AVERROR(ENOMEM);
}
-static av_cold int encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
static av_cold int encode_init_ls(AVCodecContext *ctx)
{
- ctx->coded_frame = av_frame_alloc();
- if (!ctx->coded_frame)
- return AVERROR(ENOMEM);
-
ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
ctx->coded_frame->key_frame = 1;
@@ -444,7 +434,6 @@ AVCodec ff_jpegls_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_JPEGLS,
.init = encode_init_ls,
- .close = encode_close,
.capabilities = CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY,
.encode2 = encode_picture_ls,
.pix_fmts = (const enum AVPixelFormat[]) {
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index bce1d537a2..256d0ca5be 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -135,10 +135,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (!avctx->extradata)
return AVERROR(ENOMEM);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
@@ -183,8 +179,6 @@ static av_cold int encode_end(AVCodecContext *avctx)
av_freep(&avctx->extradata);
deflateEnd(&c->zstream);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 014c2f9d28..f48e55e164 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -242,18 +242,11 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
goto fail;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
- goto fail;
- }
-
return 0;
fail:
opj_image_destroy(ctx->image);
ctx->image = NULL;
- av_frame_free(&avctx->coded_frame);
return err;
}
@@ -608,7 +601,6 @@ static av_cold int libopenjpeg_encode_close(AVCodecContext *avctx)
opj_image_destroy(ctx->image);
ctx->image = NULL;
- av_frame_free(&avctx->coded_frame);
return 0;
}
diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c
index f7a32353e2..4ba56c40b2 100644
--- a/libavcodec/libschroedingerenc.c
+++ b/libavcodec/libschroedingerenc.c
@@ -159,10 +159,6 @@ static av_cold int libschroedinger_encode_init(AVCodecContext *avctx)
avctx->width,
avctx->height);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
if (!avctx->gop_size) {
schro_encoder_setting_set_double(p_schro_params->encoder,
"gop_structure",
@@ -436,8 +432,6 @@ static int libschroedinger_encode_close(AVCodecContext *avctx)
/* Free the video format structure. */
av_freep(&p_schro_params->format);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c
index fac8e725ac..3e4e2e9877 100644
--- a/libavcodec/libspeexenc.c
+++ b/libavcodec/libspeexenc.c
@@ -244,8 +244,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
below with speex_header_free() */
header_data = speex_header_to_packet(&s->header, &header_size);
- /* allocate extradata and coded_frame */
- avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ /* allocate extradata */
+ avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata) {
speex_header_free(header_data);
speex_encoder_destroy(s->enc_state);
diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index ff681f3243..ccfb21ea0b 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -267,11 +267,6 @@ static av_cold int encode_init(AVCodecContext* avc_context)
th_comment_clear(&t_comment);
- /* Set up the output AVFrame */
- avc_context->coded_frame = av_frame_alloc();
- if (!avc_context->coded_frame)
- return AVERROR(ENOMEM);
-
return 0;
}
@@ -363,7 +358,6 @@ static av_cold int encode_close(AVCodecContext* avc_context)
th_encode_free(h->t_state);
av_freep(&h->stats);
- av_frame_free(&avc_context->coded_frame);
av_freep(&avc_context->stats_out);
av_freep(&avc_context->extradata);
avc_context->extradata_size = 0;
diff --git a/libavcodec/libutvideoenc.cpp b/libavcodec/libutvideoenc.cpp
index cf669d28a0..38d019b18b 100644
--- a/libavcodec/libutvideoenc.cpp
+++ b/libavcodec/libutvideoenc.cpp
@@ -81,7 +81,6 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
flags = ((avctx->prediction_method + 1) << 8) | (avctx->thread_count - 1);
avctx->priv_data = utv;
- avctx->coded_frame = av_frame_alloc();
/* Alloc extradata buffer */
info = (UtVideoExtra *)av_malloc(sizeof(*info));
@@ -211,7 +210,6 @@ static av_cold int utvideo_encode_close(AVCodecContext *avctx)
{
UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
av_freep(&avctx->extradata);
av_freep(&utv->buffer);
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index f3030f7a10..ff052c5b58 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -265,7 +265,6 @@ static av_cold int vp8_free(AVCodecContext *avctx)
if (ctx->is_alpha)
vpx_codec_destroy(&ctx->encoder_alpha);
av_freep(&ctx->twopass_stats.buf);
- av_frame_free(&avctx->coded_frame);
av_freep(&avctx->stats_out);
free_frame_list(ctx->coded_frame_list);
return 0;
@@ -640,12 +639,6 @@ static av_cold int vpx_init(AVCodecContext *avctx,
vpx_img_wrap(&ctx->rawimg_alpha, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
(unsigned char*)1);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
- vp8_free(avctx);
- return AVERROR(ENOMEM);
- }
return 0;
}
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 3e789e5ec3..868b99e732 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -321,8 +321,6 @@ static av_cold int X264_close(AVCodecContext *avctx)
x4->enc = NULL;
}
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
@@ -708,10 +706,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (!x4->enc)
return AVERROR_EXTERNAL;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
x264_nal_t *nal;
uint8_t *p;
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index e9240f9491..19c7742b6d 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -66,8 +66,6 @@ static av_cold int libx265_encode_close(AVCodecContext *avctx)
{
libx265Context *ctx = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
-
ctx->api->param_free(ctx->params);
if (ctx->encoder)
@@ -92,12 +90,6 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
return AVERROR(ENOSYS);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
- return AVERROR(ENOMEM);
- }
-
ctx->params = ctx->api->param_alloc();
if (!ctx->params) {
av_log(avctx, AV_LOG_ERROR, "Could not allocate x265 param structure.\n");
diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c
index 30d1479836..ca9539a656 100644
--- a/libavcodec/libxavs.c
+++ b/libavcodec/libxavs.c
@@ -207,8 +207,6 @@ static av_cold int XAVS_close(AVCodecContext *avctx)
if (x4->enc)
xavs_encoder_close(x4->enc);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
@@ -357,10 +355,6 @@ static av_cold int XAVS_init(AVCodecContext *avctx)
if (!(x4->pts_buffer = av_mallocz_array((avctx->max_b_frames+1), sizeof(*x4->pts_buffer))))
return AVERROR(ENOMEM);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
/* TAG: Do we have GLOBAL HEADER in AVS */
/* We Have PPS and SPS in AVS */
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER && 0) {
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index e0e7cbd024..4574f380ba 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -680,9 +680,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
}
x->encoder_handle = xvid_enc_create.handle;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
return 0;
}
@@ -818,7 +815,6 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx)
x->encoder_handle = NULL;
}
- av_frame_free(&avctx->coded_frame);
av_freep(&avctx->extradata);
if (x->twopassbuffer) {
av_freep(&x->twopassbuffer);
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 8c0ebf5e08..2716c7014d 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -265,7 +265,6 @@ static av_cold int ljpeg_encode_close(AVCodecContext *avctx)
{
LJpegEncContext *s = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
av_freep(&s->scratch);
return 0;
@@ -286,10 +285,6 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 71c3b54451..fec4eca042 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1617,8 +1617,7 @@ static void frame_end(MpegEncContext *s)
if (s->pict_type!= AV_PICTURE_TYPE_B)
s->last_non_b_pict_type = s->pict_type;
- s->avctx->coded_frame = s->current_picture_ptr->f;
-
+ av_frame_copy_props(s->avctx->coded_frame, s->current_picture.f);
}
static void update_noise_reduction(MpegEncContext *s)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index a63c779d61..1f40086d28 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -563,12 +563,6 @@ static av_cold int nvenc_encode_init(AVCodecContext *avctx)
if (!nvenc_dyload_nvenc(avctx))
return AVERROR_EXTERNAL;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- res = AVERROR(ENOMEM);
- goto error;
- }
-
ctx->last_dts = AV_NOPTS_VALUE;
ctx->encode_config.version = NV_ENC_CONFIG_VER;
@@ -1051,8 +1045,6 @@ error:
if (ctx->cu_context)
dl_fn->cu_ctx_destroy(ctx->cu_context);
- av_frame_free(&avctx->coded_frame);
-
nvenc_unload_nvenc(avctx);
ctx->nvencoder = NULL;
@@ -1086,8 +1078,6 @@ static av_cold int nvenc_encode_close(AVCodecContext *avctx)
nvenc_unload_nvenc(avctx);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c
index 7a51fe62b3..b361380ff6 100644
--- a/libavcodec/pamenc.c
+++ b/libavcodec/pamenc.c
@@ -129,29 +129,18 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int pam_encode_init(AVCodecContext *avctx)
{
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
return 0;
}
-static av_cold int pam_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_pam_encoder = {
.name = "pam",
.long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PAM,
.init = pam_encode_init,
- .close = pam_encode_close,
.encode2 = pam_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c
index a718428d7a..2a4eb8ef59 100644
--- a/libavcodec/pcxenc.c
+++ b/libavcodec/pcxenc.c
@@ -35,22 +35,12 @@ static const uint32_t monoblack_pal[16] = { 0x000000, 0xFFFFFF };
static av_cold int pcx_encode_init(AVCodecContext *avctx)
{
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
return 0;
}
-static av_cold int pcx_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
/**
* PCX run-length encoder
* @param dst output buffer
@@ -216,7 +206,6 @@ AVCodec ff_pcx_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PCX,
.init = pcx_encode_init,
- .close = pcx_encode_close,
.encode2 = pcx_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24,
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 7a9d0b0f79..94f2b108ae 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -627,10 +627,6 @@ static av_cold int png_enc_init(AVCodecContext *avctx)
avctx->bits_per_coded_sample = 8;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
@@ -713,7 +709,6 @@ static av_cold int png_enc_close(AVCodecContext *avctx)
PNGEncContext *s = avctx->priv_data;
deflateEnd(&s->zstream);
- av_frame_free(&avctx->coded_frame);
return 0;
}
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index e6c3635e7b..9f9d9f5eb0 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -120,22 +120,12 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int pnm_encode_init(AVCodecContext *avctx)
{
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
return 0;
}
-static av_cold int pnm_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
#if CONFIG_PGM_ENCODER
AVCodec ff_pgm_encoder = {
.name = "pgm",
@@ -143,7 +133,6 @@ AVCodec ff_pgm_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PGM,
.init = pnm_encode_init,
- .close = pnm_encode_close,
.encode2 = pnm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE
@@ -158,7 +147,6 @@ AVCodec ff_pgmyuv_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PGMYUV,
.init = pnm_encode_init,
- .close = pnm_encode_close,
.encode2 = pnm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_NONE
@@ -173,7 +161,6 @@ AVCodec ff_ppm_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PPM,
.init = pnm_encode_init,
- .close = pnm_encode_close,
.encode2 = pnm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_NONE
@@ -188,7 +175,6 @@ AVCodec ff_pbm_encoder = {
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PBM,
.init = pnm_encode_init,
- .close = pnm_encode_close,
.encode2 = pnm_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_MONOWHITE,
AV_PIX_FMT_NONE },
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 48eb44ec16..607053412c 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -590,9 +590,6 @@ static av_cold int prores_encode_init(AVCodecContext *avctx)
scale_mat(QMAT_CHROMA[avctx->profile], ctx->qmat_chroma[i - 1], i);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
avctx->coded_frame->key_frame = 1;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
@@ -602,7 +599,6 @@ static av_cold int prores_encode_init(AVCodecContext *avctx)
static av_cold int prores_encode_close(AVCodecContext *avctx)
{
ProresContext* ctx = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
av_freep(&ctx->fill_y);
return 0;
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 1abc496b3f..46f932f596 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1092,8 +1092,6 @@ static av_cold int encode_close(AVCodecContext *avctx)
ProresContext *ctx = avctx->priv_data;
int i;
- av_frame_free(&avctx->coded_frame);
-
if (ctx->tdata) {
for (i = 0; i < avctx->thread_count; i++)
av_freep(&ctx->tdata[i].nodes);
@@ -1127,9 +1125,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
int interlaced = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT);
avctx->bits_per_raw_sample = 10;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 116011e907..ac53bc4fb5 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -254,10 +254,6 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
return ret;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
q->avctx = avctx;
return 0;
@@ -535,7 +531,5 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
av_fifo_free(q->async_fifo);
q->async_fifo = NULL;
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index bf68d7f242..5fd633a582 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -67,8 +67,6 @@ static av_cold int qtrle_encode_end(AVCodecContext *avctx)
{
QtrleEncContext *s = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
-
avpicture_free(&s->previous_frame);
av_free(s->rlecode_table);
av_free(s->length_table);
@@ -128,12 +126,6 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx)
+ s->avctx->height*2 /* skip code+rle end */
+ s->logical_width/MAX_RLE_BULK + 1 /* rle codes */;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- qtrle_encode_end(avctx);
- return AVERROR(ENOMEM);
- }
-
return 0;
}
diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c
index b7d5a07deb..0aae40977f 100644
--- a/libavcodec/r210enc.c
+++ b/libavcodec/r210enc.c
@@ -24,16 +24,6 @@
#include "internal.h"
#include "bytestream.h"
-static av_cold int encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame = av_frame_alloc();
-
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
- return 0;
-}
-
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic, int *got_packet)
{
@@ -78,12 +68,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
-static av_cold int encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
-
- return 0;
-}
#if CONFIG_R210_ENCODER
AVCodec ff_r210_encoder = {
@@ -91,9 +75,7 @@ AVCodec ff_r210_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_R210,
- .init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE },
};
#endif
@@ -103,9 +85,7 @@ AVCodec ff_r10k_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_R10K,
- .init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE },
};
#endif
@@ -115,9 +95,7 @@ AVCodec ff_avrp_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_AVRP,
- .init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB48, AV_PIX_FMT_NONE },
};
#endif
diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index 71c1de5b0e..8a1b1dc4d0 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -35,10 +35,6 @@ static av_cold int raw_encode_init(AVCodecContext *avctx)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc);
if(!avctx->codec_tag)
@@ -71,18 +67,11 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
-static av_cold int raw_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_rawvideo_encoder = {
.name = "rawvideo",
.long_name = NULL_IF_CONFIG_SMALL("raw video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_RAWVIDEO,
.init = raw_encode_init,
- .close = raw_encode_close,
.encode2 = raw_encode,
};
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 157719a4dc..bb5be77211 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -979,7 +979,6 @@ static av_cold int roq_encode_end(AVCodecContext *avctx)
av_frame_free(&enc->current_frame);
av_frame_free(&enc->last_frame);
- av_frame_free(&enc->avctx->coded_frame);
av_freep(&enc->tmpData);
av_freep(&enc->this_motion4);
@@ -1020,8 +1019,7 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
enc->last_frame = av_frame_alloc();
enc->current_frame = av_frame_alloc();
- avctx->coded_frame = av_frame_alloc();
- if (!enc->last_frame || !enc->current_frame || !avctx->coded_frame) {
+ if (!enc->last_frame || !enc->current_frame) {
roq_encode_end(avctx);
return AVERROR(ENOMEM);
}
diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c
index 2f45eb3984..14efabeb03 100644
--- a/libavcodec/sgienc.c
+++ b/libavcodec/sgienc.c
@@ -37,10 +37,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
return 0;
}
@@ -206,12 +202,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
-static av_cold int encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_sgi_encoder = {
.name = "sgi",
.long_name = NULL_IF_CONFIG_SMALL("SGI image"),
@@ -219,7 +209,6 @@ AVCodec ff_sgi_encoder = {
.id = AV_CODEC_ID_SGI,
.init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
AV_PIX_FMT_RGB48LE, AV_PIX_FMT_RGB48BE,
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index bd5c0fde15..9c804acbd4 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -122,8 +122,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, s->avctx->me_sub_cmp);
s->input_picture = av_frame_alloc();
- avctx->coded_frame = av_frame_alloc();
- if (!s->input_picture || !avctx->coded_frame)
+ if (!s->input_picture)
return AVERROR(ENOMEM);
if ((ret = ff_snow_get_buffer(s, s->input_picture)) < 0)
@@ -1852,7 +1851,7 @@ redo_frame:
emms_c();
pkt->size = ff_rac_terminate(c);
- if (avctx->coded_frame->key_frame)
+ if (s->current_picture->key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -1866,7 +1865,6 @@ static av_cold int encode_end(AVCodecContext *avctx)
ff_snow_common_end(s);
ff_rate_control_uninit(&s->m);
av_frame_free(&s->input_picture);
- av_frame_free(&avctx->coded_frame);
av_freep(&avctx->stats_out);
return 0;
diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c
index cff8c85c3f..b6eb38f8b9 100644
--- a/libavcodec/sunrastenc.c
+++ b/libavcodec/sunrastenc.c
@@ -199,12 +199,6 @@ static int sunrast_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
return 0;
}
-static av_cold int sunrast_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
static const AVCodecDefault sunrast_defaults[] = {
{ "coder", "rle" },
{ NULL },
@@ -217,7 +211,6 @@ AVCodec ff_sunrast_encoder = {
.id = AV_CODEC_ID_SUNRAST,
.priv_data_size = sizeof(SUNRASTContext),
.init = sunrast_encode_init,
- .close = sunrast_encode_close,
.encode2 = sunrast_encode_frame,
.defaults = sunrast_defaults,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24,
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index a5b46a023e..a74d0e4e10 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -504,7 +504,6 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx)
av_frame_free(&s->current_picture);
av_frame_free(&s->last_picture);
- av_frame_free(&avctx->coded_frame);
return 0;
}
@@ -518,10 +517,9 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
ff_me_cmp_init(&s->mecc, avctx);
ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx);
- avctx->coded_frame = av_frame_alloc();
s->current_picture = av_frame_alloc();
s->last_picture = av_frame_alloc();
- if (!avctx->coded_frame || !s->current_picture || !s->last_picture) {
+ if (!s->current_picture || !s->last_picture) {
svq1_encode_end(avctx);
return AVERROR(ENOMEM);
}
diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index d4483ec398..57e47b12d2 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -172,29 +172,18 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int targa_encode_init(AVCodecContext *avctx)
{
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->key_frame = 1;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
return 0;
}
-static av_cold int targa_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_targa_encoder = {
.name = "targa",
.long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_TARGA,
.init = targa_encode_init,
- .close = targa_encode_close,
.encode2 = targa_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_BGR24, AV_PIX_FMT_BGRA, AV_PIX_FMT_RGB555LE, AV_PIX_FMT_GRAY8, AV_PIX_FMT_PAL8,
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 2cdac0b213..273f8e4039 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -521,11 +521,6 @@ fail:
static av_cold int encode_init(AVCodecContext *avctx)
{
TiffEncoderContext *s = avctx->priv_data;
-
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
s->avctx = avctx;
@@ -537,7 +532,6 @@ static av_cold int encode_close(AVCodecContext *avctx)
{
TiffEncoderContext *s = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
av_freep(&s->strip_sizes);
av_freep(&s->strip_offsets);
av_freep(&s->yuv_line);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 53b01b09ba..3aa861abfb 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;
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 99791ba1a9..0cf593038a 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -48,7 +48,6 @@ static av_cold int utvideo_encode_close(AVCodecContext *avctx)
UtvideoContext *c = avctx->priv_data;
int i;
- av_frame_free(&avctx->coded_frame);
av_freep(&c->slice_bits);
for (i = 0; i < 4; i++)
av_freep(&c->slice_buffer[i]);
@@ -154,14 +153,6 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- avctx->coded_frame = av_frame_alloc();
-
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
- utvideo_encode_close(avctx);
- return AVERROR(ENOMEM);
- }
-
/* extradata size is 4 * 32bit */
avctx->extradata_size = 16;
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 2e0fd43b4e..c19d755818 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -91,10 +91,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->pack_line_8 = v210_planar_pack_8_c;
@@ -213,13 +209,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
-static av_cold int encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
-
- return 0;
-}
-
AVCodec ff_v210_encoder = {
.name = "v210",
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"),
@@ -228,6 +217,5 @@ AVCodec ff_v210_encoder = {
.priv_data_size = sizeof(V210EncContext),
.init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE },
};
diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c
index 408784b044..0e5ab822c0 100644
--- a/libavcodec/v308enc.c
+++ b/libavcodec/v308enc.c
@@ -31,13 +31,6 @@ static av_cold int v308_encode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- avctx->coded_frame = av_frame_alloc();
-
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
- return AVERROR(ENOMEM);
- }
-
return 0;
}
@@ -77,8 +70,6 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int v308_encode_close(AVCodecContext *avctx)
{
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c
index cdb2efaf7a..b09da89eaa 100644
--- a/libavcodec/v408enc.c
+++ b/libavcodec/v408enc.c
@@ -26,12 +26,6 @@
static av_cold int v408_encode_init(AVCodecContext *avctx)
{
- avctx->coded_frame = av_frame_alloc();
-
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
- return AVERROR(ENOMEM);
- }
return 0;
}
@@ -82,8 +76,6 @@ static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int v408_encode_close(AVCodecContext *avctx)
{
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c
index f2f7d7349b..90653784a7 100644
--- a/libavcodec/v410enc.c
+++ b/libavcodec/v410enc.c
@@ -32,13 +32,6 @@ static av_cold int v410_encode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- avctx->coded_frame = av_frame_alloc();
-
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
- return AVERROR(ENOMEM);
- }
-
return 0;
}
@@ -79,13 +72,6 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
-static av_cold int v410_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
-
- return 0;
-}
-
AVCodec ff_v410_encoder = {
.name = "v410",
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"),
@@ -93,6 +79,5 @@ AVCodec ff_v410_encoder = {
.id = AV_CODEC_ID_V410,
.init = v410_encode_init,
.encode2 = v410_encode_frame,
- .close = v410_encode_close,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE },
};
diff --git a/libavcodec/xfaceenc.c b/libavcodec/xfaceenc.c
index fa6f22734b..ca0f72bc9e 100644
--- a/libavcodec/xfaceenc.c
+++ b/libavcodec/xfaceenc.c
@@ -126,9 +126,6 @@ static void encode_block(char *bitmap, int w, int h, int level, ProbRangesQueue
static av_cold int xface_encode_init(AVCodecContext *avctx)
{
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
return 0;
@@ -223,8 +220,6 @@ static int xface_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int xface_encode_close(AVCodecContext *avctx)
{
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c
index 477861880e..b30cbfaf26 100644
--- a/libavcodec/y41penc.c
+++ b/libavcodec/y41penc.c
@@ -30,14 +30,8 @@ static av_cold int y41p_encode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- avctx->coded_frame = av_frame_alloc();
avctx->bits_per_coded_sample = 12;
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
- return AVERROR(ENOMEM);
- }
-
return 0;
}
@@ -84,8 +78,6 @@ static int y41p_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int y41p_encode_close(AVCodecContext *avctx)
{
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c
index 5ce48467d1..cc9ecbbf87 100644
--- a/libavcodec/yuv4enc.c
+++ b/libavcodec/yuv4enc.c
@@ -25,13 +25,6 @@
static av_cold int yuv4_encode_init(AVCodecContext *avctx)
{
- avctx->coded_frame = av_frame_alloc();
-
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
- return AVERROR(ENOMEM);
- }
-
return 0;
}
@@ -74,8 +67,6 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int yuv4_encode_close(AVCodecContext *avctx)
{
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
index 2d56a13e01..46bda2a97d 100644
--- a/libavcodec/zmbvenc.c
+++ b/libavcodec/zmbvenc.c
@@ -259,8 +259,6 @@ static av_cold int encode_end(AVCodecContext *avctx)
deflateEnd(&c->zstream);
av_freep(&c->prev);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
@@ -324,12 +322,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return -1;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- encode_end(avctx);
- return AVERROR(ENOMEM);
- }
-
return 0;
}