diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/bmpenc.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/bmpenc.c')
| -rw-r--r-- | ffmpeg/libavcodec/bmpenc.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/ffmpeg/libavcodec/bmpenc.c b/ffmpeg/libavcodec/bmpenc.c index bda6799..2a1956d 100644 --- a/ffmpeg/libavcodec/bmpenc.c +++ b/ffmpeg/libavcodec/bmpenc.c @@ -32,11 +32,6 @@ static const uint32_t rgb565_masks[] = { 0xF800, 0x07E0, 0x001F }; static const uint32_t rgb444_masks[] = { 0x0F00, 0x00F0, 0x000F }; static av_cold int bmp_encode_init(AVCodecContext *avctx){ - BMPContext *s = avctx->priv_data; - - avcodec_get_frame_defaults(&s->picture); - avctx->coded_frame = &s->picture; - switch (avctx->pix_fmt) { case AV_PIX_FMT_BGRA: avctx->bits_per_coded_sample = 32; @@ -62,26 +57,29 @@ static av_cold int bmp_encode_init(AVCodecContext *avctx){ break; default: av_log(avctx, AV_LOG_INFO, "unsupported pixel format\n"); - return -1; + 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) { - BMPContext *s = avctx->priv_data; - AVFrame * const p = &s->picture; + 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; - *p = *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; @@ -165,13 +163,20 @@ 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)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_BMP, - .priv_data_size = sizeof(BMPContext), .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, @@ -179,5 +184,4 @@ AVCodec ff_bmp_encoder = { AV_PIX_FMT_MONOBLACK, AV_PIX_FMT_NONE }, - .long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"), }; |
