From 30c006f15a596fa867552081bd8a3cfc21a530ee Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 24 Mar 2009 16:56:41 -0500 Subject: [PATCH] bmp decoder: consolidate 8, 16, 24bpp line copying and use new LE 16-bpp pixfmts --- libavcodec/bmp.c | 28 +++++++--------------------- 1 files changed, 7 insertions(+), 21 deletions(-) diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index 14c070d..ff1b344 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -159,9 +159,9 @@ static int bmp_decode_frame(AVCodecContext *avctx, break; case 16: if(comp == BMP_RGB) - avctx->pix_fmt = PIX_FMT_RGB555; + avctx->pix_fmt = PIX_FMT_RGB555LE; if(comp == BMP_BITFIELDS) - avctx->pix_fmt = rgb[1] == 0x07E0 ? PIX_FMT_RGB565 : PIX_FMT_RGB555; + avctx->pix_fmt = rgb[1] == 0x07E0 ? PIX_FMT_RGB565LE : PIX_FMT_RGB555LE; break; case 8: if(hsize - ihsize - 14 > 0) @@ -262,31 +262,17 @@ static int bmp_decode_frame(AVCodecContext *avctx, } break; case 8: - for(i = 0; i < avctx->height; i++){ - memcpy(ptr, buf, avctx->width); - buf += n; - ptr += linesize; - } - break; - case 24: - for(i = 0; i < avctx->height; i++){ - memcpy(ptr, buf, avctx->width*(depth>>3)); - buf += n; - ptr += linesize; - } - break; case 16: + case 24: + { + int in_linesize = avctx->width * (depth >> 3); for(i = 0; i < avctx->height; i++){ - const uint16_t *src = (const uint16_t *) buf; - uint16_t *dst = (uint16_t *) ptr; - - for(j = 0; j < avctx->width; j++) - *dst++ = le2me_16(*src++); - + memcpy(ptr, buf, in_linesize); buf += n; ptr += linesize; } break; + } case 32: for(i = 0; i < avctx->height; i++){ const uint8_t *src = buf; -- 1.6.2