From 2a2bbcb05fde486eef76d070f26eecddd4de0ace Mon Sep 17 00:00:00 2001 From: Mike Melanson Date: Thu, 30 Oct 2003 05:40:58 +0000 Subject: revised palette API, courtesy of Roberto Togni (rtogni at freemail.it) Originally committed as revision 2451 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/interplayvideo.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'libavcodec/interplayvideo.c') diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index a8a7c0f562..72e0377475 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -65,8 +65,6 @@ typedef struct IpvideoContext { unsigned char *buf; int size; - unsigned char palette[PALETTE_COUNT * 4]; - unsigned char *stream_ptr; unsigned char *stream_end; unsigned char *pixel_ptr; @@ -83,21 +81,6 @@ typedef struct IpvideoContext { return -1; \ } -static void ipvideo_new_palette(IpvideoContext *s, unsigned char *palette) { - - int i; - unsigned char r, g, b; - unsigned int *palette32; - - palette32 = (unsigned int *)s->palette; - for (i = 0; i < PALETTE_COUNT; i++) { - r = *palette++; - g = *palette++; - b = *palette++; - palette32[i] = (r << 16) | (g << 8) | (b); - } -} - #define COPY_FROM_CURRENT() \ motion_offset = current_offset; \ motion_offset += y * s->stride; \ @@ -828,7 +811,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s) code_counts[x] = 0; /* this is PAL8, so make the palette available */ - memcpy(s->current_frame.data[1], s->palette, PALETTE_COUNT * 4); + memcpy(s->current_frame.data[1], s->avctx->palctrl->palette, PALETTE_COUNT * 4); s->stride = s->current_frame.linesize[0]; s->stream_ptr = s->buf + 14; /* data starts 14 bytes in */ @@ -874,9 +857,8 @@ static int ipvideo_decode_init(AVCodecContext *avctx) s->avctx = avctx; - if (s->avctx->extradata_size != sizeof(AVPaletteControl)) { - printf (" Interplay video: expected extradata_size of %d\n", - (int)sizeof(AVPaletteControl)); + if (s->avctx->palctrl == NULL) { + printf (" Interplay video: palette expected.\n"); return -1; } @@ -916,13 +898,7 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size) { IpvideoContext *s = avctx->priv_data; - AVPaletteControl *palette_control = (AVPaletteControl *)avctx->extradata; - - if (palette_control->palette_changed) { - /* load the new palette and reset the palette control */ - ipvideo_new_palette(s, palette_control->palette); - palette_control->palette_changed = 0; - } + AVPaletteControl *palette_control = avctx->palctrl; s->decoding_map = buf; s->buf = buf + s->decoding_map_size; @@ -936,6 +912,11 @@ static int ipvideo_decode_frame(AVCodecContext *avctx, ipvideo_decode_opcodes(s); + if (palette_control->palette_changed) { + palette_control->palette_changed = 0; + s->current_frame.palette_has_changed = 1; + } + *data_size = sizeof(AVFrame); *(AVFrame*)data = s->current_frame; -- cgit v1.2.3