[FFmpeg-devel] [PATCH] Use RGB555LE/RGB565LE pixfmts instead of byte swapping in bmpenc
Daniel Verkamp
daniel
Wed Mar 25 06:50:38 CET 2009
On Wed, Mar 25, 2009 at 12:47 AM, Kostya <kostya.shishkov at gmail.com> wrote:
> On Tue, Mar 24, 2009 at 04:56:30PM -0500, Daniel Verkamp wrote:
>> On Tue, Mar 24, 2009 at 3:19 PM, Daniel Verkamp <daniel at drv.nu> wrote:
>> > Hi,
>> >
>> > The recent addition of LE/BE pixfmts for 15/16-bit RGB allows some
>> > simplification in the bmp encoder.
>> >
>> > Thanks,
>> > -- Daniel Verkamp
>> >
>>
>> Similar patch for bmp decoder; also consolidates almost-identical
>> cases for 8, 16, and 24bpp.
>>
>> Thanks,
>> -- Daniel Verkamp
>
>> From 30c006f15a596fa867552081bd8a3cfc21a530ee Mon Sep 17 00:00:00 2001
>> From: Daniel Verkamp <daniel at drv.nu>
>> 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)
>
> As Michael said, this is on hold.
>
>> @@ -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;
>
> I think I'll merge 8 and 24 cases first.
1 can be merged as well with a slightly more complicated calculation
for in_linesize.
Thanks,
-- Daniel Verkamp
More information about the ffmpeg-devel
mailing list