"Fossies" - the Fresh Open Source Software Archive

Member "quicktime4linux-2.3/funcprotos.h" (9 Jan 2007, 16653 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 #ifndef FUNCPROTOS_H
    2 #define FUNCPROTOS_H
    3 
    4 #include "graphics.h"
    5 #include "qtprivate.h"
    6 
    7 /* atom handling routines */
    8 int quicktime_atom_write_header(quicktime_t *file, quicktime_atom_t *atom, char *text);
    9 int quicktime_atom_write_header64(quicktime_t *file, quicktime_atom_t *atom, char *text);
   10 int64_t quicktime_byte_position(quicktime_t *file);
   11 // Used internally to replace ftello values
   12 int64_t quicktime_ftell(quicktime_t *file);
   13 int quicktime_atom_is(quicktime_atom_t *atom, unsigned char *type);
   14 
   15 quicktime_trak_t* quicktime_add_track(quicktime_t *file);
   16 
   17 
   18 
   19 int quicktime_file_open(quicktime_t *file, char *path, int rd, int wr);
   20 int quicktime_file_close(quicktime_t *file);
   21 int64_t quicktime_get_file_length(char *path);
   22 
   23 /* Initialize audio_map_t and video_map_t objects after loading headers */
   24 /* Called by quicktime_read_info */
   25 void quicktime_init_maps(quicktime_t *file);
   26 
   27 int quicktime_read_char(quicktime_t *file);
   28 float quicktime_read_fixed32(quicktime_t *file);
   29 float quicktime_read_fixed16(quicktime_t *file);
   30 int64_t quicktime_read_int64(quicktime_t *file);
   31 int64_t quicktime_read_int64_le(quicktime_t *file);
   32 unsigned long quicktime_read_uint32(quicktime_t *file);
   33 long quicktime_read_int32(quicktime_t *file);
   34 long quicktime_read_int32_le(quicktime_t *file);
   35 long quicktime_read_int24(quicktime_t *file);
   36 int64_t quicktime_position(quicktime_t *file);
   37 int quicktime_set_position(quicktime_t *file, int64_t position);
   38 int quicktime_write_fixed32(quicktime_t *file, float number);
   39 int quicktime_write_char(quicktime_t *file, char x);
   40 int quicktime_write_int16(quicktime_t *file, int number);
   41 int quicktime_write_int16_le(quicktime_t *file, int number);
   42 int quicktime_write_int24(quicktime_t *file, long number);
   43 int quicktime_write_int32(quicktime_t *file, long value);
   44 int quicktime_write_int32_le(quicktime_t *file, long value);
   45 int quicktime_write_int64(quicktime_t *file, int64_t value);
   46 int quicktime_write_int64_le(quicktime_t *file, int64_t value);
   47 int quicktime_write_char32(quicktime_t *file, char *string);
   48 int quicktime_write_fixed16(quicktime_t *file, float number);
   49 
   50 /* Returns number of bytes written */
   51 int quicktime_write_data(quicktime_t *file, char *data, int size);
   52 /* Enable or disable presave */
   53 void quicktime_set_presave(quicktime_t *file, int value);
   54 /* Returns 1 if equal or 0 if different */
   55 int quicktime_match_32(char *input, char *output);
   56 int quicktime_match_24(char *input, char *output);
   57 void quicktime_write_pascal(quicktime_t *file, char *data);
   58 int quicktime_read_data(quicktime_t *file, char *data, int64_t size);
   59 /* Quantize the number to the nearest multiple of 16 */
   60 /* Used by ffmpeg codecs */
   61 int quicktime_quantize16(int number);
   62 int quicktime_quantize32(int number);
   63 
   64 
   65 
   66 /* Convert Microsoft audio id to codec */
   67 void quicktime_id_to_codec(char *result, int id);
   68 
   69 int quicktime_find_vcodec(quicktime_video_map_t *vtrack);
   70 int quicktime_find_acodec(quicktime_audio_map_t *atrack);
   71 
   72 
   73 
   74 
   75 /* Track functions */
   76 
   77 
   78 /* Most codecs don't specify the actual number of bits on disk in the stbl. */
   79 /* Convert the samples to the number of bytes for reading depending on the codec. */
   80 int64_t quicktime_samples_to_bytes(quicktime_trak_t *track, long samples);
   81 
   82 char* quicktime_compressor(quicktime_trak_t *trak);
   83 
   84 /* Get median duration of video frames for calculating frame rate. */
   85 int quicktime_sample_duration(quicktime_trak_t *trak);
   86 
   87 /* Get alternative mpeg4 parameters from esds table */
   88 void quicktime_esds_samplerate(quicktime_stsd_table_t *table, 
   89     quicktime_esds_t *esds);
   90 
   91 
   92 
   93 /* Graphics */
   94 quicktime_scaletable_t* quicktime_new_scaletable(int input_w, int input_h, int output_w, int output_h);
   95 
   96 
   97 
   98 /* chunks always start on 1 */
   99 /* samples start on 0 */
  100 
  101 /* update the position pointers in all the tracks after a set_position */
  102 int quicktime_update_positions(quicktime_t *file);
  103 
  104 
  105 
  106 
  107 
  108 
  109 
  110 /* AVI section */
  111 void quicktime_read_strh(quicktime_t *file, quicktime_atom_t *parent_atom);
  112 void quicktime_write_strh(quicktime_t *file, int track);
  113 
  114 
  115 
  116 
  117 /* Create new strl object for reading or writing */
  118 quicktime_strl_t* quicktime_new_strl();
  119 /* Initialize new strl object for writing */
  120 void quicktime_init_strl(quicktime_t *file, 
  121     quicktime_audio_map_t *atrack,
  122     quicktime_video_map_t *vtrack,
  123     quicktime_trak_t *trak,
  124     quicktime_strl_t *strl);
  125 void quicktime_delete_strl(quicktime_strl_t *strl);
  126 /* Read strl object */
  127 void quicktime_read_strl(quicktime_t *file, 
  128     quicktime_strl_t *strl, 
  129     quicktime_atom_t *parent_atom);
  130 
  131 
  132 void quicktime_delete_indx(quicktime_indx_t *indx);
  133 void quicktime_init_indx(quicktime_t *file, 
  134     quicktime_indx_t *indx, 
  135     quicktime_strl_t *strl);
  136 void quicktime_update_indx(quicktime_t *file, 
  137     quicktime_indx_t *indx, 
  138     quicktime_ix_t *ix);
  139 void quicktime_finalize_indx(quicktime_t *file);
  140 /* Called by quicktime_read_strl */
  141 void quicktime_read_indx(quicktime_t *file, 
  142     quicktime_strl_t *strl, 
  143     quicktime_atom_t *parent_atom);
  144 
  145 
  146 
  147 void quicktime_delete_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl);
  148 void quicktime_read_hdrl(quicktime_t *file, 
  149     quicktime_hdrl_t *hdrl,
  150     quicktime_atom_t *parent_atom);
  151 void quicktime_init_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl);
  152 void quicktime_finalize_hdrl(quicktime_t *file, quicktime_hdrl_t *hdrl);
  153 
  154 
  155 void quicktime_delete_esds(quicktime_esds_t *esds);
  156 void quicktime_read_esds(quicktime_t *file, 
  157     quicktime_atom_t *parent_atom, 
  158     quicktime_esds_t *esds);
  159 void quicktime_write_esds(quicktime_t *file, 
  160     quicktime_esds_t *esds,
  161     int do_video,
  162     int do_audio);
  163 // Set esds header to a copy of the argument
  164 void quicktime_set_mpeg4_header(quicktime_stsd_table_t *table,
  165     unsigned char *data, 
  166     int size);
  167 void quicktime_esds_dump(quicktime_esds_t *esds);
  168 
  169 
  170 void quicktime_delete_avcc(quicktime_avcc_t *avcc);
  171 int quicktime_read_avcc(quicktime_t *file, 
  172     quicktime_atom_t *parent_atom,
  173     quicktime_avcc_t *avcc);
  174 void quicktime_avcc_dump(quicktime_avcc_t *avcc);
  175 void quicktime_set_avcc_header(quicktime_avcc_t *avcc,
  176     unsigned char *data, 
  177     int size);
  178 
  179 void quicktime_delete_frma(quicktime_frma_t *frma);
  180 int quicktime_read_frma(quicktime_t *file, 
  181     quicktime_atom_t *parent_atom,
  182     quicktime_atom_t *leaf_atom,
  183     quicktime_frma_t *frma);
  184 void quicktime_frma_dump(quicktime_frma_t *frma);
  185 
  186 
  187 
  188 /* Read movi and create objects */
  189 void quicktime_delete_movi(quicktime_t *file, quicktime_movi_t *movi);
  190 void quicktime_read_movi(quicktime_t *file, 
  191     quicktime_atom_t *parent_atom,
  192     quicktime_movi_t *movi);
  193 /* Write preliminary movi data and create objects */
  194 void quicktime_init_movi(quicktime_t *file, quicktime_riff_t *riff);
  195 void quicktime_finalize_movi(quicktime_t *file, quicktime_movi_t *movi);
  196 
  197 
  198 
  199 
  200 
  201 
  202 void quicktime_delete_idx1(quicktime_idx1_t *idx1);
  203 void quicktime_read_idx1(quicktime_t *file, 
  204     quicktime_riff_t *riff, 
  205     quicktime_atom_t *parent_atom);
  206 void quicktime_write_idx1(quicktime_t *file, 
  207     quicktime_idx1_t *idx1);
  208 /* Set the keyframe flag in the right IDX1 entry.  new_keyframes starts on 0 */
  209 /* Used by quicktime_insert_keyframe */
  210 void quicktime_set_idx1_keyframe(quicktime_t *file, 
  211     quicktime_trak_t *trak,
  212     int new_keyframe);
  213 /* Create new IDX1 entry.  Used by quicktime_write_chunk_footer */
  214 void quicktime_update_idx1table(quicktime_t *file, 
  215     quicktime_trak_t *trak, 
  216     int offset,
  217     int size);
  218 
  219 
  220 
  221 
  222 void quicktime_read_odml(quicktime_t *file, quicktime_atom_t *parent_atom);
  223 void quicktime_finalize_odml(quicktime_t *file, quicktime_hdrl_t *hdrl);
  224 void quicktime_init_odml(quicktime_t *file, quicktime_hdrl_t *hdrl);
  225 
  226 
  227 
  228 
  229 
  230 
  231 
  232 
  233 /* Create new riff and put on riff table */
  234 quicktime_riff_t* quicktime_new_riff(quicktime_t *file);
  235 void quicktime_delete_riff(quicktime_t *file, quicktime_riff_t *riff);
  236 void quicktime_read_riff(quicktime_t *file, quicktime_atom_t *parent_atom);
  237 
  238 /* Write riff header and initialize structures */
  239 /* Only the first riff has a hdrl object */
  240 void quicktime_init_riff(quicktime_t *file);
  241 void quicktime_finalize_riff(quicktime_t *file, quicktime_riff_t *riff);
  242 
  243 
  244 /* Create ix object for writing only */
  245 quicktime_ix_t* quicktime_new_ix(quicktime_t *file, 
  246     quicktime_trak_t *trak,
  247     quicktime_strl_t *strl);
  248 void quicktime_delete_ix(quicktime_ix_t *ix);
  249 void quicktime_update_ixtable(quicktime_t *file, 
  250     quicktime_trak_t *trak, 
  251     int64_t offset,
  252     int size);
  253 void quicktime_write_ix(quicktime_t *file,
  254     quicktime_ix_t *ix,
  255     int track);
  256 /* Read entire ix atom from current position in file */
  257 /* Called by quicktime_read_indx. */
  258 void quicktime_read_ix(quicktime_t *file,
  259     quicktime_ix_t *ix);
  260 
  261 
  262 
  263 void quicktime_write_moov(quicktime_t *file, 
  264     quicktime_moov_t *moov,
  265     int rewind);
  266 
  267 
  268 /* compression_id is for AVI reading */
  269 int quicktime_trak_init_audio(quicktime_t *file, 
  270                             quicktime_trak_t *trak, 
  271                             int channels, 
  272                             int sample_rate, 
  273                             int bits, 
  274                             char *compressor);
  275 int quicktime_trak_init_video(quicktime_t *file, 
  276                             quicktime_trak_t *trak, 
  277                             int frame_w, 
  278                             int frame_h, 
  279                             float frame_rate,
  280                             char *compressor);
  281 int quicktime_trak_delete(quicktime_trak_t *trak);
  282 int quicktime_trak_dump(quicktime_trak_t *trak);
  283 int quicktime_delete_trak(quicktime_moov_t *moov);
  284 int quicktime_read_trak(quicktime_t *file, quicktime_trak_t *trak, quicktime_atom_t *trak_atom);
  285 int quicktime_write_trak(quicktime_t *file, quicktime_trak_t *trak, long moov_time_scale);
  286 int64_t quicktime_track_end(quicktime_trak_t *trak);
  287 
  288 
  289 
  290 /* the total number of samples in the track depending on the access mode */
  291 long quicktime_track_samples(quicktime_t *file, quicktime_trak_t *trak);
  292 
  293 
  294 /* queries for every atom */
  295 /* the starting sample in the given chunk */
  296 long quicktime_sample_of_chunk(quicktime_trak_t *trak, long chunk);
  297 
  298 
  299 /* the byte offset from mdat start of the chunk.  Chunk is numbered from 1 */
  300 int64_t quicktime_chunk_to_offset(quicktime_t *file, quicktime_trak_t *trak, long chunk);
  301 
  302 
  303 /* the chunk of any offset from mdat start */
  304 long quicktime_offset_to_chunk(int64_t *chunk_offset, 
  305     quicktime_trak_t *trak, 
  306     int64_t offset);
  307 
  308 /* Bytes in the chunk.  Chunk is numbered from 1 */
  309 /* Only available in AVI. */
  310 /* Reads the chunk header to get the size. */
  311 /* Stores the chunk offset in chunk_offset. */
  312 /* Returns the bytes in the chunk less the 8 byte header size */
  313 int quicktime_chunk_bytes(quicktime_t *file, 
  314     int64_t *chunk_offset,
  315     int chunk, 
  316     quicktime_trak_t *trak);
  317 
  318 
  319 /* total bytes between the two samples */
  320 int64_t quicktime_sample_range_size(quicktime_trak_t *trak, 
  321     long chunk_sample, 
  322     long sample);
  323 
  324 
  325 int quicktime_chunk_of_sample(int64_t *chunk_sample, 
  326     int64_t *chunk, 
  327     quicktime_trak_t *trak, 
  328     int64_t sample);
  329 
  330 
  331 
  332 /* converting between mdat offsets to samples */
  333 int64_t quicktime_sample_to_offset(quicktime_t *file, quicktime_trak_t *trak, long sample);
  334 long quicktime_offset_to_sample(quicktime_trak_t *trak, int64_t offset);
  335 quicktime_trak_t* quicktime_add_trak(quicktime_t *file);
  336 
  337 
  338 int quicktime_time_to_sample(quicktime_stts_t *stts,
  339     int64_t *start_time);
  340 /* Used by VBR to append a sample of known duration to the table. */
  341 /* Overrides any previous fixed bitrate entry. */
  342 /* Sets the is_vbr flag to prevent post processing of the table. */
  343 void quicktime_stts_append_audio(quicktime_t *file, 
  344     quicktime_stts_t *stts, 
  345     int sample_duration);
  346 /* Get total stts samples for VBR encoding. */
  347 int64_t quicktime_stts_total_samples(quicktime_t *file, 
  348     quicktime_stts_t *stts);
  349 
  350 
  351 void quicktime_write_chunk_header(quicktime_t *file, 
  352     quicktime_trak_t *trak, 
  353     quicktime_atom_t *chunk);
  354 void quicktime_write_chunk_footer(quicktime_t *file, 
  355     quicktime_trak_t *trak,
  356     int current_chunk,
  357     quicktime_atom_t *chunk, 
  358     int samples);
  359 /* Write VBR frame */
  360 int quicktime_write_vbr_frame(quicktime_t *file, 
  361     int track,
  362     char *data,
  363     int data_size,
  364     int samples);
  365 /* update all the tables after writing a buffer */
  366 /* set sample_size to 0 if no sample size should be set */
  367 void quicktime_update_stco(quicktime_stco_t *stco, long chunk, int64_t offset);
  368 void quicktime_update_stsz(quicktime_stsz_t *stsz, long sample, long sample_size);
  369 int quicktime_update_stsc(quicktime_stsc_t *stsc, long chunk, long samples);
  370 int quicktime_trak_duration(quicktime_trak_t *trak, long *duration, long *timescale);
  371 int quicktime_trak_fix_counts(quicktime_t *file, quicktime_trak_t *trak);
  372 int quicktime_sample_size(quicktime_trak_t *trak, int sample);
  373 
  374 /* number of samples in the chunk */
  375 long quicktime_chunk_samples(quicktime_trak_t *trak, long chunk);
  376 int quicktime_trak_shift_offsets(quicktime_trak_t *trak, int64_t offset);
  377 void quicktime_mhvd_init_video(quicktime_t *file, 
  378     quicktime_mvhd_t *mvhd, 
  379     double frame_rate);
  380 
  381 
  382 void quicktime_stsd_init_video(quicktime_t *file, 
  383                                 quicktime_stsd_t *stsd, 
  384                                 int frame_w,
  385                                 int frame_h, 
  386                                 float frame_rate,
  387                                 char *compression);
  388 void quicktime_stsd_init_audio(quicktime_t *file, 
  389                             quicktime_stsd_t *stsd, 
  390                             int channels,
  391                             int sample_rate, 
  392                             int bits, 
  393                             char *compressor);
  394 void quicktime_stts_init_video(quicktime_t *file, 
  395                             quicktime_stts_t *stts, 
  396                             int time_scale, 
  397                             float frame_rate);
  398 void quicktime_stbl_init_video(quicktime_t *file, 
  399                                 quicktime_stbl_t *stbl, 
  400                                 int frame_w,
  401                                 int frame_h, 
  402                                 int time_scale, 
  403                                 float frame_rate,
  404                                 char *compressor);
  405 void quicktime_stbl_init_audio(quicktime_t *file, 
  406                             quicktime_stbl_t *stbl, 
  407                             int channels, 
  408                             int sample_rate, 
  409                             int bits, 
  410                             char *compressor);
  411 void quicktime_minf_init_video(quicktime_t *file, 
  412                                 quicktime_minf_t *minf, 
  413                                 int frame_w,
  414                                 int frame_h, 
  415                                 int time_scale, 
  416                                 float frame_rate,
  417                                 char *compressor);
  418 void quicktime_mdhd_init_video(quicktime_t *file, 
  419                                 quicktime_mdhd_t *mdhd, 
  420                                 int frame_w,
  421                                 int frame_h, 
  422                                 float frame_rate);
  423 void quicktime_mdhd_init_audio(quicktime_mdhd_t *mdhd, 
  424                             int sample_rate);
  425 void quicktime_minf_init_audio(quicktime_t *file, 
  426                             quicktime_minf_t *minf, 
  427                             int channels, 
  428                             int sample_rate, 
  429                             int bits, 
  430                             char *compressor);
  431 void quicktime_mdia_init_video(quicktime_t *file, 
  432                                 quicktime_mdia_t *mdia,
  433                                 int frame_w,
  434                                 int frame_h, 
  435                                 float frame_rate,
  436                                 char *compressor);
  437 void quicktime_mdia_init_audio(quicktime_t *file, 
  438                             quicktime_mdia_t *mdia, 
  439                             int channels,
  440                             int sample_rate, 
  441                             int bits, 
  442                             char *compressor);
  443 void quicktime_tkhd_init_video(quicktime_t *file, 
  444                                 quicktime_tkhd_t *tkhd, 
  445                                 int frame_w, 
  446                                 int frame_h);
  447 int quicktime_get_timescale(double frame_rate);
  448 
  449 unsigned long quicktime_current_time(void);
  450 
  451 
  452 
  453 
  454 
  455 
  456 
  457 
  458 
  459 
  460 // Utility functions for decoding vbr audio codecs
  461 
  462 // Delete buffers from the vbr structure when finished
  463 void quicktime_clear_vbr(quicktime_vbr_t  *ptr);
  464 void quicktime_vbr_set_channels(quicktime_vbr_t *ptr, int channels);
  465 void quicktime_init_vbr(quicktime_vbr_t *ptr, int channels);
  466 
  467 // Shift the output buffer and fix pointers for the given range.
  468 // Return 1 if not possible to handle the sample count.
  469 int quicktime_align_vbr(quicktime_audio_map_t *atrack, 
  470     int samples);
  471 
  472 // The current endpoint of the buffer
  473 int64_t quicktime_vbr_end(quicktime_vbr_t  *ptr);
  474 unsigned char* quicktime_vbr_input(quicktime_vbr_t *ptr);
  475 int quicktime_vbr_input_size(quicktime_vbr_t *ptr);
  476 
  477 // Append the next sample/frame of compressed data to the input buffer
  478 // and advance the counters.
  479 int quicktime_read_vbr(quicktime_t *file,
  480     quicktime_audio_map_t *atrack);
  481 
  482 // Shift the input buffer
  483 void quicktime_shift_vbr(quicktime_audio_map_t *atrack, int bytes);
  484 
  485 // Put the next sample/frame of uncompressed data in the buffer and advance the
  486 // counters
  487 void quicktime_store_vbr_float(quicktime_audio_map_t *atrack,
  488     float *samples,
  489     int sample_count);
  490 void quicktime_store_vbr_int16(quicktime_audio_map_t *atrack,
  491     int16_t *samples,
  492     int sample_count);
  493 
  494 void quicktime_copy_vbr_float(quicktime_vbr_t *vbr,
  495     int64_t start_position, 
  496     int samples,
  497     float *output, 
  498     int channel);
  499 
  500 
  501 
  502 // Frame caching for keyframed video.
  503 quicktime_cache_t* quicktime_new_cache();
  504 void quicktime_delete_cache(quicktime_cache_t *ptr);
  505 void quicktime_reset_cache(quicktime_cache_t *ptr);
  506 void quicktime_put_frame(quicktime_cache_t *ptr,
  507     int64_t frame_number,
  508     unsigned char *y,
  509     unsigned char *u,
  510     unsigned char *v,
  511     int y_size,
  512     int u_size,
  513     int v_size);
  514 // Return 1 if the frame was found.
  515 int quicktime_get_frame(quicktime_cache_t *ptr,
  516     int64_t frame_number,
  517     unsigned char **y,
  518     unsigned char **u,
  519     unsigned char **v);
  520 int quicktime_has_frame(quicktime_cache_t *ptr,
  521     int64_t frame_number);
  522 int64_t quicktime_cache_usage(quicktime_cache_t *ptr);
  523 
  524 
  525 
  526 
  527 
  528 #endif