Allocating coded_frame is what most encoders do anyway, so it makes sense to always allocate and free it in a single place. Moreover a lot of encoders freed the frame with av_freep() instead of the correct API av_frame_free(). This bring uniformity to encoder behaviour and prevents applications from erroneusly accessing this field when not allocated. Additionally this helps isolating encoders that export information with coded_frame, and heavily simplifies its deprecation. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>tags/n2.8
| @@ -166,7 +166,6 @@ static void render_charset(AVCodecContext *avctx, uint8_t *charset, | |||||
| static av_cold int a64multi_close_encoder(AVCodecContext *avctx) | static av_cold int a64multi_close_encoder(AVCodecContext *avctx) | ||||
| { | { | ||||
| A64Context *c = avctx->priv_data; | A64Context *c = avctx->priv_data; | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| av_free(c->mc_meta_charset); | av_free(c->mc_meta_charset); | ||||
| av_free(c->mc_best_cb); | av_free(c->mc_best_cb); | ||||
| av_free(c->mc_charset); | av_free(c->mc_charset); | ||||
| @@ -218,12 +217,6 @@ static av_cold int a64multi_encode_init(AVCodecContext *avctx) | |||||
| AV_WB32(avctx->extradata, c->mc_lifetime); | AV_WB32(avctx->extradata, c->mc_lifetime); | ||||
| AV_WB32(avctx->extradata + 16, INTERLACED); | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| if (!avctx->codec_tag) | if (!avctx->codec_tag) | ||||
| @@ -483,7 +483,6 @@ static av_cold int alac_encode_close(AVCodecContext *avctx) | |||||
| ff_lpc_end(&s->lpc_ctx); | ff_lpc_end(&s->lpc_ctx); | ||||
| av_freep(&avctx->extradata); | av_freep(&avctx->extradata); | ||||
| avctx->extradata_size = 0; | avctx->extradata_size = 0; | ||||
| av_freep(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -579,12 +578,6 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) | |||||
| goto error; | goto error; | ||||
| } | } | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) { | |||||
| ret = AVERROR(ENOMEM); | |||||
| goto error; | |||||
| } | |||||
| s->avctx = avctx; | s->avctx = avctx; | ||||
| if ((ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, | if ((ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, | ||||
| @@ -27,14 +27,6 @@ | |||||
| #define ALIAS_HEADER_SIZE 10 | #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, | static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | ||||
| const AVFrame *frame, int *got_packet) | const AVFrame *frame, int *got_packet) | ||||
| { | { | ||||
| @@ -114,20 +106,12 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_alias_pix_encoder = { | AVCodec ff_alias_pix_encoder = { | ||||
| .name = "alias_pix", | .name = "alias_pix", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"), | .long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"), | ||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_ALIAS_PIX, | .id = AV_CODEC_ID_ALIAS_PIX, | ||||
| .init = encode_init, | |||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .close = encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]) { | .pix_fmts = (const enum AVPixelFormat[]) { | ||||
| AV_PIX_FMT_BGR24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE | AV_PIX_FMT_BGR24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE | ||||
| }, | }, | ||||
| @@ -282,9 +282,6 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| int i; | int i; | ||||
| const int scale = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2; | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| @@ -313,13 +310,6 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int asv_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| #if CONFIG_ASV1_ENCODER | #if CONFIG_ASV1_ENCODER | ||||
| AVCodec ff_asv1_encoder = { | AVCodec ff_asv1_encoder = { | ||||
| .name = "asv1", | .name = "asv1", | ||||
| @@ -329,11 +319,9 @@ AVCodec ff_asv1_encoder = { | |||||
| .priv_data_size = sizeof(ASV1Context), | .priv_data_size = sizeof(ASV1Context), | ||||
| .init = encode_init, | .init = encode_init, | ||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .close = asv_encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, | .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, | ||||
| AV_PIX_FMT_NONE }, | AV_PIX_FMT_NONE }, | ||||
| .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | | |||||
| FF_CODEC_CAP_INIT_CLEANUP, | |||||
| .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, | |||||
| }; | }; | ||||
| #endif | #endif | ||||
| @@ -346,10 +334,8 @@ AVCodec ff_asv2_encoder = { | |||||
| .priv_data_size = sizeof(ASV1Context), | .priv_data_size = sizeof(ASV1Context), | ||||
| .init = encode_init, | .init = encode_init, | ||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .close = asv_encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, | .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, | ||||
| AV_PIX_FMT_NONE }, | AV_PIX_FMT_NONE }, | ||||
| .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | | |||||
| FF_CODEC_CAP_INIT_CLEANUP, | |||||
| .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, | |||||
| }; | }; | ||||
| #endif | #endif | ||||
| @@ -56,10 +56,6 @@ static av_cold int bmp_encode_init(AVCodecContext *avctx){ | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -157,12 +153,6 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| 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 = { | AVCodec ff_bmp_encoder = { | ||||
| .name = "bmp", | .name = "bmp", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"), | .long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"), | ||||
| @@ -170,7 +160,6 @@ AVCodec ff_bmp_encoder = { | |||||
| .id = AV_CODEC_ID_BMP, | .id = AV_CODEC_ID_BMP, | ||||
| .init = bmp_encode_init, | .init = bmp_encode_init, | ||||
| .encode2 = bmp_encode_frame, | .encode2 = bmp_encode_frame, | ||||
| .close = bmp_encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]){ | .pix_fmts = (const enum AVPixelFormat[]){ | ||||
| AV_PIX_FMT_BGR24, | AV_PIX_FMT_BGR24, | ||||
| AV_PIX_FMT_RGB555, AV_PIX_FMT_RGB444, AV_PIX_FMT_RGB565, | AV_PIX_FMT_RGB555, AV_PIX_FMT_RGB444, AV_PIX_FMT_RGB565, | ||||
| @@ -30,21 +30,6 @@ | |||||
| #include "internal.h" | #include "internal.h" | ||||
| #include "put_bits.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, | static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | ||||
| const AVFrame *p, int *got_packet) | const AVFrame *p, int *got_packet) | ||||
| { | { | ||||
| @@ -89,9 +74,7 @@ AVCodec ff_cljr_encoder = { | |||||
| .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), | .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), | ||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_CLJR, | .id = AV_CODEC_ID_CLJR, | ||||
| .init = encode_init, | |||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .close = encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, | .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, | ||||
| AV_PIX_FMT_NONE }, | AV_PIX_FMT_NONE }, | ||||
| }; | }; | ||||
| @@ -372,10 +372,6 @@ FF_ENABLE_DEPRECATION_WARNINGS | |||||
| FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, | FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_qscale, | ||||
| ctx->m.mb_num * sizeof(uint8_t), fail); | 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->key_frame = 1; | ||||
| avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | ||||
| @@ -1127,8 +1123,6 @@ static av_cold int dnxhd_encode_end(AVCodecContext *avctx) | |||||
| for (i = 1; i < avctx->thread_count; i++) | for (i = 1; i < avctx->thread_count; i++) | ||||
| av_freep(&ctx->thread[i]); | av_freep(&ctx->thread[i]); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -35,10 +35,6 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| { | { | ||||
| DPXContext *s = avctx->priv_data; | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| @@ -177,12 +173,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_dpx_encoder = { | AVCodec ff_dpx_encoder = { | ||||
| .name = "dpx", | .name = "dpx", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("DPX image"), | .long_name = NULL_IF_CONFIG_SMALL("DPX image"), | ||||
| @@ -191,7 +181,6 @@ AVCodec ff_dpx_encoder = { | |||||
| .priv_data_size = sizeof(DPXContext), | .priv_data_size = sizeof(DPXContext), | ||||
| .init = encode_init, | .init = encode_init, | ||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .close = encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]){ | .pix_fmts = (const enum AVPixelFormat[]){ | ||||
| AV_PIX_FMT_RGB24, | AV_PIX_FMT_RGB24, | ||||
| AV_PIX_FMT_RGBA, | AV_PIX_FMT_RGBA, | ||||
| @@ -61,10 +61,6 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| dv_vlc_map_tableinit(); | dv_vlc_map_tableinit(); | ||||
| ff_fdctdsp_init(&fdsp, avctx); | ff_fdctdsp_init(&fdsp, avctx); | ||||
| @@ -737,12 +733,6 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int dvvideo_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_dvvideo_encoder = { | AVCodec ff_dvvideo_encoder = { | ||||
| .name = "dvvideo", | .name = "dvvideo", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), | .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), | ||||
| @@ -751,7 +741,6 @@ AVCodec ff_dvvideo_encoder = { | |||||
| .priv_data_size = sizeof(DVVideoContext), | .priv_data_size = sizeof(DVVideoContext), | ||||
| .init = dvvideo_encode_init, | .init = dvvideo_encode_init, | ||||
| .encode2 = dvvideo_encode_frame, | .encode2 = dvvideo_encode_frame, | ||||
| .close = dvvideo_encode_close, | |||||
| .capabilities = CODEC_CAP_SLICE_THREADS, | .capabilities = CODEC_CAP_SLICE_THREADS, | ||||
| .pix_fmts = (const enum AVPixelFormat[]) { | .pix_fmts = (const enum AVPixelFormat[]) { | ||||
| AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P, | AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P, | ||||
| @@ -721,10 +721,6 @@ static av_cold int ffv1_encode_init(AVCodecContext *avctx) | |||||
| if ((ret = ffv1_allocate_initial_states(s)) < 0) | if ((ret = ffv1_allocate_initial_states(s)) < 0) | ||||
| return ret; | return ret; | ||||
| 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| if (!s->transparency) | if (!s->transparency) | ||||
| @@ -1061,7 +1057,6 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| static av_cold int ffv1_encode_close(AVCodecContext *avctx) | static av_cold int ffv1_encode_close(AVCodecContext *avctx) | ||||
| { | { | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| ffv1_close(avctx); | ffv1_close(avctx); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -98,8 +98,6 @@ static av_cold int flashsv_encode_end(AVCodecContext *avctx) | |||||
| av_free(s->previous_frame); | av_free(s->previous_frame); | ||||
| av_free(s->tmpblock); | av_free(s->tmpblock); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -131,12 +129,6 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx) | |||||
| return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
| } | } | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) { | |||||
| flashsv_encode_end(avctx); | |||||
| return AVERROR(ENOMEM); | |||||
| } | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -130,10 +130,6 @@ static av_cold int gif_encode_init(AVCodecContext *avctx) | |||||
| { | { | ||||
| GIFContext *s = avctx->priv_data; | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| @@ -174,8 +170,6 @@ static int gif_encode_close(AVCodecContext *avctx) | |||||
| { | { | ||||
| GIFContext *s = avctx->priv_data; | GIFContext *s = avctx->priv_data; | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| av_freep(&s->lzw); | av_freep(&s->lzw); | ||||
| av_freep(&s->buf); | av_freep(&s->buf); | ||||
| return 0; | return 0; | ||||
| @@ -154,8 +154,7 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 | avctx->stats_out = av_mallocz(1024*30); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132 | ||||
| s->version = 2; | 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); | return AVERROR(ENOMEM); | ||||
| avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | ||||
| @@ -680,8 +679,6 @@ static av_cold int encode_end(AVCodecContext *avctx) | |||||
| av_freep(&avctx->extradata); | av_freep(&avctx->extradata); | ||||
| av_freep(&avctx->stats_out); | av_freep(&avctx->stats_out); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -413,18 +413,8 @@ memfail: | |||||
| return AVERROR(ENOMEM); | 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) | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| ctx->coded_frame->key_frame = 1; | ctx->coded_frame->key_frame = 1; | ||||
| @@ -445,7 +435,6 @@ AVCodec ff_jpegls_encoder = { | |||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_JPEGLS, | .id = AV_CODEC_ID_JPEGLS, | ||||
| .init = encode_init_ls, | .init = encode_init_ls, | ||||
| .close = encode_close, | |||||
| .encode2 = encode_picture_ls, | .encode2 = encode_picture_ls, | ||||
| .pix_fmts = (const enum AVPixelFormat[]) { | .pix_fmts = (const enum AVPixelFormat[]) { | ||||
| AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, | AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, | ||||
| @@ -138,10 +138,6 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| if (!avctx->extradata) | if (!avctx->extradata) | ||||
| return AVERROR(ENOMEM); | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| @@ -185,8 +181,6 @@ static av_cold int encode_end(AVCodecContext *avctx) | |||||
| av_freep(&avctx->extradata); | av_freep(&avctx->extradata); | ||||
| deflateEnd(&c->zstream); | deflateEnd(&c->zstream); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -206,7 +206,6 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx) | |||||
| s->enc_state = Encoder_Interface_init(s->enc_dtx); | s->enc_state = Encoder_Interface_init(s->enc_dtx); | ||||
| if (!s->enc_state) { | if (!s->enc_state) { | ||||
| av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n"); | av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n"); | ||||
| av_freep(&avctx->coded_frame); | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| @@ -169,12 +169,6 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx) | |||||
| return AVERROR(ENOMEM); | 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); | ctx->image = libopenjpeg_create_image(avctx, &ctx->enc_params); | ||||
| if (!ctx->image) { | if (!ctx->image) { | ||||
| av_log(avctx, AV_LOG_ERROR, "Error creating the mj2 image\n"); | av_log(avctx, AV_LOG_ERROR, "Error creating the mj2 image\n"); | ||||
| @@ -191,7 +185,6 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx) | |||||
| fail: | fail: | ||||
| av_freep(&ctx->compress); | av_freep(&ctx->compress); | ||||
| av_freep(&avctx->coded_frame); | |||||
| return err; | return err; | ||||
| } | } | ||||
| @@ -371,7 +364,6 @@ static av_cold int libopenjpeg_encode_close(AVCodecContext *avctx) | |||||
| opj_destroy_compress(ctx->compress); | opj_destroy_compress(ctx->compress); | ||||
| opj_image_destroy(ctx->image); | opj_image_destroy(ctx->image); | ||||
| av_freep(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -158,10 +158,6 @@ static av_cold int libschroedinger_encode_init(AVCodecContext *avctx) | |||||
| avctx->width, | avctx->width, | ||||
| avctx->height); | avctx->height); | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| if (!avctx->gop_size) { | if (!avctx->gop_size) { | ||||
| schro_encoder_setting_set_double(p_schro_params->encoder, | schro_encoder_setting_set_double(p_schro_params->encoder, | ||||
| "gop_structure", | "gop_structure", | ||||
| @@ -437,8 +433,6 @@ static int libschroedinger_encode_close(AVCodecContext *avctx) | |||||
| /* Free the video format structure. */ | /* Free the video format structure. */ | ||||
| av_freep(&p_schro_params->format); | av_freep(&p_schro_params->format); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -243,8 +243,8 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| below with speex_header_free() */ | below with speex_header_free() */ | ||||
| header_data = speex_header_to_packet(&s->header, &header_size); | 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) { | if (!avctx->extradata) { | ||||
| speex_header_free(header_data); | speex_header_free(header_data); | ||||
| speex_encoder_destroy(s->enc_state); | speex_encoder_destroy(s->enc_state); | ||||
| @@ -264,11 +264,6 @@ static av_cold int encode_init(AVCodecContext* avc_context) | |||||
| th_comment_clear(&t_comment); | 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; | return 0; | ||||
| } | } | ||||
| @@ -362,7 +357,6 @@ static av_cold int encode_close(AVCodecContext* avc_context) | |||||
| th_encode_free(h->t_state); | th_encode_free(h->t_state); | ||||
| av_freep(&h->stats); | av_freep(&h->stats); | ||||
| av_freep(&avc_context->coded_frame); | |||||
| av_freep(&avc_context->stats_out); | av_freep(&avc_context->stats_out); | ||||
| av_freep(&avc_context->extradata); | av_freep(&avc_context->extradata); | ||||
| avc_context->extradata_size = 0; | avc_context->extradata_size = 0; | ||||
| @@ -210,7 +210,6 @@ static av_cold int vp8_free(AVCodecContext *avctx) | |||||
| vpx_codec_destroy(&ctx->encoder); | vpx_codec_destroy(&ctx->encoder); | ||||
| av_freep(&ctx->twopass_stats.buf); | av_freep(&ctx->twopass_stats.buf); | ||||
| av_freep(&avctx->coded_frame); | |||||
| av_freep(&avctx->stats_out); | av_freep(&avctx->stats_out); | ||||
| free_frame_list(ctx->coded_frame_list); | free_frame_list(ctx->coded_frame_list); | ||||
| return 0; | return 0; | ||||
| @@ -371,12 +370,6 @@ static av_cold int vpx_init(AVCodecContext *avctx, | |||||
| vpx_img_wrap(&ctx->rawimg, ff_vpx_pixfmt_to_imgfmt(avctx->pix_fmt), | vpx_img_wrap(&ctx->rawimg, ff_vpx_pixfmt_to_imgfmt(avctx->pix_fmt), | ||||
| avctx->width, avctx->height, 1, (unsigned char *)1); | 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; | return 0; | ||||
| } | } | ||||
| @@ -287,8 +287,6 @@ static av_cold int X264_close(AVCodecContext *avctx) | |||||
| x4->enc = NULL; | x4->enc = NULL; | ||||
| } | } | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -546,10 +544,6 @@ static av_cold int X264_init(AVCodecContext *avctx) | |||||
| if (!x4->enc) | if (!x4->enc) | ||||
| return AVERROR_UNKNOWN; | return AVERROR_UNKNOWN; | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { | if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { | ||||
| x264_nal_t *nal; | x264_nal_t *nal; | ||||
| uint8_t *p; | uint8_t *p; | ||||
| @@ -66,8 +66,6 @@ static av_cold int libx265_encode_close(AVCodecContext *avctx) | |||||
| { | { | ||||
| libx265Context *ctx = avctx->priv_data; | libx265Context *ctx = avctx->priv_data; | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| ctx->api->param_free(ctx->params); | ctx->api->param_free(ctx->params); | ||||
| if (ctx->encoder) | if (ctx->encoder) | ||||
| @@ -92,12 +90,6 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) | |||||
| return AVERROR(ENOSYS); | 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(); | ctx->params = ctx->api->param_alloc(); | ||||
| if (!ctx->params) { | if (!ctx->params) { | ||||
| av_log(avctx, AV_LOG_ERROR, "Could not allocate x265 param structure.\n"); | av_log(avctx, AV_LOG_ERROR, "Could not allocate x265 param structure.\n"); | ||||
| @@ -209,8 +209,6 @@ static av_cold int XAVS_close(AVCodecContext *avctx) | |||||
| if (x4->enc) | if (x4->enc) | ||||
| xavs_encoder_close(x4->enc); | xavs_encoder_close(x4->enc); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -358,10 +356,6 @@ static av_cold int XAVS_init(AVCodecContext *avctx) | |||||
| if (!(x4->pts_buffer = av_mallocz((avctx->max_b_frames+1) * sizeof(*x4->pts_buffer)))) | if (!(x4->pts_buffer = av_mallocz((avctx->max_b_frames+1) * sizeof(*x4->pts_buffer)))) | ||||
| return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| /* TAG: Do we have GLOBAL HEADER in AVS */ | /* TAG: Do we have GLOBAL HEADER in AVS */ | ||||
| /* We Have PPS and SPS in AVS */ | /* We Have PPS and SPS in AVS */ | ||||
| if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { | if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { | ||||
| @@ -651,9 +651,6 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) | |||||
| } | } | ||||
| x->encoder_handle = xvid_enc_create.handle; | x->encoder_handle = xvid_enc_create.handle; | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -790,7 +787,6 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx) | |||||
| x->encoder_handle = NULL; | x->encoder_handle = NULL; | ||||
| } | } | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| av_freep(&avctx->extradata); | av_freep(&avctx->extradata); | ||||
| if (x->twopassbuffer) { | if (x->twopassbuffer) { | ||||
| av_free(x->twopassbuffer); | av_free(x->twopassbuffer); | ||||
| @@ -255,7 +255,6 @@ static av_cold int ljpeg_encode_close(AVCodecContext *avctx) | |||||
| { | { | ||||
| LJpegEncContext *s = avctx->priv_data; | LJpegEncContext *s = avctx->priv_data; | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| av_freep(&s->scratch); | av_freep(&s->scratch); | ||||
| return 0; | return 0; | ||||
| @@ -277,10 +276,6 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx) | |||||
| return AVERROR(EINVAL); | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| @@ -1475,8 +1475,7 @@ static void frame_end(MpegEncContext *s) | |||||
| } | } | ||||
| } | } | ||||
| 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) | static void update_noise_reduction(MpegEncContext *s) | ||||
| @@ -771,8 +771,6 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx) | |||||
| NV_ENCODE_API_FUNCTION_LIST *nv = &ctx->nvel.nvenc_funcs; | NV_ENCODE_API_FUNCTION_LIST *nv = &ctx->nvel.nvenc_funcs; | ||||
| int i; | int i; | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| if (ctx->in) { | if (ctx->in) { | ||||
| for (i = 0; i < ctx->nb_surfaces; ++i) { | for (i = 0; i < ctx->nb_surfaces; ++i) { | ||||
| nv->nvEncDestroyInputBuffer(ctx->nvenc_ctx, ctx->in[i].in); | nv->nvEncDestroyInputBuffer(ctx->nvenc_ctx, ctx->in[i].in); | ||||
| @@ -819,10 +817,6 @@ av_cold int ff_nvenc_encode_init(AVCodecContext *avctx) | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -109,29 +109,18 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| static av_cold int pam_encode_init(AVCodecContext *avctx) | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int pam_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_pam_encoder = { | AVCodec ff_pam_encoder = { | ||||
| .name = "pam", | .name = "pam", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), | .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), | ||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_PAM, | .id = AV_CODEC_ID_PAM, | ||||
| .init = pam_encode_init, | .init = pam_encode_init, | ||||
| .close = pam_encode_close, | |||||
| .encode2 = pam_encode_frame, | .encode2 = pam_encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]){ | .pix_fmts = (const enum AVPixelFormat[]){ | ||||
| AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB32, AV_PIX_FMT_GRAY8, AV_PIX_FMT_MONOWHITE, | AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB32, AV_PIX_FMT_GRAY8, AV_PIX_FMT_MONOWHITE, | ||||
| @@ -48,16 +48,6 @@ static av_cold int pcm_encode_init(AVCodecContext *avctx) | |||||
| avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id); | 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->block_align = avctx->channels * avctx->bits_per_coded_sample / 8; | ||||
| avctx->bit_rate = avctx->block_align * avctx->sample_rate * 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; | return 0; | ||||
| } | } | ||||
| @@ -460,7 +450,6 @@ AVCodec ff_ ## name_ ## _encoder = { \ | |||||
| .id = AV_CODEC_ID_ ## id_, \ | .id = AV_CODEC_ID_ ## id_, \ | ||||
| .init = pcm_encode_init, \ | .init = pcm_encode_init, \ | ||||
| .encode2 = pcm_encode_frame, \ | .encode2 = pcm_encode_frame, \ | ||||
| .close = pcm_encode_close, \ | |||||
| .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE, \ | .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE, \ | ||||
| .sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \ | .sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \ | ||||
| AV_SAMPLE_FMT_NONE }, \ | AV_SAMPLE_FMT_NONE }, \ | ||||
| @@ -34,22 +34,12 @@ static const uint32_t monoblack_pal[16] = { 0x000000, 0xFFFFFF }; | |||||
| static av_cold int pcx_encode_init(AVCodecContext *avctx) | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int pcx_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| /** | /** | ||||
| * PCX run-length encoder | * PCX run-length encoder | ||||
| * @param dst output buffer | * @param dst output buffer | ||||
| @@ -206,7 +196,6 @@ AVCodec ff_pcx_encoder = { | |||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_PCX, | .id = AV_CODEC_ID_PCX, | ||||
| .init = pcx_encode_init, | .init = pcx_encode_init, | ||||
| .close = pcx_encode_close, | |||||
| .encode2 = pcx_encode_frame, | .encode2 = pcx_encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]){ | .pix_fmts = (const enum AVPixelFormat[]){ | ||||
| AV_PIX_FMT_RGB24, | AV_PIX_FMT_RGB24, | ||||
| @@ -455,10 +455,6 @@ static av_cold int png_enc_init(AVCodecContext *avctx) | |||||
| { | { | ||||
| PNGEncContext *s = avctx->priv_data; | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| @@ -473,12 +469,6 @@ static av_cold int png_enc_init(AVCodecContext *avctx) | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int png_enc_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_png_encoder = { | AVCodec ff_png_encoder = { | ||||
| .name = "png", | .name = "png", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"), | .long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"), | ||||
| @@ -486,7 +476,6 @@ AVCodec ff_png_encoder = { | |||||
| .id = AV_CODEC_ID_PNG, | .id = AV_CODEC_ID_PNG, | ||||
| .priv_data_size = sizeof(PNGEncContext), | .priv_data_size = sizeof(PNGEncContext), | ||||
| .init = png_enc_init, | .init = png_enc_init, | ||||
| .close = png_enc_close, | |||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]) { | .pix_fmts = (const enum AVPixelFormat[]) { | ||||
| AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB32, AV_PIX_FMT_PAL8, AV_PIX_FMT_GRAY8, | AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB32, AV_PIX_FMT_PAL8, AV_PIX_FMT_GRAY8, | ||||
| @@ -120,22 +120,12 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| static av_cold int pnm_encode_init(AVCodecContext *avctx) | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int pnm_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| #if CONFIG_PGM_ENCODER | #if CONFIG_PGM_ENCODER | ||||
| AVCodec ff_pgm_encoder = { | AVCodec ff_pgm_encoder = { | ||||
| .name = "pgm", | .name = "pgm", | ||||
| @@ -143,7 +133,6 @@ AVCodec ff_pgm_encoder = { | |||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_PGM, | .id = AV_CODEC_ID_PGM, | ||||
| .init = pnm_encode_init, | .init = pnm_encode_init, | ||||
| .close = pnm_encode_close, | |||||
| .encode2 = pnm_encode_frame, | .encode2 = pnm_encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]){ | .pix_fmts = (const enum AVPixelFormat[]){ | ||||
| AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE | AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE | ||||
| @@ -158,7 +147,6 @@ AVCodec ff_pgmyuv_encoder = { | |||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_PGMYUV, | .id = AV_CODEC_ID_PGMYUV, | ||||
| .init = pnm_encode_init, | .init = pnm_encode_init, | ||||
| .close = pnm_encode_close, | |||||
| .encode2 = pnm_encode_frame, | .encode2 = pnm_encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]){ | .pix_fmts = (const enum AVPixelFormat[]){ | ||||
| AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_NONE | AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P16BE, AV_PIX_FMT_NONE | ||||
| @@ -173,7 +161,6 @@ AVCodec ff_ppm_encoder = { | |||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_PPM, | .id = AV_CODEC_ID_PPM, | ||||
| .init = pnm_encode_init, | .init = pnm_encode_init, | ||||
| .close = pnm_encode_close, | |||||
| .encode2 = pnm_encode_frame, | .encode2 = pnm_encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]){ | .pix_fmts = (const enum AVPixelFormat[]){ | ||||
| AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_NONE | AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_NONE | ||||
| @@ -188,7 +175,6 @@ AVCodec ff_pbm_encoder = { | |||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_PBM, | .id = AV_CODEC_ID_PBM, | ||||
| .init = pnm_encode_init, | .init = pnm_encode_init, | ||||
| .close = pnm_encode_close, | |||||
| .encode2 = pnm_encode_frame, | .encode2 = pnm_encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_MONOWHITE, | .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_MONOWHITE, | ||||
| AV_PIX_FMT_NONE }, | AV_PIX_FMT_NONE }, | ||||
| @@ -1097,8 +1097,6 @@ static av_cold int encode_close(AVCodecContext *avctx) | |||||
| ProresContext *ctx = avctx->priv_data; | ProresContext *ctx = avctx->priv_data; | ||||
| int i; | int i; | ||||
| av_freep(&avctx->coded_frame); | |||||
| if (ctx->tdata) { | if (ctx->tdata) { | ||||
| for (i = 0; i < avctx->thread_count; i++) | for (i = 0; i < avctx->thread_count; i++) | ||||
| av_free(ctx->tdata[i].nodes); | av_free(ctx->tdata[i].nodes); | ||||
| @@ -1132,9 +1130,6 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| int interlaced = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT); | int interlaced = !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT); | ||||
| avctx->bits_per_raw_sample = 10; | avctx->bits_per_raw_sample = 10; | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| ctx->fdct = prores_fdct; | ctx->fdct = prores_fdct; | ||||
| ctx->scantable = interlaced ? ff_prores_interlaced_scan | ctx->scantable = interlaced ? ff_prores_interlaced_scan | ||||
| @@ -240,10 +240,6 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| q->avctx = avctx; | q->avctx = avctx; | ||||
| return 0; | return 0; | ||||
| @@ -511,7 +507,5 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) | |||||
| av_fifo_free(q->async_fifo); | av_fifo_free(q->async_fifo); | ||||
| q->async_fifo = NULL; | q->async_fifo = NULL; | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -66,8 +66,6 @@ static av_cold int qtrle_encode_end(AVCodecContext *avctx) | |||||
| { | { | ||||
| QtrleEncContext *s = avctx->priv_data; | QtrleEncContext *s = avctx->priv_data; | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| avpicture_free(&s->previous_frame); | avpicture_free(&s->previous_frame); | ||||
| av_free(s->rlecode_table); | av_free(s->rlecode_table); | ||||
| av_free(s->length_table); | av_free(s->length_table); | ||||
| @@ -117,12 +115,6 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx) | |||||
| + s->avctx->height*2 /* skip code+rle end */ | + s->avctx->height*2 /* skip code+rle end */ | ||||
| + s->avctx->width/MAX_RLE_BULK + 1 /* rle codes */; | + 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; | return 0; | ||||
| } | } | ||||
| @@ -35,10 +35,6 @@ static av_cold int raw_encode_init(AVCodecContext *avctx) | |||||
| { | { | ||||
| const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc); | avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc); | ||||
| @@ -72,18 +68,11 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int raw_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_rawvideo_encoder = { | AVCodec ff_rawvideo_encoder = { | ||||
| .name = "rawvideo", | .name = "rawvideo", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("raw video"), | .long_name = NULL_IF_CONFIG_SMALL("raw video"), | ||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_RAWVIDEO, | .id = AV_CODEC_ID_RAWVIDEO, | ||||
| .init = raw_encode_init, | .init = raw_encode_init, | ||||
| .close = raw_encode_close, | |||||
| .encode2 = raw_encode, | .encode2 = raw_encode, | ||||
| }; | }; | ||||
| @@ -36,10 +36,6 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | ||||
| } | } | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) | |||||
| return AVERROR(ENOMEM); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -205,12 +201,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_sgi_encoder = { | AVCodec ff_sgi_encoder = { | ||||
| .name = "sgi", | .name = "sgi", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("SGI image"), | .long_name = NULL_IF_CONFIG_SMALL("SGI image"), | ||||
| @@ -218,7 +208,6 @@ AVCodec ff_sgi_encoder = { | |||||
| .id = AV_CODEC_ID_SGI, | .id = AV_CODEC_ID_SGI, | ||||
| .init = encode_init, | .init = encode_init, | ||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .close = encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]) { | .pix_fmts = (const enum AVPixelFormat[]) { | ||||
| AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, | AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, | ||||
| AV_PIX_FMT_RGB48LE, AV_PIX_FMT_RGB48BE, | AV_PIX_FMT_RGB48LE, AV_PIX_FMT_RGB48BE, | ||||
| @@ -153,10 +153,6 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx) | |||||
| return AVERROR(EINVAL); | 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->key_frame = 1; | ||||
| avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | ||||
| s->maptype = RMT_NONE; | s->maptype = RMT_NONE; | ||||
| @@ -210,12 +206,6 @@ static int sunrast_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int sunrast_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| static const AVCodecDefault sunrast_defaults[] = { | static const AVCodecDefault sunrast_defaults[] = { | ||||
| { "coder", "rle" }, | { "coder", "rle" }, | ||||
| { NULL }, | { NULL }, | ||||
| @@ -228,7 +218,6 @@ AVCodec ff_sunrast_encoder = { | |||||
| .id = AV_CODEC_ID_SUNRAST, | .id = AV_CODEC_ID_SUNRAST, | ||||
| .priv_data_size = sizeof(SUNRASTContext), | .priv_data_size = sizeof(SUNRASTContext), | ||||
| .init = sunrast_encode_init, | .init = sunrast_encode_init, | ||||
| .close = sunrast_encode_close, | |||||
| .encode2 = sunrast_encode_frame, | .encode2 = sunrast_encode_frame, | ||||
| .defaults = sunrast_defaults, | .defaults = sunrast_defaults, | ||||
| .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, | .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, | ||||
| @@ -499,7 +499,6 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) | |||||
| av_frame_free(&s->current_picture); | av_frame_free(&s->current_picture); | ||||
| av_frame_free(&s->last_picture); | av_frame_free(&s->last_picture); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -513,10 +512,9 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) | |||||
| ff_me_cmp_init(&s->mecc, avctx); | ff_me_cmp_init(&s->mecc, avctx); | ||||
| ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx); | ff_mpegvideoencdsp_init(&s->m.mpvencdsp, avctx); | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| s->current_picture = av_frame_alloc(); | s->current_picture = av_frame_alloc(); | ||||
| s->last_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); | svq1_encode_end(avctx); | ||||
| return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
| } | } | ||||
| @@ -150,29 +150,18 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| static av_cold int targa_encode_init(AVCodecContext *avctx) | 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->key_frame = 1; | ||||
| avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int targa_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_targa_encoder = { | AVCodec ff_targa_encoder = { | ||||
| .name = "targa", | .name = "targa", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), | .long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), | ||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_TARGA, | .id = AV_CODEC_ID_TARGA, | ||||
| .init = targa_encode_init, | .init = targa_encode_init, | ||||
| .close = targa_encode_close, | |||||
| .encode2 = targa_encode_frame, | .encode2 = targa_encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]){ | .pix_fmts = (const enum AVPixelFormat[]){ | ||||
| AV_PIX_FMT_BGR24, AV_PIX_FMT_BGRA, AV_PIX_FMT_RGB555LE, AV_PIX_FMT_GRAY8, | AV_PIX_FMT_BGR24, AV_PIX_FMT_BGRA, AV_PIX_FMT_RGB555LE, AV_PIX_FMT_GRAY8, | ||||
| @@ -490,22 +490,12 @@ fail: | |||||
| static av_cold int encode_init(AVCodecContext *avctx) | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| avctx->coded_frame->key_frame = 1; | avctx->coded_frame->key_frame = 1; | ||||
| return 0; | 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 OFFSET(x) offsetof(TiffEncoderContext, x) | ||||
| #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM | #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM | ||||
| static const AVOption options[] = { | static const AVOption options[] = { | ||||
| @@ -533,7 +523,6 @@ AVCodec ff_tiff_encoder = { | |||||
| .id = AV_CODEC_ID_TIFF, | .id = AV_CODEC_ID_TIFF, | ||||
| .priv_data_size = sizeof(TiffEncoderContext), | .priv_data_size = sizeof(TiffEncoderContext), | ||||
| .init = encode_init, | .init = encode_init, | ||||
| .close = encode_close, | |||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .pix_fmts = (const enum AVPixelFormat[]) { | .pix_fmts = (const enum AVPixelFormat[]) { | ||||
| AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48LE, AV_PIX_FMT_PAL8, | AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48LE, AV_PIX_FMT_PAL8, | ||||
| @@ -1169,6 +1169,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code | |||||
| if (av_codec_is_encoder(avctx->codec)) { | if (av_codec_is_encoder(avctx->codec)) { | ||||
| int i; | int i; | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) { | |||||
| ret = AVERROR(ENOMEM); | |||||
| goto free_and_end; | |||||
| } | |||||
| if (avctx->codec->sample_fmts) { | if (avctx->codec->sample_fmts) { | ||||
| for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) { | for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) { | ||||
| if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) | if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) | ||||
| @@ -1296,6 +1301,8 @@ free_and_end: | |||||
| av_opt_free(avctx->priv_data); | av_opt_free(avctx->priv_data); | ||||
| av_opt_free(avctx); | av_opt_free(avctx); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| av_dict_free(&tmp); | av_dict_free(&tmp); | ||||
| av_freep(&avctx->priv_data); | av_freep(&avctx->priv_data); | ||||
| if (avctx->internal) { | if (avctx->internal) { | ||||
| @@ -1797,7 +1804,6 @@ av_cold int avcodec_close(AVCodecContext *avctx) | |||||
| ff_thread_free(avctx); | ff_thread_free(avctx); | ||||
| if (avctx->codec && avctx->codec->close) | if (avctx->codec && avctx->codec->close) | ||||
| avctx->codec->close(avctx); | avctx->codec->close(avctx); | ||||
| avctx->coded_frame = NULL; | |||||
| av_frame_free(&avctx->internal->to_free); | av_frame_free(&avctx->internal->to_free); | ||||
| for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++) | for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++) | ||||
| av_buffer_pool_uninit(&pool->pools[i]); | av_buffer_pool_uninit(&pool->pools[i]); | ||||
| @@ -1814,8 +1820,10 @@ av_cold int avcodec_close(AVCodecContext *avctx) | |||||
| av_opt_free(avctx->priv_data); | av_opt_free(avctx->priv_data); | ||||
| av_opt_free(avctx); | av_opt_free(avctx); | ||||
| av_freep(&avctx->priv_data); | av_freep(&avctx->priv_data); | ||||
| if (av_codec_is_encoder(avctx->codec)) | |||||
| if (av_codec_is_encoder(avctx->codec)) { | |||||
| av_freep(&avctx->extradata); | av_freep(&avctx->extradata); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| } | |||||
| avctx->codec = NULL; | avctx->codec = NULL; | ||||
| avctx->active_thread_type = 0; | avctx->active_thread_type = 0; | ||||
| @@ -48,7 +48,6 @@ static av_cold int utvideo_encode_close(AVCodecContext *avctx) | |||||
| UtvideoContext *c = avctx->priv_data; | UtvideoContext *c = avctx->priv_data; | ||||
| int i; | int i; | ||||
| av_freep(&avctx->coded_frame); | |||||
| av_freep(&c->slice_bits); | av_freep(&c->slice_bits); | ||||
| for (i = 0; i < 4; i++) | for (i = 0; i < 4; i++) | ||||
| av_freep(&c->slice_buffer[i]); | av_freep(&c->slice_buffer[i]); | ||||
| @@ -154,14 +153,6 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx) | |||||
| return AVERROR(EINVAL); | 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 */ | /* extradata size is 4 * 32bit */ | ||||
| avctx->extradata_size = 16; | avctx->extradata_size = 16; | ||||
| @@ -91,10 +91,6 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| return AVERROR(EINVAL); | 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->pict_type = AV_PICTURE_TYPE_I; | ||||
| s->pack_line_8 = v210_planar_pack_8_c; | s->pack_line_8 = v210_planar_pack_8_c; | ||||
| @@ -213,13 +209,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_freep(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_v210_encoder = { | AVCodec ff_v210_encoder = { | ||||
| .name = "v210", | .name = "v210", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), | .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), | .priv_data_size = sizeof(V210EncContext), | ||||
| .init = encode_init, | .init = encode_init, | ||||
| .encode2 = encode_frame, | .encode2 = encode_frame, | ||||
| .close = encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE }, | .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE }, | ||||
| }; | }; | ||||
| @@ -32,13 +32,6 @@ static av_cold int v410_encode_init(AVCodecContext *avctx) | |||||
| return AVERROR_INVALIDDATA; | 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; | ||||
| } | } | ||||
| @@ -81,13 +74,6 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int v410_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_freep(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_v410_encoder = { | AVCodec ff_v410_encoder = { | ||||
| .name = "v410", | .name = "v410", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"), | .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"), | ||||
| @@ -95,6 +81,5 @@ AVCodec ff_v410_encoder = { | |||||
| .id = AV_CODEC_ID_V410, | .id = AV_CODEC_ID_V410, | ||||
| .init = v410_encode_init, | .init = v410_encode_init, | ||||
| .encode2 = v410_encode_frame, | .encode2 = v410_encode_frame, | ||||
| .close = v410_encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE }, | .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE }, | ||||
| }; | }; | ||||
| @@ -26,9 +26,6 @@ | |||||
| static av_cold int xbm_encode_init(AVCodecContext *avctx) | 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; | avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; | ||||
| return 0; | return 0; | ||||
| @@ -67,13 +64,6 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| 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 = { | AVCodec ff_xbm_encoder = { | ||||
| .name = "xbm", | .name = "xbm", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"), | .long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"), | ||||
| @@ -81,7 +71,6 @@ AVCodec ff_xbm_encoder = { | |||||
| .id = AV_CODEC_ID_XBM, | .id = AV_CODEC_ID_XBM, | ||||
| .init = xbm_encode_init, | .init = xbm_encode_init, | ||||
| .encode2 = xbm_encode_frame, | .encode2 = xbm_encode_frame, | ||||
| .close = xbm_encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, | .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, | ||||
| AV_PIX_FMT_NONE }, | AV_PIX_FMT_NONE }, | ||||
| }; | }; | ||||
| @@ -30,15 +30,6 @@ | |||||
| #define WINDOW_NAME "lavcxwdenc" | #define WINDOW_NAME "lavcxwdenc" | ||||
| #define WINDOW_NAME_SIZE 11 | #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, | static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | ||||
| const AVFrame *p, int *got_packet) | const AVFrame *p, int *got_packet) | ||||
| { | { | ||||
| @@ -213,21 +204,12 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static av_cold int xwd_encode_close(AVCodecContext *avctx) | |||||
| { | |||||
| av_freep(&avctx->coded_frame); | |||||
| return 0; | |||||
| } | |||||
| AVCodec ff_xwd_encoder = { | AVCodec ff_xwd_encoder = { | ||||
| .name = "xwd", | .name = "xwd", | ||||
| .long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"), | .long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"), | ||||
| .type = AVMEDIA_TYPE_VIDEO, | .type = AVMEDIA_TYPE_VIDEO, | ||||
| .id = AV_CODEC_ID_XWD, | .id = AV_CODEC_ID_XWD, | ||||
| .init = xwd_encode_init, | |||||
| .encode2 = xwd_encode_frame, | .encode2 = xwd_encode_frame, | ||||
| .close = xwd_encode_close, | |||||
| .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGRA, | .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGRA, | ||||
| AV_PIX_FMT_RGBA, | AV_PIX_FMT_RGBA, | ||||
| AV_PIX_FMT_ARGB, | AV_PIX_FMT_ARGB, | ||||
| @@ -261,8 +261,6 @@ static av_cold int encode_end(AVCodecContext *avctx) | |||||
| deflateEnd(&c->zstream); | deflateEnd(&c->zstream); | ||||
| av_freep(&c->prev); | av_freep(&c->prev); | ||||
| av_frame_free(&avctx->coded_frame); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -326,12 +324,6 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| avctx->coded_frame = av_frame_alloc(); | |||||
| if (!avctx->coded_frame) { | |||||
| encode_end(avctx); | |||||
| return AVERROR(ENOMEM); | |||||
| } | |||||
| return 0; | return 0; | ||||
| } | } | ||||