Go to the documentation of this file.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 void (*cleanup)(AVFormatContext *s, int idx);
00059 };
00060
00061 struct ogg_stream {
00062 uint8_t *buf;
00063 unsigned int bufsize;
00064 unsigned int bufpos;
00065 unsigned int pstart;
00066 unsigned int psize;
00067 unsigned int pflags;
00068 unsigned int pduration;
00069 uint32_t serial;
00070 uint64_t 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 void *private;
00084 };
00085
00086 struct ogg_state {
00087 uint64_t pos;
00088 int curidx;
00089 struct ogg_state *next;
00090 int nstreams;
00091 struct ogg_stream streams[1];
00092 };
00093
00094 struct ogg {
00095 struct ogg_stream *streams;
00096 int nstreams;
00097 int headers;
00098 int curidx;
00099 struct ogg_state *state;
00100 };
00101
00102 #define OGG_FLAG_CONT 1
00103 #define OGG_FLAG_BOS 2
00104 #define OGG_FLAG_EOS 4
00105
00106 extern const struct ogg_codec ff_celt_codec;
00107 extern const struct ogg_codec ff_dirac_codec;
00108 extern const struct ogg_codec ff_flac_codec;
00109 extern const struct ogg_codec ff_ogm_audio_codec;
00110 extern const struct ogg_codec ff_ogm_old_codec;
00111 extern const struct ogg_codec ff_ogm_text_codec;
00112 extern const struct ogg_codec ff_ogm_video_codec;
00113 extern const struct ogg_codec ff_old_dirac_codec;
00114 extern const struct ogg_codec ff_old_flac_codec;
00115 extern const struct ogg_codec ff_skeleton_codec;
00116 extern const struct ogg_codec ff_speex_codec;
00117 extern const struct ogg_codec ff_theora_codec;
00118 extern const struct ogg_codec ff_vorbis_codec;
00119
00120 int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size);
00121
00122 static inline int
00123 ogg_find_stream (struct ogg * ogg, int serial)
00124 {
00125 int i;
00126
00127 for (i = 0; i < ogg->nstreams; i++)
00128 if (ogg->streams[i].serial == serial)
00129 return i;
00130
00131 return -1;
00132 }
00133
00134 static inline uint64_t
00135 ogg_gptopts (AVFormatContext * s, int i, uint64_t gp, int64_t *dts)
00136 {
00137 struct ogg *ogg = s->priv_data;
00138 struct ogg_stream *os = ogg->streams + i;
00139 uint64_t pts = AV_NOPTS_VALUE;
00140
00141 if(os->codec && os->codec->gptopts){
00142 pts = os->codec->gptopts(s, i, gp, dts);
00143 } else {
00144 pts = gp;
00145 if (dts)
00146 *dts = pts;
00147 }
00148
00149 return pts;
00150 }
00151
00152 #endif