You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

621 lines
19KB

  1. /*
  2. * MPEG1/2 demuxer
  3. * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "avformat.h"
  22. #include "mpeg.h"
  23. //#define DEBUG_SEEK
  24. #undef NDEBUG
  25. #include <assert.h>
  26. /*********************************************/
  27. /* demux code */
  28. #define MAX_SYNC_SIZE 100000
  29. static int check_pes(uint8_t *p, uint8_t *end){
  30. int pes1;
  31. int pes2= (p[3] & 0xC0) == 0x80
  32. && (p[4] & 0xC0) != 0x40
  33. &&((p[4] & 0xC0) == 0x00 || (p[4]&0xC0)>>2 == (p[6]&0xF0));
  34. for(p+=3; p<end && *p == 0xFF; p++);
  35. if((*p&0xC0) == 0x40) p+=2;
  36. if((*p&0xF0) == 0x20){
  37. pes1= p[0]&p[2]&p[4]&1;
  38. }else if((*p&0xF0) == 0x30){
  39. pes1= p[0]&p[2]&p[4]&p[5]&p[7]&p[9]&1;
  40. }else
  41. pes1 = *p == 0x0F;
  42. return pes1||pes2;
  43. }
  44. static int mpegps_probe(AVProbeData *p)
  45. {
  46. uint32_t code= -1;
  47. int sys=0, pspack=0, priv1=0, vid=0, audio=0, invalid=0;
  48. int i;
  49. int score=0;
  50. for(i=0; i<p->buf_size; i++){
  51. code = (code<<8) + p->buf[i];
  52. if ((code & 0xffffff00) == 0x100) {
  53. int pes= check_pes(p->buf+i, p->buf+p->buf_size);
  54. if(code == SYSTEM_HEADER_START_CODE) sys++;
  55. else if(code == PRIVATE_STREAM_1) priv1++;
  56. else if(code == PACK_START_CODE) pspack++;
  57. else if((code & 0xf0) == VIDEO_ID && pes) vid++;
  58. else if((code & 0xe0) == AUDIO_ID && pes) audio++;
  59. else if((code & 0xf0) == VIDEO_ID && !pes) invalid++;
  60. else if((code & 0xe0) == AUDIO_ID && !pes) invalid++;
  61. }
  62. }
  63. if(vid+audio > invalid) /* invalid VDR files nd short PES streams */
  64. score= AVPROBE_SCORE_MAX/4;
  65. //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d %d %d len:%d\n", sys, priv1, pspack,vid, audio, invalid, p->buf_size);
  66. if(sys>invalid && sys*9 <= pspack*10)
  67. return pspack > 2 ? AVPROBE_SCORE_MAX/2+2 : AVPROBE_SCORE_MAX/4; // +1 for .mpg
  68. if(pspack > invalid && (priv1+vid+audio)*10 >= pspack*9)
  69. return pspack > 2 ? AVPROBE_SCORE_MAX/2+2 : AVPROBE_SCORE_MAX/4; // +1 for .mpg
  70. if((!!vid ^ !!audio) && (audio > 4 || vid > 1) && !sys && !pspack && p->buf_size>2048 && vid + audio > invalid) /* PES stream */
  71. return (audio > 12 || vid > 3) ? AVPROBE_SCORE_MAX/2+2 : AVPROBE_SCORE_MAX/4;
  72. //02-Penguin.flac has sys:0 priv1:0 pspack:0 vid:0 audio:1
  73. //mp3_misidentified_2.mp3 has sys:0 priv1:0 pspack:0 vid:0 audio:6
  74. return score;
  75. }
  76. typedef struct MpegDemuxContext {
  77. int32_t header_state;
  78. unsigned char psm_es_type[256];
  79. int sofdec;
  80. } MpegDemuxContext;
  81. static int mpegps_read_header(AVFormatContext *s,
  82. AVFormatParameters *ap)
  83. {
  84. MpegDemuxContext *m = s->priv_data;
  85. const char *sofdec = "Sofdec";
  86. int v, i = 0;
  87. m->header_state = 0xff;
  88. s->ctx_flags |= AVFMTCTX_NOHEADER;
  89. m->sofdec = -1;
  90. do {
  91. v = get_byte(s->pb);
  92. m->header_state = m->header_state << 8 | v;
  93. m->sofdec++;
  94. } while (v == sofdec[i] && i++ < 6);
  95. m->sofdec = (m->sofdec == 6) ? 1 : 0;
  96. /* no need to do more */
  97. return 0;
  98. }
  99. static int64_t get_pts(ByteIOContext *pb, int c)
  100. {
  101. uint8_t buf[5];
  102. buf[0] = c<0 ? get_byte(pb) : c;
  103. get_buffer(pb, buf+1, 4);
  104. return ff_parse_pes_pts(buf);
  105. }
  106. static int find_next_start_code(ByteIOContext *pb, int *size_ptr,
  107. int32_t *header_state)
  108. {
  109. unsigned int state, v;
  110. int val, n;
  111. state = *header_state;
  112. n = *size_ptr;
  113. while (n > 0) {
  114. if (url_feof(pb))
  115. break;
  116. v = get_byte(pb);
  117. n--;
  118. if (state == 0x000001) {
  119. state = ((state << 8) | v) & 0xffffff;
  120. val = state;
  121. goto found;
  122. }
  123. state = ((state << 8) | v) & 0xffffff;
  124. }
  125. val = -1;
  126. found:
  127. *header_state = state;
  128. *size_ptr = n;
  129. return val;
  130. }
  131. #if 0 /* unused, remove? */
  132. /* XXX: optimize */
  133. static int find_prev_start_code(ByteIOContext *pb, int *size_ptr)
  134. {
  135. int64_t pos, pos_start;
  136. int max_size, start_code;
  137. max_size = *size_ptr;
  138. pos_start = url_ftell(pb);
  139. /* in order to go faster, we fill the buffer */
  140. pos = pos_start - 16386;
  141. if (pos < 0)
  142. pos = 0;
  143. url_fseek(pb, pos, SEEK_SET);
  144. get_byte(pb);
  145. pos = pos_start;
  146. for(;;) {
  147. pos--;
  148. if (pos < 0 || (pos_start - pos) >= max_size) {
  149. start_code = -1;
  150. goto the_end;
  151. }
  152. url_fseek(pb, pos, SEEK_SET);
  153. start_code = get_be32(pb);
  154. if ((start_code & 0xffffff00) == 0x100)
  155. break;
  156. }
  157. the_end:
  158. *size_ptr = pos_start - pos;
  159. return start_code;
  160. }
  161. #endif
  162. /**
  163. * Extracts stream types from a program stream map
  164. * According to ISO/IEC 13818-1 ('MPEG-2 Systems') table 2-35
  165. *
  166. * @return number of bytes occupied by PSM in the bitstream
  167. */
  168. static long mpegps_psm_parse(MpegDemuxContext *m, ByteIOContext *pb)
  169. {
  170. int psm_length, ps_info_length, es_map_length;
  171. psm_length = get_be16(pb);
  172. get_byte(pb);
  173. get_byte(pb);
  174. ps_info_length = get_be16(pb);
  175. /* skip program_stream_info */
  176. url_fskip(pb, ps_info_length);
  177. es_map_length = get_be16(pb);
  178. /* at least one es available? */
  179. while (es_map_length >= 4){
  180. unsigned char type = get_byte(pb);
  181. unsigned char es_id = get_byte(pb);
  182. uint16_t es_info_length = get_be16(pb);
  183. /* remember mapping from stream id to stream type */
  184. m->psm_es_type[es_id] = type;
  185. /* skip program_stream_info */
  186. url_fskip(pb, es_info_length);
  187. es_map_length -= 4 + es_info_length;
  188. }
  189. get_be32(pb); /* crc32 */
  190. return 2 + psm_length;
  191. }
  192. /* read the next PES header. Return its position in ppos
  193. (if not NULL), and its start code, pts and dts.
  194. */
  195. static int mpegps_read_pes_header(AVFormatContext *s,
  196. int64_t *ppos, int *pstart_code,
  197. int64_t *ppts, int64_t *pdts)
  198. {
  199. MpegDemuxContext *m = s->priv_data;
  200. int len, size, startcode, c, flags, header_len;
  201. int pes_ext, ext2_len, id_ext, skip;
  202. int64_t pts, dts;
  203. int64_t last_sync= url_ftell(s->pb);
  204. error_redo:
  205. url_fseek(s->pb, last_sync, SEEK_SET);
  206. redo:
  207. /* next start code (should be immediately after) */
  208. m->header_state = 0xff;
  209. size = MAX_SYNC_SIZE;
  210. startcode = find_next_start_code(s->pb, &size, &m->header_state);
  211. last_sync = url_ftell(s->pb);
  212. //printf("startcode=%x pos=0x%"PRIx64"\n", startcode, url_ftell(s->pb));
  213. if (startcode < 0){
  214. if(url_feof(s->pb))
  215. return AVERROR_EOF;
  216. //FIXME we should remember header_state
  217. return AVERROR(EAGAIN);
  218. }
  219. if (startcode == PACK_START_CODE)
  220. goto redo;
  221. if (startcode == SYSTEM_HEADER_START_CODE)
  222. goto redo;
  223. if (startcode == PADDING_STREAM) {
  224. url_fskip(s->pb, get_be16(s->pb));
  225. goto redo;
  226. }
  227. if (startcode == PRIVATE_STREAM_2) {
  228. len = get_be16(s->pb);
  229. if (!m->sofdec) {
  230. while (len-- >= 6) {
  231. if (get_byte(s->pb) == 'S') {
  232. uint8_t buf[5];
  233. get_buffer(s->pb, buf, sizeof(buf));
  234. m->sofdec = !memcmp(buf, "ofdec", 5);
  235. len -= sizeof(buf);
  236. break;
  237. }
  238. }
  239. m->sofdec -= !m->sofdec;
  240. }
  241. url_fskip(s->pb, len);
  242. goto redo;
  243. }
  244. if (startcode == PROGRAM_STREAM_MAP) {
  245. mpegps_psm_parse(m, s->pb);
  246. goto redo;
  247. }
  248. /* find matching stream */
  249. if (!((startcode >= 0x1c0 && startcode <= 0x1df) ||
  250. (startcode >= 0x1e0 && startcode <= 0x1ef) ||
  251. (startcode == 0x1bd) || (startcode == 0x1fd)))
  252. goto redo;
  253. if (ppos) {
  254. *ppos = url_ftell(s->pb) - 4;
  255. }
  256. len = get_be16(s->pb);
  257. pts =
  258. dts = AV_NOPTS_VALUE;
  259. /* stuffing */
  260. for(;;) {
  261. if (len < 1)
  262. goto error_redo;
  263. c = get_byte(s->pb);
  264. len--;
  265. /* XXX: for mpeg1, should test only bit 7 */
  266. if (c != 0xff)
  267. break;
  268. }
  269. if ((c & 0xc0) == 0x40) {
  270. /* buffer scale & size */
  271. get_byte(s->pb);
  272. c = get_byte(s->pb);
  273. len -= 2;
  274. }
  275. if ((c & 0xe0) == 0x20) {
  276. dts = pts = get_pts(s->pb, c);
  277. len -= 4;
  278. if (c & 0x10){
  279. dts = get_pts(s->pb, -1);
  280. len -= 5;
  281. }
  282. } else if ((c & 0xc0) == 0x80) {
  283. /* mpeg 2 PES */
  284. #if 0 /* some streams have this field set for no apparent reason */
  285. if ((c & 0x30) != 0) {
  286. /* Encrypted multiplex not handled */
  287. goto redo;
  288. }
  289. #endif
  290. flags = get_byte(s->pb);
  291. header_len = get_byte(s->pb);
  292. len -= 2;
  293. if (header_len > len)
  294. goto error_redo;
  295. len -= header_len;
  296. if (flags & 0x80) {
  297. dts = pts = get_pts(s->pb, -1);
  298. header_len -= 5;
  299. if (flags & 0x40) {
  300. dts = get_pts(s->pb, -1);
  301. header_len -= 5;
  302. }
  303. }
  304. if (flags & 0x3f && header_len == 0){
  305. flags &= 0xC0;
  306. av_log(s, AV_LOG_WARNING, "Further flags set but no bytes left\n");
  307. }
  308. if (flags & 0x01) { /* PES extension */
  309. pes_ext = get_byte(s->pb);
  310. header_len--;
  311. /* Skip PES private data, program packet sequence counter and P-STD buffer */
  312. skip = (pes_ext >> 4) & 0xb;
  313. skip += skip & 0x9;
  314. if (pes_ext & 0x40 || skip > header_len){
  315. av_log(s, AV_LOG_WARNING, "pes_ext %X is invalid\n", pes_ext);
  316. pes_ext=skip=0;
  317. }
  318. url_fskip(s->pb, skip);
  319. header_len -= skip;
  320. if (pes_ext & 0x01) { /* PES extension 2 */
  321. ext2_len = get_byte(s->pb);
  322. header_len--;
  323. if ((ext2_len & 0x7f) > 0) {
  324. id_ext = get_byte(s->pb);
  325. if ((id_ext & 0x80) == 0)
  326. startcode = ((startcode & 0xff) << 8) | id_ext;
  327. header_len--;
  328. }
  329. }
  330. }
  331. if(header_len < 0)
  332. goto error_redo;
  333. url_fskip(s->pb, header_len);
  334. }
  335. else if( c!= 0xf )
  336. goto redo;
  337. if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
  338. startcode = get_byte(s->pb);
  339. len--;
  340. if (startcode >= 0x80 && startcode <= 0xcf) {
  341. /* audio: skip header */
  342. get_byte(s->pb);
  343. get_byte(s->pb);
  344. get_byte(s->pb);
  345. len -= 3;
  346. if (startcode >= 0xb0 && startcode <= 0xbf) {
  347. /* MLP/TrueHD audio has a 4-byte header */
  348. get_byte(s->pb);
  349. len--;
  350. }
  351. }
  352. }
  353. if(len<0)
  354. goto error_redo;
  355. if(dts != AV_NOPTS_VALUE && ppos){
  356. int i;
  357. for(i=0; i<s->nb_streams; i++){
  358. if(startcode == s->streams[i]->id &&
  359. !url_is_streamed(s->pb) /* index useless on streams anyway */) {
  360. ff_reduce_index(s, i);
  361. av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
  362. }
  363. }
  364. }
  365. *pstart_code = startcode;
  366. *ppts = pts;
  367. *pdts = dts;
  368. return len;
  369. }
  370. static int mpegps_read_packet(AVFormatContext *s,
  371. AVPacket *pkt)
  372. {
  373. MpegDemuxContext *m = s->priv_data;
  374. AVStream *st;
  375. int len, startcode, i, es_type;
  376. enum CodecID codec_id = CODEC_ID_NONE;
  377. enum CodecType type;
  378. int64_t pts, dts, dummy_pos; //dummy_pos is needed for the index building to work
  379. uint8_t av_uninit(dvdaudio_substream_type);
  380. redo:
  381. len = mpegps_read_pes_header(s, &dummy_pos, &startcode, &pts, &dts);
  382. if (len < 0)
  383. return len;
  384. if(startcode == 0x1bd) {
  385. dvdaudio_substream_type = get_byte(s->pb);
  386. url_fskip(s->pb, 3);
  387. len -= 4;
  388. }
  389. /* now find stream */
  390. for(i=0;i<s->nb_streams;i++) {
  391. st = s->streams[i];
  392. if (st->id == startcode)
  393. goto found;
  394. }
  395. es_type = m->psm_es_type[startcode & 0xff];
  396. if(es_type > 0 && es_type != STREAM_TYPE_PRIVATE_DATA){
  397. if(es_type == STREAM_TYPE_VIDEO_MPEG1){
  398. codec_id = CODEC_ID_MPEG2VIDEO;
  399. type = CODEC_TYPE_VIDEO;
  400. } else if(es_type == STREAM_TYPE_VIDEO_MPEG2){
  401. codec_id = CODEC_ID_MPEG2VIDEO;
  402. type = CODEC_TYPE_VIDEO;
  403. } else if(es_type == STREAM_TYPE_AUDIO_MPEG1 ||
  404. es_type == STREAM_TYPE_AUDIO_MPEG2){
  405. codec_id = CODEC_ID_MP3;
  406. type = CODEC_TYPE_AUDIO;
  407. } else if(es_type == STREAM_TYPE_AUDIO_AAC){
  408. codec_id = CODEC_ID_AAC;
  409. type = CODEC_TYPE_AUDIO;
  410. } else if(es_type == STREAM_TYPE_VIDEO_MPEG4){
  411. codec_id = CODEC_ID_MPEG4;
  412. type = CODEC_TYPE_VIDEO;
  413. } else if(es_type == STREAM_TYPE_VIDEO_H264){
  414. codec_id = CODEC_ID_H264;
  415. type = CODEC_TYPE_VIDEO;
  416. } else if(es_type == STREAM_TYPE_AUDIO_AC3){
  417. codec_id = CODEC_ID_AC3;
  418. type = CODEC_TYPE_AUDIO;
  419. } else {
  420. goto skip;
  421. }
  422. } else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
  423. static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
  424. unsigned char buf[8];
  425. get_buffer(s->pb, buf, 8);
  426. url_fseek(s->pb, -8, SEEK_CUR);
  427. if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
  428. codec_id = CODEC_ID_CAVS;
  429. else
  430. codec_id = CODEC_ID_PROBE;
  431. type = CODEC_TYPE_VIDEO;
  432. } else if (startcode >= 0x1c0 && startcode <= 0x1df) {
  433. type = CODEC_TYPE_AUDIO;
  434. codec_id = m->sofdec > 0 ? CODEC_ID_ADPCM_ADX : CODEC_ID_MP2;
  435. } else if (startcode >= 0x80 && startcode <= 0x87) {
  436. type = CODEC_TYPE_AUDIO;
  437. codec_id = CODEC_ID_AC3;
  438. } else if ( ( startcode >= 0x88 && startcode <= 0x8f)
  439. ||( startcode >= 0x98 && startcode <= 0x9f)) {
  440. /* 0x90 - 0x97 is reserved for SDDS in DVD specs */
  441. type = CODEC_TYPE_AUDIO;
  442. codec_id = CODEC_ID_DTS;
  443. } else if (startcode >= 0xa0 && startcode <= 0xaf) {
  444. type = CODEC_TYPE_AUDIO;
  445. /* 16 bit form will be handled as CODEC_ID_PCM_S16BE */
  446. codec_id = CODEC_ID_PCM_DVD;
  447. } else if (startcode >= 0xb0 && startcode <= 0xbf) {
  448. type = CODEC_TYPE_AUDIO;
  449. codec_id = CODEC_ID_TRUEHD;
  450. } else if (startcode >= 0xc0 && startcode <= 0xcf) {
  451. /* Used for both AC-3 and E-AC-3 in EVOB files */
  452. type = CODEC_TYPE_AUDIO;
  453. codec_id = CODEC_ID_AC3;
  454. } else if (startcode >= 0x20 && startcode <= 0x3f) {
  455. type = CODEC_TYPE_SUBTITLE;
  456. codec_id = CODEC_ID_DVD_SUBTITLE;
  457. } else if (startcode >= 0xfd55 && startcode <= 0xfd5f) {
  458. type = CODEC_TYPE_VIDEO;
  459. codec_id = CODEC_ID_VC1;
  460. } else if (startcode == 0x1bd) {
  461. // check dvd audio substream type
  462. type = CODEC_TYPE_AUDIO;
  463. switch(dvdaudio_substream_type & 0xe0) {
  464. case 0xa0: codec_id = CODEC_ID_PCM_DVD;
  465. break;
  466. case 0x80: if((dvdaudio_substream_type & 0xf8) == 0x88)
  467. codec_id = CODEC_ID_DTS;
  468. else codec_id = CODEC_ID_AC3;
  469. break;
  470. default: av_log(s, AV_LOG_ERROR, "Unknown 0x1bd sub-stream\n");
  471. goto skip;
  472. }
  473. } else {
  474. skip:
  475. /* skip packet */
  476. url_fskip(s->pb, len);
  477. goto redo;
  478. }
  479. /* no stream found: add a new stream */
  480. st = av_new_stream(s, startcode);
  481. if (!st)
  482. goto skip;
  483. st->codec->codec_type = type;
  484. st->codec->codec_id = codec_id;
  485. if (codec_id != CODEC_ID_PCM_S16BE)
  486. st->need_parsing = AVSTREAM_PARSE_FULL;
  487. found:
  488. if(st->discard >= AVDISCARD_ALL)
  489. goto skip;
  490. if ((startcode >= 0xa0 && startcode <= 0xaf) ||
  491. (startcode == 0x1bd && ((dvdaudio_substream_type & 0xe0) == 0xa0))) {
  492. int b1, freq;
  493. /* for LPCM, we just skip the header and consider it is raw
  494. audio data */
  495. if (len <= 3)
  496. goto skip;
  497. get_byte(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
  498. b1 = get_byte(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
  499. get_byte(s->pb); /* dynamic range control (0x80 = off) */
  500. len -= 3;
  501. freq = (b1 >> 4) & 3;
  502. st->codec->sample_rate = lpcm_freq_tab[freq];
  503. st->codec->channels = 1 + (b1 & 7);
  504. st->codec->bits_per_coded_sample = 16 + ((b1 >> 6) & 3) * 4;
  505. st->codec->bit_rate = st->codec->channels *
  506. st->codec->sample_rate *
  507. st->codec->bits_per_coded_sample;
  508. if (st->codec->bits_per_coded_sample == 16)
  509. st->codec->codec_id = CODEC_ID_PCM_S16BE;
  510. else if (st->codec->bits_per_coded_sample == 28)
  511. return AVERROR(EINVAL);
  512. }
  513. av_new_packet(pkt, len);
  514. get_buffer(s->pb, pkt->data, pkt->size);
  515. pkt->pts = pts;
  516. pkt->dts = dts;
  517. pkt->pos = dummy_pos;
  518. pkt->stream_index = st->index;
  519. #if 0
  520. av_log(s, AV_LOG_DEBUG, "%d: pts=%0.3f dts=%0.3f size=%d\n",
  521. pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0, pkt->size);
  522. #endif
  523. return 0;
  524. }
  525. static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index,
  526. int64_t *ppos, int64_t pos_limit)
  527. {
  528. int len, startcode;
  529. int64_t pos, pts, dts;
  530. pos = *ppos;
  531. #ifdef DEBUG_SEEK
  532. printf("read_dts: pos=0x%"PRIx64" next=%d -> ", pos, find_next);
  533. #endif
  534. if (url_fseek(s->pb, pos, SEEK_SET) < 0)
  535. return AV_NOPTS_VALUE;
  536. for(;;) {
  537. len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts);
  538. if (len < 0) {
  539. #ifdef DEBUG_SEEK
  540. printf("none (ret=%d)\n", len);
  541. #endif
  542. return AV_NOPTS_VALUE;
  543. }
  544. if (startcode == s->streams[stream_index]->id &&
  545. dts != AV_NOPTS_VALUE) {
  546. break;
  547. }
  548. url_fskip(s->pb, len);
  549. }
  550. #ifdef DEBUG_SEEK
  551. printf("pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", pos, dts, dts / 90000.0);
  552. #endif
  553. *ppos = pos;
  554. return dts;
  555. }
  556. AVInputFormat mpegps_demuxer = {
  557. "mpeg",
  558. NULL_IF_CONFIG_SMALL("MPEG-PS format"),
  559. sizeof(MpegDemuxContext),
  560. mpegps_probe,
  561. mpegps_read_header,
  562. mpegps_read_packet,
  563. NULL,
  564. NULL, //mpegps_read_seek,
  565. mpegps_read_dts,
  566. .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT,
  567. };