#include "bytestream.h"
#include "bmp.h"
-static int bmp_decode_init(AVCodecContext *avctx){
+static av_cold int bmp_decode_init(AVCodecContext *avctx){
BMPContext *s = avctx->priv_data;
avcodec_get_frame_defaults((AVFrame*)&s->picture);
static int bmp_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- uint8_t *buf, int buf_size)
+ const uint8_t *buf, int buf_size)
{
BMPContext *s = avctx->priv_data;
AVFrame *picture = data;
uint32_t rgb[3];
uint8_t *ptr;
int dsize;
- uint8_t *buf0 = buf;
+ const uint8_t *buf0 = buf;
if(buf_size < 14){
av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
rgb[2] = bytestream_get_le32(&buf);
}
- avctx->codec_id = CODEC_ID_BMP;
avctx->width = width;
avctx->height = height > 0? height: -height;
break;
case 16:
for(i = 0; i < avctx->height; i++){
- uint16_t *src = (uint16_t *) buf;
+ const uint16_t *src = (const uint16_t *) buf;
uint16_t *dst = (uint16_t *) ptr;
for(j = 0; j < avctx->width; j++)
break;
case 32:
for(i = 0; i < avctx->height; i++){
- uint8_t *src = buf;
+ const uint8_t *src = buf;
uint8_t *dst = ptr;
for(j = 0; j < avctx->width; j++){
return buf_size;
}
+static av_cold int bmp_decode_end(AVCodecContext *avctx)
+{
+ BMPContext* c = avctx->priv_data;
+
+ if (c->picture.data[0])
+ avctx->release_buffer(avctx, &c->picture);
+
+ return 0;
+}
+
AVCodec bmp_decoder = {
"bmp",
CODEC_TYPE_VIDEO,
sizeof(BMPContext),
bmp_decode_init,
NULL,
- NULL,
+ bmp_decode_end,
bmp_decode_frame
};