annotate libmpdemux/demux_mpg.c @ 27319:09cf111f68b8

Revert to previous dependency checking behavior. Take included header files into account when generating dependency files. This has problems when header files are removed or renamed, but does not silently miscompile files.
author diego
date Sat, 26 Jul 2008 18:36:48 +0000
parents ff446aa58931
children 9e739bdb049c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 // MPG/VOB file parser for DEMUXER v2.5 by A'rpi/ESP-team
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
3 #include <stdio.h>
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
4 #include <stdlib.h>
1430
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1338
diff changeset
5 #include <unistd.h>
22036
2c6cccdeaf65 include math.h for fabsf()
nicodvb
parents: 22035
diff changeset
6 #include <math.h>
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
7
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
8 #include "config.h"
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
9 #include "mp_msg.h"
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1735
diff changeset
10 #include "help_mp.h"
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
11
22605
4d81dbdf46b9 Add explicit location for headers from the stream/ directory.
diego
parents: 22507
diff changeset
12 #include "stream/stream.h"
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
13 #include "demuxer.h"
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
14 #include "parse_es.h"
2338
4f3e8c8ea32f includes cleanup
arpi
parents: 2310
diff changeset
15 #include "stheader.h"
4711
39f5eccd54c2 added mp3 detection
arpi
parents: 4391
diff changeset
16 #include "mp3_hdr.h"
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
17
524
9105fc95636c A fast'n'ugly hack to correct DVD VOB playback problems
lgb
parents: 501
diff changeset
18 //#define MAX_PS_PACKETSIZE 2048
501
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
19 #define MAX_PS_PACKETSIZE (224*1024)
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
20
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
21 #define UNKNOWN 0
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
22 #define VIDEO_MPEG1 0x10000001
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
23 #define VIDEO_MPEG2 0x10000002
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
24 #define VIDEO_MPEG4 0x10000004
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
25 #define VIDEO_H264 0x10000005
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
26 #define AUDIO_MP2 0x50
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
27 #define AUDIO_A52 0x2000
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
28 #define AUDIO_LPCM_BE 0x10001
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
29 #define AUDIO_AAC mmioFOURCC('M', 'P', '4', 'A')
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
30
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
31 typedef struct mpg_demuxer {
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
32 float last_pts;
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
33 float first_pts; // first pts found in stream
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
34 float first_to_final_pts_len; // difference between final pts and first pts
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
35 int has_valid_timestamps; // !=0 iff time stamps look linear
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
36 // (not necessarily starting with 0)
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
37 unsigned int es_map[0x40]; //es map of stream types (associated to the pes id) from 0xb0 to 0xef
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
38 int num_a_streams;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
39 int a_stream_ids[MAX_A_STREAMS];
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
40 } mpg_demuxer_t;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
41
17286
b0046966ab82 don't reset dvdsub->id unless -slang is specified; assign default sub stream id when demux->sub->id is -1 (autodetect)
nicodvb
parents: 16877
diff changeset
42 extern char* dvdsub_lang;
547
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
43 static int mpeg_pts_error=0;
22037
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
44 off_t ps_probe = 0;
547
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
45
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
46 static int parse_psm(demuxer_t *demux, int len) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
47 unsigned char c, id, type;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
48 unsigned int plen, prog_len, es_map_len;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
49 mpg_demuxer_t *priv = (mpg_demuxer_t *) demux->priv;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
50
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
51 mp_dbg(MSGT_DEMUX,MSGL_V, "PARSE_PSM, len=%d\n", len);
18549
845f94a75729 psm longer than 1018 bytes is not allowed, thus invalid
nicodvb
parents: 18382
diff changeset
52 if(! len || len > 1018)
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
53 return 0;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
54
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
55 c = stream_read_char(demux->stream);
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
56 if(! (c & 0x80)) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
57 stream_skip(demux->stream, len - 1); //not yet valid, discard
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
58 return 0;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
59 }
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
60 stream_skip(demux->stream, 1);
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
61 prog_len = stream_read_word(demux->stream); //length of program descriptors
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
62 stream_skip(demux->stream, prog_len); //.. that we ignore
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
63 es_map_len = stream_read_word(demux->stream); //length of elementary streams map
21531
a90aa203186c Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents: 20872
diff changeset
64 es_map_len = FFMIN(es_map_len, len - prog_len - 8); //sanity check
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
65 while(es_map_len > 0) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
66 type = stream_read_char(demux->stream);
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
67 id = stream_read_char(demux->stream);
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
68 if(id >= 0xB0 && id <= 0xEF && priv) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
69 int idoffset = id - 0xB0;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
70 switch(type) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
71 case 0x1:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
72 priv->es_map[idoffset] = VIDEO_MPEG1;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
73 break;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
74 case 0x2:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
75 priv->es_map[idoffset] = VIDEO_MPEG2;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
76 break;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
77 case 0x3:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
78 case 0x4:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
79 priv->es_map[idoffset] = AUDIO_MP2;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
80 break;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
81 case 0x0f:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
82 case 0x11:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
83 priv->es_map[idoffset] = AUDIO_AAC;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
84 break;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
85 case 0x10:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
86 priv->es_map[idoffset] = VIDEO_MPEG4;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
87 break;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
88 case 0x1b:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
89 priv->es_map[idoffset] = VIDEO_H264;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
90 break;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
91 case 0x81:
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
92 priv->es_map[idoffset] = AUDIO_A52;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
93 break;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
94 }
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
95 mp_dbg(MSGT_DEMUX,MSGL_V, "PSM ES, id=0x%x, type=%x, stype: %x\n", id, type, priv->es_map[idoffset]);
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
96 }
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
97 plen = stream_read_word(demux->stream); //length of elementary stream descriptors
21531
a90aa203186c Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents: 20872
diff changeset
98 plen = FFMIN(plen, es_map_len); //sanity check
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
99 stream_skip(demux->stream, plen); //skip descriptors for now
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
100 es_map_len -= 4 + plen;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
101 }
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
102 stream_skip(demux->stream, 4); //skip crc32
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
103 return 1;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
104 }
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
105
18072
284751bccd04 make sure the check for valid timestamps does not accidentially search through
reimar
parents: 17822
diff changeset
106 // 500000 is a wild guess
284751bccd04 make sure the check for valid timestamps does not accidentially search through
reimar
parents: 17822
diff changeset
107 #define TIMESTAMP_PROBE_LEN 500000
284751bccd04 make sure the check for valid timestamps does not accidentially search through
reimar
parents: 17822
diff changeset
108
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
109 //MAX_PTS_DIFF_FOR_CONSECUTIVE denotes the maximum difference
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
110 //between two pts to consider them consecutive
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
111 //1.0 is a wild guess
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
112 #define MAX_PTS_DIFF_FOR_CONSECUTIVE 1.0
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
113
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
114 //returns the first pts found within TIME_STAMP_PROBE_LEN bytes after stream_pos in demuxer's stream.
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
115 //if no pts is found or an error occurs, -1.0 is returned.
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
116 //Packs are freed.
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
117 static float read_first_mpeg_pts_at_position(demuxer_t* demuxer, off_t stream_pos)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
118 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
119 stream_t *s = demuxer->stream;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
120 mpg_demuxer_t *mpg_d = demuxer->priv;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
121 float pts = -1.0; //the pts to return;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
122 float found_pts1; //the most recently found pts
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
123 float found_pts2; //the pts found before found_pts1
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
124 float found_pts3; //the pts found before found_pts2
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
125 int found = 0;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
126
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
127 if(!mpg_d || stream_pos < 0)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
128 return pts;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
129
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
130 found_pts3 = found_pts2 = found_pts1 = mpg_d->last_pts;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
131 stream_seek(s, stream_pos);
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
132
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
133 //We look for pts.
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
134 //However, we do not stop at the first found one, as timestamps may reset
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
135 //Therefore, we seek until we found three consecutive
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
136 //pts within MAX_PTS_DIFF_FOR_CONSECUTIVE.
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
137
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
138 while(found<3 && !s->eof
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
139 && (fabsf(found_pts2-found_pts1) < MAX_PTS_DIFF_FOR_CONSECUTIVE)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
140 && (fabsf(found_pts3-found_pts2) < MAX_PTS_DIFF_FOR_CONSECUTIVE)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
141 && (stream_tell(s) < stream_pos + TIMESTAMP_PROBE_LEN)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
142 && ds_fill_buffer(demuxer->video))
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
143 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
144 if(mpg_d->last_pts != found_pts1)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
145 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
146 if(!found)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
147 found_pts3 = found_pts2 = found_pts1 = mpg_d->last_pts; //the most recently found pts
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
148 else
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
149 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
150 found_pts3 = found_pts2;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
151 found_pts2 = found_pts1;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
152 found_pts1 = mpg_d->last_pts;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
153 }
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
154 found++;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
155 }
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
156 }
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
157
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
158 if(found == 3) pts = found_pts3;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
159
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
160 //clean up from searching of first pts;
26927
ff446aa58931 use demux_flush() where appropriate
nicodvb
parents: 25883
diff changeset
161 demux_flush(demuxer);
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
162
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
163 return pts;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
164 }
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
165
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
166 /// Open an mpg physical stream
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
167 static demuxer_t* demux_mpg_open(demuxer_t* demuxer) {
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
168 stream_t *s = demuxer->stream;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
169 mpg_demuxer_t* mpg_d;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
170
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
171 if (!ds_fill_buffer(demuxer->video)) return 0;
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18758
diff changeset
172 mpg_d = calloc(1,sizeof(mpg_demuxer_t));
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
173 if(mpg_d)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
174 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
175 demuxer->priv = mpg_d;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
176 mpg_d->last_pts = -1.0;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
177 mpg_d->first_pts = -1.0;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
178
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
179 //if seeking is allowed set has_valid_timestamps if appropriate
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
180 if(demuxer->seekable
22363
03ba33feaae9 test the continuity of timestamps for STREAMTYPE_VCD, too; patch by Zuxy Meng
nicodvb
parents: 22352
diff changeset
181 && (demuxer->stream->type == STREAMTYPE_FILE
03ba33feaae9 test the continuity of timestamps for STREAMTYPE_VCD, too; patch by Zuxy Meng
nicodvb
parents: 22352
diff changeset
182 || demuxer->stream->type == STREAMTYPE_VCD)
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
183 && demuxer->movi_start != demuxer-> movi_end
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
184 )
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
185 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
186 //We seek to the beginning of the stream, to somewhere in the
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
187 //middle, and to the end of the stream, while remembering the pts
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
188 //at each of the three positions. With these pts, we check whether
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
189 //or not the pts are "linear enough" to justify seeking by the pts
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
190 //of the stream
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
191
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
192 //The position where the stream is now
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
193 off_t pos = stream_tell(s);
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
194 float first_pts = read_first_mpeg_pts_at_position(demuxer, demuxer->movi_start);
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
195 if(first_pts != -1.0)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
196 {
22351
1f40a27bd2ad 100000l: average != semidistance, fixed seeking to the middle position; patch by Zuxy meng (zuxy.megn gmail com)
nicodvb
parents: 22170
diff changeset
197 float middle_pts = read_first_mpeg_pts_at_position(demuxer, (demuxer->movi_end + demuxer->movi_start)/2);
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
198 if(middle_pts != -1.0)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
199 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
200 float final_pts = read_first_mpeg_pts_at_position(demuxer, demuxer->movi_end - TIMESTAMP_PROBE_LEN);
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
201 if(final_pts != -1.0)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
202 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
203 // found proper first, middle, and final pts.
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
204 float proportion = (middle_pts-first_pts==0) ? -1 : (final_pts-middle_pts)/(middle_pts-first_pts);
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
205 // if they are linear enough set has_valid_timestamps
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
206 if((0.5 < proportion) && (proportion < 2))
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
207 {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
208 mpg_d->first_pts = first_pts;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
209 mpg_d->first_to_final_pts_len = final_pts - first_pts;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
210 mpg_d->has_valid_timestamps = 1;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
211 }
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
212 }
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
213 }
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
214 }
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
215
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
216 //Cleaning up from seeking in stream
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
217 demuxer->stream->eof=0;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
218 demuxer->video->eof=0;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
219 demuxer->audio->eof=0;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
220
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
221 stream_seek(s,pos);
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
222 ds_fill_buffer(demuxer->video);
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
223 } // if ( demuxer->seekable )
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
224 } // if ( mpg_d )
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
225 return demuxer;
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
226 }
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
227
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
228 static void demux_close_mpg(demuxer_t* demuxer) {
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
229 mpg_demuxer_t* mpg_d = demuxer->priv;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
230 if (mpg_d) free(mpg_d);
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
231 }
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
232
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
233
18077
cede662f40a5 timestamps are 33 bits long, so they don't fit in an unsigned int; 10l
nicodvb
parents: 18072
diff changeset
234 static unsigned long long read_mpeg_timestamp(stream_t *s,int c){
18381
bbf33e805e74 stream_read_word() returns _unsigned_ int
nicodvb
parents: 18380
diff changeset
235 unsigned int d,e;
18077
cede662f40a5 timestamps are 33 bits long, so they don't fit in an unsigned int; 10l
nicodvb
parents: 18072
diff changeset
236 unsigned long long pts;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 d=stream_read_word(s);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 e=stream_read_word(s);
547
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
239 if( ((c&1)!=1) || ((d&1)!=1) || ((e&1)!=1) ){
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
240 ++mpeg_pts_error;
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
241 return 0; // invalid pts
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
242 }
18380
841789620ed1 in read_mpeg_timestamp() cast int expression to uint64_t before shifting to avoid truncation of bits and to prevent propagation of bit 1 as sign bit in pts
nicodvb
parents: 18077
diff changeset
243 pts=(((uint64_t)((c>>1)&7))<<30)|((d>>1)<<15)|(e>>1);
18382
8486998ba174 fixed %d->PRIu64 in read_mpeg_timestamp()
nicodvb
parents: 18381
diff changeset
244 mp_dbg(MSGT_DEMUX,MSGL_DBG3," pts {%"PRIu64"}",pts);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 return pts;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
248 static void new_audio_stream(demuxer_t *demux, int aid){
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
249 if(!demux->a_streams[aid]){
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
250 mpg_demuxer_t *mpg_d=(mpg_demuxer_t*)demux->priv;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
251 sh_audio_t* sh_a;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
252 new_sh_audio(demux,aid);
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
253 sh_a = (sh_audio_t*)demux->a_streams[aid];
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
254 switch(aid & 0xE0){ // 1110 0000 b (high 3 bit: type low 5: id)
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
255 case 0x00: sh_a->format=0x50;break; // mpeg
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
256 case 0xA0: sh_a->format=0x10001;break; // dvd pcm
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
257 case 0x80: if((aid & 0xF8) == 0x88) sh_a->format=0x2001;//dts
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
258 else sh_a->format=0x2000;break; // ac3
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
259 }
21927
ee422890bca9 in evo files [e]ac3 substreams range from 0xc0 to 0xcf
nicodvb
parents: 21919
diff changeset
260 //evo files
21934
a18fc58a4900 1000l; fixed wrong operator precedence
nicodvb
parents: 21927
diff changeset
261 if((aid & 0xC0) == 0xC0) sh_a->format=0x2000;
22170
cc7967b389a1 substream id 0x98..0x9f identifies dts
nicodvb
parents: 22155
diff changeset
262 else if(aid >= 0x98 && aid <= 0x9f) sh_a->format=0x2001;
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
263 if (mpg_d) mpg_d->a_stream_ids[mpg_d->num_a_streams++] = aid;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
264 }
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
265 if(demux->audio->id==-1) demux->audio->id=aid;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
266 }
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
267
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 static int demux_mpg_read_packet(demuxer_t *demux,int id){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 int d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 int len;
21978
1dbe952f3b56 set priv->last_pts to the pts read only if the pts was really read; patch by zaek7q gmx net (Christian Aistleitner)
nicodvb
parents: 21948
diff changeset
271 int set_pts=0; // !=0 iff pts has been set to a proper value
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 unsigned char c=0;
18077
cede662f40a5 timestamps are 33 bits long, so they don't fit in an unsigned int; 10l
nicodvb
parents: 18072
diff changeset
273 unsigned long long pts=0;
cede662f40a5 timestamps are 33 bits long, so they don't fit in an unsigned int; 10l
nicodvb
parents: 18072
diff changeset
274 unsigned long long dts=0;
21781
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
275 int l;
21948
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
276 int pes_ext2_subid=-1;
21781
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
277 double stream_pts = MP_NOPTS_VALUE;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 demux_stream_t *ds=NULL;
21781
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
279 demux_packet_t* dp;
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
280 mpg_demuxer_t *priv = (mpg_demuxer_t *) demux->priv;
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
281
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
282 mp_dbg(MSGT_DEMUX,MSGL_DBG3,"demux_read_packet: %X\n",id);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283
536
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
284 // if(id==0x1F0){
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
285 // demux->synced=0; // force resync after 0x1F0
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
286 // return -1;
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
287 //}
501
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
288
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 // if(id==0x1BA) packet_start_pos=stream_tell(demux->stream);
21948
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
290 if((id<0x1BC || id>=0x1F0) && id != 0x1FD) return -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 if(id==0x1BE) return -1; // padding stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 if(id==0x1BF) return -1; // private2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 len=stream_read_word(demux->stream);
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
295 mp_dbg(MSGT_DEMUX,MSGL_DBG3,"PACKET len=%d",len);
536
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
296 // if(len==62480){ demux->synced=0;return -1;} /* :) */
501
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
297 if(len==0 || len>MAX_PS_PACKETSIZE){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
298 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"Invalid PS packet len: %d\n",len);
501
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
299 return -2; // invalid packet !!!!!!
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
300 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301
547
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
302 mpeg_pts_error=0;
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
303
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
304 if(id==0x1BC) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
305 parse_psm(demux, len);
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
306 return 0;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
307 }
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
308
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 while(len>0){ // Skip stuFFing bytes
23710
df28abb8fe74 cosmetics: split separate instructions in separate lines
nicodvb
parents: 23709
diff changeset
310 c=stream_read_char(demux->stream);
df28abb8fe74 cosmetics: split separate instructions in separate lines
nicodvb
parents: 23709
diff changeset
311 --len;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 if(c!=0xFF)break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314 if((c>>6)==1){ // Read (skip) STD scale & size value
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 // printf(" STD_scale=%d",(c>>5)&1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 d=((c&0x1F)<<8)|stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 len-=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 // printf(" STD_size=%d",d);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 // Read System-1 stream timestamps:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 if((c>>4)==2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 pts=read_mpeg_timestamp(demux->stream,c);
21978
1dbe952f3b56 set priv->last_pts to the pts read only if the pts was really read; patch by zaek7q gmx net (Christian Aistleitner)
nicodvb
parents: 21948
diff changeset
324 set_pts=1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325 len-=4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 if((c>>4)==3){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 pts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 if((c>>4)!=1) pts=0; //printf("{ERROR4}");
21978
1dbe952f3b56 set priv->last_pts to the pts read only if the pts was really read; patch by zaek7q gmx net (Christian Aistleitner)
nicodvb
parents: 21948
diff changeset
331 else set_pts = 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 dts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 len-=4+1+4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 if((c>>6)==2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 int pts_flags;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 int hdrlen;
21948
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
338 int parse_ext2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 // System-2 (.VOB) stream:
23710
df28abb8fe74 cosmetics: split separate instructions in separate lines
nicodvb
parents: 23709
diff changeset
340 c=stream_read_char(demux->stream);
df28abb8fe74 cosmetics: split separate instructions in separate lines
nicodvb
parents: 23709
diff changeset
341 pts_flags=c>>6;
21948
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
342 parse_ext2 = (id == 0x1FD) && ((c & 0x3F) == 1);
23710
df28abb8fe74 cosmetics: split separate instructions in separate lines
nicodvb
parents: 23709
diff changeset
343 c=stream_read_char(demux->stream);
df28abb8fe74 cosmetics: split separate instructions in separate lines
nicodvb
parents: 23709
diff changeset
344 hdrlen=c;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 len-=2;
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
346 mp_dbg(MSGT_DEMUX,MSGL_DBG3," hdrlen=%d (len=%d)",hdrlen,len);
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
347 if(hdrlen>len){ mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: invalid header length \n"); return -1;}
7671
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
348 if(pts_flags==2 && hdrlen>=5){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 pts=read_mpeg_timestamp(demux->stream,c);
21978
1dbe952f3b56 set priv->last_pts to the pts read only if the pts was really read; patch by zaek7q gmx net (Christian Aistleitner)
nicodvb
parents: 21948
diff changeset
351 set_pts=1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 len-=5;hdrlen-=5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 } else
7671
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
354 if(pts_flags==3 && hdrlen>=10){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 pts=read_mpeg_timestamp(demux->stream,c);
21978
1dbe952f3b56 set priv->last_pts to the pts read only if the pts was really read; patch by zaek7q gmx net (Christian Aistleitner)
nicodvb
parents: 21948
diff changeset
357 set_pts=1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 dts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 len-=10;hdrlen-=10;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362 len-=hdrlen;
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
363 if(parse_ext2 && hdrlen>=3) {
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
364 c=stream_read_char(demux->stream);
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
365 hdrlen--;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
366
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
367 if((c & 0x0F) != 0x0F) {
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
368 mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: pes_extension_flag2 not set, discarding pes packet\n");
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
369 return -1;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
370 }
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
371 if(c & 0x80) { //pes_private_data_flag
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
372 if(hdrlen<16) {
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
373 mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: not enough pes_private_data bytes: %d < 16, discarding pes packet\n", hdrlen);
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
374 return -1;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
375 }
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
376 stream_skip(demux->stream, 16);
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
377 hdrlen-=16;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
378 }
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
379 if(c & 0x40) { //pack_header_field_flag
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
380 int l = stream_read_char(demux->stream);
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
381 if(l < 0) //couldn't read from the stream?
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
382 return -1;
21948
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
383 hdrlen--;
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
384 if(l < 0 || hdrlen < l) {
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
385 mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: not enough pack_header bytes: hdrlen: %d < skip: %d, discarding pes packet\n",
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
386 hdrlen, l);
23709
b214397ad0e2 proper parsing of pes_extension[12] fields (replaces the previous code that relied on specific flags set
nicodvb
parents: 23550
diff changeset
387 return -1;
b214397ad0e2 proper parsing of pes_extension[12] fields (replaces the previous code that relied on specific flags set
nicodvb
parents: 23550
diff changeset
388 }
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
389 stream_skip(demux->stream, l);
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
390 hdrlen-=l;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
391 }
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
392 if(c & 0x20) { //program_packet_sequence_counter_flag
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
393 if(hdrlen < 2) {
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
394 mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: not enough program_packet bytes: hdrlen: %d, discarding pes packet\n", hdrlen);
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
395 return -1;
23709
b214397ad0e2 proper parsing of pes_extension[12] fields (replaces the previous code that relied on specific flags set
nicodvb
parents: 23550
diff changeset
396 }
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
397 stream_skip(demux->stream, 2);
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
398 hdrlen-=2;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
399 }
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
400 if(c & 0x10) {
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
401 //STD
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
402 stream_skip(demux->stream, 2);
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
403 hdrlen-=2;
21948
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
404 }
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
405 c=stream_read_char(demux->stream); //pes_extension2 flag
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
406 hdrlen--;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
407 if(c!=0x81) { mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: unknown pes_extension2 format, len is > 1 \n"); return -1;}
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
408 c=stream_read_char(demux->stream); //pes_extension2 payload === substream id
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
409 hdrlen--;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
410 if(c<0x55 || c>0x5F) { mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: unknown vc1 substream_id: 0x%x \n", c); return -1;}
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
411 pes_ext2_subid=c;
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
412 }
23722
5c5a3b4c0eb7 unified the skip of header and stuffing bytes after the parsing of pes_extension[12] fields
nicodvb
parents: 23711
diff changeset
413 if(hdrlen>0)
5c5a3b4c0eb7 unified the skip of header and stuffing bytes after the parsing of pes_extension[12] fields
nicodvb
parents: 23711
diff changeset
414 stream_skip(demux->stream,hdrlen); // skip header and stuffing bytes
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
415
21948
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
416 if(id==0x1FD && pes_ext2_subid!=-1) {
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
417 //==== EVO VC1 STREAMS ===//
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
418 if(!demux->v_streams[pes_ext2_subid]) new_sh_video(demux,pes_ext2_subid);
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
419 if(demux->video->id==-1) demux->video->id=pes_ext2_subid;
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
420 if(demux->video->id==pes_ext2_subid){
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
421 ds=demux->video;
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
422 if(!ds->sh) ds->sh=demux->v_streams[pes_ext2_subid];
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
423 if(priv && ds->sh) {
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
424 sh_video_t *sh = (sh_video_t *)ds->sh;
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
425 sh->format = mmioFOURCC('W', 'V', 'C', '1');
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
426 }
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
427 }
3b9115e57f24 demux vc1 (stream id 0x1Fd with 0x55 <= substream id <= 0x5F in the pes_extension_2 payload)
nicodvb
parents: 21934
diff changeset
428 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 //============== DVD Audio sub-stream ======================
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 if(id==0x1BD){
15815
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
431 int aid, rawa52 = 0;
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
432 off_t tmppos;
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
433 unsigned int tmp;
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
434
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
435 tmppos = stream_tell(demux->stream);
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
436 tmp = stream_read_word(demux->stream);
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
437 stream_seek(demux->stream, tmppos);
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
438 /// vdr stores A52 without the 4 header bytes, so we have to check this condition first
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
439 if(tmp == 0x0B77) {
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
440 aid = 128;
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
441 rawa52 = 1;
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
442 }
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
443 else {
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
444 aid=stream_read_char(demux->stream);--len;
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
445 if(len<3) return -1; // invalid audio packet
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
446 }
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
447
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
448 // AID:
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
449 // 0x20..0x3F subtitle
23530
c325aaa89171 clearly specify the valid substream id range, rather than using unreadable bitmasks (it also prevents misdetection 0xFF as valid)
nicodvb
parents: 22886
diff changeset
450 // 0x80..0x87 and 0xC0..0xCF AC3 audio
c325aaa89171 clearly specify the valid substream id range, rather than using unreadable bitmasks (it also prevents misdetection 0xFF as valid)
nicodvb
parents: 22886
diff changeset
451 // 0x88..0x8F and 0x98..0x9F DTS audio
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
452 // 0xA0..0xBF PCM audio
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
453
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
454 if((aid & 0xE0) == 0x20){
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
455 // subtitle:
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
456 aid&=0x1F;
426
26e513f392b2 new stream selection code
arpi_esp
parents: 397
diff changeset
457
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
458 if(!demux->s_streams[aid]){
23550
1915012c8f7d Set subtitle type in mpg demuxer. Fixes subtitle switching with 'j'
reimar
parents: 23530
diff changeset
459 sh_sub_t *sh = new_sh_sub(demux, aid);
1915012c8f7d Set subtitle type in mpg demuxer. Fixes subtitle switching with 'j'
reimar
parents: 23530
diff changeset
460 if (sh) sh->type = 'v';
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
461 mp_msg(MSGT_DEMUX,MSGL_V,"==> Found subtitle: %d\n",aid);
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
462 }
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
463
17286
b0046966ab82 don't reset dvdsub->id unless -slang is specified; assign default sub stream id when demux->sub->id is -1 (autodetect)
nicodvb
parents: 16877
diff changeset
464 if(demux->sub->id > -1)
b0046966ab82 don't reset dvdsub->id unless -slang is specified; assign default sub stream id when demux->sub->id is -1 (autodetect)
nicodvb
parents: 16877
diff changeset
465 demux->sub->id &= 0x1F;
b0046966ab82 don't reset dvdsub->id unless -slang is specified; assign default sub stream id when demux->sub->id is -1 (autodetect)
nicodvb
parents: 16877
diff changeset
466 if(!dvdsub_lang && demux->sub->id == -1)
b0046966ab82 don't reset dvdsub->id unless -slang is specified; assign default sub stream id when demux->sub->id is -1 (autodetect)
nicodvb
parents: 16877
diff changeset
467 demux->sub->id = aid;
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
468 if(demux->sub->id==aid){
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
469 ds=demux->sub;
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
470 }
23530
c325aaa89171 clearly specify the valid substream id range, rather than using unreadable bitmasks (it also prevents misdetection 0xFF as valid)
nicodvb
parents: 22886
diff changeset
471 } else if((aid >= 0x80 && aid <= 0x8F) || (aid >= 0x98 && aid <= 0xAF) || (aid >= 0xC0 && aid <= 0xCF)) {
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
472
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
473 // aid=128+(aid&0x7F);
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
474 // aid=0x80..0xBF
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
475 new_audio_stream(demux, aid);
426
26e513f392b2 new stream selection code
arpi_esp
parents: 397
diff changeset
476 if(demux->audio->id==aid){
7671
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
477 int type;
426
26e513f392b2 new stream selection code
arpi_esp
parents: 397
diff changeset
478 ds=demux->audio;
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
479 if(!ds->sh) ds->sh=demux->a_streams[aid];
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
480 // READ Packet: Skip additional audio header data:
15815
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
481 if(!rawa52) {
7671
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
482 c=stream_read_char(demux->stream);//num of frames
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
483 type=stream_read_char(demux->stream);//startpos hi
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
484 type=(type<<8)|stream_read_char(demux->stream);//startpos lo
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
485 // printf("\r[%02X][%04X]",c,type);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
486 len-=3;
15815
488f31bd127e support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
nicodvb
parents: 15670
diff changeset
487 }
7671
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
488 if((aid&0xE0)==0xA0 && len>=3){
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
489 unsigned char* hdr;
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
490 // save audio header as codecdata!
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
491 if(!((sh_audio_t*)(ds->sh))->codecdata_len){
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
492 ((sh_audio_t*)(ds->sh))->codecdata=malloc(3);
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
493 ((sh_audio_t*)(ds->sh))->codecdata_len=3;
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
494 }
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
495 hdr=((sh_audio_t*)(ds->sh))->codecdata;
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
496 // read LPCM header:
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
497 // emphasis[1], mute[1], rvd[1], frame number[5]:
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
498 hdr[0]=stream_read_char(demux->stream);
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
499 // printf(" [%01X:%02d]",c>>5,c&31);
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
500 // quantization[2],freq[2],rvd[1],channels[3]
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
501 hdr[1]=stream_read_char(demux->stream);
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
502 // printf("[%01X:%01X] ",c>>4,c&15);
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
503 // dynamic range control (0x80=off):
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
504 hdr[2]=stream_read_char(demux->stream);
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
505 // printf("[%02X] ",c);
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
506 len-=3;
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
507 if(len<=0) mp_msg(MSGT_DEMUX,MSGL_V,"End of packet while searching for PCM header\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
508 }
7671
2d186a94dd5f fixed LPCM parsing
arpi
parents: 7559
diff changeset
509 // printf(" \n");
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
510 } // if(demux->audio->id==aid)
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
511
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
512 } else mp_msg(MSGT_DEMUX,MSGL_V,"Unknown 0x1BD substream: 0x%02X \n",aid);
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 547
diff changeset
513 } //if(id==0x1BD)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
514 } else {
539
48f0c6f0519f dumb bug here too :)
arpi_esp
parents: 536
diff changeset
515 if(c!=0x0f){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
516 mp_msg(MSGT_DEMUX,MSGL_V," {ERROR5,c=%d} \n",c);
539
48f0c6f0519f dumb bug here too :)
arpi_esp
parents: 536
diff changeset
517 return -1; // invalid packet !!!!!!
48f0c6f0519f dumb bug here too :)
arpi_esp
parents: 536
diff changeset
518 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
519 }
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
520 if(mpeg_pts_error) mp_msg(MSGT_DEMUX,MSGL_V," {PTS_err:%d} \n",mpeg_pts_error);
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
521 mp_dbg(MSGT_DEMUX,MSGL_DBG3," => len=%d\n",len);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
522
501
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
523 // if(len<=0 || len>MAX_PS_PACKETSIZE) return -1; // Invalid packet size
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
524 if(len<=0 || len>MAX_PS_PACKETSIZE){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
525 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"Invalid PS data len: %d\n",len);
501
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
526 return -1; // invalid packet !!!!!!
bfc86f5a5ba7 PES supported again, VOB 0x1F0 problems fixed
arpi_esp
parents: 494
diff changeset
527 }
23723
148b85340a65 100% cosmetics: reindentation and removal of trailing spaces
nicodvb
parents: 23722
diff changeset
528
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
529 if(id>=0x1C0 && id<=0x1DF){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
530 // mpeg audio
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
531 int aid=id-0x1C0;
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
532 new_audio_stream(demux, aid);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
533 if(demux->audio->id==aid){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
534 ds=demux->audio;
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
535 if(!ds->sh) ds->sh=demux->a_streams[aid];
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
536 if(priv && ds->sh) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
537 sh_audio_t *sh = (sh_audio_t *)ds->sh;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
538 if(priv->es_map[id - 0x1B0])
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
539 sh->format = priv->es_map[id - 0x1B0];
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
540 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"ASSIGNED TO STREAM %d CODEC %x\n", id, priv->es_map[id - 0x1B0]);
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
541 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
542 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
543 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
544 if(id>=0x1E0 && id<=0x1EF){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
545 // mpeg video
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
546 int aid=id-0x1E0;
1289
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1162
diff changeset
547 if(!demux->v_streams[aid]) new_sh_video(demux,aid);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
548 if(demux->video->id==-1) demux->video->id=aid;
426
26e513f392b2 new stream selection code
arpi_esp
parents: 397
diff changeset
549 if(demux->video->id==aid){
26e513f392b2 new stream selection code
arpi_esp
parents: 397
diff changeset
550 ds=demux->video;
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
551 if(!ds->sh) ds->sh=demux->v_streams[aid];
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
552 if(priv && ds->sh) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
553 sh_video_t *sh = (sh_video_t *)ds->sh;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
554 if(priv->es_map[id - 0x1B0]) {
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
555 sh->format = priv->es_map[id - 0x1B0];
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
556 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"ASSIGNED TO STREAM %d CODEC %x\n", id, priv->es_map[id - 0x1B0]);
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
557 }
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
558 }
426
26e513f392b2 new stream selection code
arpi_esp
parents: 397
diff changeset
559 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
560 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
561
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
562 if(ds){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
563 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_MPG: Read %d data bytes from packet %04X\n",len,id);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
564 // printf("packet start = 0x%X \n",stream_tell(demux->stream)-packet_start_pos);
21781
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
565
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
566 dp=new_demux_packet(len);
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
567 if(!dp) {
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
568 mp_dbg(MSGT_DEMUX,MSGL_ERR,"DEMUX_MPG ERROR: couldn't create demux_packet(%d bytes)\n",len);
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
569 stream_skip(demux->stream,len);
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
570 return 0;
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
571 }
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
572 l = stream_read(demux->stream,dp->buffer,len);
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
573 if(l<len)
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
574 resize_demux_packet(dp, l);
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
575 len = l;
24945
46337ac77770 10l, setting a non-existent timestamp (default 0.0) when the pts flag isn't set in
nicodvb
parents: 24681
diff changeset
576 if(set_pts)
24946
259a3df86fbc reindented
nicodvb
parents: 24945
diff changeset
577 dp->pts=pts/90000.0f;
21781
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
578 dp->pos=demux->filepos;
21789
b266f27109a6 set dp->stream_pts only when feeding the video stream to workaround
nicodvb
parents: 21781
diff changeset
579 /*
b266f27109a6 set dp->stream_pts only when feeding the video stream to workaround
nicodvb
parents: 21781
diff changeset
580 workaround:
b266f27109a6 set dp->stream_pts only when feeding the video stream to workaround
nicodvb
parents: 21781
diff changeset
581 set dp->stream_pts only when feeding the video stream, or strangely interleaved files
b266f27109a6 set dp->stream_pts only when feeding the video stream to workaround
nicodvb
parents: 21781
diff changeset
582 (such as SWIII) will show strange alternations in the stream time, wildly going
b266f27109a6 set dp->stream_pts only when feeding the video stream to workaround
nicodvb
parents: 21781
diff changeset
583 back and forth
b266f27109a6 set dp->stream_pts only when feeding the video stream to workaround
nicodvb
parents: 21781
diff changeset
584 */
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 23723
diff changeset
585 if(ds == demux->video && stream_control(demux->stream, STREAM_CTRL_GET_CURRENT_TIME,(void *)&stream_pts)!=STREAM_UNSUPPORTED)
21781
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
586 dp->stream_pts = stream_pts;
36112fcf78d6 replace call to ds_read_packet() with the usual stream_read()+ds_add_packet() sequence;
nicodvb
parents: 21531
diff changeset
587 ds_add_packet(ds,dp);
21978
1dbe952f3b56 set priv->last_pts to the pts read only if the pts was really read; patch by zaek7q gmx net (Christian Aistleitner)
nicodvb
parents: 21948
diff changeset
588 if (demux->priv && set_pts) ((mpg_demuxer_t*)demux->priv)->last_pts = pts/90000.0f;
554
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
589 // if(ds==demux->sub) parse_dvdsub(ds->last->buffer,ds->last->len);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
590 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
591 }
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
592 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_MPG: Skipping %d data bytes from packet %04X\n",len,id);
536
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
593 if(len<=2356) stream_skip(demux->stream,len);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
594 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
595 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
596
15670
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
597 static int num_elementary_packets100=0;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
598 static int num_elementary_packets101=0;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
599 static int num_elementary_packets12x=0;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
600 static int num_elementary_packets1B6=0;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
601 static int num_elementary_packetsPES=0;
25838
f75a531569a2 in the crazy ES probing code return DEMUXER_TYPE_MPEG_ES (mpeg12v) only if we have at least a couple of SEQ/GOP startcodes
nicodvb
parents: 25707
diff changeset
602 static int num_mpeg12_startcode=0;
15670
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
603 static int num_h264_slice=0; //combined slice
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
604 static int num_h264_dpa=0; //DPA Slice
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
605 static int num_h264_dpb=0; //DPB Slice
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
606 static int num_h264_dpc=0; //DPC Slice
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
607 static int num_h264_idr=0; //IDR Slice
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
608 static int num_h264_sps=0;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
609 static int num_h264_pps=0;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
610
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
611 static int num_mp3audio_packets=0;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
612
22886
71b3e04d0555 "()" to "(void)" function param list fixes
uau
parents: 22605
diff changeset
613 static void clear_stats(void)
22034
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
614 {
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
615 num_elementary_packets100=0;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
616 num_elementary_packets101=0;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
617 num_elementary_packets1B6=0;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
618 num_elementary_packets12x=0;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
619 num_elementary_packetsPES=0;
25838
f75a531569a2 in the crazy ES probing code return DEMUXER_TYPE_MPEG_ES (mpeg12v) only if we have at least a couple of SEQ/GOP startcodes
nicodvb
parents: 25707
diff changeset
620 num_mpeg12_startcode=0;
22034
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
621 num_h264_slice=0; //combined slice
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
622 num_h264_dpa=0; //DPA Slice
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
623 num_h264_dpb=0; //DPB Slice
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
624 num_h264_dpc=0; //DPC Slice
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
625 num_h264_idr=0; //IDR Slice
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
626 num_h264_sps=0;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
627 num_h264_pps=0;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
628 num_mp3audio_packets=0;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
629 }
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
630
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
631 //assumes demuxer->synced < 2
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
632 static inline void update_stats(int head)
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
633 {
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
634 if(head==0x1B6) ++num_elementary_packets1B6;
25838
f75a531569a2 in the crazy ES probing code return DEMUXER_TYPE_MPEG_ES (mpeg12v) only if we have at least a couple of SEQ/GOP startcodes
nicodvb
parents: 25707
diff changeset
635 else if(head==0x1B3 || head==0x1B8) ++num_mpeg12_startcode;
22034
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
636 else if(head==0x100) ++num_elementary_packets100;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
637 else if(head==0x101) ++num_elementary_packets101;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
638 else if(head==0x1BD || (0x1C0<=head && head<=0x1EF))
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
639 num_elementary_packetsPES++;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
640 else if(head>=0x120 && head<=0x12F) ++num_elementary_packets12x;
24681
1ecf2ff1d512 in update_stats() removed a wrong 'else' that would prevent h264 headers to be recognized:
nicodvb
parents: 24257
diff changeset
641 if(head>=0x100 && head<0x1B0)
22034
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
642 {
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
643 if((head&~0x60) == 0x101) ++num_h264_slice;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
644 else if((head&~0x60) == 0x102) ++num_h264_dpa;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
645 else if((head&~0x60) == 0x103) ++num_h264_dpb;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
646 else if((head&~0x60) == 0x104) ++num_h264_dpc;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
647 else if((head&~0x60) == 0x105 && head != 0x105) ++num_h264_idr;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
648 else if((head&~0x60) == 0x107 && head != 0x107) ++num_h264_sps;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
649 else if((head&~0x60) == 0x108 && head != 0x108) ++num_h264_pps;
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
650 }
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
651 }
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
652
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
653 static int demux_mpg_probe(demuxer_t *demuxer) {
15670
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
654 int pes=1;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
655 int tmp;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
656 off_t tmppos;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
657 int file_format = DEMUXER_TYPE_UNKNOWN;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
658
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
659 tmppos=stream_tell(demuxer->stream);
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
660 tmp=stream_read_dword(demuxer->stream);
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
661 if(tmp==0x1E0 || tmp==0x1C0) {
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
662 tmp=stream_read_word(demuxer->stream);
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
663 if(tmp>1 && tmp<=2048) pes=0; // demuxer->synced=3; // PES...
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
664 }
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
665 stream_seek(demuxer->stream,tmppos);
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
666
22034
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
667 clear_stats();
9824
39b68c2664ec H264-ES demuxer
michael
parents: 9069
diff changeset
668
15670
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
669 if(demux_mpg_open(demuxer))
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
670 file_format=DEMUXER_TYPE_MPEG_PS;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
671 else {
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
672 mp_msg(MSGT_DEMUX,MSGL_V,"MPEG packet stats: p100: %d p101: %d p1B6: %d p12x: %d sli: %d a: %d b: %d c: %d idr: %d sps: %d pps: %d PES: %d MP3: %d, synced: %d\n",
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
673 num_elementary_packets100,num_elementary_packets101,
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
674 num_elementary_packets1B6,num_elementary_packets12x,
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
675 num_h264_slice, num_h264_dpa,
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
676 num_h264_dpb, num_h264_dpc=0,
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
677 num_h264_idr, num_h264_sps=0,
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
678 num_h264_pps,
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
679 num_elementary_packetsPES,num_mp3audio_packets, demuxer->synced);
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
680
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
681 //MPEG packet stats: p100: 458 p101: 458 PES: 0 MP3: 1103 (.m2v)
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
682 if(num_mp3audio_packets>50 && num_mp3audio_packets>2*num_elementary_packets100
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
683 && abs(num_elementary_packets100-num_elementary_packets101)>2)
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
684 return file_format;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
685
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
686 // some hack to get meaningfull error messages to our unhappy users:
25838
f75a531569a2 in the crazy ES probing code return DEMUXER_TYPE_MPEG_ES (mpeg12v) only if we have at least a couple of SEQ/GOP startcodes
nicodvb
parents: 25707
diff changeset
687 if(num_mpeg12_startcode>=2 && num_elementary_packets100>=2 && num_elementary_packets101>=2 &&
15670
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
688 abs(num_elementary_packets101+8-num_elementary_packets100)<16) {
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
689 if(num_elementary_packetsPES>=4 && num_elementary_packetsPES>=num_elementary_packets100-4) {
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
690 return file_format;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
691 }
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
692 file_format=DEMUXER_TYPE_MPEG_ES; // <-- hack is here :)
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
693 } else
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
694 // fuzzy mpeg4-es detection. do NOT enable without heavy testing of mpeg formats detection!
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
695 if(num_elementary_packets1B6>3 && num_elementary_packets12x>=1 &&
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
696 num_elementary_packetsPES==0 && num_elementary_packets100<=num_elementary_packets12x &&
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
697 demuxer->synced<2) {
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
698 file_format=DEMUXER_TYPE_MPEG4_ES;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
699 } else
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
700 // fuzzy h264-es detection. do NOT enable without heavy testing of mpeg formats detection!
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
701 if((num_h264_slice>3 || (num_h264_dpa>3 && num_h264_dpb>3 && num_h264_dpc>3)) &&
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
702 /* FIXME num_h264_sps>=1 && */ num_h264_pps>=1 && num_h264_idr>=1 &&
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
703 num_elementary_packets1B6==0 && num_elementary_packetsPES==0 &&
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
704 demuxer->synced<2) {
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
705 file_format=DEMUXER_TYPE_H264_ES;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
706 } else
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
707 {
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
708 if(demuxer->synced==2)
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
709 mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug);
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
710 else
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
711 mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_NotSystemStream);
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
712 }
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
713 }
22094
e2d1bb1d2c6b demux_mpg_probe() seek to the initial position before returning - patch by reimar
nicodvb
parents: 22088
diff changeset
714 //FIXME this shouldn't be necessary
e2d1bb1d2c6b demux_mpg_probe() seek to the initial position before returning - patch by reimar
nicodvb
parents: 22088
diff changeset
715 stream_seek(demuxer->stream,tmppos);
15670
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
716 return file_format;
081bee8052cf moved mpeg-ps/es probing code to demux_mpg.c
nicodvb
parents: 15285
diff changeset
717 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
718
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
719 static int demux_mpg_es_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
720 // Elementary video stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
721 if(demux->stream->eof) return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
722 demux->filepos=stream_tell(demux->stream);
1735
bdc1ec6fe668 gui seekbar position fixed
arpi
parents: 1628
diff changeset
723 ds_read_packet(demux->video,demux->stream,STREAM_BUFFER_SIZE,0,demux->filepos,0);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
724 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
725 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
726
16369
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
727 /**
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
728 * \brief discard until 0x100 header and return a filled buffer
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
729 * \param b buffer-end pointer
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
730 * \param pos current pos in stream, negative since b points to end of buffer
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
731 * \param s stream to read from
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
732 * \return new position, differs from original pos when eof hit and thus
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
733 * b was modified to point to the new end of buffer
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
734 */
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
735 static int find_end(unsigned char **b, int pos, stream_t *s) {
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
736 register int state = 0xffffffff;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
737 unsigned char *buf = *b;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
738 int start = pos;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
739 int read, unused;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
740 // search already read part
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
741 while (state != 0x100 && pos) {
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
742 state = state << 8 | buf[pos++];
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
743 }
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
744 // continue search in stream
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
745 while (state != 0x100) {
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
746 register int c = stream_read_char(s);
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
747 if (c < 0) break;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
748 state = state << 8 | c;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
749 }
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
750 // modify previous header (from 0x1bc or 0x1bf to 0x100)
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
751 buf[start++] = 0;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
752 // copy remaining buffer part to current pos
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
753 memmove(&buf[start], &buf[pos], -pos);
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
754 unused = start + -pos; // -unused bytes in buffer
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
755 read = stream_read(s, &buf[unused], -unused);
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
756 unused += read;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
757 // fix buffer so it ends at pos == 0 (eof case)
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
758 *b = &buf[unused];
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
759 start -= unused;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
760 return start;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
761 }
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
762
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
763 /**
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
764 * This format usually uses an insane bitrate, which makes this function
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
765 * performance-critical!
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
766 * Be sure to benchmark any changes with different compiler versions.
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
767 */
16310
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
768 static int demux_mpg_gxf_fill_buffer(demuxer_t *demux, demux_stream_t *ds) {
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
769 demux_packet_t *pack;
16369
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
770 int len;
16310
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
771 demux->filepos = stream_tell(demux->stream);
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
772 pack = new_demux_packet(STREAM_BUFFER_SIZE);
16369
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
773 len = stream_read(demux->stream, pack->buffer, STREAM_BUFFER_SIZE);
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
774 if (len <= 0)
17779
031185213fa9 Missing free_demux_packet after read error
reimar
parents: 17699
diff changeset
775 {
031185213fa9 Missing free_demux_packet after read error
reimar
parents: 17699
diff changeset
776 free_demux_packet(pack);
16369
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
777 return 0;
17779
031185213fa9 Missing free_demux_packet after read error
reimar
parents: 17699
diff changeset
778 }
16369
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
779 {
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
780 register uint32_t state = (uint32_t)demux->priv;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
781 register int pos = -len;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
782 unsigned char *buf = &pack->buffer[len];
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
783 do {
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
784 state = state << 8 | buf[pos];
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
785 if (unlikely((state | 3) == 0x1bf))
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
786 pos = find_end(&buf, pos, demux->stream);
19182
c68cf9a578a8 Incorrect check in gxf demuxer leading to crash with textKO.gxf sample file
reimar
parents: 18958
diff changeset
787 } while (++pos < 0);
16369
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
788 demux->priv = (void *)state;
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
789 len = buf - pack->buffer;
16310
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
790 }
16369
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
791 if (len < STREAM_BUFFER_SIZE)
8ea2e7ab3106 faster mpg and much faster gxf demuxing
reimar
parents: 16346
diff changeset
792 resize_demux_packet(pack, len);
16310
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
793 ds_add_packet(ds, pack);
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
794 return 1;
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
795 }
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
796
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
797 int demux_mpg_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
798 unsigned int head=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
799 int skipped=0;
5570
3a8d8c51355a max_packs increased for some dvd with too many audio/sub
arpi
parents: 4711
diff changeset
800 int max_packs=256; // 512kbyte
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
801 int ret=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
802
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
803 // System stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
804 do{
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
805 demux->filepos=stream_tell(demux->stream);
18713
c6c78e77c857 workaround: at every read update demux->movi_end with stream->end_pos; needed to show the progress bar when playing dvdnav streams
nicodvb
parents: 18680
diff changeset
806 #if 1
c6c78e77c857 workaround: at every read update demux->movi_end with stream->end_pos; needed to show the progress bar when playing dvdnav streams
nicodvb
parents: 18680
diff changeset
807 //lame workaround: this is needed to show the progress bar when playing dvdnav://
c6c78e77c857 workaround: at every read update demux->movi_end with stream->end_pos; needed to show the progress bar when playing dvdnav streams
nicodvb
parents: 18680
diff changeset
808 //(ths poor guy doesn't know teh length of the stream at startup)
c6c78e77c857 workaround: at every read update demux->movi_end with stream->end_pos; needed to show the progress bar when playing dvdnav streams
nicodvb
parents: 18680
diff changeset
809 demux->movi_end = demux->stream->end_pos;
c6c78e77c857 workaround: at every read update demux->movi_end with stream->end_pos; needed to show the progress bar when playing dvdnav streams
nicodvb
parents: 18680
diff changeset
810 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
811 head=stream_read_dword(demux->stream);
547
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
812 if((head&0xFFFFFF00)!=0x100){
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
813 // sync...
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
814 demux->filepos-=skipped;
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
815 while(1){
536
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
816 int c=stream_read_char(demux->stream);
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
817 if(c<0) break; //EOF
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
818 head<<=8;
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
819 if(head!=0x100){
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
820 head|=c;
4711
39f5eccd54c2 added mp3 detection
arpi
parents: 4391
diff changeset
821 if(mp_check_mp3_header(head)) ++num_mp3audio_packets;
536
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
822 ++skipped; //++demux->filepos;
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
823 continue;
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
824 }
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
825 head|=c;
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
826 break;
547
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
827 }
3e46eab9f782 small bugfix in the new optimized head sync code
arpi_esp
parents: 546
diff changeset
828 demux->filepos+=skipped;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
829 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
830 if(stream_eof(demux->stream)) break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
831 // sure: head=0x000001XX
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
832 mp_dbg(MSGT_DEMUX,MSGL_DBG4,"*** head=0x%X\n",head);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
833 if(demux->synced==0){
3770
4f1a99fb9d9a mpeg VDR vs. BIN fixed?
arpi
parents: 3255
diff changeset
834 if(head==0x1BA) demux->synced=1; //else
4f1a99fb9d9a mpeg VDR vs. BIN fixed?
arpi
parents: 3255
diff changeset
835 // if(head==0x1BD || (head>=0x1C0 && head<=0x1EF)) demux->synced=3; // PES?
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
836 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
837 if(demux->synced==1){
929
6dedc7cb0146 accept 1BD packets for PS stream sync
arpi_esp
parents: 605
diff changeset
838 if(head==0x1BB || head==0x1BD || (head>=0x1C0 && head<=0x1EF)){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
839 demux->synced=2;
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17289
diff changeset
840 mp_msg(MSGT_DEMUX,MSGL_V,"system stream synced at 0x%"PRIX64" (%"PRId64")!\n",(int64_t)demux->filepos,(int64_t)demux->filepos);
536
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
841 num_elementary_packets100=0; // requires for re-sync!
3c9b3ce721f0 PES vs. VOB problem... yet another solution
arpi_esp
parents: 524
diff changeset
842 num_elementary_packets101=0; // requires for re-sync!
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
843 } else demux->synced=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
844 } // else
3255
ee28577dad02 combined PS/PES sync to allow .VDR playback from stdin
arpi
parents: 2555
diff changeset
845 if(demux->synced>=2){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
846 ret=demux_mpg_read_packet(demux,head);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
847 if(!ret)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
848 if(--max_packs==0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
849 demux->stream->eof=1;
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1735
diff changeset
850 mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_DoesntContainSelectedStream);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
851 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
852 }
3255
ee28577dad02 combined PS/PES sync to allow .VDR playback from stdin
arpi
parents: 2555
diff changeset
853 if(demux->synced==3) demux->synced=(ret==1)?2:0; // PES detect
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
854 } else {
22034
a3d208daed8c moved scoreboarding code to 2 separate functions (update_stats() and clear_stats()) to be reused next
nicodvb
parents: 22021
diff changeset
855 update_stats(head);
22035
3d619d883ca5 cosmetics: reindentation and braces removal
nicodvb
parents: 22034
diff changeset
856 if(head>=0x100 && head<0x1B0)
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
857 mp_msg(MSGT_DEMUX,MSGL_DBG3,"Opps... elementary video packet found: %03X\n",head);
22035
3d619d883ca5 cosmetics: reindentation and braces removal
nicodvb
parents: 22034
diff changeset
858 else if((head>=0x1C0 && head<0x1F0) || head==0x1BD)
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
859 mp_msg(MSGT_DEMUX,MSGL_DBG3,"Opps... PES packet found: %03X\n",head);
21919
05223564b604 one more #if 1 removed
nicodvb
parents: 21918
diff changeset
860
22035
3d619d883ca5 cosmetics: reindentation and braces removal
nicodvb
parents: 22034
diff changeset
861 if(((num_elementary_packets100>50 && num_elementary_packets101>50) ||
3d619d883ca5 cosmetics: reindentation and braces removal
nicodvb
parents: 22034
diff changeset
862 (num_elementary_packetsPES>50)) && skipped>4000000){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
863 mp_msg(MSGT_DEMUX,MSGL_V,"sync_mpeg_ps: seems to be ES/PES stream...\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
864 demux->stream->eof=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
865 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
866 }
4711
39f5eccd54c2 added mp3 detection
arpi
parents: 4391
diff changeset
867 if(num_mp3audio_packets>100 && num_elementary_packets100<10){
39f5eccd54c2 added mp3 detection
arpi
parents: 4391
diff changeset
868 mp_msg(MSGT_DEMUX,MSGL_V,"sync_mpeg_ps: seems to be MP3 stream...\n");
39f5eccd54c2 added mp3 detection
arpi
parents: 4391
diff changeset
869 demux->stream->eof=1;
39f5eccd54c2 added mp3 detection
arpi
parents: 4391
diff changeset
870 break;
39f5eccd54c2 added mp3 detection
arpi
parents: 4391
diff changeset
871 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
872 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
873 } while(ret!=1);
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
874 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"demux: %d bad bytes skipped\n",skipped);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
875 if(demux->stream->eof){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
876 mp_msg(MSGT_DEMUX,MSGL_V,"MPEG Stream reached EOF\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
877 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
878 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
879 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
880 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
881
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7671
diff changeset
882 extern void skip_audio_frame(sh_audio_t *sh_audio);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7671
diff changeset
883
17636
b849a99cdc3c Second-try commit of this patch.
corey
parents: 17569
diff changeset
884 void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,float audio_delay, int flags){
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
885 demux_stream_t *d_audio=demuxer->audio;
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
886 demux_stream_t *d_video=demuxer->video;
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
887 sh_audio_t *sh_audio=d_audio->sh;
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
888 sh_video_t *sh_video=d_video->sh;
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
889 mpg_demuxer_t *mpg_d=(mpg_demuxer_t*)demuxer->priv;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
890 int precision = 1;
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
891 float oldpts = 0;
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
892 off_t oldpos = demuxer->filepos;
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
893 float newpts = 0;
25883
baf32110d3fc Use defines to give names to the different seek flags.
reimar
parents: 25838
diff changeset
894 off_t newpos = (flags & SEEK_ABSOLUTE) ? demuxer->movi_start : oldpos;
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
895
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
896 if(mpg_d)
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
897 oldpts = mpg_d->last_pts;
25883
baf32110d3fc Use defines to give names to the different seek flags.
reimar
parents: 25838
diff changeset
898 newpts = (flags & SEEK_ABSOLUTE) ? 0.0 : oldpts;
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
899 //================= seek in MPEG ==========================
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
900 //calculate the pts to seek to
25883
baf32110d3fc Use defines to give names to the different seek flags.
reimar
parents: 25838
diff changeset
901 if(flags & SEEK_FACTOR) {
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
902 if (mpg_d && mpg_d->first_to_final_pts_len > 0.0)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
903 newpts += mpg_d->first_to_final_pts_len * rel_seek_secs;
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
904 else
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
905 newpts += rel_seek_secs * (demuxer->movi_end - demuxer->movi_start) * oldpts / oldpos;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
906 } else
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
907 newpts += rel_seek_secs;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
908 if (newpts < 0) newpts = 0;
1628
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
909
25883
baf32110d3fc Use defines to give names to the different seek flags.
reimar
parents: 25838
diff changeset
910 if(flags&SEEK_FACTOR){
1628
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
911 // float seek 0..1
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
912 newpos+=(demuxer->movi_end-demuxer->movi_start)*rel_seek_secs;
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
913 } else {
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
914 // time seek (secs)
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
915 if (mpg_d && mpg_d->has_valid_timestamps) {
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
916 if (mpg_d->first_to_final_pts_len > 0.0)
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
917 newpos += rel_seek_secs * (demuxer->movi_end - demuxer->movi_start) / mpg_d->first_to_final_pts_len;
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
918 else if (oldpts > 0.0)
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
919 newpos += rel_seek_secs * (oldpos - demuxer->movi_start) / oldpts;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
920 } else if(!sh_video || !sh_video->i_bps) // unspecified or VBR
1628
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
921 newpos+=2324*75*rel_seek_secs; // 174.3 kbyte/sec
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
922 else
1628
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
923 newpos+=sh_video->i_bps*rel_seek_secs;
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
924 }
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
925
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
926 while (1) {
4391
6394c1e9e770 DVD start position handling changed (progbar/eta fix)
arpi
parents: 3975
diff changeset
927 if(newpos<demuxer->movi_start){
6394c1e9e770 DVD start position handling changed (progbar/eta fix)
arpi
parents: 3975
diff changeset
928 if(demuxer->stream->type!=STREAMTYPE_VCD) demuxer->movi_start=0; // for VCD
6394c1e9e770 DVD start position handling changed (progbar/eta fix)
arpi
parents: 3975
diff changeset
929 if(newpos<demuxer->movi_start) newpos=demuxer->movi_start;
6394c1e9e770 DVD start position handling changed (progbar/eta fix)
arpi
parents: 3975
diff changeset
930 }
1628
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1597
diff changeset
931
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
932 stream_seek(demuxer->stream,newpos);
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
933
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
934 // re-sync video:
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
935 videobuf_code_len=0; // reset ES stream buffer
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
936
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
937 ds_fill_buffer(d_video);
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
938 if(sh_audio){
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
939 ds_fill_buffer(d_audio);
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
940 }
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
941
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
942 while(1){
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
943 int i;
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
944 if(sh_audio && !d_audio->eof && d_video->pts && d_audio->pts){
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
945 float a_pts=d_audio->pts;
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
946 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
947 if(d_video->pts>a_pts){
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
948 skip_audio_frame(sh_audio); // sync audio
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
949 continue;
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
950 }
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
951 }
17821
6be72b753b82 check sh_video before seeking; closes cid 56
nicodvb
parents: 17819
diff changeset
952 if(!sh_video) break;
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
953 i=sync_video_packet(d_video);
22155
bea181ba1df4 when seeking and the codec is VC1 sync to sequence or entry point headers
nicodvb
parents: 22094
diff changeset
954 if(sh_video->format == mmioFOURCC('W', 'V', 'C', '1')) {
bea181ba1df4 when seeking and the codec is VC1 sync to sequence or entry point headers
nicodvb
parents: 22094
diff changeset
955 if(i==0x10E || i==0x10F) //entry point or sequence header
bea181ba1df4 when seeking and the codec is VC1 sync to sequence or entry point headers
nicodvb
parents: 22094
diff changeset
956 break;
bea181ba1df4 when seeking and the codec is VC1 sync to sequence or entry point headers
nicodvb
parents: 22094
diff changeset
957 } else
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
958 if(sh_video->format == 0x10000004) { //mpeg4
14923
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
959 if(i==0x1B6) { //vop (frame) startcode
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
960 int pos = videobuf_len;
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
961 if(!read_video_packet(d_video)) break; // EOF
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
962 if((videobuffer[pos+4] & 0x3F) == 0) break; //I-frame
658fc109eefc added support for other codecs (mpeg4/h264/aac) in mpeg-ps parsing the PSM
nicodvb
parents: 14502
diff changeset
963 }
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
964 } else if(sh_video->format == 0x10000005){ //h264
17289
0c031c0ba80b h264es: don't seek to non-keyframes
lorenm
parents: 17286
diff changeset
965 if((i & ~0x60) == 0x105) break;
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
966 } else { //default mpeg1/2
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
967 if(i==0x1B3 || i==0x1B8) break; // found it!
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
968 }
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
969 if(!i || !skip_video_packet(d_video)) break; // EOF?
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
970 }
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
971 if(!mpg_d)
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
972 break;
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
973 if (!precision || abs(newpts - mpg_d->last_pts) < 0.5 || (mpg_d->last_pts == oldpts)) break;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
974 if ((newpos - oldpos) * (mpg_d->last_pts - oldpts) < 0) { // invalid timestamps
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
975 mpg_d->has_valid_timestamps = 0;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
976 break;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
977 }
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
978 precision--;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
979 //prepare another seek because we are off by more than 0.5s
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
980 if(mpg_d) {
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
981 newpos += (newpts - mpg_d->last_pts) * (newpos - oldpos) / (mpg_d->last_pts - oldpts);
26927
ff446aa58931 use demux_flush() where appropriate
nicodvb
parents: 25883
diff changeset
982 demux_flush(demuxer);
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
983 demuxer->stream->eof=0; // clear eof flag
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
984 d_video->eof=0;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
985 d_audio->eof=0;
14426
3faa873334d7 fixed broken seeking in mpeg-es files; syncword seeking for all 3 video codecs
nicodvb
parents: 13738
diff changeset
986 }
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
987 }
1466
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
988 }
7845f6d7c4ba format-specific seeking code moved to demuxer_ stuff
arpi
parents: 1430
diff changeset
989
8208
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
990 int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
991 mpg_demuxer_t *mpg_d=(mpg_demuxer_t*)demuxer->priv;
8208
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
992
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
993 switch(cmd) {
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
994 case DEMUXER_CTRL_GET_TIME_LENGTH:
24257
d261f5109660 cosmetics: typo fix UNSUPORTED --> UNSUPPORTED
diego
parents: 23723
diff changeset
995 if(stream_control(demuxer->stream, STREAM_CTRL_GET_TIME_LENGTH, arg) != STREAM_UNSUPPORTED) {
20851
6602a90a06ec consistency fix: STREAM_CTRL_GET_TIME_LENGTH and STREAM_CTRL_GET_CURRENT_TIME now return time in (double) seconds
nicodvb
parents: 20005
diff changeset
996 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"\r\nDEMUX_MPG_CTRL, (%.3lf)\r\n", *((double*)arg));
17699
b742a2c71c25 try to get duration from the stream layer, if an implementation of STREAM_CTRL_GET_TIME_LENGTH is available
nicodvb
parents: 17636
diff changeset
997 return DEMUXER_CTRL_GUESS;
b742a2c71c25 try to get duration from the stream layer, if an implementation of STREAM_CTRL_GET_TIME_LENGTH is available
nicodvb
parents: 17636
diff changeset
998 }
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
999 if (mpg_d && mpg_d->has_valid_timestamps) {
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
1000 *((double *)arg)=(double)mpg_d->first_to_final_pts_len;
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
1001 return DEMUXER_CTRL_OK;
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
1002 }
8208
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
1003 return DEMUXER_CTRL_DONTKNOW;
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
1004
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
1005 case DEMUXER_CTRL_GET_PERCENT_POS:
22021
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
1006 if (mpg_d && mpg_d->has_valid_timestamps && mpg_d->first_to_final_pts_len > 0.0) {
71d78117fbf0 set has_valid_timestamps and corresponding first and final pts only after
nicodvb
parents: 21979
diff changeset
1007 *((int *)arg)=(int)(100 * (mpg_d->last_pts-mpg_d->first_pts) / mpg_d->first_to_final_pts_len);
13738
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
1008 return DEMUXER_CTRL_OK;
39004f891def seeking based on the largest timestamp in an mpeg stream
aurel
parents: 13649
diff changeset
1009 }
14502
8769fa370f83 Move generic length and percent pos calculation to demuxer.c
reimar
parents: 14426
diff changeset
1010 return DEMUXER_CTRL_DONTKNOW;
8208
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
1011
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1012 case DEMUXER_CTRL_SWITCH_AUDIO:
17822
24fc4279bf99 fail immediately if any of the parameters necessary to switch audio stream isn't set/correct; closes cid 55
nicodvb
parents: 17821
diff changeset
1013 if(! (mpg_d && mpg_d->num_a_streams > 1 && demuxer->audio && demuxer->audio->sh))
24fc4279bf99 fail immediately if any of the parameters necessary to switch audio stream isn't set/correct; closes cid 55
nicodvb
parents: 17821
diff changeset
1014 return DEMUXER_CTRL_NOTIMPL;
24fc4279bf99 fail immediately if any of the parameters necessary to switch audio stream isn't set/correct; closes cid 55
nicodvb
parents: 17821
diff changeset
1015 else {
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1016 demux_stream_t *d_audio = demuxer->audio;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1017 sh_audio_t *sh_audio = d_audio->sh;
17819
7d5716fd634c init sh_a (new audio stream) to sh_audio (current audio stream); closes cid 241
nicodvb
parents: 17779
diff changeset
1018 sh_audio_t *sh_a = sh_audio;
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1019 int i;
17822
24fc4279bf99 fail immediately if any of the parameters necessary to switch audio stream isn't set/correct; closes cid 55
nicodvb
parents: 17821
diff changeset
1020 if(!sh_audio)
24fc4279bf99 fail immediately if any of the parameters necessary to switch audio stream isn't set/correct; closes cid 55
nicodvb
parents: 17821
diff changeset
1021 return DEMUXER_CTRL_NOTIMPL;
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1022 if (*((int*)arg) < 0)
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1023 {
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1024 for (i = 0; i < mpg_d->num_a_streams; i++) {
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1025 if (d_audio->id == mpg_d->a_stream_ids[i]) break;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1026 }
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1027 i = (i+1) % mpg_d->num_a_streams;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1028 sh_a = (sh_audio_t*)demuxer->a_streams[mpg_d->a_stream_ids[i]];
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1029 }
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1030 else {
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1031 for (i = 0; i < mpg_d->num_a_streams; i++)
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1032 if (*((int*)arg) == mpg_d->a_stream_ids[i]) break;
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1033 if (i < mpg_d->num_a_streams)
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1034 sh_a = (sh_audio_t*)demuxer->a_streams[*((int*)arg)];
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1035 }
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1036 if (i < mpg_d->num_a_streams && d_audio->id != mpg_d->a_stream_ids[i]) {
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1037 d_audio->id = mpg_d->a_stream_ids[i];
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1038 d_audio->sh = sh_a;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1039 ds_free_packs(d_audio);
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1040 }
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1041 }
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15046
diff changeset
1042 *((int*)arg) = demuxer->audio->id;
15046
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1043 return DEMUXER_CTRL_OK;
b7aa70b05d76 Added support of audio stream switching in the MPEG demuxer using the #-key
gpoirier
parents: 14923
diff changeset
1044
8208
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
1045 default:
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
1046 return DEMUXER_CTRL_NOTIMPL;
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
1047 }
ae5a2ae1c349 demuxer_control(), percent position and time length query implemented in
arpi
parents: 8123
diff changeset
1048 }
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1049
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1050
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1051 static int demux_mpg_pes_probe(demuxer_t *demuxer) {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1052 demuxer->synced = 3;
16314
6720cdd99559 Fix mpeg-pes playback
rtognimp
parents: 16310
diff changeset
1053 return (demux_mpg_probe(demuxer) == DEMUXER_TYPE_MPEG_PS) ? DEMUXER_TYPE_MPEG_PES : 0;
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1054 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1055
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1056
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1057 static demuxer_t* demux_mpg_es_open(demuxer_t* demuxer)
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1058 {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1059 sh_video_t *sh_video=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1060
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1061 demuxer->audio->sh = NULL; // ES streams has no audio channel
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1062 demuxer->video->sh = new_sh_video(demuxer,0); // create dummy video stream header, id=0
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1063 sh_video=demuxer->video->sh;sh_video->ds=demuxer->video;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1064
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1065 return demuxer;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1066 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1067
16310
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1068 static demuxer_t *demux_mpg_gxf_open(demuxer_t *demuxer) {
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1069 demuxer->audio->sh = NULL;
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1070 demuxer->video->sh = new_sh_video(demuxer,0);
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1071 ((sh_video_t *)demuxer->video->sh)->ds = demuxer->video;
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1072 demuxer->priv = (void *) 0xffffffff;
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1073 return demuxer;
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1074 }
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1075
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1076 static demuxer_t* demux_mpg_ps_open(demuxer_t* demuxer)
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1077 {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1078 sh_audio_t *sh_audio=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1079 sh_video_t *sh_video=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1080
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1081 sh_video=demuxer->video->sh;sh_video->ds=demuxer->video;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1082
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1083 if(demuxer->audio->id!=-2) {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1084 if(!ds_fill_buffer(demuxer->audio)){
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1085 mp_msg(MSGT_DEMUXER,MSGL_INFO,"MPEG: " MSGTR_MissingAudioStream);
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1086 demuxer->audio->sh=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1087 } else {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1088 sh_audio=demuxer->audio->sh;sh_audio->ds=demuxer->audio;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1089 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1090 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1091
22037
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1092 if(!sh_video->format && ps_probe > 0) {
22088
8c4ae9883d53 removed unused variables
nicodvb
parents: 22041
diff changeset
1093 int head;
22037
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1094 off_t pos = stream_tell(demuxer->stream);
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1095
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1096 clear_stats();
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1097 do {
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1098 head=sync_video_packet(demuxer->video);
22041
f0172904ff02 sanity checks during codec detection; also reset demuxer->stream->eof
nicodvb
parents: 22037
diff changeset
1099 if(!head) break;
22037
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1100 update_stats(head);
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1101 skip_video_packet(demuxer->video);
22041
f0172904ff02 sanity checks during codec detection; also reset demuxer->stream->eof
nicodvb
parents: 22037
diff changeset
1102 } while(stream_tell(demuxer->stream) < pos + ps_probe && !demuxer->stream->eof);
22037
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1103
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1104 ds_free_packs(demuxer->video);
22041
f0172904ff02 sanity checks during codec detection; also reset demuxer->stream->eof
nicodvb
parents: 22037
diff changeset
1105 demuxer->stream->eof=0;
22037
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1106 stream_seek(demuxer->stream, pos);
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1107 mp_msg(MSGT_DEMUX,MSGL_INFO,"MPEG packet stats: p100: %d p101: %d p1B6: %d p12x: %d sli: %d a: %d b: %d c: %d idr: %d sps: %d pps: %d\n",
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1108 num_elementary_packets100, num_elementary_packets101,
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1109 num_elementary_packets1B6, num_elementary_packets12x,
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1110 num_h264_slice, num_h264_dpa, num_h264_dpb, num_h264_dpc,
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1111 num_h264_idr, num_h264_sps, num_h264_pps);
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1112
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1113 if(num_elementary_packets1B6>3 && num_elementary_packets12x>=1 &&
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1114 num_elementary_packets100<=num_elementary_packets12x)
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1115 sh_video->format = 0x10000004;
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1116 else if((num_h264_slice>3 || (num_h264_dpa>3 && num_h264_dpb>3 && num_h264_dpc>3)) &&
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1117 num_h264_sps>=1 && num_h264_pps>=1 && num_h264_idr>=1 &&
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1118 num_elementary_packets1B6==0)
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1119 sh_video->format = 0x10000005;
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1120 else sh_video->format = 0x10000002;
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1121 }
489b443a8ecf added code to scan the video stream to search the actual video codec used;
nicodvb
parents: 22036
diff changeset
1122
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1123 return demuxer;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1124 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1125
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1126
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 24946
diff changeset
1127 const demuxer_desc_t demuxer_desc_mpeg_ps = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1128 "MPEG PS demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1129 "mpegps",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1130 "MPEG-PS",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1131 "Arpi?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1132 "Mpeg",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1133 DEMUXER_TYPE_MPEG_PS,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1134 0, // unsafe autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1135 demux_mpg_probe,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1136 demux_mpg_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1137 demux_mpg_ps_open,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1138 demux_close_mpg,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1139 demux_seek_mpg,
16771
82a56c89b54d 10l, demux_mpg_control was missing from demuxer info struct, causing audio
reimar
parents: 16369
diff changeset
1140 demux_mpg_control,
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1141 };
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1142
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1143
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 24946
diff changeset
1144 const demuxer_desc_t demuxer_desc_mpeg_pes = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1145 "MPEG PES demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1146 "mpegpes",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1147 "MPEG-PES",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1148 "Arpi?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1149 "Mpeg",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1150 DEMUXER_TYPE_MPEG_PES,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1151 0, // unsafe autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1152 demux_mpg_pes_probe,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1153 demux_mpg_fill_buffer,
16314
6720cdd99559 Fix mpeg-pes playback
rtognimp
parents: 16310
diff changeset
1154 demux_mpg_ps_open,
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1155 demux_close_mpg,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1156 demux_seek_mpg,
16771
82a56c89b54d 10l, demux_mpg_control was missing from demuxer info struct, causing audio
reimar
parents: 16369
diff changeset
1157 demux_mpg_control,
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1158 };
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1159
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1160
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 24946
diff changeset
1161 const demuxer_desc_t demuxer_desc_mpeg_gxf = {
16310
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1162 "MPEG ES in GXF demuxer",
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1163 "mpeggxf",
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1164 "MPEG-ES in GXF",
22507
a46ab26b2d5e Source files should not contain non-ASCII characters.
diego
parents: 22363
diff changeset
1165 "Reimar Doeffinger",
16310
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1166 "Mpeg",
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1167 DEMUXER_TYPE_MPEG_GXF,
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1168 0, // hack autodetection
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1169 NULL,
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1170 demux_mpg_gxf_fill_buffer,
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1171 demux_mpg_gxf_open,
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1172 NULL,
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1173 NULL,
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1174 NULL
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1175 };
fb95057e370e support MPEG in GXF container with extension-based detection.
reimar
parents: 16175
diff changeset
1176
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 24946
diff changeset
1177 const demuxer_desc_t demuxer_desc_mpeg_es = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1178 "MPEG ES demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1179 "mpeges",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1180 "MPEG-ES",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1181 "Arpi?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1182 "Mpeg",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1183 DEMUXER_TYPE_MPEG_ES,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1184 0, // hack autodetection
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1185 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1186 demux_mpg_es_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1187 demux_mpg_es_open,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1188 demux_close_mpg,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1189 demux_seek_mpg,
16771
82a56c89b54d 10l, demux_mpg_control was missing from demuxer info struct, causing audio
reimar
parents: 16369
diff changeset
1190 demux_mpg_control,
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1191 };
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1192
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1193
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 24946
diff changeset
1194 const demuxer_desc_t demuxer_desc_mpeg4_es = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1195 "MPEG4 ES demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1196 "mpeg4es",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1197 "MPEG-ES",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1198 "Arpi?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1199 "Mpeg",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1200 DEMUXER_TYPE_MPEG4_ES,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1201 0, // hack autodetection
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1202 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1203 demux_mpg_es_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1204 demux_mpg_es_open,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1205 demux_close_mpg,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1206 demux_seek_mpg,
16771
82a56c89b54d 10l, demux_mpg_control was missing from demuxer info struct, causing audio
reimar
parents: 16369
diff changeset
1207 demux_mpg_control,
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1208 };
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1209
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1210
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 24946
diff changeset
1211 const demuxer_desc_t demuxer_desc_h264_es = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1212 "H.264 ES demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1213 "h264es",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1214 "H264-ES",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1215 "Arpi?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1216 "Mpeg",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1217 DEMUXER_TYPE_H264_ES,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1218 0, // hack autodetection
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1219 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1220 demux_mpg_es_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1221 demux_mpg_es_open,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1222 demux_close_mpg,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1223 demux_seek_mpg,
16771
82a56c89b54d 10l, demux_mpg_control was missing from demuxer info struct, causing audio
reimar
parents: 16369
diff changeset
1224 demux_mpg_control,
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15815
diff changeset
1225 };