summaryrefslogtreecommitdiff
path: root/libavcodec/bmp.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2008-09-23 08:45:12 +0000
committerKostya Shishkov <kostya.shishkov@gmail.com>2008-09-23 08:45:12 +0000
commitfca506dfb6294f365de284af1019f8e121a9bb7e (patch)
tree844a5829c7057bb4bef70a811057475093c72a5d /libavcodec/bmp.c
parent15501c32d04db0c9e0fa35b00f714187e6533e89 (diff)
Add RLE4 and RLE8 decoding support for BMP
Originally committed as revision 15390 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/bmp.c')
-rw-r--r--libavcodec/bmp.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index 62beb6dac4..d88131a77e 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "bytestream.h"
#include "bmp.h"
+#include "msrledec.h"
static av_cold int bmp_decode_init(AVCodecContext *avctx){
BMPContext *s = avctx->priv_data;
@@ -107,7 +108,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
else
comp = BMP_RGB;
- if(comp != BMP_RGB && comp != BMP_BITFIELDS){
+ if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){
av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp);
return -1;
}
@@ -196,12 +197,16 @@ static int bmp_decode_frame(AVCodecContext *avctx,
/* Line size in file multiple of 4 */
n = ((avctx->width * depth) / 8 + 3) & ~3;
- if(n * avctx->height > dsize){
+ if(n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8){
av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
dsize, n * avctx->height);
return -1;
}
+ // RLE may skip decoding some picture areas, so blank picture before decoding
+ if(comp == BMP_RLE4 || comp == BMP_RLE8)
+ memset(p->data[0], 0, avctx->height * p->linesize[0]);
+
if(depth == 4 || depth == 8)
memset(p->data[1], 0, 1024);
@@ -224,6 +229,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
}
buf = buf0 + hsize;
}
+ if(comp == BMP_RLE4 || comp == BMP_RLE8){
+ ff_msrle_decode(avctx, p, depth, buf, dsize);
+ }else{
switch(depth){
case 1:
for(i = 0; i < avctx->height; i++){
@@ -290,6 +298,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n");
return -1;
}
+ }
*picture = s->picture;
*data_size = sizeof(AVPicture);