oggdec.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * Ogg bitstream support
  3. * Luca Barbato <lu_zero@gentoo.org>
  4. * Based on tcvp implementation
  5. *
  6. */
  7. /**
  8. Copyright (C) 2005 Michael Ahlberg, Måns Rullgård
  9. Permission is hereby granted, free of charge, to any person
  10. obtaining a copy of this software and associated documentation
  11. files (the "Software"), to deal in the Software without
  12. restriction, including without limitation the rights to use, copy,
  13. modify, merge, publish, distribute, sublicense, and/or sell copies
  14. of the Software, and to permit persons to whom the Software is
  15. furnished to do so, subject to the following conditions:
  16. The above copyright notice and this permission notice shall be
  17. included in all copies or substantial portions of the Software.
  18. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  22. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  23. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. DEALINGS IN THE SOFTWARE.
  26. **/
  27. #include <stdio.h>
  28. #include "oggdec.h"
  29. #include "avformat.h"
  30. #include "internal.h"
  31. #include "vorbiscomment.h"
  32. #define MAX_PAGE_SIZE 65307
  33. #define DECODER_BUFFER_SIZE MAX_PAGE_SIZE
  34. static const struct ogg_codec * const ogg_codecs[] = {
  35. &ff_skeleton_codec,
  36. &ff_dirac_codec,
  37. &ff_speex_codec,
  38. &ff_vorbis_codec,
  39. &ff_theora_codec,
  40. &ff_flac_codec,
  41. &ff_celt_codec,
  42. &ff_old_dirac_codec,
  43. &ff_old_flac_codec,
  44. &ff_ogm_video_codec,
  45. &ff_ogm_audio_codec,
  46. &ff_ogm_text_codec,
  47. &ff_ogm_old_codec,
  48. NULL
  49. };
  50. //FIXME We could avoid some structure duplication
  51. static int ogg_save(AVFormatContext *s)
  52. {
  53. struct ogg *ogg = s->priv_data;
  54. struct ogg_state *ost =
  55. av_malloc(sizeof (*ost) + (ogg->nstreams-1) * sizeof (*ogg->streams));
  56. int i;
  57. ost->pos = avio_tell (s->pb);
  58. ost->curidx = ogg->curidx;
  59. ost->next = ogg->state;
  60. ost->nstreams = ogg->nstreams;
  61. memcpy(ost->streams, ogg->streams, ogg->nstreams * sizeof(*ogg->streams));
  62. for (i = 0; i < ogg->nstreams; i++){
  63. struct ogg_stream *os = ogg->streams + i;
  64. os->buf = av_malloc (os->bufsize);
  65. memset (os->buf, 0, os->bufsize);
  66. memcpy (os->buf, ost->streams[i].buf, os->bufpos);
  67. }
  68. ogg->state = ost;
  69. return 0;
  70. }
  71. static int ogg_restore(AVFormatContext *s, int discard)
  72. {
  73. struct ogg *ogg = s->priv_data;
  74. AVIOContext *bc = s->pb;
  75. struct ogg_state *ost = ogg->state;
  76. int i;
  77. if (!ost)
  78. return 0;
  79. ogg->state = ost->next;
  80. if (!discard){
  81. struct ogg_stream *old_streams = ogg->streams;
  82. for (i = 0; i < ogg->nstreams; i++)
  83. av_free (ogg->streams[i].buf);
  84. avio_seek (bc, ost->pos, SEEK_SET);
  85. ogg->curidx = ost->curidx;
  86. ogg->nstreams = ost->nstreams;
  87. ogg->streams = av_realloc (ogg->streams,
  88. ogg->nstreams * sizeof (*ogg->streams));
  89. if (ogg->streams) {
  90. memcpy(ogg->streams, ost->streams,
  91. ost->nstreams * sizeof(*ogg->streams));
  92. } else {
  93. av_free(old_streams);
  94. ogg->nstreams = 0;
  95. }
  96. }
  97. av_free (ost);
  98. return 0;
  99. }
  100. static int ogg_reset(struct ogg *ogg)
  101. {
  102. int i;
  103. for (i = 0; i < ogg->nstreams; i++){
  104. struct ogg_stream *os = ogg->streams + i;
  105. os->bufpos = 0;
  106. os->pstart = 0;
  107. os->psize = 0;
  108. os->granule = -1;
  109. os->lastpts = AV_NOPTS_VALUE;
  110. os->lastdts = AV_NOPTS_VALUE;
  111. os->sync_pos = -1;
  112. os->page_pos = 0;
  113. os->nsegs = 0;
  114. os->segp = 0;
  115. os->incomplete = 0;
  116. }
  117. ogg->curidx = -1;
  118. return 0;
  119. }
  120. static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size)
  121. {
  122. int i;
  123. for (i = 0; ogg_codecs[i]; i++)
  124. if (size >= ogg_codecs[i]->magicsize &&
  125. !memcmp (buf, ogg_codecs[i]->magic, ogg_codecs[i]->magicsize))
  126. return ogg_codecs[i];
  127. return NULL;
  128. }
  129. static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream)
  130. {
  131. struct ogg *ogg = s->priv_data;
  132. int idx = ogg->nstreams++;
  133. AVStream *st;
  134. struct ogg_stream *os;
  135. ogg->streams = av_realloc (ogg->streams,
  136. ogg->nstreams * sizeof (*ogg->streams));
  137. memset (ogg->streams + idx, 0, sizeof (*ogg->streams));
  138. os = ogg->streams + idx;
  139. os->serial = serial;
  140. os->bufsize = DECODER_BUFFER_SIZE;
  141. os->buf = av_malloc(os->bufsize);
  142. os->header = -1;
  143. if (new_avstream) {
  144. st = avformat_new_stream(s, NULL);
  145. if (!st)
  146. return AVERROR(ENOMEM);
  147. st->id = idx;
  148. av_set_pts_info(st, 64, 1, 1000000);
  149. }
  150. return idx;
  151. }
  152. static int ogg_new_buf(struct ogg *ogg, int idx)
  153. {
  154. struct ogg_stream *os = ogg->streams + idx;
  155. uint8_t *nb = av_malloc(os->bufsize);
  156. int size = os->bufpos - os->pstart;
  157. if(os->buf){
  158. memcpy(nb, os->buf + os->pstart, size);
  159. av_free(os->buf);
  160. }
  161. os->buf = nb;
  162. os->bufpos = size;
  163. os->pstart = 0;
  164. return 0;
  165. }
  166. static int ogg_read_page(AVFormatContext *s, int *str)
  167. {
  168. AVIOContext *bc = s->pb;
  169. struct ogg *ogg = s->priv_data;
  170. struct ogg_stream *os;
  171. int ret, i = 0;
  172. int flags, nsegs;
  173. uint64_t gp;
  174. uint32_t serial;
  175. int size, idx;
  176. uint8_t sync[4];
  177. int sp = 0;
  178. ret = avio_read(bc, sync, 4);
  179. if (ret < 4)
  180. return ret < 0 ? ret : AVERROR_EOF;
  181. do{
  182. int c;
  183. if (sync[sp & 3] == 'O' &&
  184. sync[(sp + 1) & 3] == 'g' &&
  185. sync[(sp + 2) & 3] == 'g' && sync[(sp + 3) & 3] == 'S')
  186. break;
  187. c = avio_r8(bc);
  188. if (url_feof(bc))
  189. return AVERROR_EOF;
  190. sync[sp++ & 3] = c;
  191. }while (i++ < MAX_PAGE_SIZE);
  192. if (i >= MAX_PAGE_SIZE){
  193. av_log (s, AV_LOG_INFO, "ogg, can't find sync word\n");
  194. return AVERROR_INVALIDDATA;
  195. }
  196. if (avio_r8(bc) != 0) /* version */
  197. return AVERROR_INVALIDDATA;
  198. flags = avio_r8(bc);
  199. gp = avio_rl64 (bc);
  200. serial = avio_rl32 (bc);
  201. avio_skip(bc, 8); /* seq, crc */
  202. nsegs = avio_r8(bc);
  203. idx = ogg_find_stream (ogg, serial);
  204. if (idx < 0){
  205. if (ogg->headers) {
  206. int n;
  207. for (n = 0; n < ogg->nstreams; n++) {
  208. av_freep(&ogg->streams[n].buf);
  209. if (!ogg->state || ogg->state->streams[n].private != ogg->streams[n].private)
  210. av_freep(&ogg->streams[n].private);
  211. }
  212. ogg->curidx = -1;
  213. ogg->nstreams = 0;
  214. idx = ogg_new_stream(s, serial, 0);
  215. } else {
  216. idx = ogg_new_stream(s, serial, 1);
  217. }
  218. if (idx < 0)
  219. return idx;
  220. }
  221. os = ogg->streams + idx;
  222. os->page_pos = avio_tell(bc) - 27;
  223. if(os->psize > 0)
  224. ogg_new_buf(ogg, idx);
  225. ret = avio_read(bc, os->segments, nsegs);
  226. if (ret < nsegs)
  227. return ret < 0 ? ret : AVERROR_EOF;
  228. os->nsegs = nsegs;
  229. os->segp = 0;
  230. size = 0;
  231. for (i = 0; i < nsegs; i++)
  232. size += os->segments[i];
  233. if (flags & OGG_FLAG_CONT || os->incomplete){
  234. if (!os->psize){
  235. while (os->segp < os->nsegs){
  236. int seg = os->segments[os->segp++];
  237. os->pstart += seg;
  238. if (seg < 255)
  239. break;
  240. }
  241. os->sync_pos = os->page_pos;
  242. }
  243. }else{
  244. os->psize = 0;
  245. os->sync_pos = os->page_pos;
  246. }
  247. if (os->bufsize - os->bufpos < size){
  248. uint8_t *nb = av_malloc (os->bufsize *= 2);
  249. memcpy (nb, os->buf, os->bufpos);
  250. av_free (os->buf);
  251. os->buf = nb;
  252. }
  253. ret = avio_read(bc, os->buf + os->bufpos, size);
  254. if (ret < size)
  255. return ret < 0 ? ret : AVERROR_EOF;
  256. os->bufpos += size;
  257. os->granule = gp;
  258. os->flags = flags;
  259. if (str)
  260. *str = idx;
  261. return 0;
  262. }
  263. static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
  264. int64_t *fpos)
  265. {
  266. struct ogg *ogg = s->priv_data;
  267. int idx, i, ret;
  268. struct ogg_stream *os;
  269. int complete = 0;
  270. int segp = 0, psize = 0;
  271. av_dlog(s, "ogg_packet: curidx=%i\n", ogg->curidx);
  272. do{
  273. idx = ogg->curidx;
  274. while (idx < 0){
  275. ret = ogg_read_page(s, &idx);
  276. if (ret < 0)
  277. return ret;
  278. }
  279. os = ogg->streams + idx;
  280. av_dlog(s, "ogg_packet: idx=%d pstart=%d psize=%d segp=%d nsegs=%d\n",
  281. idx, os->pstart, os->psize, os->segp, os->nsegs);
  282. if (!os->codec){
  283. if (os->header < 0){
  284. os->codec = ogg_find_codec (os->buf, os->bufpos);
  285. if (!os->codec){
  286. av_log(s, AV_LOG_WARNING, "Codec not found\n");
  287. os->header = 0;
  288. return 0;
  289. }
  290. }else{
  291. return 0;
  292. }
  293. }
  294. segp = os->segp;
  295. psize = os->psize;
  296. while (os->segp < os->nsegs){
  297. int ss = os->segments[os->segp++];
  298. os->psize += ss;
  299. if (ss < 255){
  300. complete = 1;
  301. break;
  302. }
  303. }
  304. if (!complete && os->segp == os->nsegs){
  305. ogg->curidx = -1;
  306. os->incomplete = 1;
  307. }
  308. }while (!complete);
  309. if (os->granule == -1)
  310. av_log(s, AV_LOG_WARNING, "Page at %"PRId64" is missing granule\n", os->page_pos);
  311. ogg->curidx = idx;
  312. os->incomplete = 0;
  313. if (os->header) {
  314. os->header = os->codec->header (s, idx);
  315. if (!os->header){
  316. os->segp = segp;
  317. os->psize = psize;
  318. // We have reached the first non-header packet in this stream.
  319. // Unfortunately more header packets may still follow for others,
  320. // but if we continue with header parsing we may lose data packets.
  321. ogg->headers = 1;
  322. // Update the header state for all streams and
  323. // compute the data_offset.
  324. if (!s->data_offset)
  325. s->data_offset = os->sync_pos;
  326. for (i = 0; i < ogg->nstreams; i++) {
  327. struct ogg_stream *cur_os = ogg->streams + i;
  328. // if we have a partial non-header packet, its start is
  329. // obviously at or after the data start
  330. if (cur_os->incomplete)
  331. s->data_offset = FFMIN(s->data_offset, cur_os->sync_pos);
  332. }
  333. }else{
  334. os->pstart += os->psize;
  335. os->psize = 0;
  336. }
  337. } else {
  338. os->pflags = 0;
  339. os->pduration = 0;
  340. if (os->codec && os->codec->packet)
  341. os->codec->packet (s, idx);
  342. if (str)
  343. *str = idx;
  344. if (dstart)
  345. *dstart = os->pstart;
  346. if (dsize)
  347. *dsize = os->psize;
  348. if (fpos)
  349. *fpos = os->sync_pos;
  350. os->pstart += os->psize;
  351. os->psize = 0;
  352. if(os->pstart == os->bufpos)
  353. os->bufpos = os->pstart = 0;
  354. os->sync_pos = os->page_pos;
  355. }
  356. // determine whether there are more complete packets in this page
  357. // if not, the page's granule will apply to this packet
  358. os->page_end = 1;
  359. for (i = os->segp; i < os->nsegs; i++)
  360. if (os->segments[i] < 255) {
  361. os->page_end = 0;
  362. break;
  363. }
  364. if (os->segp == os->nsegs)
  365. ogg->curidx = -1;
  366. return 0;
  367. }
  368. static int ogg_get_headers(AVFormatContext *s)
  369. {
  370. struct ogg *ogg = s->priv_data;
  371. int ret;
  372. do{
  373. ret = ogg_packet(s, NULL, NULL, NULL, NULL);
  374. if (ret < 0)
  375. return ret;
  376. }while (!ogg->headers);
  377. av_dlog(s, "found headers\n");
  378. return 0;
  379. }
  380. static int ogg_get_length(AVFormatContext *s)
  381. {
  382. struct ogg *ogg = s->priv_data;
  383. int i;
  384. int64_t size, end;
  385. int streams_left=0;
  386. if(!s->pb->seekable)
  387. return 0;
  388. // already set
  389. if (s->duration != AV_NOPTS_VALUE)
  390. return 0;
  391. size = avio_size(s->pb);
  392. if(size < 0)
  393. return 0;
  394. end = size > MAX_PAGE_SIZE? size - MAX_PAGE_SIZE: 0;
  395. ogg_save (s);
  396. avio_seek (s->pb, end, SEEK_SET);
  397. while (!ogg_read_page (s, &i)){
  398. if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
  399. ogg->streams[i].codec) {
  400. s->streams[i]->duration =
  401. ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
  402. if (s->streams[i]->start_time != AV_NOPTS_VALUE){
  403. s->streams[i]->duration -= s->streams[i]->start_time;
  404. streams_left-= (ogg->streams[i].got_start==-1);
  405. ogg->streams[i].got_start= 1;
  406. }else if(!ogg->streams[i].got_start){
  407. ogg->streams[i].got_start= -1;
  408. streams_left++;
  409. }
  410. }
  411. }
  412. ogg_restore (s, 0);
  413. ogg_save (s);
  414. avio_seek (s->pb, 0, SEEK_SET);
  415. while (!ogg_read_page (s, &i)){
  416. if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
  417. ogg->streams[i].codec) {
  418. if(s->streams[i]->duration && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){
  419. int64_t start= ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
  420. if(av_rescale_q(start, s->streams[i]->time_base, AV_TIME_BASE_Q) > AV_TIME_BASE)
  421. s->streams[i]->duration -= start;
  422. ogg->streams[i].got_start= 1;
  423. streams_left--;
  424. }
  425. if(streams_left<=0)
  426. break;
  427. }
  428. }
  429. ogg_restore (s, 0);
  430. return 0;
  431. }
  432. static int ogg_read_header(AVFormatContext *s, AVFormatParameters *ap)
  433. {
  434. struct ogg *ogg = s->priv_data;
  435. int ret, i;
  436. ogg->curidx = -1;
  437. //linear headers seek from start
  438. ret = ogg_get_headers(s);
  439. if (ret < 0)
  440. return ret;
  441. for (i = 0; i < ogg->nstreams; i++)
  442. if (ogg->streams[i].header < 0)
  443. ogg->streams[i].codec = NULL;
  444. //linear granulepos seek from end
  445. ogg_get_length (s);
  446. //fill the extradata in the per codec callbacks
  447. return 0;
  448. }
  449. static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts)
  450. {
  451. struct ogg *ogg = s->priv_data;
  452. struct ogg_stream *os = ogg->streams + idx;
  453. int64_t pts = AV_NOPTS_VALUE;
  454. if (dts)
  455. *dts = AV_NOPTS_VALUE;
  456. if (os->lastpts != AV_NOPTS_VALUE) {
  457. pts = os->lastpts;
  458. os->lastpts = AV_NOPTS_VALUE;
  459. }
  460. if (os->lastdts != AV_NOPTS_VALUE) {
  461. if (dts)
  462. *dts = os->lastdts;
  463. os->lastdts = AV_NOPTS_VALUE;
  464. }
  465. if (os->page_end) {
  466. if (os->granule != -1LL) {
  467. if (os->codec && os->codec->granule_is_start)
  468. pts = ogg_gptopts(s, idx, os->granule, dts);
  469. else
  470. os->lastpts = ogg_gptopts(s, idx, os->granule, &os->lastdts);
  471. os->granule = -1LL;
  472. }
  473. }
  474. return pts;
  475. }
  476. static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
  477. {
  478. struct ogg *ogg;
  479. struct ogg_stream *os;
  480. int idx = -1, ret;
  481. int pstart, psize;
  482. int64_t fpos, pts, dts;
  483. //Get an ogg packet
  484. retry:
  485. do{
  486. ret = ogg_packet(s, &idx, &pstart, &psize, &fpos);
  487. if (ret < 0)
  488. return ret;
  489. }while (idx < 0 || !s->streams[idx]);
  490. ogg = s->priv_data;
  491. os = ogg->streams + idx;
  492. // pflags might not be set until after this
  493. pts = ogg_calc_pts(s, idx, &dts);
  494. if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY))
  495. goto retry;
  496. os->keyframe_seek = 0;
  497. //Alloc a pkt
  498. ret = av_new_packet(pkt, psize);
  499. if (ret < 0)
  500. return ret;
  501. pkt->stream_index = idx;
  502. memcpy (pkt->data, os->buf + pstart, psize);
  503. pkt->pts = pts;
  504. pkt->dts = dts;
  505. pkt->flags = os->pflags;
  506. pkt->duration = os->pduration;
  507. pkt->pos = fpos;
  508. return psize;
  509. }
  510. static int ogg_read_close(AVFormatContext *s)
  511. {
  512. struct ogg *ogg = s->priv_data;
  513. int i;
  514. for (i = 0; i < ogg->nstreams; i++){
  515. av_free (ogg->streams[i].buf);
  516. av_free (ogg->streams[i].private);
  517. }
  518. av_free (ogg->streams);
  519. return 0;
  520. }
  521. static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,
  522. int64_t *pos_arg, int64_t pos_limit)
  523. {
  524. struct ogg *ogg = s->priv_data;
  525. AVIOContext *bc = s->pb;
  526. int64_t pts = AV_NOPTS_VALUE;
  527. int i = -1;
  528. avio_seek(bc, *pos_arg, SEEK_SET);
  529. ogg_reset(ogg);
  530. while (avio_tell(bc) < pos_limit && !ogg_packet(s, &i, NULL, NULL, pos_arg)) {
  531. if (i == stream_index) {
  532. struct ogg_stream *os = ogg->streams + stream_index;
  533. pts = ogg_calc_pts(s, i, NULL);
  534. if (os->keyframe_seek && !(os->pflags & AV_PKT_FLAG_KEY))
  535. pts = AV_NOPTS_VALUE;
  536. }
  537. if (pts != AV_NOPTS_VALUE)
  538. break;
  539. }
  540. ogg_reset(ogg);
  541. return pts;
  542. }
  543. static int ogg_read_seek(AVFormatContext *s, int stream_index,
  544. int64_t timestamp, int flags)
  545. {
  546. struct ogg *ogg = s->priv_data;
  547. struct ogg_stream *os = ogg->streams + stream_index;
  548. int ret;
  549. // Try seeking to a keyframe first. If this fails (very possible),
  550. // av_seek_frame will fall back to ignoring keyframes
  551. if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_VIDEO
  552. && !(flags & AVSEEK_FLAG_ANY))
  553. os->keyframe_seek = 1;
  554. ret = ff_seek_frame_binary(s, stream_index, timestamp, flags);
  555. os = ogg->streams + stream_index;
  556. if (ret < 0)
  557. os->keyframe_seek = 0;
  558. return ret;
  559. }
  560. static int ogg_probe(AVProbeData *p)
  561. {
  562. if (!memcmp("OggS", p->buf, 5) && p->buf[5] <= 0x7)
  563. return AVPROBE_SCORE_MAX;
  564. return 0;
  565. }
  566. AVInputFormat ff_ogg_demuxer = {
  567. .name = "ogg",
  568. .long_name = NULL_IF_CONFIG_SMALL("Ogg"),
  569. .priv_data_size = sizeof(struct ogg),
  570. .read_probe = ogg_probe,
  571. .read_header = ogg_read_header,
  572. .read_packet = ogg_read_packet,
  573. .read_close = ogg_read_close,
  574. .read_seek = ogg_read_seek,
  575. .read_timestamp = ogg_read_timestamp,
  576. .extensions = "ogg",
  577. .flags = AVFMT_GENERIC_INDEX,
  578. };