movenc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * MOV, 3GP, MP4 muxer
  3. * Copyright (c) 2003 Thomas Raivio
  4. * Copyright (c) 2004 Gildas Bazin <gbazin at videolan dot org>
  5. * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
  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_MOVENC_H
  24. #define AVFORMAT_MOVENC_H
  25. #include "avformat.h"
  26. #define MOV_INDEX_CLUSTER_SIZE 16384
  27. #define MOV_TIMESCALE 1000
  28. #define RTP_MAX_PACKET_SIZE 1450
  29. #define MODE_MP4 0x01
  30. #define MODE_MOV 0x02
  31. #define MODE_3GP 0x04
  32. #define MODE_PSP 0x08 // example working PSP command line:
  33. // ffmpeg -i testinput.avi -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 M4V00001.MP4
  34. #define MODE_3G2 0x10
  35. #define MODE_IPOD 0x20
  36. typedef struct MOVIentry {
  37. unsigned int size;
  38. uint64_t pos;
  39. unsigned int samplesInChunk;
  40. unsigned int entries;
  41. int cts;
  42. int64_t dts;
  43. #define MOV_SYNC_SAMPLE 0x0001
  44. #define MOV_PARTIAL_SYNC_SAMPLE 0x0002
  45. uint32_t flags;
  46. } MOVIentry;
  47. typedef struct HintSample {
  48. uint8_t *data;
  49. int size;
  50. int sample_number;
  51. int offset;
  52. int own_data;
  53. } HintSample;
  54. typedef struct {
  55. int size;
  56. int len;
  57. HintSample *samples;
  58. } HintSampleQueue;
  59. typedef struct MOVIndex {
  60. int mode;
  61. int entry;
  62. unsigned timescale;
  63. uint64_t time;
  64. int64_t trackDuration;
  65. long sampleCount;
  66. long sampleSize;
  67. int hasKeyframes;
  68. #define MOV_TRACK_CTTS 0x0001
  69. #define MOV_TRACK_STPS 0x0002
  70. uint32_t flags;
  71. int language;
  72. int trackID;
  73. int tag; ///< stsd fourcc
  74. AVCodecContext *enc;
  75. int vosLen;
  76. uint8_t *vosData;
  77. MOVIentry *cluster;
  78. int audio_vbr;
  79. int height; ///< active picture (w/o VBI) height for D-10/IMX
  80. uint32_t tref_tag;
  81. int tref_id; ///< trackID of the referenced track
  82. int hint_track; ///< the track that hints this track, -1 if no hint track is set
  83. int src_track; ///< the track that this hint track describes
  84. AVFormatContext *rtp_ctx; ///< the format context for the hinting rtp muxer
  85. uint32_t prev_rtp_ts;
  86. int64_t cur_rtp_ts_unwrapped;
  87. uint32_t max_packet_size;
  88. HintSampleQueue sample_queue;
  89. } MOVTrack;
  90. typedef struct MOVMuxContext {
  91. const AVClass *av_class;
  92. int mode;
  93. int64_t time;
  94. int nb_streams;
  95. int chapter_track; ///< qt chapter track number
  96. int64_t mdat_pos;
  97. uint64_t mdat_size;
  98. MOVTrack *tracks;
  99. int flags;
  100. int rtp_flags;
  101. } MOVMuxContext;
  102. #define FF_MOV_FLAG_RTP_HINT 1
  103. int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
  104. int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index);
  105. int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt,
  106. int track_index, int sample);
  107. void ff_mov_close_hinting(MOVTrack *track);
  108. #endif /* AVFORMAT_MOVENC_H */