You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
4.0KB

  1. /*
  2. * ISO Media common code
  3. * copyright (c) 2001 Fabrice Bellard
  4. * copyright (c) 2002 Francois Revol <revol@free.fr>
  5. * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef AVFORMAT_ISOM_H
  24. #define AVFORMAT_ISOM_H
  25. #include "avio.h"
  26. #include "riff.h"
  27. #include "dv.h"
  28. /* isom.c */
  29. extern const AVCodecTag ff_mp4_obj_type[];
  30. extern const AVCodecTag codec_movvideo_tags[];
  31. extern const AVCodecTag codec_movaudio_tags[];
  32. extern const AVCodecTag ff_codec_movsubtitle_tags[];
  33. int ff_mov_iso639_to_lang(const char *lang, int mp4);
  34. int ff_mov_lang_to_iso639(unsigned code, char *to);
  35. /* the QuickTime file format is quite convoluted...
  36. * it has lots of index tables, each indexing something in another one...
  37. * Here we just use what is needed to read the chunks
  38. */
  39. typedef struct {
  40. int count;
  41. int duration;
  42. } MOVStts;
  43. typedef struct {
  44. int first;
  45. int count;
  46. int id;
  47. } MOVStsc;
  48. typedef struct {
  49. uint32_t type;
  50. char *path;
  51. } MOVDref;
  52. typedef struct {
  53. uint32_t type;
  54. int64_t offset;
  55. int64_t size; /* total size (excluding the size and type fields) */
  56. } MOVAtom;
  57. struct MOVParseTableEntry;
  58. typedef struct {
  59. unsigned track_id;
  60. uint64_t base_data_offset;
  61. uint64_t moof_offset;
  62. unsigned stsd_id;
  63. unsigned duration;
  64. unsigned size;
  65. unsigned flags;
  66. } MOVFragment;
  67. typedef struct {
  68. unsigned track_id;
  69. unsigned stsd_id;
  70. unsigned duration;
  71. unsigned size;
  72. unsigned flags;
  73. } MOVTrackExt;
  74. typedef struct MOVStreamContext {
  75. ByteIOContext *pb;
  76. int ffindex; ///< AVStream index
  77. int next_chunk;
  78. unsigned int chunk_count;
  79. int64_t *chunk_offsets;
  80. unsigned int stts_count;
  81. MOVStts *stts_data;
  82. unsigned int ctts_count;
  83. MOVStts *ctts_data;
  84. unsigned int stsc_count;
  85. MOVStsc *stsc_data;
  86. unsigned int stps_count;
  87. unsigned *stps_data; ///< partial sync sample for mpeg-2 open gop
  88. int ctts_index;
  89. int ctts_sample;
  90. unsigned int sample_size;
  91. unsigned int sample_count;
  92. int *sample_sizes;
  93. unsigned int keyframe_count;
  94. int *keyframes;
  95. int time_scale;
  96. int time_rate;
  97. int time_offset; ///< time offset of the first edit list entry
  98. int current_sample;
  99. unsigned int bytes_per_frame;
  100. unsigned int samples_per_frame;
  101. int dv_audio_container;
  102. int pseudo_stream_id; ///< -1 means demux all ids
  103. int16_t audio_cid; ///< stsd audio compression id
  104. unsigned drefs_count;
  105. MOVDref *drefs;
  106. int dref_id;
  107. int wrong_dts; ///< dts are wrong due to huge ctts offset (iMovie files)
  108. int width; ///< tkhd width
  109. int height; ///< tkhd height
  110. int dts_shift; ///< dts shift when ctts is negative
  111. } MOVStreamContext;
  112. typedef struct MOVContext {
  113. AVFormatContext *fc;
  114. int time_scale;
  115. int64_t duration; ///< duration of the longest track
  116. int found_moov; ///< 'moov' atom has been found
  117. int found_mdat; ///< 'mdat' atom has been found
  118. DVDemuxContext *dv_demux;
  119. AVFormatContext *dv_fctx;
  120. int isom; ///< 1 if file is ISO Media (mp4/3gp)
  121. MOVFragment fragment; ///< current fragment in moof atom
  122. MOVTrackExt *trex_data;
  123. unsigned trex_count;
  124. int itunes_metadata; ///< metadata are itunes style
  125. } MOVContext;
  126. #endif /* AVFORMAT_ISOM_H */