Libav
|
00001 00025 #ifndef AVFORMAT_OGGDEC_H 00026 #define AVFORMAT_OGGDEC_H 00027 00028 #include "avformat.h" 00029 #include "metadata.h" 00030 00031 struct ogg_codec { 00032 const int8_t *magic; 00033 uint8_t magicsize; 00034 const int8_t *name; 00041 int (*header)(AVFormatContext *, int); 00042 int (*packet)(AVFormatContext *, int); 00048 uint64_t (*gptopts)(AVFormatContext *, int, uint64_t, int64_t *dts); 00053 int granule_is_start; 00054 }; 00055 00056 struct ogg_stream { 00057 uint8_t *buf; 00058 unsigned int bufsize; 00059 unsigned int bufpos; 00060 unsigned int pstart; 00061 unsigned int psize; 00062 unsigned int pflags; 00063 unsigned int pduration; 00064 uint32_t serial; 00065 uint64_t granule; 00066 int64_t lastpts; 00067 int64_t lastdts; 00068 int64_t sync_pos; 00069 int64_t page_pos; 00070 int flags; 00071 const struct ogg_codec *codec; 00072 int header; 00073 int nsegs, segp; 00074 uint8_t segments[255]; 00075 int incomplete; 00076 int page_end; 00077 int keyframe_seek; 00078 void *private; 00079 }; 00080 00081 struct ogg_state { 00082 uint64_t pos; 00083 int curidx; 00084 struct ogg_state *next; 00085 int nstreams; 00086 struct ogg_stream streams[1]; 00087 }; 00088 00089 struct ogg { 00090 struct ogg_stream *streams; 00091 int nstreams; 00092 int headers; 00093 int curidx; 00094 struct ogg_state *state; 00095 }; 00096 00097 #define OGG_FLAG_CONT 1 00098 #define OGG_FLAG_BOS 2 00099 #define OGG_FLAG_EOS 4 00100 00101 extern const struct ogg_codec ff_dirac_codec; 00102 extern const struct ogg_codec ff_flac_codec; 00103 extern const struct ogg_codec ff_ogm_audio_codec; 00104 extern const struct ogg_codec ff_ogm_old_codec; 00105 extern const struct ogg_codec ff_ogm_text_codec; 00106 extern const struct ogg_codec ff_ogm_video_codec; 00107 extern const struct ogg_codec ff_old_dirac_codec; 00108 extern const struct ogg_codec ff_old_flac_codec; 00109 extern const struct ogg_codec ff_skeleton_codec; 00110 extern const struct ogg_codec ff_speex_codec; 00111 extern const struct ogg_codec ff_theora_codec; 00112 extern const struct ogg_codec ff_vorbis_codec; 00113 00114 int ff_vorbis_comment(AVFormatContext *ms, AVMetadata **m, const uint8_t *buf, int size); 00115 00116 static inline int 00117 ogg_find_stream (struct ogg * ogg, int serial) 00118 { 00119 int i; 00120 00121 for (i = 0; i < ogg->nstreams; i++) 00122 if (ogg->streams[i].serial == serial) 00123 return i; 00124 00125 return -1; 00126 } 00127 00128 static inline uint64_t 00129 ogg_gptopts (AVFormatContext * s, int i, uint64_t gp, int64_t *dts) 00130 { 00131 struct ogg *ogg = s->priv_data; 00132 struct ogg_stream *os = ogg->streams + i; 00133 uint64_t pts = AV_NOPTS_VALUE; 00134 00135 if(os->codec && os->codec->gptopts){ 00136 pts = os->codec->gptopts(s, i, gp, dts); 00137 } else { 00138 pts = gp; 00139 if (dts) 00140 *dts = pts; 00141 } 00142 00143 return pts; 00144 } 00145 00146 #endif /* AVFORMAT_OGGDEC_H */