Merge remote-tracking branch 'richardpl/sws'
* richardpl/sws: rgb2rgb: remove unused bgr8torgb8() rgb2rgb: rgb12tobgr12() rgb2rgb: allow conversion for <15 bpp bmpenc: support for PIX_FMT_RGB444 bmpdec: support for rgb444 with bitfields compression Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -163,8 +163,18 @@ static int bmp_decode_frame(AVCodecContext *avctx,
|
||||
case 16:
|
||||
if(comp == BMP_RGB)
|
||||
avctx->pix_fmt = PIX_FMT_RGB555;
|
||||
if(comp == BMP_BITFIELDS)
|
||||
avctx->pix_fmt = rgb[1] == 0x07E0 ? PIX_FMT_RGB565 : PIX_FMT_RGB555;
|
||||
else if (comp == BMP_BITFIELDS) {
|
||||
if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)
|
||||
avctx->pix_fmt = PIX_FMT_RGB565;
|
||||
else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)
|
||||
avctx->pix_fmt = PIX_FMT_RGB555;
|
||||
else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
|
||||
avctx->pix_fmt = PIX_FMT_RGB444;
|
||||
else {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if(hsize - ihsize - 14 > 0)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
static const uint32_t monoblack_pal[] = { 0x000000, 0xFFFFFF };
|
||||
static const uint32_t rgb565_masks[] = { 0xF800, 0x07E0, 0x001F };
|
||||
static const uint32_t rgb444_masks[] = { 0x0F00, 0x00F0, 0x000F };
|
||||
|
||||
static av_cold int bmp_encode_init(AVCodecContext *avctx){
|
||||
BMPContext *s = avctx->priv_data;
|
||||
@@ -40,9 +41,8 @@ static av_cold int bmp_encode_init(AVCodecContext *avctx){
|
||||
avctx->bits_per_coded_sample = 24;
|
||||
break;
|
||||
case PIX_FMT_RGB555:
|
||||
avctx->bits_per_coded_sample = 16;
|
||||
break;
|
||||
case PIX_FMT_RGB565:
|
||||
case PIX_FMT_RGB444:
|
||||
avctx->bits_per_coded_sample = 16;
|
||||
break;
|
||||
case PIX_FMT_RGB8:
|
||||
@@ -79,6 +79,11 @@ static int bmp_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s
|
||||
p->pict_type= AV_PICTURE_TYPE_I;
|
||||
p->key_frame= 1;
|
||||
switch (avctx->pix_fmt) {
|
||||
case PIX_FMT_RGB444:
|
||||
compression = BMP_BITFIELDS;
|
||||
pal = rgb444_masks; // abuse pal to hold color masks
|
||||
pal_entries = 3;
|
||||
break;
|
||||
case PIX_FMT_RGB565:
|
||||
compression = BMP_BITFIELDS;
|
||||
pal = rgb565_masks; // abuse pal to hold color masks
|
||||
@@ -163,7 +168,7 @@ AVCodec ff_bmp_encoder = {
|
||||
.encode = bmp_encode_frame,
|
||||
.pix_fmts = (const enum PixelFormat[]){
|
||||
PIX_FMT_BGR24,
|
||||
PIX_FMT_RGB555, PIX_FMT_RGB565,
|
||||
PIX_FMT_RGB555, PIX_FMT_RGB444, PIX_FMT_RGB565,
|
||||
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},
|
||||
|
||||
Reference in New Issue
Block a user