Skip to content

Commit

Permalink
lavc/cdg: Add transparency support.
Browse files Browse the repository at this point in the history
  • Loading branch information
cehoyos committed Oct 30, 2015
1 parent b7fb7c4 commit 2f1d6d4
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 214 deletions.
8 changes: 8 additions & 0 deletions libavcodec/cdgraphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#define LIBAVCODEC_VERSION_MAJOR 57
#define LIBAVCODEC_VERSION_MINOR 13
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 101

#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
Expand Down
2 changes: 1 addition & 1 deletion tests/fate/video.mak
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ FATE_VIDEO-$(call DEMDEC, MPEGPS, CAVS) += fate-cavs
fate-cavs: CMD = framecrc -i $(TARGET_SAMPLES)/cavs/cavs.mpg -an

FATE_VIDEO-$(call DEMDEC, CDG, CDGRAPHICS) += fate-cdgraphics
fate-cdgraphics: CMD = framecrc -i $(TARGET_SAMPLES)/cdgraphics/BrotherJohn.cdg -pix_fmt rgb24 -t 1
fate-cdgraphics: CMD = framecrc -i $(TARGET_SAMPLES)/cdgraphics/BrotherJohn.cdg -pix_fmt rgba -t 1

FATE_VIDEO-$(call DEMDEC, AVI, CLJR) += fate-cljr
fate-cljr: CMD = framecrc -i $(TARGET_SAMPLES)/cljr/testcljr-partial.avi
Expand Down
Loading

0 comments on commit 2f1d6d4

Please sign in to comment.