"Fossies" - the Fresh Open Source Software Archive

Member "quicktime4linux-2.3/stbl.c" (9 Jan 2007, 4161 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 void quicktime_stbl_init(quicktime_stbl_t *stbl)
    5 {
    6     stbl->version = 0;
    7     stbl->flags = 0;
    8     quicktime_stsd_init(&(stbl->stsd));
    9     quicktime_stts_init(&(stbl->stts));
   10     quicktime_stss_init(&(stbl->stss));
   11     quicktime_stsc_init(&(stbl->stsc));
   12     quicktime_stsz_init(&(stbl->stsz));
   13     quicktime_stco_init(&(stbl->stco));
   14 }
   15 
   16 void quicktime_stbl_init_video(quicktime_t *file, 
   17                                 quicktime_stbl_t *stbl, 
   18                                 int frame_w,
   19                                 int frame_h, 
   20                                 int time_scale, 
   21                                 float frame_rate,
   22                                 char *compressor)
   23 {
   24 //printf("quicktime_stbl_init_video 1\n");
   25     quicktime_stsd_init_video(file, &(stbl->stsd), frame_w, frame_h, frame_rate, compressor);
   26 //printf("quicktime_stbl_init_video 1 %d %f\n", time_scale, frame_rate);
   27     quicktime_stts_init_video(file, &(stbl->stts), time_scale, frame_rate);
   28 //printf("quicktime_stbl_init_video 1\n");
   29     quicktime_stsc_init_video(file, &(stbl->stsc));
   30 //printf("quicktime_stbl_init_video 1\n");
   31     quicktime_stsz_init_video(file, &(stbl->stsz));
   32 //printf("quicktime_stbl_init_video 1\n");
   33     quicktime_stco_init_common(file, &(stbl->stco));
   34 //printf("quicktime_stbl_init_video 2\n");
   35 }
   36 
   37 
   38 void quicktime_stbl_init_audio(quicktime_t *file, 
   39                             quicktime_stbl_t *stbl, 
   40                             int channels, 
   41                             int sample_rate, 
   42                             int bits, 
   43                             char *compressor)
   44 {
   45     quicktime_stsd_init_audio(file, &(stbl->stsd), 
   46         channels, 
   47         sample_rate, 
   48         bits, 
   49         compressor);
   50     quicktime_stts_init_audio(file, &(stbl->stts), sample_rate);
   51     quicktime_stsc_init_audio(file, &(stbl->stsc), sample_rate);
   52     quicktime_stsz_init_audio(file, &(stbl->stsz), channels, bits, compressor);
   53     quicktime_stco_init_common(file, &(stbl->stco));
   54 }
   55 
   56 void quicktime_stbl_delete(quicktime_stbl_t *stbl)
   57 {
   58     quicktime_stsd_delete(&(stbl->stsd));
   59     quicktime_stts_delete(&(stbl->stts));
   60     quicktime_stss_delete(&(stbl->stss));
   61     quicktime_stsc_delete(&(stbl->stsc));
   62     quicktime_stsz_delete(&(stbl->stsz));
   63     quicktime_stco_delete(&(stbl->stco));
   64 }
   65 
   66 void quicktime_stbl_dump(void *minf_ptr, quicktime_stbl_t *stbl)
   67 {
   68     printf("    sample table\n");
   69     quicktime_stsd_dump(minf_ptr, &(stbl->stsd));
   70     quicktime_stts_dump(&(stbl->stts));
   71     quicktime_stss_dump(&(stbl->stss));
   72     quicktime_stsc_dump(&(stbl->stsc));
   73     quicktime_stsz_dump(&(stbl->stsz));
   74     quicktime_stco_dump(&(stbl->stco));
   75 }
   76 
   77 int quicktime_read_stbl(quicktime_t *file, quicktime_minf_t *minf, quicktime_stbl_t *stbl, quicktime_atom_t *parent_atom)
   78 {
   79     quicktime_atom_t leaf_atom;
   80 
   81     do
   82     {
   83         quicktime_atom_read_header(file, &leaf_atom);
   84 
   85 //printf("quicktime_read_stbl 1\n");
   86 /* mandatory */
   87         if(quicktime_atom_is(&leaf_atom, "stsd"))
   88         { 
   89             quicktime_read_stsd(file, minf, &(stbl->stsd)); 
   90 /* Some codecs store extra information at the end of this */
   91             quicktime_atom_skip(file, &leaf_atom);
   92         }
   93         else
   94         if(quicktime_atom_is(&leaf_atom, "stts"))
   95             { quicktime_read_stts(file, &(stbl->stts)); }
   96         else
   97         if(quicktime_atom_is(&leaf_atom, "stss"))
   98             { quicktime_read_stss(file, &(stbl->stss)); }
   99         else
  100         if(quicktime_atom_is(&leaf_atom, "stsc"))
  101         {
  102             quicktime_read_stsc(file, &(stbl->stsc));
  103 /* 
  104  * Minolta DimageZ3 pads stsc with zeroes
  105  * so we need to jump to next atom explicitly 
  106  */
  107             quicktime_atom_skip(file, &leaf_atom);
  108         }
  109         else
  110         if(quicktime_atom_is(&leaf_atom, "stsz"))
  111             { quicktime_read_stsz(file, &(stbl->stsz)); }
  112         else
  113         if(quicktime_atom_is(&leaf_atom, "co64"))
  114             { quicktime_read_stco64(file, &(stbl->stco)); }
  115         else
  116         if(quicktime_atom_is(&leaf_atom, "stco"))
  117             { quicktime_read_stco(file, &(stbl->stco)); }
  118         else
  119         {
  120             quicktime_atom_skip(file, &leaf_atom);
  121         }
  122     }while(quicktime_position(file) < parent_atom->end);
  123 
  124     return 0;
  125 }
  126 
  127 void quicktime_write_stbl(quicktime_t *file, quicktime_minf_t *minf, quicktime_stbl_t *stbl)
  128 {
  129     quicktime_atom_t atom;
  130     quicktime_atom_write_header(file, &atom, "stbl");
  131 
  132     quicktime_write_stsd(file, minf, &(stbl->stsd));
  133     quicktime_write_stts(file, &(stbl->stts));
  134     quicktime_write_stss(file, &(stbl->stss));
  135     quicktime_write_stsc(file, &(stbl->stsc));
  136     quicktime_write_stsz(file, &(stbl->stsz));
  137     quicktime_write_stco(file, &(stbl->stco));
  138 
  139     quicktime_atom_write_footer(file, &atom);
  140 }
  141 
  142