]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/bmp.c
non-recursive makefiles
[ffmpeg] / libavcodec / bmp.c
index 30eee65185135103728476cfbcd54947dc136d32..52de3be2148569f24f8858eec7a19a27954a10c5 100644 (file)
@@ -23,7 +23,7 @@
 #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);
@@ -34,7 +34,7 @@ static int bmp_decode_init(AVCodecContext *avctx){
 
 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;
@@ -48,7 +48,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
     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);
@@ -111,7 +111,6 @@ static int bmp_decode_frame(AVCodecContext *avctx,
         rgb[2] = bytestream_get_le32(&buf);
     }
 
-    avctx->codec_id = CODEC_ID_BMP;
     avctx->width = width;
     avctx->height = height > 0? height: -height;
 
@@ -194,7 +193,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
         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++)
@@ -206,7 +205,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
         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++){
@@ -232,6 +231,16 @@ static int bmp_decode_frame(AVCodecContext *avctx,
     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,
@@ -239,6 +248,6 @@ AVCodec bmp_decoder = {
     sizeof(BMPContext),
     bmp_decode_init,
     NULL,
-    NULL,
+    bmp_decode_end,
     bmp_decode_frame
 };