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.

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