Mercurial > libavcodec.hg
comparison flicvideo.c @ 4045:1bf7bc44430f libavcodec
correct signaling of palette change
author | alex |
---|---|
date | Thu, 19 Oct 2006 23:03:47 +0000 |
parents | c8c591fe26f8 |
children | 214d3d9b69dc |
comparison
equal
deleted
inserted
replaced
4044:5ccdefd60f61 | 4045:1bf7bc44430f |
---|---|
188 | 188 |
189 switch (chunk_type) { | 189 switch (chunk_type) { |
190 case FLI_256_COLOR: | 190 case FLI_256_COLOR: |
191 case FLI_COLOR: | 191 case FLI_COLOR: |
192 stream_ptr_after_color_chunk = stream_ptr + chunk_size - 6; | 192 stream_ptr_after_color_chunk = stream_ptr + chunk_size - 6; |
193 s->new_palette = 1; | |
194 | 193 |
195 /* check special case: If this file is from the Magic Carpet | 194 /* check special case: If this file is from the Magic Carpet |
196 * game and uses 6-bit colors even though it reports 256-color | 195 * game and uses 6-bit colors even though it reports 256-color |
197 * chunks in a 0xAF12-type file (fli_type is set to 0xAF13 during | 196 * chunks in a 0xAF12-type file (fli_type is set to 0xAF13 during |
198 * initialization) */ | 197 * initialization) */ |
214 /* if there are 0 color changes, there are actually 256 */ | 213 /* if there are 0 color changes, there are actually 256 */ |
215 if (color_changes == 0) | 214 if (color_changes == 0) |
216 color_changes = 256; | 215 color_changes = 256; |
217 | 216 |
218 for (j = 0; j < color_changes; j++) { | 217 for (j = 0; j < color_changes; j++) { |
218 unsigned int entry; | |
219 | 219 |
220 /* wrap around, for good measure */ | 220 /* wrap around, for good measure */ |
221 if ((unsigned)palette_ptr >= 256) | 221 if ((unsigned)palette_ptr >= 256) |
222 palette_ptr = 0; | 222 palette_ptr = 0; |
223 | 223 |
224 r = buf[stream_ptr++] << color_shift; | 224 r = buf[stream_ptr++] << color_shift; |
225 g = buf[stream_ptr++] << color_shift; | 225 g = buf[stream_ptr++] << color_shift; |
226 b = buf[stream_ptr++] << color_shift; | 226 b = buf[stream_ptr++] << color_shift; |
227 s->palette[palette_ptr++] = (r << 16) | (g << 8) | b; | 227 entry = (r << 16) | (g << 8) | b; |
228 if (s->palette[palette_ptr] != entry) | |
229 s->new_palette = 1; | |
230 s->palette[palette_ptr++] = entry; | |
228 } | 231 } |
229 } | 232 } |
230 | 233 |
231 /* color chunks sometimes have weird 16-bit alignment issues; | 234 /* color chunks sometimes have weird 16-bit alignment issues; |
232 * therefore, take the hardline approach and set the stream_ptr | 235 * therefore, take the hardline approach and set the stream_ptr |
402 if ((stream_ptr != buf_size) && (stream_ptr != buf_size - 1)) | 405 if ((stream_ptr != buf_size) && (stream_ptr != buf_size - 1)) |
403 av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ | 406 av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ |
404 "and final chunk ptr = %d\n", buf_size, stream_ptr); | 407 "and final chunk ptr = %d\n", buf_size, stream_ptr); |
405 | 408 |
406 /* make the palette available on the way out */ | 409 /* make the palette available on the way out */ |
407 // if (s->new_palette) { | 410 memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); |
408 if (1) { | 411 if (s->new_palette) { |
409 memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); | |
410 s->frame.palette_has_changed = 1; | 412 s->frame.palette_has_changed = 1; |
411 s->new_palette = 0; | 413 s->new_palette = 0; |
412 } | 414 } |
413 | 415 |
414 *data_size=sizeof(AVFrame); | 416 *data_size=sizeof(AVFrame); |