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.

139 lines
3.8KB

  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; /* the ffmpeg stream id */
  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. int ctts_index;
  87. int ctts_sample;
  88. unsigned int sample_size;
  89. unsigned int sample_count;
  90. int *sample_sizes;
  91. unsigned int keyframe_count;
  92. int *keyframes;
  93. int time_scale;
  94. int time_rate;
  95. int time_offset; ///< time offset of the first edit list entry
  96. int current_sample;
  97. unsigned int bytes_per_frame;
  98. unsigned int samples_per_frame;
  99. int dv_audio_container;
  100. int pseudo_stream_id; ///< -1 means demux all ids
  101. int16_t audio_cid; ///< stsd audio compression id
  102. unsigned drefs_count;
  103. MOVDref *drefs;
  104. int dref_id;
  105. int wrong_dts; ///< dts are wrong due to negative ctts
  106. int width; ///< tkhd width
  107. int height; ///< tkhd height
  108. } MOVStreamContext;
  109. typedef struct MOVContext {
  110. AVFormatContext *fc;
  111. int time_scale;
  112. int64_t duration; /* duration of the longest track */
  113. int found_moov; /* when both 'moov' and 'mdat' sections has been found */
  114. int found_mdat; /* we suppose we have enough data to read the file */
  115. DVDemuxContext *dv_demux;
  116. AVFormatContext *dv_fctx;
  117. int isom; /* 1 if file is ISO Media (mp4/3gp) */
  118. MOVFragment fragment; ///< current fragment in moof atom
  119. MOVTrackExt *trex_data;
  120. unsigned trex_count;
  121. int itunes_metadata; ///< metadata are itunes style
  122. } MOVContext;
  123. #endif /* AVFORMAT_ISOM_H */