summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h19
-rw-r--r--libavcodec/xan.c12
2 files changed, 25 insertions, 6 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c193117deb..16fe4ed8f6 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1305,6 +1305,25 @@ typedef struct AVPicture {
int linesize[4]; ///< number of bytes per line
} AVPicture;
+/**
+ * AVPaletteControl
+ * This structure defines a method for communicating palette changes
+ * between and demuxer and a decoder.
+ */
+typedef struct AVPaletteControl {
+
+ /* demuxer sets this to 1 to indicate the palette has changed;
+ * decoder resets to 0 */
+ int palette_changed;
+
+ /* 256 3-byte RGB palette entries; the components should be
+ * formatted in the buffer as "RGBRGB..." and should be scaled to
+ * 8 bits if they originally represented 6-bit VGA palette
+ * components */
+ unsigned char palette[256 * 3];
+
+} AVPaletteControl;
+
extern AVCodec ac3_encoder;
extern AVCodec mp2_encoder;
extern AVCodec mp3lame_encoder;
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index fa41c1da9b..918048f45f 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -115,9 +115,9 @@ static int xan_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
if ((avctx->codec->id == CODEC_ID_XAN_WC3) &&
- (s->avctx->extradata_size != PALETTE_CONTROL_SIZE)) {
+ (s->avctx->extradata_size != sizeof(AVPaletteControl))) {
printf (" WC3 Xan video: expected extradata_size of %d\n",
- PALETTE_CONTROL_SIZE);
+ sizeof(AVPaletteControl));
return -1;
}
@@ -809,13 +809,13 @@ static int xan_decode_frame(AVCodecContext *avctx,
uint8_t *buf, int buf_size)
{
XanContext *s = avctx->priv_data;
- unsigned char *palette_control = avctx->extradata;
+ AVPaletteControl *palette_control = (AVPaletteControl *)avctx->extradata;
int keyframe = 0;
- if (palette_control[0]) {
+ if (palette_control->palette_changed) {
/* load the new palette and reset the palette control */
- xan_wc3_build_palette(s, &palette_control[1]);
- palette_control[0] = 0;
+ xan_wc3_build_palette(s, palette_control->palette);
+ palette_control->palette_changed = 0;
keyframe = 1;
}