"Fossies" - the Fresh Open Source Software Archive

Member "quicktime4linux-2.3/elst.c" (9 Jan 2007, 2902 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 void quicktime_elst_table_init(quicktime_elst_table_t *table)
    6 {
    7     table->duration = 0;
    8     table->time = 0;
    9     table->rate = 1;
   10 }
   11 
   12 void quicktime_elst_table_delete(quicktime_elst_table_t *table)
   13 {
   14 }
   15 
   16 void quicktime_read_elst_table(quicktime_t *file, quicktime_elst_table_t *table)
   17 {
   18     table->duration = quicktime_read_int32(file);
   19     table->time = quicktime_read_int32(file);
   20     table->rate = quicktime_read_fixed32(file);
   21 }
   22 
   23 void quicktime_write_elst_table(quicktime_t *file, quicktime_elst_table_t *table, long duration)
   24 {
   25     table->duration = duration;
   26     quicktime_write_int32(file, table->duration);
   27     quicktime_write_int32(file, table->time);
   28     quicktime_write_fixed32(file, table->rate);
   29 }
   30 
   31 void quicktime_elst_table_dump(quicktime_elst_table_t *table)
   32 {
   33     printf("    edit list table\n");
   34     printf("     duration %ld\n", table->duration);
   35     printf("     time %ld\n", table->time);
   36     printf("     rate %f\n", table->rate);
   37 }
   38 
   39 void quicktime_elst_init(quicktime_elst_t *elst)
   40 {
   41     elst->version = 0;
   42     elst->flags = 0;
   43     elst->total_entries = 0;
   44     elst->table = 0;
   45 }
   46 
   47 void quicktime_elst_init_all(quicktime_elst_t *elst)
   48 {
   49     if(!elst->total_entries)
   50     {
   51         elst->total_entries = 1;
   52         elst->table = (quicktime_elst_table_t*)calloc(1, sizeof(quicktime_elst_table_t) * elst->total_entries);
   53         quicktime_elst_table_init(&(elst->table[0]));
   54     }
   55 }
   56 
   57 void quicktime_elst_delete(quicktime_elst_t *elst)
   58 {
   59     int i;
   60     if(elst->total_entries)
   61     {
   62         for(i = 0; i < elst->total_entries; i++)
   63             quicktime_elst_table_delete(&(elst->table[i]));
   64         free(elst->table);
   65     }
   66     elst->total_entries = 0;
   67 }
   68 
   69 void quicktime_elst_dump(quicktime_elst_t *elst)
   70 {
   71     int i;
   72     printf("   edit list (elst)\n");
   73     printf("    version %d\n", elst->version);
   74     printf("    flags %d\n", elst->flags);
   75     printf("    total_entries %d\n", elst->total_entries);
   76 
   77     for(i = 0; i < elst->total_entries; i++)
   78     {
   79         quicktime_elst_table_dump(&(elst->table[i]));
   80     }
   81 }
   82 
   83 void quicktime_read_elst(quicktime_t *file, quicktime_elst_t *elst)
   84 {
   85     int i;
   86     quicktime_atom_t leaf_atom;
   87 
   88     elst->version = quicktime_read_char(file);
   89     elst->flags = quicktime_read_int24(file);
   90     elst->total_entries = quicktime_read_int32(file);
   91     elst->table = (quicktime_elst_table_t*)calloc(1, sizeof(quicktime_elst_table_t) * elst->total_entries);
   92     for(i = 0; i < elst->total_entries; i++)
   93     {
   94         quicktime_elst_table_init(&(elst->table[i]));
   95         quicktime_read_elst_table(file, &(elst->table[i]));
   96     }
   97 }
   98 
   99 void quicktime_write_elst(quicktime_t *file, quicktime_elst_t *elst, long duration)
  100 {
  101     quicktime_atom_t atom;
  102     int i;
  103     quicktime_atom_write_header(file, &atom, "elst");
  104 
  105     quicktime_write_char(file, elst->version);
  106     quicktime_write_int24(file, elst->flags);
  107     quicktime_write_int32(file, elst->total_entries);
  108     for(i = 0; i < elst->total_entries; i++)
  109     {
  110         quicktime_write_elst_table(file, elst->table, duration);
  111     }
  112 
  113     quicktime_atom_write_footer(file, &atom);
  114 }