# HG changeset patch # User kostya # Date 1222159512 0 # Node ID 87bbd8322244045b97c0e43d6673d0da8fa05a2c # Parent 9fd3f57e4c16ae8d1a01c3522c0736c426d1e6ef Add RLE4 and RLE8 decoding support for BMP diff -r 9fd3f57e4c16 -r 87bbd8322244 Makefile --- a/Makefile Tue Sep 23 08:38:32 2008 +0000 +++ b/Makefile Tue Sep 23 08:45:12 2008 +0000 @@ -41,7 +41,7 @@ OBJS-$(CONFIG_AVS_DECODER) += avs.o OBJS-$(CONFIG_BETHSOFTVID_DECODER) += bethsoftvideo.o OBJS-$(CONFIG_BFI_DECODER) += bfi.o -OBJS-$(CONFIG_BMP_DECODER) += bmp.o +OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o OBJS-$(CONFIG_C93_DECODER) += c93.o OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o golomb.o mpeg12data.o mpegvideo.o diff -r 9fd3f57e4c16 -r 87bbd8322244 bmp.c --- a/bmp.c Tue Sep 23 08:38:32 2008 +0000 +++ b/bmp.c Tue Sep 23 08:45:12 2008 +0000 @@ -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 @@ 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 @@ /* 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 @@ } 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 @@ av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n"); return -1; } + } *picture = s->picture; *data_size = sizeof(AVPicture);