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;
00057 int nb_header;
00058 };
00059
00060 struct ogg_stream {
00061 uint8_t *buf;
00062 unsigned int bufsize;
00063 unsigned int bufpos;
00064 unsigned int pstart;
00065 unsigned int psize;
00066 unsigned int pflags;
00067 unsigned int pduration;
00068 uint32_t serial;
00069 uint64_t granule;
00070 uint64_t start_granule;
00071 int64_t lastpts;
00072 int64_t lastdts;
00073 int64_t sync_pos;
00074 int64_t page_pos;
00075 int flags;
00076 const struct ogg_codec *codec;
00077 int header;
00078 int nsegs, segp;
00079 uint8_t segments[255];
00080 int incomplete;
00081 int page_end;
00082 int keyframe_seek;
00083 int got_start;
00084 int got_data;
00085 int nb_header;
00086 void *private;
00087 };
00088
00089 struct ogg_state {
00090 uint64_t pos;
00091 int curidx;
00092 struct ogg_state *next;
00093 int nstreams;
00094 struct ogg_stream streams[1];
00095 };
00096
00097 struct ogg {
00098 struct ogg_stream *streams;
00099 int nstreams;
00100 int headers;
00101 int curidx;
00102 struct ogg_state *state;
00103 };
00104
00105 #define OGG_FLAG_CONT 1
00106 #define OGG_FLAG_BOS 2
00107 #define OGG_FLAG_EOS 4
00108
00109 #define OGG_NOGRANULE_VALUE (-1ull)
00110
00111 extern const struct ogg_codec ff_celt_codec;
00112 extern const struct ogg_codec ff_dirac_codec;
00113 extern const struct ogg_codec ff_flac_codec;
00114 extern const struct ogg_codec ff_ogm_audio_codec;
00115 extern const struct ogg_codec ff_ogm_old_codec;
00116 extern const struct ogg_codec ff_ogm_text_codec;
00117 extern const struct ogg_codec ff_ogm_video_codec;
00118 extern const struct ogg_codec ff_old_dirac_codec;
00119 extern const struct ogg_codec ff_old_flac_codec;
00120 extern const struct ogg_codec ff_opus_codec;
00121 extern const struct ogg_codec ff_skeleton_codec;
00122 extern const struct ogg_codec ff_speex_codec;
00123 extern const struct ogg_codec ff_theora_codec;
00124 extern const struct ogg_codec ff_vorbis_codec;
00125
00126 int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size);
00127
00128 static inline int
00129 ogg_find_stream (struct ogg * ogg, int serial)
00130 {
00131 int i;
00132
00133 for (i = 0; i < ogg->nstreams; i++)
00134 if (ogg->streams[i].serial == serial)
00135 return i;
00136
00137 return -1;
00138 }
00139
00140 static inline uint64_t
00141 ogg_gptopts (AVFormatContext * s, int i, uint64_t gp, int64_t *dts)
00142 {
00143 struct ogg *ogg = s->priv_data;
00144 struct ogg_stream *os = ogg->streams + i;
00145 uint64_t pts = AV_NOPTS_VALUE;
00146
00147 if(os->codec && os->codec->gptopts){
00148 pts = os->codec->gptopts(s, i, gp, dts);
00149 } else {
00150 pts = gp;
00151 if (dts)
00152 *dts = pts;
00153 }
00154
00155 return pts;
00156 }
00157
00158 #endif