X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fbmpenc.c;h=2a1956dc4ab2c9a3476ea30de53ece032f52f8e1;hb=fe540ae6b72a20e84f828b2e37a0a538631b4049;hp=ad02a6b314bdc2e5c22e54f374abe1d28bb57c27;hpb=e25ed2608c960302d6f4832a5435c9672d78e282;p=ffmpeg diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index ad02a6b314b..2a1956dc4ab 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -60,22 +60,26 @@ 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; } static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { + const AVFrame * const p = pict; int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret; const uint32_t *pal = NULL; uint32_t palette256[256]; int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB; int bit_count = avctx->bits_per_coded_sample; uint8_t *ptr, *buf; - AVFrame * const p = (AVFrame *)pict; - p->pict_type= AV_PICTURE_TYPE_I; - p->key_frame= 1; + avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; + avctx->coded_frame->key_frame = 1; switch (avctx->pix_fmt) { case AV_PIX_FMT_RGB444: compression = BMP_BITFIELDS; @@ -159,6 +163,12 @@ 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)"), @@ -166,6 +176,7 @@ 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,