[FFmpeg-devel] [PATCH] Use RGB555LE/RGB565LE pixfmts instead of byte swapping in bmpenc
Daniel Verkamp
daniel
Tue Mar 24 21:19:28 CET 2009
Hi,
The recent addition of LE/BE pixfmts for 15/16-bit RGB allows some
simplification in the bmp encoder.
Thanks,
-- Daniel Verkamp
-------------- next part --------------
>From 3ad8a81af639f34947a70a67233e83ca5779ee57 Mon Sep 17 00:00:00 2001
From: Daniel Verkamp <daniel at drv.nu>
Date: Tue, 24 Mar 2009 15:19:50 -0500
Subject: [PATCH] Use RGB555LE/RGB565LE pixfmts instead of byte swapping in bmpenc
---
libavcodec/bmpenc.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
index 578813a..02c10ff 100644
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -52,10 +52,10 @@ static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s
case PIX_FMT_BGR24:
bit_count = 24;
break;
- case PIX_FMT_RGB555:
+ case PIX_FMT_RGB555LE:
bit_count = 16;
break;
- case PIX_FMT_RGB565:
+ case PIX_FMT_RGB565LE:
bit_count = 16;
compression = BMP_BITFIELDS;
pal = rgb565_masks; // abuse pal to hold color masks
@@ -115,14 +115,7 @@ static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s
ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
buf = buf0 + hsize;
for(i = 0; i < avctx->height; i++) {
- if (bit_count == 16) {
- const uint16_t *src = (const uint16_t *) ptr;
- uint16_t *dst = (uint16_t *) buf;
- for(n = 0; n < avctx->width; n++)
- AV_WL16(dst + n, src[n]);
- } else {
- memcpy(buf, ptr, n_bytes_per_row);
- }
+ memcpy(buf, ptr, n_bytes_per_row);
buf += n_bytes_per_row;
memset(buf, 0, pad_bytes_per_row);
buf += pad_bytes_per_row;
@@ -141,7 +134,7 @@ AVCodec bmp_encoder = {
NULL, //encode_end,
.pix_fmts = (enum PixelFormat[]){
PIX_FMT_BGR24,
- PIX_FMT_RGB555, PIX_FMT_RGB565,
+ PIX_FMT_RGB555LE, PIX_FMT_RGB565LE,
PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8,
PIX_FMT_MONOBLACK,
PIX_FMT_NONE},
--
1.6.2
More information about the ffmpeg-devel
mailing list