00001 #ifndef PRIVATE_H
00002 #define PRIVATE_H
00003
00004
00005
00006
00007 #define QUICKTIME_MAJOR 2
00008 #define QUICKTIME_MINOR 2
00009 #define QUICKTIME_RELEASE 0
00010
00011
00012 #define HEADER_LENGTH 8
00013 #define MAXTRACKS 1024
00014
00015
00016 #define AVI_HASINDEX 0x00000010 // Index at end of file?
00017 #define AVI_MUSTUSEINDEX 0x00000020
00018 #define AVI_ISINTERLEAVED 0x00000100
00019 #define AVI_TRUSTCKTYPE 0x00000800 // Use CKType to find key frames?
00020 #define AVI_WASCAPTUREFILE 0x00010000
00021 #define AVI_COPYRIGHTED 0x00020000
00022 #define AVIF_WASCAPTUREFILE 0x00010000
00023 #define AVI_KEYFRAME 0x10
00024 #define AVI_INDEX_OF_CHUNKS 0x01
00025 #define AVI_INDEX_OF_INDEXES 0x00
00026
00027 #define AVI_FRAME_RATE_BASE 10000
00028 #define MAX_RIFFS 0x100
00029
00030 #include <stdio.h>
00031 #include <stdint.h>
00032 #include <stdlib.h>
00033
00034
00035
00036
00037 #define FTELL ftello64
00038 #define FSEEK fseeko64
00039
00040
00041
00042
00043 extern int ffmpeg_initialized;
00044 extern pthread_mutex_t ffmpeg_lock;
00045
00046
00047
00048
00049 typedef struct
00050 {
00051
00052 int64_t buffer_end;
00053
00054 int buffer_size;
00055
00056 int buffer_ptr;
00057
00058 double **output_buffer;
00059
00060 int channels;
00061
00062 int input_size;
00063 int input_allocation;
00064 unsigned char *input_buffer;
00065
00066 int sample_size_entry;
00067
00068 int64_t sample;
00069 } quicktime_vbr_t;
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 typedef struct
00080 {
00081
00082
00083 int64_t start;
00084 int64_t end;
00085 int64_t size;
00086 int use_64;
00087 unsigned char type[5];
00088 } quicktime_atom_t;
00089
00090 typedef struct
00091 {
00092 float values[9];
00093 } quicktime_matrix_t;
00094
00095
00096 typedef struct
00097 {
00098 int version;
00099 long flags;
00100 unsigned long creation_time;
00101 unsigned long modification_time;
00102 int track_id;
00103 long reserved1;
00104 long duration;
00105 char reserved2[8];
00106 int layer;
00107 int alternate_group;
00108 float volume;
00109 long reserved3;
00110 quicktime_matrix_t matrix;
00111 float track_width;
00112 float track_height;
00113 } quicktime_tkhd_t;
00114
00115
00116 typedef struct
00117 {
00118 long seed;
00119 long flags;
00120 long size;
00121 short int *alpha;
00122 short int *red;
00123 short int *green;
00124 short int *blue;
00125 } quicktime_ctab_t;
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 typedef struct
00136 {
00137 int motion_jpeg_quantization_table;
00138 } quicktime_mjqt_t;
00139
00140
00141 typedef struct
00142 {
00143 int motion_jpeg_huffman_table;
00144 } quicktime_mjht_t;
00145
00146
00147 typedef struct
00148 {
00149 char *mpeg4_header;
00150 int mpeg4_header_size;
00151 } quicktime_esds_t;
00152
00153 typedef struct
00154 {
00155 char *data;
00156 int data_size;
00157 } quicktime_avcc_t;
00158
00159 typedef struct
00160 {
00161 char format[4];
00162 char reserved[6];
00163 int data_reference;
00164
00165
00166 int version;
00167 int revision;
00168 char vendor[4];
00169
00170
00171 long temporal_quality;
00172 long spatial_quality;
00173 int width;
00174 int height;
00175 float dpi_horizontal;
00176 float dpi_vertical;
00177 int64_t data_size;
00178 int frames_per_sample;
00179 char compressor_name[32];
00180 int depth;
00181 int ctab_id;
00182 quicktime_ctab_t ctab;
00183 float gamma;
00184
00185 int fields;
00186
00187 int field_dominance;
00188 quicktime_mjqt_t mjqt;
00189 quicktime_mjht_t mjht;
00190
00191
00192 int channels;
00193 int sample_size;
00194 int compression_id;
00195 int packet_size;
00196 float sample_rate;
00197
00198
00199 int samples_per_packet;
00200 int bytes_per_packet;
00201 int bytes_per_frame;
00202 int bytes_per_sample;
00203
00204 quicktime_esds_t esds;
00205 quicktime_avcc_t avcc;
00206
00207 int extradata_size;
00208 char *extradata;
00209 } quicktime_stsd_table_t;
00210
00211
00212 typedef struct
00213 {
00214 int version;
00215 long flags;
00216 long total_entries;
00217 quicktime_stsd_table_t *table;
00218 } quicktime_stsd_t;
00219
00220
00221
00222 typedef struct
00223 {
00224 long sample_count;
00225 long sample_duration;
00226 } quicktime_stts_table_t;
00227
00228 typedef struct
00229 {
00230 int version;
00231 long flags;
00232 long total_entries;
00233 int is_vbr;
00234 quicktime_stts_table_t *table;
00235 } quicktime_stts_t;
00236
00237
00238
00239 typedef struct
00240 {
00241 int64_t sample;
00242 } quicktime_stss_table_t;
00243
00244 typedef struct
00245 {
00246 int version;
00247 long flags;
00248 long total_entries;
00249 long entries_allocated;
00250 quicktime_stss_table_t *table;
00251 } quicktime_stss_t;
00252
00253
00254
00255 typedef struct
00256 {
00257 long chunk;
00258 long samples;
00259 long id;
00260 } quicktime_stsc_table_t;
00261
00262 typedef struct
00263 {
00264 int version;
00265 long flags;
00266 long total_entries;
00267
00268 long entries_allocated;
00269 quicktime_stsc_table_t *table;
00270 } quicktime_stsc_t;
00271
00272
00273
00274 typedef struct
00275 {
00276 int64_t size;
00277 } quicktime_stsz_table_t;
00278
00279 typedef struct
00280 {
00281 int version;
00282 long flags;
00283 int64_t sample_size;
00284 long total_entries;
00285
00286 long entries_allocated;
00287 quicktime_stsz_table_t *table;
00288 } quicktime_stsz_t;
00289
00290
00291
00292 typedef struct
00293 {
00294 int64_t offset;
00295 } quicktime_stco_table_t;
00296
00297 typedef struct
00298 {
00299 int version;
00300 long flags;
00301 long total_entries;
00302
00303 long entries_allocated;
00304 quicktime_stco_table_t *table;
00305 } quicktime_stco_t;
00306
00307
00308
00309 typedef struct
00310 {
00311 int version;
00312 long flags;
00313 quicktime_stsd_t stsd;
00314 quicktime_stts_t stts;
00315 quicktime_stss_t stss;
00316 quicktime_stsc_t stsc;
00317 quicktime_stsz_t stsz;
00318 quicktime_stco_t stco;
00319 } quicktime_stbl_t;
00320
00321
00322
00323 typedef struct
00324 {
00325 int64_t size;
00326 char type[4];
00327 int version;
00328 long flags;
00329 char *data_reference;
00330 } quicktime_dref_table_t;
00331
00332 typedef struct
00333 {
00334 int version;
00335 long flags;
00336 long total_entries;
00337 quicktime_dref_table_t *table;
00338 } quicktime_dref_t;
00339
00340
00341
00342 typedef struct
00343 {
00344 quicktime_dref_t dref;
00345 } quicktime_dinf_t;
00346
00347
00348
00349 typedef struct
00350 {
00351 int version;
00352 long flags;
00353 int graphics_mode;
00354 int opcolor[3];
00355 } quicktime_vmhd_t;
00356
00357
00358
00359
00360 typedef struct
00361 {
00362 int version;
00363 long flags;
00364 int balance;
00365 int reserved;
00366 } quicktime_smhd_t;
00367
00368
00369
00370 typedef struct
00371 {
00372 int version;
00373 long flags;
00374 char component_type[4];
00375 char component_subtype[4];
00376 long component_manufacturer;
00377 long component_flags;
00378 long component_flag_mask;
00379 char component_name[256];
00380 } quicktime_hdlr_t;
00381
00382
00383
00384 typedef struct
00385 {
00386 int is_video;
00387 int is_audio;
00388 quicktime_vmhd_t vmhd;
00389 quicktime_smhd_t smhd;
00390 quicktime_stbl_t stbl;
00391 quicktime_hdlr_t hdlr;
00392 quicktime_dinf_t dinf;
00393 } quicktime_minf_t;
00394
00395
00396
00397
00398 typedef struct
00399 {
00400 int version;
00401 long flags;
00402 unsigned long creation_time;
00403 unsigned long modification_time;
00404 long time_scale;
00405 long duration;
00406 int language;
00407 int quality;
00408 } quicktime_mdhd_t;
00409
00410
00411
00412
00413 typedef struct
00414 {
00415 quicktime_mdhd_t mdhd;
00416 quicktime_minf_t minf;
00417 quicktime_hdlr_t hdlr;
00418 } quicktime_mdia_t;
00419
00420
00421 typedef struct
00422 {
00423 long duration;
00424 long time;
00425 float rate;
00426 } quicktime_elst_table_t;
00427
00428 typedef struct
00429 {
00430 int version;
00431 long flags;
00432 long total_entries;
00433
00434 quicktime_elst_table_t *table;
00435 } quicktime_elst_t;
00436
00437 typedef struct
00438 {
00439 quicktime_elst_t elst;
00440 } quicktime_edts_t;
00441
00442
00443
00444
00445 typedef struct
00446 {
00447 quicktime_tkhd_t tkhd;
00448 quicktime_mdia_t mdia;
00449 quicktime_edts_t edts;
00450 } quicktime_trak_t;
00451
00452
00453 typedef struct
00454 {
00455 int version;
00456 long flags;
00457 unsigned long creation_time;
00458 unsigned long modification_time;
00459 long time_scale;
00460 long duration;
00461 float preferred_rate;
00462 float preferred_volume;
00463 char reserved[10];
00464 quicktime_matrix_t matrix;
00465 long preview_time;
00466 long preview_duration;
00467 long poster_time;
00468 long selection_time;
00469 long selection_duration;
00470 long current_time;
00471 long next_track_id;
00472 } quicktime_mvhd_t;
00473
00474 typedef struct
00475 {
00476 char *copyright;
00477 int copyright_len;
00478 char *name;
00479 int name_len;
00480 char *info;
00481 int info_len;
00482 char *require;
00483 int require_len;
00484 char *encoder;
00485 int encoder_len;
00486 } quicktime_udta_t;
00487
00488
00489 typedef struct
00490 {
00491 int total_tracks;
00492
00493 quicktime_mvhd_t mvhd;
00494 quicktime_trak_t *trak[MAXTRACKS];
00495 quicktime_udta_t udta;
00496 quicktime_ctab_t ctab;
00497 } quicktime_moov_t;
00498
00499 typedef struct
00500 {
00501 quicktime_atom_t atom;
00502 } quicktime_mdat_t;
00503
00504 typedef struct
00505 {
00506
00507 int relative_offset;
00508
00509 int size;
00510 } quicktime_ixtable_t;
00511
00512 typedef struct
00513 {
00514 quicktime_atom_t atom;
00515 quicktime_ixtable_t *table;
00516 int table_size;
00517 int table_allocation;
00518 int longs_per_entry;
00519 int index_type;
00520
00521 int64_t base_offset;
00522
00523 char tag[5];
00524
00525 char chunk_id[5];
00526 } quicktime_ix_t;
00527
00528
00529 typedef struct
00530 {
00531 quicktime_atom_t atom;
00532
00533
00534
00535
00536 quicktime_ix_t *ix[MAXTRACKS];
00537 } quicktime_movi_t;
00538
00539 typedef struct
00540 {
00541
00542 int64_t index_offset;
00543
00544 int index_size;
00545
00546 int duration;
00547
00548
00549 quicktime_ix_t *ix;
00550 } quicktime_indxtable_t;
00551
00552 typedef struct
00553 {
00554 quicktime_atom_t atom;
00555 int longs_per_entry;
00556 int index_subtype;
00557 int index_type;
00558
00559 char chunk_id[5];
00560
00561
00562 int table_size;
00563 int table_allocation;
00564 quicktime_indxtable_t *table;
00565 } quicktime_indx_t;
00566
00567 typedef struct
00568 {
00569 quicktime_atom_t atom;
00570
00571 quicktime_indx_t indx;
00572
00573 int64_t length_offset;
00574 int64_t samples_per_chunk_offset;
00575 int64_t sample_size_offset;
00576
00577 int64_t indx_offset;
00578
00579 int64_t padding_size;
00580
00581 char tag[5];
00582
00583 int is_audio;
00584 int is_video;
00585
00586 int have_indx;
00587 } quicktime_strl_t;
00588
00589 typedef struct
00590 {
00591 quicktime_atom_t atom;
00592 int64_t frames_offset;
00593 int64_t bitrate_offset;
00594
00595 int64_t total_frames_offset;
00596
00597
00598
00599 quicktime_strl_t *strl[MAXTRACKS];
00600 } quicktime_hdrl_t;
00601
00602 typedef struct
00603 {
00604 char tag[5];
00605 uint32_t flags;
00606
00607 int32_t offset;
00608
00609 int32_t size;
00610 } quicktime_idx1table_t;
00611
00612 typedef struct
00613 {
00614 quicktime_atom_t atom;
00615 quicktime_idx1table_t *table;
00616 int table_size;
00617 int table_allocation;
00618 } quicktime_idx1_t;
00619
00620 typedef struct
00621 {
00622 quicktime_atom_t atom;
00623 quicktime_movi_t movi;
00624 quicktime_hdrl_t hdrl;
00625
00626
00627 quicktime_idx1_t idx1;
00628
00629 int have_idx1;
00630 int have_hdrl;
00631 } quicktime_riff_t;
00632
00633 typedef struct
00634 {
00635 unsigned char *y, *u, *v;
00636 int y_size;
00637 int u_size;
00638 int v_size;
00639 int64_t frame_number;
00640 } quicktime_cacheframe_t;
00641
00642 typedef struct
00643 {
00644 quicktime_cacheframe_t *frames;
00645 int total;
00646 int allocation;
00647 } quicktime_cache_t;
00648
00649
00650 typedef struct
00651 {
00652 quicktime_trak_t *track;
00653 int channels;
00654 int64_t current_position;
00655 int64_t current_chunk;
00656 quicktime_vbr_t vbr;
00657
00658 void *codec;
00659 } quicktime_audio_map_t;
00660
00661 typedef struct
00662 {
00663 quicktime_trak_t *track;
00664 int64_t current_position;
00665 int64_t current_chunk;
00666
00667 quicktime_cache_t *frame_cache;
00668
00669 void *codec;
00670 } quicktime_video_map_t;
00671
00672
00673 typedef struct
00674 {
00675 FILE *stream;
00676 int64_t total_length;
00677 quicktime_mdat_t mdat;
00678 quicktime_moov_t moov;
00679 int rd;
00680 int wr;
00681
00682
00683 int compressed_moov;
00684 unsigned char *moov_data;
00685
00686
00687
00688
00689 int64_t moov_end;
00690 int64_t moov_size;
00691 int64_t old_preload_size;
00692 char *old_preload_buffer;
00693 int64_t old_preload_start;
00694 int64_t old_preload_end;
00695 int64_t old_preload_ptr;
00696
00697
00698
00699 int use_asf;
00700
00701
00702
00703
00704
00705 int use_avi;
00706
00707 quicktime_riff_t *riff[MAX_RIFFS];
00708 int total_riffs;
00709
00710 int is_odml;
00711
00712
00713
00714
00715
00716
00717
00718 int64_t offset;
00719
00720
00721
00722 int64_t file_position;
00723
00724
00725
00726 int64_t ftell_position;
00727
00728
00729 int64_t preload_size;
00730 char *preload_buffer;
00731 int64_t preload_start;
00732 int64_t preload_end;
00733 int64_t preload_ptr;
00734
00735
00736
00737 int64_t presave_size;
00738
00739 int64_t presave_position;
00740 char *presave_buffer;
00741
00742 #define QUICKTIME_PRESAVE 0x100000
00743 int use_presave;
00744
00745
00746
00747 int total_atracks;
00748 quicktime_audio_map_t *atracks;
00749
00750
00751 int total_vtracks;
00752 quicktime_video_map_t *vtracks;
00753
00754
00755 int cpus;
00756
00757
00758 int do_scaling;
00759 int in_x, in_y, in_w, in_h, out_w, out_h;
00760 int color_model, row_span;
00761
00762
00763 int64_t current_frame;
00764
00765 } quicktime_t;
00766
00767
00768
00769 typedef struct
00770 {
00771 int (*delete_vcodec)(quicktime_video_map_t *vtrack);
00772 int (*delete_acodec)(quicktime_audio_map_t *atrack);
00773
00774 int (*decode_video)(quicktime_t *file,
00775 unsigned char **row_pointers,
00776 int track);
00777
00778 int (*encode_video)(quicktime_t *file,
00779 unsigned char **row_pointers,
00780 int track);
00781
00782 int (*decode_audio)(quicktime_t *file,
00783 int16_t *output_i,
00784 float *output_f,
00785 long samples,
00786 int track,
00787 int channel);
00788
00789 int (*encode_audio)(quicktime_t *file,
00790 int16_t **input_i,
00791 float **input_f,
00792 int track,
00793 long samples);
00794 int (*reads_colormodel)(quicktime_t *file,
00795 int colormodel,
00796 int track);
00797 int (*writes_colormodel)(quicktime_t *file,
00798 int colormodel,
00799 int track);
00800
00801 int (*set_parameter)(quicktime_t *file,
00802 int track,
00803 char *key,
00804 void *value);
00805 void (*flush)(quicktime_t *file,
00806 int track);
00807
00808
00809 int wav_id;
00810
00811
00812 char *fourcc;
00813
00814
00815 char *title;
00816
00817
00818 char *desc;
00819
00820
00821
00822
00823
00824 void *priv;
00825 } quicktime_codec_t;
00826
00827
00828
00829
00830 typedef struct
00831 {
00832 void (*init_vcodec)(quicktime_video_map_t *);
00833 void (*init_acodec)(quicktime_audio_map_t *);
00834 } quicktime_codectable_t;
00835
00836
00837
00838
00839 #endif