static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
{
A64Context *c = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
av_free(c->mc_meta_charset);
av_free(c->mc_best_cb);
av_free(c->mc_charset);
AV_WB32(avctx->extradata, c->mc_lifetime);
AV_WB32(avctx->extradata + 16, INTERLACED);
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- a64multi_close_encoder(avctx);
- return AVERROR(ENOMEM);
- }
-
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
if (!avctx->codec_tag)
ff_lpc_end(&s->lpc_ctx);
av_freep(&avctx->extradata);
avctx->extradata_size = 0;
- av_freep(&avctx->coded_frame);
return 0;
}
goto error;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- ret = AVERROR(ENOMEM);
- goto error;
- }
-
s->avctx = avctx;
if ((ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,
#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)
{
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
},
int i;
const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
- 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 asv_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
-
- return 0;
-}
-
#if CONFIG_ASV1_ENCODER
AVCodec ff_asv1_encoder = {
.name = "asv1",
.priv_data_size = sizeof(ASV1Context),
.init = encode_init,
.encode2 = encode_frame,
- .close = asv_encode_close,
.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
.priv_data_size = sizeof(ASV1Context),
.init = encode_init,
.encode2 = encode_frame,
- .close = asv_encode_close,
.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
return -1;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
return 0;
}
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)"),
.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_BGR24,
AV_PIX_FMT_RGB555, AV_PIX_FMT_RGB444, AV_PIX_FMT_RGB565,
#include "internal.h"
#include "put_bits.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 av_cold int encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet)
{
.long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_CLJR,
- .init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P,
AV_PIX_FMT_NONE },
};
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;
for (i = 1; i < avctx->thread_count; i++)
av_freep(&ctx->thread[i]);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
{
DPXContext *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;
return 0;
}
-static av_cold int encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_dpx_encoder = {
.name = "dpx",
.long_name = NULL_IF_CONFIG_SMALL("DPX image"),
.priv_data_size = sizeof(DPXContext),
.init = encode_init,
.encode2 = encode_frame,
- .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24,
AV_PIX_FMT_RGBA,
return ret;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
dv_vlc_map_tableinit();
ff_fdctdsp_init(&fdsp, avctx);
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)"),
.priv_data_size = sizeof(DVVideoContext),
.init = dvvideo_encode_init,
.encode2 = dvvideo_encode_frame,
- .close = dvvideo_encode_close,
.capabilities = CODEC_CAP_SLICE_THREADS,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P,
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)
static av_cold int ffv1_encode_close(AVCodecContext *avctx)
{
- av_frame_free(&avctx->coded_frame);
ffv1_close(avctx);
return 0;
}
av_free(s->previous_frame);
av_free(s->tmpblock);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
return AVERROR(ENOMEM);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- flashsv_encode_end(avctx);
- return AVERROR(ENOMEM);
- }
-
return 0;
}
{
GIFContext *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;
{
GIFContext *s = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
-
av_freep(&s->lzw);
av_freep(&s->buf);
return 0;
avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
s->version = 2;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->extradata || !avctx->stats_out || !avctx->coded_frame)
+ if (!avctx->extradata || !avctx->stats_out)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
av_freep(&avctx->extradata);
av_freep(&avctx->stats_out);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
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;
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_JPEGLS,
.init = encode_init_ls,
- .close = encode_close,
.encode2 = encode_picture_ls,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24,
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;
av_freep(&avctx->extradata);
deflateEnd(&c->zstream);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
s->enc_state = Encoder_Interface_init(s->enc_dtx);
if (!s->enc_state) {
av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
- av_freep(&avctx->coded_frame);
return -1;
}
return AVERROR(ENOMEM);
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
- goto fail;
- }
-
ctx->image = libopenjpeg_create_image(avctx, &ctx->enc_params);
if (!ctx->image) {
av_log(avctx, AV_LOG_ERROR, "Error creating the mj2 image\n");
fail:
av_freep(&ctx->compress);
- av_freep(&avctx->coded_frame);
return err;
}
opj_destroy_compress(ctx->compress);
opj_image_destroy(ctx->image);
- av_freep(&avctx->coded_frame);
return 0;
}
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",
/* Free the video format structure. */
av_freep(&p_schro_params->format);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
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);
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;
}
th_encode_free(h->t_state);
av_freep(&h->stats);
- av_freep(&avc_context->coded_frame);
av_freep(&avc_context->stats_out);
av_freep(&avc_context->extradata);
avc_context->extradata_size = 0;
vpx_codec_destroy(&ctx->encoder);
av_freep(&ctx->twopass_stats.buf);
- av_freep(&avctx->coded_frame);
av_freep(&avctx->stats_out);
free_frame_list(ctx->coded_frame_list);
return 0;
vpx_img_wrap(&ctx->rawimg, ff_vpx_pixfmt_to_imgfmt(avctx->pix_fmt),
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;
}
x4->enc = NULL;
}
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
if (!x4->enc)
return AVERROR_UNKNOWN;
- 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;
{
libx265Context *ctx = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
-
ctx->api->param_free(ctx->params);
if (ctx->encoder)
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");
if (x4->enc)
xavs_encoder_close(x4->enc);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
if (!(x4->pts_buffer = av_mallocz((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) {
}
x->encoder_handle = xvid_enc_create.handle;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
return 0;
}
x->encoder_handle = NULL;
}
- av_frame_free(&avctx->coded_frame);
av_freep(&avctx->extradata);
if (x->twopassbuffer) {
av_free(x->twopassbuffer);
{
LJpegEncContext *s = avctx->priv_data;
- av_frame_free(&avctx->coded_frame);
av_freep(&s->scratch);
return 0;
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;
}
}
- 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)
NV_ENCODE_API_FUNCTION_LIST *nv = &ctx->nvel.nvenc_funcs;
int i;
- av_frame_free(&avctx->coded_frame);
-
if (ctx->in) {
for (i = 0; i < ctx->nb_surfaces; ++i) {
nv->nvEncDestroyInputBuffer(ctx->nvenc_ctx, ctx->in[i].in);
return ret;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
return 0;
}
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_RGB32, AV_PIX_FMT_GRAY8, AV_PIX_FMT_MONOWHITE,
avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
avctx->block_align = avctx->channels * avctx->bits_per_coded_sample / 8;
avctx->bit_rate = avctx->block_align * avctx->sample_rate * 8;
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
- return 0;
-}
-
-static av_cold int pcm_encode_close(AVCodecContext *avctx)
-{
- av_freep(&avctx->coded_frame);
return 0;
}
.id = AV_CODEC_ID_ ## id_, \
.init = pcm_encode_init, \
.encode2 = pcm_encode_frame, \
- .close = pcm_encode_close, \
.capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE, \
.sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \
AV_SAMPLE_FMT_NONE }, \
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
.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,
{
PNGEncContext *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;
return 0;
}
-static av_cold int png_enc_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
AVCodec ff_png_encoder = {
.name = "png",
.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"),
.id = AV_CODEC_ID_PNG,
.priv_data_size = sizeof(PNGEncContext),
.init = png_enc_init,
- .close = png_enc_close,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB32, AV_PIX_FMT_PAL8, AV_PIX_FMT_GRAY8,
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",
.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
.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
.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
.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 },
ProresContext *ctx = avctx->priv_data;
int i;
- av_freep(&avctx->coded_frame);
-
if (ctx->tdata) {
for (i = 0; i < avctx->thread_count; i++)
av_free(ctx->tdata[i].nodes);
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);
ctx->fdct = prores_fdct;
ctx->scantable = interlaced ? ff_prores_interlaced_scan
return ret;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
q->avctx = avctx;
return 0;
av_fifo_free(q->async_fifo);
q->async_fifo = NULL;
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
{
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);
+ s->avctx->height*2 /* skip code+rle end */
+ s->avctx->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;
}
{
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->coded_frame->key_frame = 1;
avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc);
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,
};
return AVERROR_INVALIDDATA;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
return 0;
}
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"),
.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,
return AVERROR(EINVAL);
}
- 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;
s->maptype = RMT_NONE;
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 },
.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,
av_frame_free(&s->current_picture);
av_frame_free(&s->last_picture);
- av_frame_free(&avctx->coded_frame);
return 0;
}
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);
}
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,
static av_cold int 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 encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
- return 0;
-}
-
#define OFFSET(x) offsetof(TiffEncoderContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
.id = AV_CODEC_ID_TIFF,
.priv_data_size = sizeof(TiffEncoderContext),
.init = encode_init,
- .close = encode_close,
.encode2 = encode_frame,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48LE, AV_PIX_FMT_PAL8,
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])
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) {
ff_thread_free(avctx);
if (avctx->codec && avctx->codec->close)
avctx->codec->close(avctx);
- avctx->coded_frame = NULL;
av_frame_free(&avctx->internal->to_free);
for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
av_buffer_pool_uninit(&pool->pools[i]);
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;
UtvideoContext *c = avctx->priv_data;
int i;
- av_freep(&avctx->coded_frame);
av_freep(&c->slice_bits);
for (i = 0; i < 4; i++)
av_freep(&c->slice_buffer[i]);
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;
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;
return 0;
}
-static av_cold int encode_close(AVCodecContext *avctx)
-{
- av_freep(&avctx->coded_frame);
-
- return 0;
-}
-
AVCodec ff_v210_encoder = {
.name = "v210",
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"),
.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 },
};
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;
}
return 0;
}
-static av_cold int v410_encode_close(AVCodecContext *avctx)
-{
- av_freep(&avctx->coded_frame);
-
- return 0;
-}
-
AVCodec ff_v410_encoder = {
.name = "v410",
.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"),
.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 },
};
static av_cold int xbm_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;
return 0;
}
-static av_cold int xbm_encode_close(AVCodecContext *avctx)
-{
- av_frame_free(&avctx->coded_frame);
-
- return 0;
-}
-
AVCodec ff_xbm_encoder = {
.name = "xbm",
.long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"),
.id = AV_CODEC_ID_XBM,
.init = xbm_encode_init,
.encode2 = xbm_encode_frame,
- .close = xbm_encode_close,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE,
AV_PIX_FMT_NONE },
};
#define WINDOW_NAME "lavcxwdenc"
#define WINDOW_NAME_SIZE 11
-static av_cold int xwd_encode_init(AVCodecContext *avctx)
-{
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame)
- return AVERROR(ENOMEM);
-
- return 0;
-}
-
static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *p, int *got_packet)
{
return 0;
}
-static av_cold int xwd_encode_close(AVCodecContext *avctx)
-{
- av_freep(&avctx->coded_frame);
-
- return 0;
-}
-
AVCodec ff_xwd_encoder = {
.name = "xwd",
.long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_XWD,
- .init = xwd_encode_init,
.encode2 = xwd_encode_frame,
- .close = xwd_encode_close,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGRA,
AV_PIX_FMT_RGBA,
AV_PIX_FMT_ARGB,
deflateEnd(&c->zstream);
av_freep(&c->prev);
- av_frame_free(&avctx->coded_frame);
-
return 0;
}
return -1;
}
- avctx->coded_frame = av_frame_alloc();
- if (!avctx->coded_frame) {
- encode_end(avctx);
- return AVERROR(ENOMEM);
- }
-
return 0;
}