lavc/cdg: Add transparency support.

This commit is contained in:
Carl Eugen Hoyos
2015-10-30 01:24:50 +01:00
parent b7fb7c4542
commit 2f1d6d45af
4 changed files with 222 additions and 214 deletions

View File

@@ -49,6 +49,7 @@
#define CDG_INST_TILE_BLOCK 6
#define CDG_INST_SCROLL_PRESET 20
#define CDG_INST_SCROLL_COPY 24
#define CDG_INST_TRANSPARENT_COL 28
#define CDG_INST_LOAD_PAL_LO 30
#define CDG_INST_LOAD_PAL_HIGH 31
#define CDG_INST_TILE_BLOCK_XOR 38
@@ -67,6 +68,7 @@ typedef struct CDGraphicsContext {
AVFrame *frame;
int hscroll;
int vscroll;
int transparency;
} CDGraphicsContext;
static av_cold int cdg_decode_init(AVCodecContext *avctx)
@@ -76,6 +78,7 @@ static av_cold int cdg_decode_init(AVCodecContext *avctx)
cc->frame = av_frame_alloc();
if (!cc->frame)
return AVERROR(ENOMEM);
cc->transparency = -1;
avctx->width = CDG_FULL_WIDTH;
avctx->height = CDG_FULL_HEIGHT;
@@ -120,6 +123,8 @@ static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low)
g = ((color >> 4) & 0x000F) * 17;
b = ((color ) & 0x000F) * 17;
palette[i + array_offset] = 0xFFU << 24 | r << 16 | g << 8 | b;
if (cc->transparency >= 0)
palette[cc->transparency] &= 0xFFFFFF;
}
cc->frame->palette_has_changed = 1;
}
@@ -341,6 +346,9 @@ static int cdg_decode_frame(AVCodecContext *avctx,
if (ret < 0)
return ret;
break;
case CDG_INST_TRANSPARENT_COL:
cc->transparency = cdg_data[0] & 0xF;
break;
default:
break;
}