comparison vqavideo.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 e0c02032d0f2
children 932d306bf1dc
comparison
equal deleted inserted replaced
1584:3615999a7284 1585:6b224ca24033
118 AVFrame frame; 118 AVFrame frame;
119 119
120 unsigned char *buf; 120 unsigned char *buf;
121 int size; 121 int size;
122 122
123 unsigned char palette[PALETTE_COUNT * 4]; 123 unsigned int palette[PALETTE_COUNT];
124 124
125 int width; /* width of a frame */ 125 int width; /* width of a frame */
126 int height; /* height of a frame */ 126 int height; /* height of a frame */
127 int vector_width; /* width of individual vector */ 127 int vector_width; /* width of individual vector */
128 int vector_height; /* height of individual vector */ 128 int vector_height; /* height of individual vector */
309 unsigned int chunk_size; 309 unsigned int chunk_size;
310 int byte_skip; 310 int byte_skip;
311 unsigned int index = 0; 311 unsigned int index = 0;
312 int i; 312 int i;
313 unsigned char r, g, b; 313 unsigned char r, g, b;
314 unsigned int *palette32;
315 int index_shift; 314 int index_shift;
316 315
317 int cbf0_chunk = -1; 316 int cbf0_chunk = -1;
318 int cbfz_chunk = -1; 317 int cbfz_chunk = -1;
319 int cbp0_chunk = -1; 318 int cbp0_chunk = -1;
405 printf (" VQA video: problem: found a palette chunk with %d colors\n", 404 printf (" VQA video: problem: found a palette chunk with %d colors\n",
406 chunk_size / 3); 405 chunk_size / 3);
407 return; 406 return;
408 } 407 }
409 cpl0_chunk += CHUNK_PREAMBLE_SIZE; 408 cpl0_chunk += CHUNK_PREAMBLE_SIZE;
410 palette32 = (unsigned int *)s->palette;
411 for (i = 0; i < chunk_size / 3; i++) { 409 for (i = 0; i < chunk_size / 3; i++) {
412 /* scale by 4 to transform 6-bit palette -> 8-bit */ 410 /* scale by 4 to transform 6-bit palette -> 8-bit */
413 r = s->buf[cpl0_chunk++] * 4; 411 r = s->buf[cpl0_chunk++] * 4;
414 g = s->buf[cpl0_chunk++] * 4; 412 g = s->buf[cpl0_chunk++] * 4;
415 b = s->buf[cpl0_chunk++] * 4; 413 b = s->buf[cpl0_chunk++] * 4;
416 palette32[i] = (r << 16) | (g << 8) | (b); 414 s->palette[i] = (r << 16) | (g << 8) | (b);
417 } 415 }
418 } 416 }
419 417
420 /* next, look for a full codebook */ 418 /* next, look for a full codebook */
421 if ((cbf0_chunk != -1) && (cbfz_chunk != -1)) { 419 if ((cbf0_chunk != -1) && (cbfz_chunk != -1)) {
581 579
582 vqa_decode_chunk(s); 580 vqa_decode_chunk(s);
583 581
584 /* make the palette available on the way out */ 582 /* make the palette available on the way out */
585 memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4); 583 memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4);
584 s->frame.palette_has_changed = 1;
586 585
587 *data_size = sizeof(AVFrame); 586 *data_size = sizeof(AVFrame);
588 *(AVFrame*)data = s->frame; 587 *(AVFrame*)data = s->frame;
589 588
590 /* report that the buffer was completely consumed */ 589 /* report that the buffer was completely consumed */