Mercurial > libavcodec.hg
diff interplayvideo.c @ 1585:6b224ca24033 libavcodec
revised palette API, courtesy of Roberto Togni (rtogni at freemail.it)
author | melanson |
---|---|
date | Thu, 30 Oct 2003 05:40:58 +0000 |
parents | b340e83b8d0d |
children | 932d306bf1dc |
line wrap: on
line diff
--- a/interplayvideo.c Wed Oct 29 17:30:13 2003 +0000 +++ b/interplayvideo.c Thu Oct 30 05:40:58 2003 +0000 @@ -65,8 +65,6 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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;