"Fossies" - the Fresh Open Source Software Archive

Member "quicktime4linux-2.3/ctab.c" (9 Jan 2007, 1481 Bytes) of package /linux/privat/old/quicktime4linux-2.3-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include <stdio.h>
    2 #include "funcprotos.h"
    3 #include "quicktime.h"
    4 
    5 int quicktime_ctab_init(quicktime_ctab_t *ctab)
    6 {
    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;
   15 }
   16 
   17 int quicktime_ctab_delete(quicktime_ctab_t *ctab)
   18 {
   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;
   24 }
   25 
   26 void quicktime_ctab_dump(quicktime_ctab_t *ctab)
   27 {
   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++)
   35     {
   36         printf("[%d %d %d %d]", ctab->red[i], ctab->green[i], ctab->blue[i], ctab->alpha[i]);
   37     }
   38     printf("\n");
   39 }
   40 
   41 int quicktime_read_ctab(quicktime_t *file, quicktime_ctab_t *ctab)
   42 {
   43     int i;
   44     
   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);
   52     
   53     for(i = 0; i < ctab->size; i++)
   54     {
   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);
   59     }
   60 
   61     return 0;
   62 }