"Fossies" - the Fresh Open Source Software Archive

Member "quicktime4linux-2.3/stss.c" (9 Jan 2007, 1860 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 "funcprotos.h"
    2 #include "quicktime.h"
    3 
    4 
    5 
    6 void quicktime_stss_init(quicktime_stss_t *stss)
    7 {
    8     stss->version = 0;
    9     stss->flags = 0;
   10     stss->total_entries = 0;
   11     stss->entries_allocated = 2;
   12     stss->table = (quicktime_stss_table_t*)calloc(1, sizeof(quicktime_stss_table_t) * stss->entries_allocated);
   13 }
   14 
   15 void quicktime_stss_delete(quicktime_stss_t *stss)
   16 {
   17     if(stss->entries_allocated) free(stss->table);
   18     stss->total_entries = 0;
   19     stss->entries_allocated = 0;
   20     stss->table = 0;
   21 }
   22 
   23 void quicktime_stss_dump(quicktime_stss_t *stss)
   24 {
   25     int i;
   26     printf("     sync sample\n");
   27     printf("      version %d\n", stss->version);
   28     printf("      flags %d\n", stss->flags);
   29     printf("      total_entries %d\n", stss->total_entries);
   30     for(i = 0; i < stss->total_entries; i++)
   31     {
   32         printf("       sample %x\n", stss->table[i].sample);
   33     }
   34 }
   35 
   36 void quicktime_read_stss(quicktime_t *file, quicktime_stss_t *stss)
   37 {
   38     int i;
   39     stss->version = quicktime_read_char(file);
   40     stss->flags = quicktime_read_int24(file);
   41     stss->total_entries = quicktime_read_int32(file);
   42 
   43     if(stss->entries_allocated < stss->total_entries)
   44     {
   45         stss->entries_allocated = stss->total_entries;
   46         stss->table = (quicktime_stss_table_t*)realloc(stss->table, sizeof(quicktime_stss_table_t) * stss->entries_allocated);
   47     }
   48 
   49     for(i = 0; i < stss->total_entries; i++)
   50     {
   51         stss->table[i].sample = quicktime_read_int32(file);
   52     }
   53 }
   54 
   55 
   56 void quicktime_write_stss(quicktime_t *file, quicktime_stss_t *stss)
   57 {
   58     int i;
   59     quicktime_atom_t atom;
   60 
   61     if(stss->total_entries)
   62     {
   63         quicktime_atom_write_header(file, &atom, "stss");
   64 
   65         quicktime_write_char(file, stss->version);
   66         quicktime_write_int24(file, stss->flags);
   67         quicktime_write_int32(file, stss->total_entries);
   68         for(i = 0; i < stss->total_entries; i++)
   69         {
   70             quicktime_write_int32(file, stss->table[i].sample);
   71         }
   72 
   73         quicktime_atom_write_footer(file, &atom);
   74     }
   75 }