r878: This is Cinelerra 2.1.
[cinelerra_cv/ct.git] / quicktime / ctab.c
blobf9d458f178d8dd958b41c3584fb076a1132e3ebd
1 #include <stdio.h>
2 #include "funcprotos.h"
3 #include "quicktime.h"
5 int quicktime_ctab_init(quicktime_ctab_t *ctab)
7 ctab->seed = 0;
8 ctab->flags = 0;
9 ctab->size = 0;
10 ctab->alpha = 0;
11 ctab->red = 0;
12 ctab->green = 0;
13 ctab->blue = 0;
14 return 0;
17 int quicktime_ctab_delete(quicktime_ctab_t *ctab)
19 if(ctab->alpha) free(ctab->alpha);
20 if(ctab->red) free(ctab->red);
21 if(ctab->green) free(ctab->green);
22 if(ctab->blue) free(ctab->blue);
23 return 0;
26 void quicktime_ctab_dump(quicktime_ctab_t *ctab)
28 int i;
29 printf(" color table\n");
30 printf(" seed %ld\n", ctab->seed);
31 printf(" flags %ld\n", ctab->flags);
32 printf(" size %ld\n", ctab->size);
33 printf(" colors ");
34 for(i = 0; i < ctab->size; i++)
36 printf("[%d %d %d %d]", ctab->red[i], ctab->green[i], ctab->blue[i], ctab->alpha[i]);
38 printf("\n");
41 int quicktime_read_ctab(quicktime_t *file, quicktime_ctab_t *ctab)
43 int i;
45 ctab->seed = quicktime_read_int32(file);
46 ctab->flags = quicktime_read_int16(file);
47 ctab->size = quicktime_read_int16(file) + 1;
48 ctab->alpha = malloc(sizeof(int16_t) * ctab->size);
49 ctab->red = malloc(sizeof(int16_t) * ctab->size);
50 ctab->green = malloc(sizeof(int16_t) * ctab->size);
51 ctab->blue = malloc(sizeof(int16_t) * ctab->size);
53 for(i = 0; i < ctab->size; i++)
55 ctab->alpha[i] = quicktime_read_int16(file);
56 ctab->red[i] = quicktime_read_int16(file);
57 ctab->green[i] = quicktime_read_int16(file);
58 ctab->blue[i] = quicktime_read_int16(file);
61 return 0;