Mercurial > mplayer.hg
annotate libmpdemux/demux_ts.c @ 25866:178006e9ea75
Replace with the output of the updated alaw-gen generator program.
This adds multiple inclusion guards and reformats the tables.
author | diego |
---|---|
date | Sun, 27 Jan 2008 18:49:24 +0000 |
parents | 643064afe2a4 |
children | baf32110d3fc |
rev | line source |
---|---|
9610 | 1 /* |
2 * Demultiplexer for MPEG2 Transport Streams. | |
3 * | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
4 * Written by Nico <nsabbi@libero.it> |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
5 * Kind feedback is appreciated; 'sucks' and alike is not. |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
6 * Originally based on demux_pva.c written by Matteo Giani and FFmpeg (libavformat) sources |
10014 | 7 * |
8 * This file is free software; you can redistribute it and/or | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
9 * modify it under the terms of the GNU General Public |
9610 | 10 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | |
12 * | |
10014 | 13 * This file is distributed in the hope that it will be useful, |
9610 | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this library; if not, write to the Free Software | |
17367
401b440a6d76
Update licensing information: The FSF changed postal address.
diego
parents:
17012
diff
changeset
|
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
9610 | 21 */ |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
22 |
9610 | 23 |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 #include <string.h> | |
27 | |
28 #include "config.h" | |
29 #include "mp_msg.h" | |
30 #include "help_mp.h" | |
31 | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22352
diff
changeset
|
32 #include "stream/stream.h" |
9610 | 33 #include "demuxer.h" |
11412 | 34 #include "parse_es.h" |
9610 | 35 #include "stheader.h" |
36 | |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
37 #include "ms_hdr.h" |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
38 #include "mpeg_hdr.h" |
9610 | 39 |
13994
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
40 #define TS_PH_PACKET_SIZE 192 |
9610 | 41 #define TS_FEC_PACKET_SIZE 204 |
42 #define TS_PACKET_SIZE 188 | |
43 #define NB_PID_MAX 8192 | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
44 |
9610 | 45 #define MAX_HEADER_SIZE 6 /* enough for PES header + length */ |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
46 #define MAX_CHECK_SIZE 65535 |
11190 | 47 #define TS_MAX_PROBE_SIZE 2000000 /* dont forget to change this in cfg-common.h too */ |
10014 | 48 #define NUM_CONSECUTIVE_TS_PACKETS 32 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
49 #define NUM_CONSECUTIVE_AUDIO_PACKETS 348 |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
50 #define MAX_A52_FRAME_SIZE 3840 |
9610 | 51 |
18475
23fedcdd08a0
where necesary, replaced all realloc() with realloc_struct() to prevent int oveflows
nicodvb
parents:
18474
diff
changeset
|
52 #ifndef SIZE_MAX |
23fedcdd08a0
where necesary, replaced all realloc() with realloc_struct() to prevent int oveflows
nicodvb
parents:
18474
diff
changeset
|
53 #define SIZE_MAX ((size_t)-1) |
23fedcdd08a0
where necesary, replaced all realloc() with realloc_struct() to prevent int oveflows
nicodvb
parents:
18474
diff
changeset
|
54 #endif |
9610 | 55 |
18688 | 56 #define TYPE_AUDIO 1 |
57 #define TYPE_VIDEO 2 | |
58 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
59 int ts_prog; |
11190 | 60 int ts_keep_broken=0; |
23509
53d57a0ebe13
init ts_probe to 0 and probe up to TS_MAX_PROBE_SIZE if the parameter
nicodvb
parents:
23507
diff
changeset
|
61 off_t ts_probe = 0; |
11190 | 62 extern char *dvdsub_lang, *audio_lang; //for -alang |
9610 | 63 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
64 typedef enum |
9610 | 65 { |
66 UNKNOWN = -1, | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
67 VIDEO_MPEG1 = 0x10000001, |
9610 | 68 VIDEO_MPEG2 = 0x10000002, |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
69 VIDEO_MPEG4 = 0x10000004, |
14034
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
70 VIDEO_H264 = 0x10000005, |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
71 VIDEO_AVC = mmioFOURCC('a', 'v', 'c', '1'), |
22162 | 72 VIDEO_VC1 = mmioFOURCC('W', 'V', 'C', '1'), |
9610 | 73 AUDIO_MP2 = 0x50, |
74 AUDIO_A52 = 0x2000, | |
18565
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
75 AUDIO_DTS = 0x2001, |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
76 AUDIO_LPCM_BE = 0x10001, |
11190 | 77 AUDIO_AAC = mmioFOURCC('M', 'P', '4', 'A'), |
9610 | 78 SPU_DVD = 0x3000000, |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
79 SPU_DVB = 0x3000001, |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
80 PES_PRIVATE1 = 0xBD00000, |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
81 SL_PES_STREAM = 0xD000000, |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
82 SL_SECTION = 0xD100000, |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
83 MP4_OD = 0xD200000, |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
84 } es_stream_type_t; |
9610 | 85 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
86 typedef struct { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
87 uint8_t *buffer; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
88 uint16_t buffer_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
89 } ts_section_t; |
9610 | 90 |
91 typedef struct { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
92 int size; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
93 unsigned char *start; |
10014 | 94 uint16_t payload_size; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
95 es_stream_type_t type, subtype; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
96 float pts, last_pts; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
97 int pid; |
11190 | 98 char lang[4]; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
99 int last_cc; // last cc code (-1 if first packet) |
14981
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
100 int is_synced; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
101 ts_section_t section; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
102 uint8_t *extradata; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
103 int extradata_alloc, extradata_len; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
104 struct { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
105 uint8_t au_start, au_end, last_au_end; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
106 } sl; |
10014 | 107 } ES_stream_t; |
108 | |
18688 | 109 typedef struct { |
110 void *sh; | |
111 int id; | |
112 int type; | |
113 } sh_av_t; | |
9610 | 114 |
10014 | 115 typedef struct MpegTSContext { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
116 int packet_size; // raw packet size, including FEC if present e.g. 188 bytes |
10014 | 117 ES_stream_t *pids[NB_PID_MAX]; |
18688 | 118 sh_av_t streams[NB_PID_MAX]; |
10014 | 119 } MpegTSContext; |
9610 | 120 |
10014 | 121 |
122 typedef struct { | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
123 demux_stream_t *ds; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
124 demux_packet_t *pack; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
125 int offset, buffer_size; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
126 } av_fifo_t; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
127 |
18462
557d188e915a
raised max extradata size and refuse to store more than the limit
nicodvb
parents:
18461
diff
changeset
|
128 #define MAX_EXTRADATA_SIZE 64*1024 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
129 typedef struct { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
130 int32_t object_type; //aka codec used |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
131 int32_t stream_type; //video, audio etc. |
18462
557d188e915a
raised max extradata size and refuse to store more than the limit
nicodvb
parents:
18461
diff
changeset
|
132 uint8_t buf[MAX_EXTRADATA_SIZE]; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
133 uint16_t buf_size; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
134 uint8_t szm1; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
135 } mp4_decoder_config_t; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
136 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
137 typedef struct { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
138 //flags |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
139 uint8_t flags; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
140 uint8_t au_start; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
141 uint8_t au_end; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
142 uint8_t random_accesspoint; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
143 uint8_t random_accesspoint_only; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
144 uint8_t padding; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
145 uint8_t use_ts; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
146 uint8_t idle; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
147 uint8_t duration; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
148 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
149 uint32_t ts_resolution, ocr_resolution; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
150 uint8_t ts_len, ocr_len, au_len, instant_bitrate_len, degr_len, au_seqnum_len, packet_seqnum_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
151 uint32_t timescale; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
152 uint16_t au_duration, cts_duration; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
153 uint64_t ocr, dts, cts; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
154 } mp4_sl_config_t; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
155 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
156 typedef struct { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
157 uint16_t id; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
158 uint8_t flags; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
159 mp4_decoder_config_t decoder; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
160 mp4_sl_config_t sl; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
161 } mp4_es_descr_t; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
162 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
163 typedef struct { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
164 uint16_t id; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
165 uint8_t flags; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
166 mp4_es_descr_t *es; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
167 uint16_t es_cnt; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
168 } mp4_od_t; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
169 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
170 typedef struct { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
171 uint8_t skip; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
172 uint8_t table_id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
173 uint8_t ssi; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
174 uint16_t section_length; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
175 uint16_t ts_id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
176 uint8_t version_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
177 uint8_t curr_next; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
178 uint8_t section_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
179 uint8_t last_section_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
180 struct pat_progs_t { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
181 uint16_t id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
182 uint16_t pmt_pid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
183 } *progs; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
184 uint16_t progs_cnt; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
185 ts_section_t section; |
11190 | 186 } pat_t; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
187 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
188 typedef struct { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
189 uint16_t progid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
190 uint8_t skip; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
191 uint8_t table_id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
192 uint8_t ssi; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
193 uint16_t section_length; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
194 uint8_t version_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
195 uint8_t curr_next; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
196 uint8_t section_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
197 uint8_t last_section_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
198 uint16_t PCR_PID; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
199 uint16_t prog_descr_length; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
200 ts_section_t section; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
201 uint16_t es_cnt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
202 struct pmt_es_t { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
203 uint16_t pid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
204 uint32_t type; //it's 8 bit long, but cast to the right type as FOURCC |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
205 uint16_t descr_length; |
11190 | 206 uint8_t format_descriptor[5]; |
207 uint8_t lang[4]; | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
208 uint16_t mp4_es_id; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
209 } *es; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
210 mp4_od_t iod, *od; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
211 mp4_es_descr_t *mp4es; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
212 int od_cnt, mp4es_cnt; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
213 } pmt_t; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
214 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
215 typedef struct { |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
216 uint64_t size; |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
217 float duration; |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
218 float first_pts; |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
219 float last_pts; |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
220 } TS_stream_info; |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
221 |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
222 typedef struct { |
10014 | 223 MpegTSContext ts; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
224 int last_pid; |
11190 | 225 av_fifo_t fifo[3]; //0 for audio, 1 for video, 2 for subs |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
226 pat_t pat; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
227 pmt_t *pmt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
228 uint16_t pmt_cnt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
229 uint32_t prog; |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
230 uint32_t vbitrate; |
11190 | 231 int keep_broken; |
18688 | 232 int last_aid; |
20951 | 233 int last_vid; |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
234 char packet[TS_FEC_PACKET_SIZE]; |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
235 TS_stream_info vstr, astr; |
10014 | 236 } ts_priv_t; |
237 | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
238 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
239 typedef struct { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
240 es_stream_type_t type; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
241 ts_section_t section; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
242 } TS_pids_t; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
243 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
244 |
18565
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
245 #define IS_AUDIO(x) (((x) == AUDIO_MP2) || ((x) == AUDIO_A52) || ((x) == AUDIO_LPCM_BE) || ((x) == AUDIO_AAC) || ((x) == AUDIO_DTS)) |
22162 | 246 #define IS_VIDEO(x) (((x) == VIDEO_MPEG1) || ((x) == VIDEO_MPEG2) || ((x) == VIDEO_MPEG4) || ((x) == VIDEO_H264) || ((x) == VIDEO_AVC) || ((x) == VIDEO_VC1)) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
247 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
248 static int ts_parse(demuxer_t *demuxer, ES_stream_t *es, unsigned char *packet, int probe); |
9610 | 249 |
250 static uint8_t get_packet_size(const unsigned char *buf, int size) | |
251 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
252 int i; |
9610 | 253 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
254 if (size < (TS_FEC_PACKET_SIZE * NUM_CONSECUTIVE_TS_PACKETS)) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
255 return 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
256 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
257 for(i=0; i<NUM_CONSECUTIVE_TS_PACKETS; i++) |
9610 | 258 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
259 if (buf[i * TS_PACKET_SIZE] != 0x47) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
260 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
261 mp_msg(MSGT_DEMUX, MSGL_DBG2, "GET_PACKET_SIZE, pos %d, char: %2x\n", i, buf[i * TS_PACKET_SIZE]); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
262 goto try_fec; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
263 } |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
264 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
265 return TS_PACKET_SIZE; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
266 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
267 try_fec: |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
268 for(i=0; i<NUM_CONSECUTIVE_TS_PACKETS; i++) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
269 { |
13994
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
270 if (buf[i * TS_FEC_PACKET_SIZE] != 0x47){ |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
271 mp_msg(MSGT_DEMUX, MSGL_DBG2, "GET_PACKET_SIZE, pos %d, char: %2x\n", i, buf[i * TS_PACKET_SIZE]); |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
272 goto try_philips; |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
273 } |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
274 } |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
275 return TS_FEC_PACKET_SIZE; |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
276 |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
277 try_philips: |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
278 for(i=0; i<NUM_CONSECUTIVE_TS_PACKETS; i++) |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
279 { |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
280 if (buf[i * TS_PH_PACKET_SIZE] != 0x47) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
281 return 0; |
9610 | 282 } |
13994
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
283 return TS_PH_PACKET_SIZE; |
9610 | 284 } |
285 | |
21929
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
286 static int parse_avc_sps(uint8_t *buf, int len, int *w, int *h); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
287 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
288 static void ts_add_stream(demuxer_t * demuxer, ES_stream_t *es) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
289 { |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
290 int i; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
291 ts_priv_t *priv = (ts_priv_t*) demuxer->priv; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
292 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
293 if(priv->ts.streams[es->pid].sh) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
294 return; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
295 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
296 if((IS_AUDIO(es->type) || IS_AUDIO(es->subtype)) && priv->last_aid+1 < MAX_A_STREAMS) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
297 { |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
298 sh_audio_t *sh = new_sh_audio_aid(demuxer, priv->last_aid, es->pid); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
299 if(sh) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
300 { |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
301 sh->format = IS_AUDIO(es->type) ? es->type : es->subtype; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
302 sh->ds = demuxer->audio; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
303 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
304 priv->ts.streams[es->pid].id = priv->last_aid; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
305 priv->ts.streams[es->pid].sh = sh; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
306 priv->ts.streams[es->pid].type = TYPE_AUDIO; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
307 mp_msg(MSGT_DEMUX, MSGL_V, "\r\nADDED AUDIO PID %d, type: %x stream n. %d\r\n", es->pid, sh->format, priv->last_aid); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
308 priv->last_aid++; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
309 } |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
310 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
311 if(es->extradata && es->extradata_len) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
312 { |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
313 sh->wf = (WAVEFORMATEX *) malloc(sizeof (WAVEFORMATEX) + es->extradata_len); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
314 sh->wf->cbSize = es->extradata_len; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
315 memcpy(sh->wf + 1, es->extradata, es->extradata_len); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
316 } |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
317 } |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
318 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
319 if((IS_VIDEO(es->type) || IS_VIDEO(es->subtype)) && priv->last_vid+1 < MAX_V_STREAMS) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
320 { |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
321 sh_video_t *sh = new_sh_video_vid(demuxer, priv->last_vid, es->pid); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
322 if(sh) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
323 { |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
324 sh->format = IS_VIDEO(es->type) ? es->type : es->subtype;; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
325 sh->ds = demuxer->video; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
326 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
327 priv->ts.streams[es->pid].id = priv->last_vid; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
328 priv->ts.streams[es->pid].sh = sh; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
329 priv->ts.streams[es->pid].type = TYPE_VIDEO; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
330 mp_msg(MSGT_DEMUX, MSGL_V, "\r\nADDED VIDEO PID %d, type: %x stream n. %d\r\n", es->pid, sh->format, priv->last_vid); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
331 priv->last_vid++; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
332 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
333 |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
334 if(sh->format == VIDEO_AVC && es->extradata && es->extradata_len) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
335 { |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
336 int w = 0, h = 0; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
337 sh->bih = (BITMAPINFOHEADER *) calloc(1, sizeof(BITMAPINFOHEADER) + es->extradata_len); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
338 sh->bih->biSize= sizeof(BITMAPINFOHEADER) + es->extradata_len; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
339 sh->bih->biCompression = sh->format; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
340 memcpy(sh->bih + 1, es->extradata, es->extradata_len); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
341 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "EXTRADATA(%d BYTES): \n", es->extradata_len); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
342 for(i = 0;i < es->extradata_len; i++) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
343 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "%02x ", (int) es->extradata[i]); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
344 mp_msg(MSGT_DEMUXER,MSGL_DBG2,"\n"); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
345 if(parse_avc_sps(es->extradata, es->extradata_len, &w, &h)) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
346 { |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
347 sh->bih->biWidth = w; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
348 sh->bih->biHeight = h; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
349 } |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
350 } |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
351 } |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
352 } |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
353 } |
9610 | 354 |
16175 | 355 static int ts_check_file(demuxer_t * demuxer) |
9610 | 356 { |
357 const int buf_size = (TS_FEC_PACKET_SIZE * NUM_CONSECUTIVE_TS_PACKETS); | |
10841
d4cf5407d7c6
Fix a gcc 3.x crash when compiling demux_ts.c with -g -O4 (or -O3). Patch by Arpi.
mosu
parents:
10735
diff
changeset
|
358 unsigned char buf[TS_FEC_PACKET_SIZE * NUM_CONSECUTIVE_TS_PACKETS], done = 0, *ptr; |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
359 uint32_t _read, i, count = 0, is_ts; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
360 int cc[NB_PID_MAX], last_cc[NB_PID_MAX], pid, cc_ok, c, good, bad; |
9610 | 361 uint8_t size = 0; |
362 off_t pos = 0; | |
11190 | 363 off_t init_pos; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
364 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
365 mp_msg(MSGT_DEMUX, MSGL_V, "Checking for MPEG-TS...\n"); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
366 |
11190 | 367 init_pos = stream_tell(demuxer->stream); |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
368 is_ts = 0; |
9610 | 369 while(! done) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
370 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
371 i = 1; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
372 c = 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
373 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
374 while(((c=stream_read_char(demuxer->stream)) != 0x47) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
375 && (c >= 0) |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
376 && (i < MAX_CHECK_SIZE) |
10014 | 377 && ! demuxer->stream->eof |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
378 ) i++; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
379 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
380 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
381 if(c != 0x47) |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
382 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
383 mp_msg(MSGT_DEMUX, MSGL_V, "THIS DOESN'T LOOK LIKE AN MPEG-TS FILE!\n"); |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
384 is_ts = 0; |
10014 | 385 done = 1; |
386 continue; | |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
387 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
388 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
389 pos = stream_tell(demuxer->stream) - 1; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
390 buf[0] = c; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
391 _read = stream_read(demuxer->stream, &buf[1], buf_size-1); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
392 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
393 if(_read < buf_size-1) |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
394 { |
10014 | 395 mp_msg(MSGT_DEMUX, MSGL_V, "COULDN'T READ ENOUGH DATA, EXITING TS_CHECK\n"); |
396 stream_reset(demuxer->stream); | |
397 return 0; | |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
398 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
399 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
400 size = get_packet_size(buf, buf_size); |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
401 if(size) |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
402 { |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
403 done = 1; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
404 is_ts = 1; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
405 } |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
406 |
11190 | 407 if(pos - init_pos >= MAX_CHECK_SIZE) |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
408 { |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
409 done = 1; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
410 is_ts = 0; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
411 } |
10014 | 412 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
413 |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16292
diff
changeset
|
414 mp_msg(MSGT_DEMUX, MSGL_V, "TRIED UP TO POSITION %"PRIu64", FOUND %x, packet_size= %d, SEEMS A TS? %d\n", (uint64_t) pos, c, size, is_ts); |
10014 | 415 stream_seek(demuxer->stream, pos); |
416 | |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
417 if(! is_ts) |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
418 return 0; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
419 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
420 //LET'S CHECK continuity counters |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
421 good = bad = 0; |
10014 | 422 for(count = 0; count < NB_PID_MAX; count++) |
423 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
424 cc[count] = last_cc[count] = -1; |
9610 | 425 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
426 |
10014 | 427 for(count = 0; count < NUM_CONSECUTIVE_TS_PACKETS; count++) |
428 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
429 ptr = &(buf[size * count]); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
430 pid = ((ptr[1] & 0x1f) << 8) | ptr[2]; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
431 mp_msg(MSGT_DEMUX, MSGL_DBG2, "BUF: %02x %02x %02x %02x, PID %d, SIZE: %d \n", |
10014 | 432 ptr[0], ptr[1], ptr[2], ptr[3], pid, size); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
433 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
434 if((pid == 8191) || (pid < 16)) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
435 continue; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
436 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
437 cc[pid] = (ptr[3] & 0xf); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
438 cc_ok = (last_cc[pid] < 0) || ((((last_cc[pid] + 1) & 0x0f) == cc[pid])); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
439 mp_msg(MSGT_DEMUX, MSGL_DBG2, "PID %d, COMPARE CC %d AND LAST_CC %d\n", pid, cc[pid], last_cc[pid]); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
440 if(! cc_ok) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
441 //return 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
442 bad++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
443 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
444 good++; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
445 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
446 last_cc[pid] = cc[pid]; |
10014 | 447 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
448 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
449 mp_msg(MSGT_DEMUX, MSGL_V, "GOOD CC: %d, BAD CC: %d\n", good, bad); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
450 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
451 if(good >= bad) |
16175 | 452 return size; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
453 else |
16175 | 454 return 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
455 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
456 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
457 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
458 static inline int32_t progid_idx_in_pmt(ts_priv_t *priv, uint16_t progid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
459 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
460 int x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
461 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
462 if(priv->pmt == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
463 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
464 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
465 for(x = 0; x < priv->pmt_cnt; x++) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
466 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
467 if(priv->pmt[x].progid == progid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
468 return x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
469 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
470 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
471 return -1; |
9610 | 472 } |
473 | |
474 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
475 static inline int32_t progid_for_pid(ts_priv_t *priv, int pid, int32_t req) //finds the first program listing a pid |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
476 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
477 int i, j; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
478 pmt_t *pmt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
479 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
480 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
481 if(priv->pmt == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
482 return -1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
483 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
484 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
485 for(i=0; i < priv->pmt_cnt; i++) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
486 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
487 pmt = &(priv->pmt[i]); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
488 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
489 if(pmt->es == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
490 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
491 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
492 for(j = 0; j < pmt->es_cnt; j++) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
493 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
494 if(pmt->es[j].pid == pid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
495 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
496 if((req == 0) || (req == pmt->progid)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
497 return pmt->progid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
498 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
499 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
500 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
501 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
502 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
503 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
504 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
505 |
11190 | 506 static inline int pid_match_lang(ts_priv_t *priv, uint16_t pid, char *lang) |
9610 | 507 { |
11190 | 508 uint16_t i, j; |
509 pmt_t *pmt; | |
510 | |
511 if(priv->pmt == NULL) | |
512 return -1; | |
513 | |
514 for(i=0; i < priv->pmt_cnt; i++) | |
515 { | |
516 pmt = &(priv->pmt[i]); | |
517 | |
518 if(pmt->es == NULL) | |
519 return -1; | |
520 | |
521 for(j = 0; j < pmt->es_cnt; j++) | |
522 { | |
523 if(pmt->es[j].pid != pid) | |
524 continue; | |
525 | |
526 mp_msg(MSGT_DEMUXER, MSGL_V, "CMP LANG %s AND %s, pids: %d %d\n",pmt->es[j].lang, lang, pmt->es[j].pid, pid); | |
527 if(strncmp(pmt->es[j].lang, lang, 3) == 0) | |
528 { | |
529 return 1; | |
530 } | |
531 } | |
532 | |
533 } | |
534 | |
535 return -1; | |
536 } | |
537 | |
538 typedef struct { | |
539 int32_t atype, vtype, stype; //types | |
540 int32_t apid, vpid, spid; //stream ids | |
541 char slang[4], alang[4]; //languages | |
23427
2e79a9d381dc
prog_id is an uint16_t; reported by Mario Rossi (mariofurire googlemail com)
nicodvb
parents:
22605
diff
changeset
|
542 uint16_t prog; |
11190 | 543 off_t probe; |
544 } tsdemux_init_t; | |
545 | |
13608 | 546 //stripped down version of a52_syncinfo() from liba52 |
547 //copyright belongs to Michel Lespinasse <walken@zoy.org> and Aaron Holtzman <aholtzma@ess.engr.uvic.ca> | |
17492
3f420548c0ca
export custom mp_a52_framesize(), needed to parse ac3 frames when liba52 is not present; will be moved in a more appropriate place sometimes in the future
nicodvb
parents:
17367
diff
changeset
|
548 int mp_a52_framesize(uint8_t * buf, int *srate) |
13608 | 549 { |
550 int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112, | |
551 128, 160, 192, 224, 256, 320, 384, 448, | |
552 512, 576, 640 | |
553 }; | |
554 uint8_t halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3}; | |
555 int frmsizecod, bitrate, half; | |
556 | |
557 if((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */ | |
558 return 0; | |
559 | |
560 if(buf[5] >= 0x60) /* bsid >= 12 */ | |
561 return 0; | |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
562 |
13608 | 563 half = halfrate[buf[5] >> 3]; |
564 | |
565 frmsizecod = buf[4] & 63; | |
566 if(frmsizecod >= 38) | |
567 return 0; | |
568 | |
569 bitrate = rate[frmsizecod >> 1]; | |
570 | |
571 switch(buf[4] & 0xc0) | |
572 { | |
573 case 0: /* 48 KHz */ | |
17492
3f420548c0ca
export custom mp_a52_framesize(), needed to parse ac3 frames when liba52 is not present; will be moved in a more appropriate place sometimes in the future
nicodvb
parents:
17367
diff
changeset
|
574 *srate = 48000 >> half; |
13608 | 575 return 4 * bitrate; |
576 case 0x40: /* 44.1 KHz */ | |
17492
3f420548c0ca
export custom mp_a52_framesize(), needed to parse ac3 frames when liba52 is not present; will be moved in a more appropriate place sometimes in the future
nicodvb
parents:
17367
diff
changeset
|
577 *srate = 44100 >> half; |
13608 | 578 return 2 * (320 * bitrate / 147 + (frmsizecod & 1)); |
579 case 0x80: /* 32 KHz */ | |
17492
3f420548c0ca
export custom mp_a52_framesize(), needed to parse ac3 frames when liba52 is not present; will be moved in a more appropriate place sometimes in the future
nicodvb
parents:
17367
diff
changeset
|
580 *srate = 32000 >> half; |
13608 | 581 return 6 * bitrate; |
582 } | |
583 | |
584 return 0; | |
585 } | |
586 | |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
587 //second stage: returns the count of A52 syncwords found |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
588 static int a52_check(char *buf, int len) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
589 { |
17492
3f420548c0ca
export custom mp_a52_framesize(), needed to parse ac3 frames when liba52 is not present; will be moved in a more appropriate place sometimes in the future
nicodvb
parents:
17367
diff
changeset
|
590 int cnt, frame_length, ok, srate; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
591 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
592 cnt = ok = 0; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
593 if(len < 8) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
594 return 0; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
595 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
596 while(cnt < len - 7) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
597 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
598 if(buf[cnt] == 0x0B && buf[cnt+1] == 0x77) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
599 { |
17492
3f420548c0ca
export custom mp_a52_framesize(), needed to parse ac3 frames when liba52 is not present; will be moved in a more appropriate place sometimes in the future
nicodvb
parents:
17367
diff
changeset
|
600 frame_length = mp_a52_framesize(&buf[cnt], &srate); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
601 if(frame_length>=7 && frame_length<=3840) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
602 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
603 cnt += frame_length; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
604 ok++; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
605 } |
13581
ffed770f7564
fixed a bug that makes the demuxer loop forever probing a52 audio when a52_syncinfo() returns 0
nicodvb
parents:
13579
diff
changeset
|
606 else |
ffed770f7564
fixed a bug that makes the demuxer loop forever probing a52 audio when a52_syncinfo() returns 0
nicodvb
parents:
13579
diff
changeset
|
607 cnt++; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
608 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
609 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
610 cnt++; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
611 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
612 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
613 mp_msg(MSGT_DEMUXER, MSGL_V, "A52_CHECK(%d input bytes), found %d frame syncwords of %d bytes length\n", len, ok, frame_length); |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
614 return ok; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
615 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
616 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
617 |
11190 | 618 static off_t ts_detect_streams(demuxer_t *demuxer, tsdemux_init_t *param) |
619 { | |
620 int video_found = 0, audio_found = 0, sub_found = 0, i, num_packets = 0, req_apid, req_vpid, req_spid; | |
621 int is_audio, is_video, is_sub, has_tables; | |
622 int32_t p, chosen_pid = 0; | |
23509
53d57a0ebe13
init ts_probe to 0 and probe up to TS_MAX_PROBE_SIZE if the parameter
nicodvb
parents:
23507
diff
changeset
|
623 off_t pos=0, ret = 0, init_pos, end_pos; |
10014 | 624 ES_stream_t es; |
9610 | 625 unsigned char tmp[TS_FEC_PACKET_SIZE]; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
626 ts_priv_t *priv = (ts_priv_t*) demuxer->priv; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
627 struct { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
628 char *buf; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
629 int pos; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
630 } pes_priv1[8192], *pptr; |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
631 char *tmpbuf; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
632 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
633 priv->last_pid = 8192; //invalid pid |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
634 |
11190 | 635 req_apid = param->apid; |
636 req_vpid = param->vpid; | |
637 req_spid = param->spid; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
638 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
639 has_tables = 0; |
14571
512a57bbe68d
replaced bzero() with memset(); stream_type 0x0f is AAC
nicodvb
parents:
14046
diff
changeset
|
640 memset(pes_priv1, 0, sizeof(pes_priv1)); |
11190 | 641 init_pos = stream_tell(demuxer->stream); |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
642 mp_msg(MSGT_DEMUXER, MSGL_V, "PROBING UP TO %"PRIu64", PROG: %d\n", (uint64_t) param->probe, param->prog); |
23509
53d57a0ebe13
init ts_probe to 0 and probe up to TS_MAX_PROBE_SIZE if the parameter
nicodvb
parents:
23507
diff
changeset
|
643 end_pos = init_pos + (param->probe ? param->probe : TS_MAX_PROBE_SIZE); |
24569
bc5dfd30626d
in ts_detect_streams() moved the iteration condition inside the loop
nicodvb
parents:
24424
diff
changeset
|
644 while(1) |
9610 | 645 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
646 pos = stream_tell(demuxer->stream); |
24569
bc5dfd30626d
in ts_detect_streams() moved the iteration condition inside the loop
nicodvb
parents:
24424
diff
changeset
|
647 if(pos > end_pos || demuxer->stream->eof) |
bc5dfd30626d
in ts_detect_streams() moved the iteration condition inside the loop
nicodvb
parents:
24424
diff
changeset
|
648 break; |
bc5dfd30626d
in ts_detect_streams() moved the iteration condition inside the loop
nicodvb
parents:
24424
diff
changeset
|
649 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
650 if(ts_parse(demuxer, &es, tmp, 1)) |
9610 | 651 { |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
652 //Non PES-aligned A52 audio may escape detection if PMT is not present; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
653 //in this case we try to find at least 3 A52 syncwords |
20283
385f4a815e75
fixed corner case previously mishandled: don't play an audio only stream when
nicodvb
parents:
20213
diff
changeset
|
654 if((es.type == PES_PRIVATE1) && (! audio_found) && req_apid > -2) |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
655 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
656 pptr = &pes_priv1[es.pid]; |
18474
5262ede8f2e1
when searching ac3 in unqualified pes_private1 streams there's no need to scan > 64 KB of data: frames can't be so far apart
nicodvb
parents:
18464
diff
changeset
|
657 if(pptr->pos < 64*1024) |
5262ede8f2e1
when searching ac3 in unqualified pes_private1 streams there's no need to scan > 64 KB of data: frames can't be so far apart
nicodvb
parents:
18464
diff
changeset
|
658 { |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
659 tmpbuf = (char*) realloc(pptr->buf, pptr->pos + es.size); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
660 if(tmpbuf != NULL) |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
661 { |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
662 pptr->buf = tmpbuf; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
663 memcpy(&(pptr->buf[ pptr->pos ]), es.start, es.size); |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
664 pptr->pos += es.size; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
665 if(a52_check(pptr->buf, pptr->pos) > 2) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
666 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
667 param->atype = AUDIO_A52; |
18043
97aa495df9dd
segfault fix: assign param->apid (that is the audio id found) when inexistent audio language is specified; patch by Erik Auerswald auerswal a unix-ag d uni-kl d de
nicodvb
parents:
17816
diff
changeset
|
668 param->apid = es.pid; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
669 es.type = AUDIO_A52; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
670 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
671 } |
18474
5262ede8f2e1
when searching ac3 in unqualified pes_private1 streams there's no need to scan > 64 KB of data: frames can't be so far apart
nicodvb
parents:
18464
diff
changeset
|
672 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
673 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
674 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
675 is_audio = IS_AUDIO(es.type) || ((es.type==SL_PES_STREAM) && IS_AUDIO(es.subtype)); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
676 is_video = IS_VIDEO(es.type) || ((es.type==SL_PES_STREAM) && IS_VIDEO(es.subtype)); |
11190 | 677 is_sub = ((es.type == SPU_DVD) || (es.type == SPU_DVB)); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
678 |
11190 | 679 |
680 if((! is_audio) && (! is_video) && (! is_sub)) | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
681 continue; |
20283
385f4a815e75
fixed corner case previously mishandled: don't play an audio only stream when
nicodvb
parents:
20213
diff
changeset
|
682 if(is_audio && req_apid==-2) |
385f4a815e75
fixed corner case previously mishandled: don't play an audio only stream when
nicodvb
parents:
20213
diff
changeset
|
683 continue; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
684 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
685 if(is_video) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
686 { |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
687 mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_VIDEO_ID=%d\n", es.pid); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
688 chosen_pid = (req_vpid == es.pid); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
689 if((! chosen_pid) && (req_vpid > 0)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
690 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
691 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
692 else if(is_audio) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
693 { |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
694 mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_AUDIO_ID=%d\n", es.pid); |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
18043
diff
changeset
|
695 if (es.lang[0] > 0) |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
696 mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_AID_%d_LANG=%s\n", es.pid, es.lang); |
11190 | 697 if(req_apid > 0) |
698 { | |
699 chosen_pid = (req_apid == es.pid); | |
700 if(! chosen_pid) | |
701 continue; | |
702 } | |
23835 | 703 else if(param->alang[0] > 0 && es.lang[0] > 0) |
11190 | 704 { |
705 if(pid_match_lang(priv, es.pid, param->alang) == -1) | |
706 continue; | |
707 | |
708 chosen_pid = 1; | |
709 param->apid = req_apid = es.pid; | |
710 } | |
711 } | |
712 else if(is_sub) | |
713 { | |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
714 mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_SUBTITLE_ID=%d\n", es.pid); |
18237
4231482179b6
Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents:
18043
diff
changeset
|
715 if (es.lang[0] > 0) |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
716 mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_SID_%d_LANG=%s\n", es.pid, es.lang); |
11190 | 717 chosen_pid = (req_spid == es.pid); |
718 if((! chosen_pid) && (req_spid > 0)) | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
719 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
720 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
721 |
11190 | 722 if(req_apid < 0 && (param->alang[0] == 0) && req_vpid < 0 && req_spid < 0) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
723 chosen_pid = 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
724 |
11190 | 725 if((ret == 0) && chosen_pid) |
726 { | |
727 ret = stream_tell(demuxer->stream); | |
728 } | |
729 | |
730 p = progid_for_pid(priv, es.pid, param->prog); | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
731 if(p != -1) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
732 has_tables++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
733 |
11190 | 734 if((param->prog == 0) && (p != -1)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
735 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
736 if(chosen_pid) |
11190 | 737 param->prog = p; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
738 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
739 |
11190 | 740 if((param->prog > 0) && (param->prog != p)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
741 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
742 if(audio_found) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
743 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
744 if(is_video && (req_vpid == es.pid)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
745 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
746 param->vtype = IS_VIDEO(es.type) ? es.type : es.subtype; |
11190 | 747 param->vpid = es.pid; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
748 video_found = 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
749 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
750 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
751 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
752 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
753 if(video_found) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
754 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
755 if(is_audio && (req_apid == es.pid)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
756 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
757 param->atype = IS_AUDIO(es.type) ? es.type : es.subtype; |
11190 | 758 param->apid = es.pid; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
759 audio_found = 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
760 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
761 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
762 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
763 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
764 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
765 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
766 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
767 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
768 |
11190 | 769 mp_msg(MSGT_DEMUXER, MSGL_DBG2, "TYPE: %x, PID: %d, PROG FOUND: %d\n", es.type, es.pid, param->prog); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
770 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
771 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
772 if(is_video) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
773 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
774 if((req_vpid == -1) || (req_vpid == es.pid)) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
775 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
776 param->vtype = IS_VIDEO(es.type) ? es.type : es.subtype; |
11190 | 777 param->vpid = es.pid; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
778 video_found = 1; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
779 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
780 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
781 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
782 |
23509
53d57a0ebe13
init ts_probe to 0 and probe up to TS_MAX_PROBE_SIZE if the parameter
nicodvb
parents:
23507
diff
changeset
|
783 if(((req_vpid == -2) || (num_packets >= NUM_CONSECUTIVE_AUDIO_PACKETS)) && audio_found && !param->probe) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
784 { |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
785 //novideo or we have at least 348 audio packets (64 KB) without video (TS with audio only) |
11190 | 786 param->vtype = 0; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
787 break; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
788 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
789 |
11190 | 790 if(is_sub) |
791 { | |
792 if((req_spid == -1) || (req_spid == es.pid)) | |
793 { | |
794 param->stype = es.type; | |
795 param->spid = es.pid; | |
796 sub_found = 1; | |
797 } | |
798 } | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
799 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
800 if(is_audio) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
801 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
802 if((req_apid == -1) || (req_apid == es.pid)) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
803 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
804 param->atype = IS_AUDIO(es.type) ? es.type : es.subtype; |
11190 | 805 param->apid = es.pid; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
806 audio_found = 1; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
807 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
808 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
809 |
11190 | 810 if(audio_found && (param->apid == es.pid) && (! video_found)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
811 num_packets++; |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
812 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
813 if((has_tables==0) && (video_found && audio_found) && (pos >= 1000000)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
814 break; |
9610 | 815 } |
816 } | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
817 |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
818 for(i=0; i<8192; i++) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
819 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
820 if(pes_priv1[i].buf != NULL) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
821 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
822 free(pes_priv1[i].buf); |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
823 pes_priv1[i].buf = NULL; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
824 pes_priv1[i].pos = 0; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
825 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
826 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
827 |
9610 | 828 if(video_found) |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
829 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
830 if(param->vtype == VIDEO_MPEG1) |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
831 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO MPEG1(pid=%d) ", param->vpid); |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
832 else if(param->vtype == VIDEO_MPEG2) |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
833 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO MPEG2(pid=%d) ", param->vpid); |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
834 else if(param->vtype == VIDEO_MPEG4) |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
835 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO MPEG4(pid=%d) ", param->vpid); |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
836 else if(param->vtype == VIDEO_H264) |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
837 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO H264(pid=%d) ", param->vpid); |
22162 | 838 else if(param->vtype == VIDEO_VC1) |
839 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO VC1(pid=%d) ", param->vpid); | |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
840 else if(param->vtype == VIDEO_AVC) |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
841 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO AVC(NAL-H264, pid=%d) ", param->vpid); |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
842 } |
9610 | 843 else |
844 { | |
11190 | 845 param->vtype = UNKNOWN; |
846 //WE DIDN'T MATCH ANY VIDEO STREAM | |
847 mp_msg(MSGT_DEMUXER, MSGL_INFO, "NO VIDEO! "); | |
9610 | 848 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
849 |
11190 | 850 if(param->atype == AUDIO_MP2) |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
851 mp_msg(MSGT_DEMUXER, MSGL_INFO, "AUDIO MPA(pid=%d)", param->apid); |
11190 | 852 else if(param->atype == AUDIO_A52) |
853 mp_msg(MSGT_DEMUXER, MSGL_INFO, "AUDIO A52(pid=%d)", param->apid); | |
18565
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
854 else if(param->atype == AUDIO_DTS) |
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
855 mp_msg(MSGT_DEMUXER, MSGL_INFO, "AUDIO DTS(pid=%d)", param->apid); |
11190 | 856 else if(param->atype == AUDIO_LPCM_BE) |
857 mp_msg(MSGT_DEMUXER, MSGL_INFO, "AUDIO LPCM(pid=%d)", param->apid); | |
858 else if(param->atype == AUDIO_AAC) | |
859 mp_msg(MSGT_DEMUXER, MSGL_INFO, "AUDIO AAC(pid=%d)", param->apid); | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
860 else |
9610 | 861 { |
11190 | 862 audio_found = 0; |
863 param->atype = UNKNOWN; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
864 //WE DIDN'T MATCH ANY AUDIO STREAM, SO WE FORCE THE DEMUXER TO IGNORE AUDIO |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
865 mp_msg(MSGT_DEMUXER, MSGL_INFO, "NO AUDIO! "); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
866 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
867 |
11190 | 868 if(param->stype == SPU_DVD || param->stype == SPU_DVB) |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
869 mp_msg(MSGT_DEMUXER, MSGL_INFO, " SUB %s(pid=%d) ", (param->stype==SPU_DVD ? "DVD" : "DVB"), param->spid); |
11190 | 870 else |
871 { | |
872 param->stype = UNKNOWN; | |
873 mp_msg(MSGT_DEMUXER, MSGL_INFO, " NO SUBS (yet)! "); | |
874 } | |
875 | |
876 if(video_found || audio_found) | |
877 { | |
878 if(demuxer->stream->eof && (ret == 0)) | |
879 ret = init_pos; | |
880 mp_msg(MSGT_DEMUXER, MSGL_INFO, " PROGRAM N. %d\n", param->prog); | |
881 } | |
882 else | |
883 mp_msg(MSGT_DEMUXER, MSGL_INFO, "\n"); | |
884 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
885 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
886 for(i=0; i<8192; i++) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
887 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
888 if(priv->ts.pids[i] != NULL) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
889 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
890 priv->ts.pids[i]->payload_size = 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
891 priv->ts.pids[i]->pts = priv->ts.pids[i]->last_pts = 0; |
11190 | 892 priv->ts.pids[i]->last_cc = -1; |
14981
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
893 priv->ts.pids[i]->is_synced = 0; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
894 } |
9610 | 895 } |
11190 | 896 |
897 return ret; | |
9610 | 898 } |
899 | |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
900 static int parse_avc_sps(uint8_t *buf, int len, int *w, int *h) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
901 { |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
902 int sps, sps_len; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
903 unsigned char *ptr; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
904 mp_mpeg_header_t picture; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
905 if(len < 6) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
906 return 0; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
907 sps = buf[5] & 0x1f; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
908 if(!sps) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
909 return 0; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
910 sps_len = (buf[6] << 8) | buf[7]; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
911 if(!sps_len || (sps_len > len - 8)) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
912 return 0; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
913 ptr = &(buf[8]); |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
914 picture.display_picture_width = picture.display_picture_height = 0; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
915 h264_parse_sps(&picture, ptr, len - 8); |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
916 if(!picture.display_picture_width || !picture.display_picture_height) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
917 return 0; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
918 *w = picture.display_picture_width; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
919 *h = picture.display_picture_height; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
920 return 1; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
921 } |
9610 | 922 |
16175 | 923 static demuxer_t *demux_open_ts(demuxer_t * demuxer) |
10014 | 924 { |
925 int i; | |
926 uint8_t packet_size; | |
927 sh_video_t *sh_video; | |
928 sh_audio_t *sh_audio; | |
11190 | 929 off_t start_pos; |
930 tsdemux_init_t params; | |
10014 | 931 ts_priv_t * priv = (ts_priv_t*) demuxer->priv; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
932 |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
933 mp_msg(MSGT_DEMUX, MSGL_V, "DEMUX OPEN, AUDIO_ID: %d, VIDEO_ID: %d, SUBTITLE_ID: %d,\n", |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
934 demuxer->audio->id, demuxer->video->id, demuxer->sub->id); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
935 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
936 |
10014 | 937 demuxer->type= DEMUXER_TYPE_MPEG_TS; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
938 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
939 |
10014 | 940 stream_reset(demuxer->stream); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
941 |
10014 | 942 packet_size = ts_check_file(demuxer); |
943 if(!packet_size) | |
944 return NULL; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
945 |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
946 priv = calloc(1, sizeof(ts_priv_t)); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
947 if(priv == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
948 { |
11190 | 949 mp_msg(MSGT_DEMUX, MSGL_FATAL, "DEMUX_OPEN_TS, couldn't allocate enough memory for ts->priv, exit\n"); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
950 return NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
951 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
952 |
10014 | 953 for(i=0; i < 8192; i++) |
18688 | 954 { |
10014 | 955 priv->ts.pids[i] = NULL; |
18688 | 956 priv->ts.streams[i].id = -3; |
957 } | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
958 priv->pat.progs = NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
959 priv->pat.progs_cnt = 0; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
960 priv->pat.section.buffer = NULL; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
961 priv->pat.section.buffer_len = 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
962 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
963 priv->pmt = NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
964 priv->pmt_cnt = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
965 |
11190 | 966 priv->keep_broken = ts_keep_broken; |
10014 | 967 priv->ts.packet_size = packet_size; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
968 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
969 |
10014 | 970 demuxer->priv = priv; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
971 if(demuxer->stream->type != STREAMTYPE_FILE) |
11190 | 972 demuxer->seekable = 1; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
973 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
974 demuxer->seekable = 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
975 |
11190 | 976 |
977 params.atype = params.vtype = params.stype = UNKNOWN; | |
978 params.apid = demuxer->audio->id; | |
979 params.vpid = demuxer->video->id; | |
980 params.spid = demuxer->sub->id; | |
981 params.prog = ts_prog; | |
982 params.probe = ts_probe; | |
983 | |
984 if(dvdsub_lang != NULL) | |
985 { | |
986 strncpy(params.slang, dvdsub_lang, 3); | |
987 params.slang[3] = 0; | |
988 } | |
989 else | |
990 memset(params.slang, 0, 4); | |
991 | |
992 if(audio_lang != NULL) | |
993 { | |
994 strncpy(params.alang, audio_lang, 3); | |
995 params.alang[3] = 0; | |
996 } | |
997 else | |
998 memset(params.alang, 0, 4); | |
999 | |
1000 start_pos = ts_detect_streams(demuxer, ¶ms); | |
1001 | |
1002 demuxer->sub->id = params.spid; | |
1003 priv->prog = params.prog; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1004 |
11190 | 1005 if(params.vtype != UNKNOWN) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1006 { |
21929
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
1007 ts_add_stream(demuxer, priv->ts.pids[params.vpid]); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
1008 sh_video = priv->ts.streams[params.vpid].sh; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
1009 demuxer->video->id = priv->ts.streams[params.vpid].id; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1010 sh_video->ds = demuxer->video; |
11190 | 1011 sh_video->format = params.vtype; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1012 demuxer->video->sh = sh_video; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1013 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1014 |
11190 | 1015 if(params.atype != UNKNOWN) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1016 { |
22048
5e843ca8c6a5
fix audio type when ts_detect_streams detects that a private1 stream is actually ac3
nicodvb
parents:
21929
diff
changeset
|
1017 ES_stream_t *es = priv->ts.pids[params.apid]; |
5e843ca8c6a5
fix audio type when ts_detect_streams detects that a private1 stream is actually ac3
nicodvb
parents:
21929
diff
changeset
|
1018 |
22049
cb80d1bb7ca8
5l, check that the codec type detected by ts_detect_streams() is actually audio before fixing it in the array
nicodvb
parents:
22048
diff
changeset
|
1019 if(!IS_AUDIO(es->type) && !IS_AUDIO(es->subtype) && IS_AUDIO(params.atype)) es->subtype = params.atype; |
21929
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
1020 ts_add_stream(demuxer, priv->ts.pids[params.apid]); |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
1021 sh_audio = priv->ts.streams[params.apid].sh; |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
1022 demuxer->audio->id = priv->ts.streams[params.apid].id; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1023 sh_audio->ds = demuxer->audio; |
11190 | 1024 sh_audio->format = params.atype; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1025 demuxer->audio->sh = sh_audio; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1026 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1027 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1028 |
18714
8fc996a3b4e1
reduced standard verbosity and changed output messages to more uniform descriptions
nicodvb
parents:
18688
diff
changeset
|
1029 mp_msg(MSGT_DEMUXER,MSGL_V, "Opened TS demuxer, audio: %x(pid %d), video: %x(pid %d)...POS=%"PRIu64", PROBE=%"PRIu64"\n", params.atype, demuxer->audio->id, params.vtype, demuxer->video->id, (uint64_t) start_pos, ts_probe); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1030 |
10014 | 1031 |
11190 | 1032 start_pos = (start_pos <= priv->ts.packet_size ? 0 : start_pos - priv->ts.packet_size); |
1033 demuxer->movi_start = start_pos; | |
1034 stream_reset(demuxer->stream); | |
1035 stream_seek(demuxer->stream, start_pos); //IF IT'S FROM A PIPE IT WILL FAIL, BUT WHO CARES? | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1036 |
11190 | 1037 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1038 priv->last_pid = 8192; //invalid pid |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1039 |
11190 | 1040 for(i = 0; i < 3; i++) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1041 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1042 priv->fifo[i].pack = NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1043 priv->fifo[i].offset = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1044 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1045 priv->fifo[0].ds = demuxer->audio; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1046 priv->fifo[1].ds = demuxer->video; |
11190 | 1047 priv->fifo[2].ds = demuxer->sub; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1048 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1049 priv->fifo[0].buffer_size = 1536; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1050 priv->fifo[1].buffer_size = 32767; |
11190 | 1051 priv->fifo[2].buffer_size = 32767; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1052 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1053 priv->pat.section.buffer_len = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1054 for(i = 0; i < priv->pmt_cnt; i++) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1055 priv->pmt[i].section.buffer_len = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1056 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1057 demuxer->filepos = stream_tell(demuxer->stream); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1058 return demuxer; |
10014 | 1059 } |
1060 | |
16175 | 1061 static void demux_close_ts(demuxer_t * demuxer) |
9610 | 1062 { |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1063 uint16_t i; |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1064 ts_priv_t *priv = (ts_priv_t*) demuxer->priv; |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1065 |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1066 if(priv) |
9610 | 1067 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1068 if(priv->pat.section.buffer) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1069 free(priv->pat.section.buffer); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1070 if(priv->pat.progs) |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1071 free(priv->pat.progs); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1072 |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1073 if(priv->pmt) |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1074 { |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1075 for(i = 0; i < priv->pmt_cnt; i++) |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1076 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1077 if(priv->pmt[i].section.buffer) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1078 free(priv->pmt[i].section.buffer); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1079 if(priv->pmt[i].es) |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1080 free(priv->pmt[i].es); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1081 } |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1082 free(priv->pmt); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1083 } |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1084 free(priv); |
9610 | 1085 } |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1086 demuxer->priv=NULL; |
9610 | 1087 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1088 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1089 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1090 extern unsigned char mp_getbits(unsigned char*, unsigned int, unsigned char); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1091 #define getbits mp_getbits |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1092 |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1093 static int mp4_parse_sl_packet(pmt_t *pmt, uint8_t *buf, uint16_t packet_len, int pid, ES_stream_t *pes_es) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1094 { |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1095 int i, n, m, mp4_es_id = -1; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1096 uint64_t v = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1097 uint32_t pl_size = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1098 int deg_flag = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1099 mp4_es_descr_t *es = NULL; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1100 mp4_sl_config_t *sl = NULL; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1101 uint8_t au_start = 0, au_end = 0, rap_flag = 0, ocr_flag = 0, padding = 0, padding_bits = 0, idle = 0; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1102 |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1103 pes_es->is_synced = 0; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1104 mp_msg(MSGT_DEMUXER,MSGL_V, "mp4_parse_sl_packet, pid: %d, pmt: %pm, packet_len: %d\n", pid, pmt, packet_len); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1105 if(! pmt || !packet_len) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1106 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1107 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1108 for(i = 0; i < pmt->es_cnt; i++) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1109 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1110 if(pmt->es[i].pid == pid) |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1111 mp4_es_id = pmt->es[i].mp4_es_id; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1112 } |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1113 if(mp4_es_id < 0) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1114 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1115 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1116 for(i = 0; i < pmt->mp4es_cnt; i++) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1117 { |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1118 if(pmt->mp4es[i].id == mp4_es_id) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1119 es = &(pmt->mp4es[i]); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1120 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1121 if(! es) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1122 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1123 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1124 pes_es->subtype = es->decoder.object_type; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1125 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1126 sl = &(es->sl); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1127 if(!sl) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1128 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1129 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1130 //now es is the complete es_descriptor of out mp4 ES stream |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1131 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "ID: %d, FLAGS: 0x%x, subtype: %x\n", es->id, sl->flags, pes_es->subtype); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1132 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1133 n = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1134 if(sl->au_start) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1135 pes_es->sl.au_start = au_start = getbits(buf, n++, 1); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1136 else |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1137 pes_es->sl.au_start = (pes_es->sl.last_au_end ? 1 : 0); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1138 if(sl->au_end) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1139 pes_es->sl.au_end = au_end = getbits(buf, n++, 1); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1140 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1141 if(!sl->au_start && !sl->au_end) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1142 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1143 pes_es->sl.au_start = pes_es->sl.au_end = au_start = au_end = 1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1144 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1145 pes_es->sl.last_au_end = pes_es->sl.au_end; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1146 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1147 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1148 if(sl->ocr_len > 0) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1149 ocr_flag = getbits(buf, n++, 1); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1150 if(sl->idle) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1151 idle = getbits(buf, n++, 1); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1152 if(sl->padding) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1153 padding = getbits(buf, n++, 1); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1154 if(padding) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1155 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1156 padding_bits = getbits(buf, n, 3); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1157 n += 3; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1158 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1159 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1160 if(idle || (padding && !padding_bits)) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1161 { |
14981
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
1162 pes_es->payload_size = 0; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1163 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1164 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1165 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1166 //(! idle && (!padding || padding_bits != 0)) is true |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1167 n += sl->packet_seqnum_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1168 if(sl->degr_len) |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1169 deg_flag = getbits(buf, n++, 1); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1170 if(deg_flag) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1171 n += sl->degr_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1172 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1173 if(ocr_flag) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1174 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1175 n += sl->ocr_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1176 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "OCR: %d bits\n", sl->ocr_len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1177 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1178 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1179 if(packet_len * 8 <= n) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1180 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1181 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1182 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "\nAU_START: %d, AU_END: %d\n", au_start, au_end); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1183 if(au_start) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1184 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1185 int dts_flag = 0, cts_flag = 0, ib_flag = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1186 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1187 if(sl->random_accesspoint) |
14981
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
1188 rap_flag = getbits(buf, n++, 1); |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1189 |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1190 //check commented because it seems it's rarely used, and we need this flag set in case of au_start |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1191 //the decoder will eventually discard the payload if it can't decode it |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1192 //if(rap_flag || sl->random_accesspoint_only) |
14981
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
1193 pes_es->is_synced = 1; |
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
1194 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1195 n += sl->au_seqnum_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1196 if(packet_len * 8 <= n+8) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1197 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1198 if(sl->use_ts) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1199 { |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1200 dts_flag = getbits(buf, n++, 1); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1201 cts_flag = getbits(buf, n++, 1); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1202 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1203 if(sl->instant_bitrate_len) |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1204 ib_flag = getbits(buf, n++, 1); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1205 if(packet_len * 8 <= n+8) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1206 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1207 if(dts_flag && (sl->ts_len > 0)) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1208 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1209 n += sl->ts_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1210 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "DTS: %d bits\n", sl->ts_len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1211 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1212 if(packet_len * 8 <= n+8) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1213 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1214 if(cts_flag && (sl->ts_len > 0)) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1215 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1216 int i = 0, m; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1217 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1218 while(i < sl->ts_len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1219 { |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21421
diff
changeset
|
1220 m = FFMIN(8, sl->ts_len - i); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1221 v |= getbits(buf, n, m); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1222 if(sl->ts_len - i > 8) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1223 v <<= 8; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1224 i += m; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1225 n += m; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1226 if(packet_len * 8 <= n+8) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1227 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1228 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1229 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1230 pes_es->pts = (float) v / (float) sl->ts_resolution; |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16292
diff
changeset
|
1231 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "CTS: %d bits, value: %"PRIu64"/%d = %.3f\n", sl->ts_len, v, sl->ts_resolution, pes_es->pts); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1232 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1233 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1234 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1235 i = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1236 pl_size = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1237 while(i < sl->au_len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1238 { |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21421
diff
changeset
|
1239 m = FFMIN(8, sl->au_len - i); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1240 pl_size |= getbits(buf, n, m); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1241 if(sl->au_len - i > 8) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1242 pl_size <<= 8; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1243 i += m; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1244 n += m; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1245 if(packet_len * 8 <= n+8) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1246 return -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1247 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1248 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "AU_LEN: %u (%d bits)\n", pl_size, sl->au_len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1249 if(ib_flag) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1250 n += sl->instant_bitrate_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1251 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1252 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1253 m = (n+7)/8; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1254 if(0 < pl_size && pl_size < pes_es->payload_size) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1255 pes_es->payload_size = pl_size; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1256 |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1257 mp_msg(MSGT_DEMUXER,MSGL_V, "mp4_parse_sl_packet, n=%d, m=%d, size from pes hdr: %u, sl hdr size: %u, RAP FLAGS: %d/%d\n", |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1258 n, m, pes_es->payload_size, pl_size, (int) rap_flag, (int) sl->random_accesspoint_only); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1259 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1260 return m; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1261 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1262 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1263 static int pes_parse2(unsigned char *buf, uint16_t packet_len, ES_stream_t *es, int32_t type_from_pmt, pmt_t *pmt, int pid) |
9610 | 1264 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1265 unsigned char *p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1266 uint32_t header_len; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1267 int64_t pts; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1268 uint32_t stream_id; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1269 uint32_t pkt_len, pes_is_aligned; |
9610 | 1270 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1271 //Here we are always at the start of a PES packet |
11190 | 1272 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2(%p, %d): \n", buf, (uint32_t) packet_len); |
9610 | 1273 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1274 if(packet_len == 0 || packet_len > 184) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1275 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1276 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2, BUFFER LEN IS TOO SMALL OR TOO BIG: %d EXIT\n", packet_len); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1277 return 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1278 } |
9610 | 1279 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1280 p = buf; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1281 pkt_len = packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1282 |
9610 | 1283 |
10014 | 1284 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2: HEADER %02x %02x %02x %02x\n", p[0], p[1], p[2], p[3]); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1285 if (p[0] || p[1] || (p[2] != 1)) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1286 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1287 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2: error HEADER %02x %02x %02x (should be 0x000001) \n", p[0], p[1], p[2]); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1288 return 0 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1289 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1290 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1291 packet_len -= 6; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1292 if(packet_len==0) |
11190 | 1293 { |
1294 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2: packet too short: %d, exit\n", packet_len); | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1295 return 0; |
11190 | 1296 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1297 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1298 es->payload_size = (p[4] << 8 | p[5]); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1299 pes_is_aligned = (p[6] & 4); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1300 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1301 stream_id = p[3]; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1302 |
9610 | 1303 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1304 if (p[7] & 0x80) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1305 { /* pts available */ |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1306 pts = (int64_t)(p[9] & 0x0E) << 29 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1307 pts |= p[10] << 22 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1308 pts |= (p[11] & 0xFE) << 14 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1309 pts |= p[12] << 7 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1310 pts |= (p[13] & 0xFE) >> 1 ; |
9610 | 1311 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1312 es->pts = pts / 90000.0f; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1313 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1314 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1315 es->pts = 0.0f; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1316 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1317 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1318 header_len = p[8]; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1319 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1320 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1321 if (header_len + 9 > pkt_len) //9 are the bytes read up to the header_length field |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1322 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1323 mp_msg(MSGT_DEMUX, MSGL_DBG2, "demux_ts: illegal value for PES_header_data_length (0x%02x)\n", header_len); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1324 return 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1325 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1326 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1327 p += header_len + 9; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1328 packet_len -= header_len + 3; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1329 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1330 if(es->payload_size) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1331 es->payload_size -= header_len + 3; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1332 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1333 |
20462 | 1334 es->is_synced = 1; //only for SL streams we have to make sure it's really true, see below |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1335 if (stream_id == 0xbd) |
9610 | 1336 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1337 mp_msg(MSGT_DEMUX, MSGL_DBG3, "pes_parse2: audio buf = %02X %02X %02X %02X %02X %02X %02X %02X, 80: %d\n", |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1338 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[0] & 0x80); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1339 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1340 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1341 /* |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1342 * we check the descriptor tag first because some stations |
11190 | 1343 * do not include any of the A52 header info in their audio tracks |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1344 * these "raw" streams may begin with a byte that looks like a stream type. |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1345 */ |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1346 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1347 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1348 if( |
11190 | 1349 (type_from_pmt == AUDIO_A52) || /* A52 - raw */ |
1350 (p[0] == 0x0B && p[1] == 0x77) /* A52 - syncword */ | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1351 ) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1352 { |
11190 | 1353 mp_msg(MSGT_DEMUX, MSGL_DBG2, "A52 RAW OR SYNCWORD\n"); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1354 es->start = p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1355 es->size = packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1356 es->type = AUDIO_A52; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1357 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1358 |
11190 | 1359 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1360 } |
11190 | 1361 /* SPU SUBS */ |
1362 else if(type_from_pmt == SPU_DVB || | |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1363 ((p[0] == 0x20) && pes_is_aligned)) // && p[1] == 0x00)) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1364 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1365 es->start = p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1366 es->size = packet_len; |
11190 | 1367 es->type = SPU_DVB; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1368 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1369 |
11190 | 1370 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1371 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1372 else if (pes_is_aligned && ((p[0] & 0xE0) == 0x20)) //SPU_DVD |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1373 { |
11190 | 1374 //DVD SUBS |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1375 es->start = p+1; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1376 es->size = packet_len-1; |
11190 | 1377 es->type = SPU_DVD; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1378 es->payload_size -= packet_len; |
9610 | 1379 |
11190 | 1380 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1381 } |
18460
6853dc0411c1
search ac3 in dvd substream only if pes_aligned flag is set in the pes headers, otherwise false positives are likely to occur
nicodvb
parents:
18237
diff
changeset
|
1382 else if (pes_is_aligned && (p[0] & 0xF8) == 0x80) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1383 { |
11190 | 1384 mp_msg(MSGT_DEMUX, MSGL_DBG2, "A52 WITH HEADER\n"); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1385 es->start = p+4; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1386 es->size = packet_len - 4; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1387 es->type = AUDIO_A52; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1388 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1389 |
11190 | 1390 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1391 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1392 else if (pes_is_aligned && ((p[0]&0xf0) == 0xa0)) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1393 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1394 int pcm_offset; |
9610 | 1395 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1396 for (pcm_offset=0; ++pcm_offset < packet_len-1 ; ) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1397 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1398 if (p[pcm_offset] == 0x01 && p[pcm_offset+1] == 0x80) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1399 { /* START */ |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1400 pcm_offset += 2; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1401 break; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1402 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1403 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1404 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1405 es->start = p + pcm_offset; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1406 es->size = packet_len - pcm_offset; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1407 es->type = AUDIO_LPCM_BE; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1408 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1409 |
11190 | 1410 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1411 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1412 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1413 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1414 mp_msg(MSGT_DEMUX, MSGL_DBG2, "PES_PRIVATE1\n"); |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1415 es->start = p; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1416 es->size = packet_len; |
18564
c56569da9230
fixed wrong assignment of stream type in generic PES_PRIVATE1 streams (didn't respect the type qualified in the PMT)
nicodvb
parents:
18563
diff
changeset
|
1417 es->type = (type_from_pmt == UNKNOWN ? PES_PRIVATE1 : type_from_pmt); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1418 es->payload_size -= packet_len; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1419 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1420 return 1; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1421 } |
9610 | 1422 } |
22162 | 1423 else if(((stream_id >= 0xe0) && (stream_id <= 0xef)) || (stream_id == 0xfd && type_from_pmt != UNKNOWN)) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1424 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1425 es->start = p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1426 es->size = packet_len; |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
1427 if(type_from_pmt != UNKNOWN) |
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
1428 es->type = type_from_pmt; |
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
1429 else |
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
1430 es->type = VIDEO_MPEG2; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1431 if(es->payload_size) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1432 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1433 |
11190 | 1434 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2: M2V size %d\n", es->size); |
1435 return 1; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1436 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1437 else if ((stream_id == 0xfa)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1438 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1439 int l; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1440 |
20462 | 1441 es->is_synced = 0; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1442 if(type_from_pmt != UNKNOWN) //MP4 A/V or SL |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1443 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1444 es->start = p; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1445 es->size = packet_len; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1446 es->type = type_from_pmt; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1447 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1448 if(type_from_pmt == SL_PES_STREAM) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1449 { |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1450 //if(pes_is_aligned) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1451 //{ |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1452 l = mp4_parse_sl_packet(pmt, p, packet_len, pid, es); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1453 mp_msg(MSGT_DEMUX, MSGL_DBG2, "L=%d, TYPE=%x\n", l, type_from_pmt); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1454 if(l < 0) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1455 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1456 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2: couldn't parse SL header, passing along full PES payload\n"); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1457 l = 0; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1458 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1459 //} |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1460 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1461 es->start += l; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1462 es->size -= l; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1463 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1464 |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1465 if(es->payload_size) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1466 es->payload_size -= packet_len; |
11190 | 1467 return 1; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1468 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1469 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1470 else if ((stream_id & 0xe0) == 0xc0) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1471 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1472 es->start = p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1473 es->size = packet_len; |
11190 | 1474 |
19537
45e1650f9ad5
don't try to autodetect aac in pes packets (the detection is prone to give wrong results); use the stream_type from the PMT instead
nicodvb
parents:
18714
diff
changeset
|
1475 if(type_from_pmt != UNKNOWN) |
45e1650f9ad5
don't try to autodetect aac in pes packets (the detection is prone to give wrong results); use the stream_type from the PMT instead
nicodvb
parents:
18714
diff
changeset
|
1476 es->type = type_from_pmt; |
11190 | 1477 else |
1478 es->type = AUDIO_MP2; | |
1479 | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1480 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1481 |
11190 | 1482 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1483 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1484 else if (type_from_pmt != -1) //as a last resort here we trust the PMT, if present |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1485 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1486 es->start = p; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1487 es->size = packet_len; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1488 es->type = type_from_pmt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1489 es->payload_size -= packet_len; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1490 |
11190 | 1491 return 1; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1492 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1493 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1494 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1495 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2: unknown packet, id: %x\n", stream_id); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1496 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1497 |
20462 | 1498 es->is_synced = 0; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1499 return 0; |
9610 | 1500 } |
1501 | |
1502 | |
1503 | |
1504 | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1505 static int ts_sync(stream_t *stream) |
9610 | 1506 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1507 int c=0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1508 |
22050 | 1509 mp_msg(MSGT_DEMUX, MSGL_DBG3, "TS_SYNC \n"); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1510 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1511 while(((c=stream_read_char(stream)) != 0x47) && ! stream->eof); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1512 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1513 if(c == 0x47) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1514 return c; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1515 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1516 return 0; |
9610 | 1517 } |
1518 | |
1519 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1520 static void ts_dump_streams(ts_priv_t *priv) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1521 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1522 int i; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1523 |
11190 | 1524 for(i = 0; i < 3; i++) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1525 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1526 if((priv->fifo[i].pack != NULL) && (priv->fifo[i].offset != 0)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1527 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1528 resize_demux_packet(priv->fifo[i].pack, priv->fifo[i].offset); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1529 ds_add_packet(priv->fifo[i].ds, priv->fifo[i].pack); |
11190 | 1530 priv->fifo[i].offset = 0; |
1531 priv->fifo[i].pack = NULL; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1532 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1533 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1534 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1535 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1536 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1537 static inline int32_t prog_idx_in_pat(ts_priv_t *priv, uint16_t progid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1538 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1539 int x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1540 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1541 if(priv->pat.progs == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1542 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1543 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1544 for(x = 0; x < priv->pat.progs_cnt; x++) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1545 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1546 if(priv->pat.progs[x].id == progid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1547 return x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1548 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1549 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1550 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1551 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1552 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1553 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1554 static inline int32_t prog_id_in_pat(ts_priv_t *priv, uint16_t pid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1555 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1556 int x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1557 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1558 if(priv->pat.progs == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1559 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1560 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1561 for(x = 0; x < priv->pat.progs_cnt; x++) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1562 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1563 if(priv->pat.progs[x].pmt_pid == pid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1564 return priv->pat.progs[x].id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1565 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1566 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1567 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1568 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1569 |
16934
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
1570 static int collect_section(ts_section_t *section, int is_start, unsigned char *buff, int size) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1571 { |
16934
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
1572 uint8_t *ptr; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1573 uint16_t tlen; |
16934
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
1574 int skip, tid; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1575 |
16934
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
1576 mp_msg(MSGT_DEMUX, MSGL_V, "COLLECT_SECTION, start: %d, size: %d, collected: %d\n", is_start, size, section->buffer_len); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1577 if(! is_start && !section->buffer_len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1578 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1579 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1580 if(is_start) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1581 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1582 if(! section->buffer) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1583 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1584 section->buffer = (uint8_t*) malloc(4096+256); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1585 if(section->buffer == NULL) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1586 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1587 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1588 section->buffer_len = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1589 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1590 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1591 if(size + section->buffer_len > 4096+256) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1592 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1593 mp_msg(MSGT_DEMUX, MSGL_V, "COLLECT_SECTION, excessive len: %d + %d\n", section->buffer_len, size); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1594 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1595 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1596 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1597 memcpy(&(section->buffer[section->buffer_len]), buff, size); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1598 section->buffer_len += size; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1599 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1600 if(section->buffer_len < 3) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1601 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1602 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1603 skip = section->buffer[0]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1604 if(skip + 4 > section->buffer_len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1605 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1606 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1607 ptr = &(section->buffer[skip + 1]); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1608 tid = ptr[0]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1609 tlen = ((ptr[1] & 0x0f) << 8) | ptr[2]; |
16934
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
1610 mp_msg(MSGT_DEMUX, MSGL_V, "SKIP: %d+1, TID: %d, TLEN: %d, COLLECTED: %d\n", skip, tid, tlen, section->buffer_len); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1611 if(section->buffer_len < (skip+1+3+tlen)) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1612 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1613 mp_msg(MSGT_DEMUX, MSGL_DBG2, "DATA IS NOT ENOUGH, NEXT TIME\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1614 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1615 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1616 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1617 return skip+1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1618 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1619 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1620 static int parse_pat(ts_priv_t * priv, int is_start, unsigned char *buff, int size) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1621 { |
16934
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
1622 int skip; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1623 unsigned char *ptr; |
11190 | 1624 unsigned char *base; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1625 int entries, i; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1626 uint16_t progid; |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1627 struct pat_progs_t *tmp; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1628 ts_section_t *section; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1629 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1630 section = &(priv->pat.section); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1631 skip = collect_section(section, is_start, buff, size); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1632 if(! skip) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1633 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1634 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1635 ptr = &(section->buffer[skip]); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1636 //PARSING |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1637 priv->pat.table_id = ptr[0]; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1638 if(priv->pat.table_id != 0) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1639 return 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1640 priv->pat.ssi = (ptr[1] >> 7) & 0x1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1641 priv->pat.curr_next = ptr[5] & 0x01; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1642 priv->pat.ts_id = (ptr[3] << 8 ) | ptr[4]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1643 priv->pat.version_number = (ptr[5] >> 1) & 0x1F; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1644 priv->pat.section_length = ((ptr[1] & 0x03) << 8 ) | ptr[2]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1645 priv->pat.section_number = ptr[6]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1646 priv->pat.last_section_number = ptr[7]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1647 |
11190 | 1648 //check_crc32(0xFFFFFFFFL, ptr, priv->pat.buffer_len - 4, &ptr[priv->pat.buffer_len - 4]); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1649 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_PAT: section_len: %d, section %d/%d\n", priv->pat.section_length, priv->pat.section_number, priv->pat.last_section_number); |
11190 | 1650 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1651 entries = (int) (priv->pat.section_length - 9) / 4; //entries per section |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1652 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1653 for(i=0; i < entries; i++) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1654 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1655 int32_t idx; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1656 base = &ptr[8 + i*4]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1657 progid = (base[0] << 8) | base[1]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1658 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1659 if((idx = prog_idx_in_pat(priv, progid)) == -1) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1660 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1661 int sz = sizeof(struct pat_progs_t) * (priv->pat.progs_cnt+1); |
18475
23fedcdd08a0
where necesary, replaced all realloc() with realloc_struct() to prevent int oveflows
nicodvb
parents:
18474
diff
changeset
|
1662 tmp = realloc_struct(priv->pat.progs, priv->pat.progs_cnt+1, sizeof(struct pat_progs_t)); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1663 if(tmp == NULL) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1664 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1665 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PAT: COULDN'T REALLOC %d bytes, NEXT\n", sz); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1666 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1667 } |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1668 priv->pat.progs = tmp; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1669 idx = priv->pat.progs_cnt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1670 priv->pat.progs_cnt++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1671 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1672 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1673 priv->pat.progs[idx].id = progid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1674 priv->pat.progs[idx].pmt_pid = ((base[2] & 0x1F) << 8) | base[3]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1675 mp_msg(MSGT_DEMUX, MSGL_V, "PROG: %d (%d-th of %d), PMT: %d\n", priv->pat.progs[idx].id, i+1, entries, priv->pat.progs[idx].pmt_pid); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1676 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1677 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1678 return 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1679 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1680 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1681 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1682 static inline int32_t es_pid_in_pmt(pmt_t * pmt, uint16_t pid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1683 { |
11190 | 1684 uint16_t i; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1685 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1686 if(pmt == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1687 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1688 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1689 if(pmt->es == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1690 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1691 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1692 for(i = 0; i < pmt->es_cnt; i++) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1693 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1694 if(pmt->es[i].pid == pid) |
11190 | 1695 return (int32_t) i; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1696 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1697 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1698 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1699 } |
9610 | 1700 |
1701 | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1702 static uint16_t get_mp4_desc_len(uint8_t *buf, int *len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1703 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1704 //uint16_t i = 0, size = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1705 int i = 0, j, size = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1706 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1707 mp_msg(MSGT_DEMUX, MSGL_DBG2, "PARSE_MP4_DESC_LEN(%d), bytes: ", *len); |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21421
diff
changeset
|
1708 j = FFMIN(*len, 4); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1709 while(i < j) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1710 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1711 mp_msg(MSGT_DEMUX, MSGL_DBG2, " %x ", buf[i]); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1712 size |= (buf[i] & 0x7f); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1713 if(!(buf[i] & 0x80)) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1714 break; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1715 size <<= 7; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1716 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1717 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1718 mp_msg(MSGT_DEMUX, MSGL_DBG2, ", SIZE=%d\n", size); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1719 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1720 *len = i+1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1721 return size; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1722 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1723 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1724 |
24570 | 1725 static uint16_t parse_mp4_slconfig_descriptor(uint8_t *buf, int len, void *elem) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1726 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1727 int i = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1728 mp4_es_descr_t *es; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1729 mp4_sl_config_t *sl; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1730 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1731 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4_SLCONFIG_DESCRIPTOR(%d)\n", len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1732 es = (mp4_es_descr_t *) elem; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1733 if(!es) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1734 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1735 mp_msg(MSGT_DEMUX, MSGL_V, "argh! NULL elem passed, skip\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1736 return len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1737 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1738 sl = &(es->sl); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1739 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1740 sl->ts_len = sl->ocr_len = sl->au_len = sl->instant_bitrate_len = sl->degr_len = sl->au_seqnum_len = sl->packet_seqnum_len = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1741 sl->ocr = sl->dts = sl->cts = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1742 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1743 if(buf[0] == 0) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1744 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1745 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1746 sl->flags = buf[i]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1747 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1748 sl->ts_resolution = (buf[i] << 24) | (buf[i+1] << 16) | (buf[i+2] << 8) | buf[i+3]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1749 i += 4; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1750 sl->ocr_resolution = (buf[i] << 24) | (buf[i+1] << 16) | (buf[i+2] << 8) | buf[i+3]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1751 i += 4; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1752 sl->ts_len = buf[i]; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1753 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1754 sl->ocr_len = buf[i]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1755 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1756 sl->au_len = buf[i]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1757 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1758 sl->instant_bitrate_len = buf[i]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1759 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1760 sl->degr_len = (buf[i] >> 4) & 0x0f; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1761 sl->au_seqnum_len = ((buf[i] & 0x0f) << 1) | ((buf[i+1] >> 7) & 0x01); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1762 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1763 sl->packet_seqnum_len = ((buf[i] >> 2) & 0x1f); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1764 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1765 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1766 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1767 else if(buf[0] == 1) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1768 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1769 sl->flags = 0; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1770 sl->ts_resolution = 1000; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1771 sl->ts_len = 32; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1772 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1773 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1774 else if(buf[0] == 2) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1775 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1776 sl->flags = 4; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1777 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1778 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1779 else |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1780 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1781 sl->flags = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1782 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1783 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1784 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1785 sl->au_start = (sl->flags >> 7) & 0x1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1786 sl->au_end = (sl->flags >> 6) & 0x1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1787 sl->random_accesspoint = (sl->flags >> 5) & 0x1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1788 sl->random_accesspoint_only = (sl->flags >> 4) & 0x1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1789 sl->padding = (sl->flags >> 3) & 0x1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1790 sl->use_ts = (sl->flags >> 2) & 0x1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1791 sl->idle = (sl->flags >> 1) & 0x1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1792 sl->duration = sl->flags & 0x1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1793 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1794 if(sl->duration) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1795 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1796 sl->timescale = (buf[i] << 24) | (buf[i+1] << 16) | (buf[i+2] << 8) | buf[i+3]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1797 i += 4; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1798 sl->au_duration = (buf[i] << 8) | buf[i+1]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1799 i += 2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1800 sl->cts_duration = (buf[i] << 8) | buf[i+1]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1801 i += 2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1802 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1803 else //no support for fixed durations atm |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1804 sl->timescale = sl->au_duration = sl->cts_duration = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1805 |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16292
diff
changeset
|
1806 mp_msg(MSGT_DEMUX, MSGL_V, "MP4SLCONFIG(len=0x%x), predef: %d, flags: %x, use_ts: %d, tslen: %d, timescale: %d, dts: %"PRIu64", cts: %"PRIu64"\n", |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1807 len, buf[0], sl->flags, sl->use_ts, sl->ts_len, sl->timescale, (uint64_t) sl->dts, (uint64_t) sl->cts); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1808 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1809 return len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1810 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1811 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1812 static int parse_mp4_descriptors(pmt_t *pmt, uint8_t *buf, int len, void *elem); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1813 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1814 static uint16_t parse_mp4_decoder_config_descriptor(pmt_t *pmt, uint8_t *buf, int len, void *elem) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1815 { |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1816 int i = 0, j; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1817 mp4_es_descr_t *es; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1818 mp4_decoder_config_t *dec; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1819 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1820 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4_DECODER_CONFIG_DESCRIPTOR(%d)\n", len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1821 es = (mp4_es_descr_t *) elem; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1822 if(!es) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1823 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1824 mp_msg(MSGT_DEMUX, MSGL_V, "argh! NULL elem passed, skip\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1825 return len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1826 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1827 dec = (mp4_decoder_config_t*) &(es->decoder); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1828 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1829 dec->object_type = buf[i]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1830 dec->stream_type = (buf[i+1]>>2) & 0x3f; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1831 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1832 if(dec->object_type == 1 && dec->stream_type == 1) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1833 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1834 dec->object_type = MP4_OD; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1835 dec->stream_type = MP4_OD; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1836 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1837 else if(dec->stream_type == 4) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1838 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1839 if(dec->object_type == 0x6a) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1840 dec->object_type = VIDEO_MPEG1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1841 if(dec->object_type >= 0x60 && dec->object_type <= 0x65) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1842 dec->object_type = VIDEO_MPEG2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1843 else if(dec->object_type == 0x20) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1844 dec->object_type = VIDEO_MPEG4; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1845 else if(dec->object_type == 0x21) |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1846 dec->object_type = VIDEO_AVC; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1847 /*else if(dec->object_type == 0x22) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1848 fprintf(stderr, "TYPE 0x22\n");*/ |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1849 else dec->object_type = UNKNOWN; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1850 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1851 else if(dec->stream_type == 5) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1852 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1853 if(dec->object_type == 0x40) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1854 dec->object_type = AUDIO_AAC; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1855 else if(dec->object_type == 0x6b) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1856 dec->object_type = AUDIO_MP2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1857 else if(dec->object_type >= 0x66 && dec->object_type <= 0x69) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1858 dec->object_type = AUDIO_MP2; |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1859 else |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1860 dec->object_type = UNKNOWN; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1861 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1862 else |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1863 dec->object_type = dec->stream_type = UNKNOWN; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1864 |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1865 if(dec->object_type != UNKNOWN) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1866 { |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1867 //update the type of the current stream |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1868 for(j = 0; j < pmt->es_cnt; j++) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1869 { |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1870 if(pmt->es[j].mp4_es_id == es->id) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1871 { |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1872 pmt->es[j].type = SL_PES_STREAM; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1873 } |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1874 } |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1875 } |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
1876 |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1877 if(len > 13) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1878 parse_mp4_descriptors(pmt, &buf[13], len-13, dec); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1879 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1880 mp_msg(MSGT_DEMUX, MSGL_V, "MP4DECODER(0x%x), object_type: 0x%x, stream_type: 0x%x\n", len, dec->object_type, dec->stream_type); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1881 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1882 return len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1883 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1884 |
24570 | 1885 static uint16_t parse_mp4_decoder_specific_descriptor(uint8_t *buf, int len, void *elem) |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1886 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1887 int i; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1888 mp4_decoder_config_t *dec; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1889 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1890 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4_DECODER_SPECIFIC_DESCRIPTOR(%d)\n", len); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1891 dec = (mp4_decoder_config_t *) elem; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1892 if(!dec) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1893 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1894 mp_msg(MSGT_DEMUX, MSGL_V, "argh! NULL elem passed, skip\n"); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1895 return len; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1896 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1897 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1898 mp_msg(MSGT_DEMUX, MSGL_DBG2, "MP4 SPECIFIC INFO BYTES: \n"); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1899 for(i=0; i<len; i++) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1900 mp_msg(MSGT_DEMUX, MSGL_DBG2, "%02x ", buf[i]); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1901 mp_msg(MSGT_DEMUX, MSGL_DBG2, "\n"); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1902 |
18462
557d188e915a
raised max extradata size and refuse to store more than the limit
nicodvb
parents:
18461
diff
changeset
|
1903 if(len > MAX_EXTRADATA_SIZE) |
557d188e915a
raised max extradata size and refuse to store more than the limit
nicodvb
parents:
18461
diff
changeset
|
1904 { |
557d188e915a
raised max extradata size and refuse to store more than the limit
nicodvb
parents:
18461
diff
changeset
|
1905 mp_msg(MSGT_DEMUX, MSGL_ERR, "DEMUX_TS, EXTRADATA SUSPICIOUSLY BIG: %d, REFUSED\r\n", len); |
557d188e915a
raised max extradata size and refuse to store more than the limit
nicodvb
parents:
18461
diff
changeset
|
1906 return len; |
557d188e915a
raised max extradata size and refuse to store more than the limit
nicodvb
parents:
18461
diff
changeset
|
1907 } |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1908 memcpy(dec->buf, buf, len); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1909 dec->buf_size = len; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1910 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1911 return len; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1912 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1913 |
24570 | 1914 static uint16_t parse_mp4_es_descriptor(pmt_t *pmt, uint8_t *buf, int len) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1915 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1916 int i = 0, j = 0, k, found; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1917 uint8_t flag; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1918 mp4_es_descr_t es, *target_es = NULL, *tmp; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1919 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1920 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4ES: len=%d\n", len); |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1921 memset(&es, 0, sizeof(mp4_es_descr_t)); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1922 while(i < len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1923 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1924 es.id = (buf[i] << 8) | buf[i+1]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1925 mp_msg(MSGT_DEMUX, MSGL_V, "MP4ES_ID: %d\n", es.id); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1926 i += 2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1927 flag = buf[i]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1928 i++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1929 if(flag & 0x80) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1930 i += 2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1931 if(flag & 0x40) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1932 i += buf[i]+1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1933 if(flag & 0x20) //OCR, maybe we need it |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1934 i += 2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1935 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1936 j = parse_mp4_descriptors(pmt, &buf[i], len-i, &es); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1937 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4ES, types after parse_mp4_descriptors: 0x%x, 0x%x\n", es.decoder.object_type, es.decoder.stream_type); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1938 if(es.decoder.object_type != UNKNOWN && es.decoder.stream_type != UNKNOWN) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1939 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1940 found = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1941 //search this ES_ID if we already have it |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1942 for(k=0; k < pmt->mp4es_cnt; k++) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1943 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1944 if(pmt->mp4es[k].id == es.id) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1945 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1946 target_es = &(pmt->mp4es[k]); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1947 found = 1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1948 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1949 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1950 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1951 if(! found) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1952 { |
18475
23fedcdd08a0
where necesary, replaced all realloc() with realloc_struct() to prevent int oveflows
nicodvb
parents:
18474
diff
changeset
|
1953 tmp = realloc_struct(pmt->mp4es, pmt->mp4es_cnt+1, sizeof(mp4_es_descr_t)); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1954 if(tmp == NULL) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1955 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1956 fprintf(stderr, "CAN'T REALLOC MP4_ES_DESCR\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1957 continue; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1958 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1959 pmt->mp4es = tmp; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1960 target_es = &(pmt->mp4es[pmt->mp4es_cnt]); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1961 pmt->mp4es_cnt++; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1962 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1963 memcpy(target_es, &es, sizeof(mp4_es_descr_t)); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1964 mp_msg(MSGT_DEMUX, MSGL_V, "MP4ES_CNT: %d, ID=%d\n", pmt->mp4es_cnt, target_es->id); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1965 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1966 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1967 i += j; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1968 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1969 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1970 return len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1971 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1972 |
15067 | 1973 static void parse_mp4_object_descriptor(pmt_t *pmt, uint8_t *buf, int len, void *elem) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1974 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1975 int i, j = 0, id; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1976 |
17816
c3530af0e23c
init variable in parse_mp4_object_descriptor before using it; fixes cid 237
nicodvb
parents:
17724
diff
changeset
|
1977 i=0; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1978 id = (buf[0] << 2) | ((buf[1] & 0xc0) >> 6); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1979 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4_OBJECT_DESCRIPTOR: len=%d, OD_ID=%d\n", len, id); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1980 if(buf[1] & 0x20) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1981 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1982 i += buf[2] + 1; //url |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1983 mp_msg(MSGT_DEMUX, MSGL_V, "URL\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1984 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1985 else |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1986 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1987 i = 2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1988 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1989 while(i < len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1990 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1991 j = parse_mp4_descriptors(pmt, &(buf[i]), len-i, elem); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1992 mp_msg(MSGT_DEMUX, MSGL_V, "OBJD, NOW i = %d, j=%d, LEN=%d\n", i, j, len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1993 i += j; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1994 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1995 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1996 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1997 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1998 |
15067 | 1999 static void parse_mp4_iod(pmt_t *pmt, uint8_t *buf, int len, void *elem) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2000 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2001 int i, j = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2002 mp4_od_t *iod = &(pmt->iod); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2003 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2004 iod->id = (buf[0] << 2) | ((buf[1] & 0xc0) >> 6); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2005 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4_IOD: len=%d, IOD_ID=%d\n", len, iod->id); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2006 i = 2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2007 if(buf[1] & 0x20) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2008 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2009 i += buf[2] + 1; //url |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2010 mp_msg(MSGT_DEMUX, MSGL_V, "URL\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2011 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2012 else |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2013 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2014 i = 7; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2015 while(i < len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2016 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2017 j = parse_mp4_descriptors(pmt, &(buf[i]), len-i, elem); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2018 mp_msg(MSGT_DEMUX, MSGL_V, "IOD, NOW i = %d, j=%d, LEN=%d\n", i, j, len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2019 i += j; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2020 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2021 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2022 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2023 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2024 static int parse_mp4_descriptors(pmt_t *pmt, uint8_t *buf, int len, void *elem) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2025 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2026 int tag, descr_len, i = 0, j = 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2027 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2028 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4_DESCRIPTORS, len=%d\n", len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2029 if(! len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2030 return len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2031 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2032 while(i < len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2033 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2034 tag = buf[i]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2035 j = len - i -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2036 descr_len = get_mp4_desc_len(&(buf[i+1]), &j); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2037 mp_msg(MSGT_DEMUX, MSGL_V, "TAG=%d (0x%x), DESCR_len=%d, len=%d, j=%d\n", tag, tag, descr_len, len, j); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2038 if(descr_len > len - j+1) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2039 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2040 mp_msg(MSGT_DEMUX, MSGL_V, "descriptor is too long, exit\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2041 return len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2042 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2043 i += j+1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2044 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2045 switch(tag) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2046 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2047 case 0x1: |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2048 parse_mp4_object_descriptor(pmt, &(buf[i]), descr_len, elem); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2049 break; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2050 case 0x2: |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2051 parse_mp4_iod(pmt, &(buf[i]), descr_len, elem); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2052 break; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2053 case 0x3: |
24570 | 2054 parse_mp4_es_descriptor(pmt, &(buf[i]), descr_len); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2055 break; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2056 case 0x4: |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2057 parse_mp4_decoder_config_descriptor(pmt, &buf[i], descr_len, elem); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2058 break; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2059 case 0x05: |
24570 | 2060 parse_mp4_decoder_specific_descriptor(&buf[i], descr_len, elem); |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2061 break; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2062 case 0x6: |
24570 | 2063 parse_mp4_slconfig_descriptor(&buf[i], descr_len, elem); |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2064 break; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2065 default: |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2066 mp_msg(MSGT_DEMUX, MSGL_V, "Unsupported mp4 descriptor 0x%x\n", tag); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2067 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2068 i += descr_len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2069 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2070 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2071 return len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2072 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2073 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2074 static ES_stream_t *new_pid(ts_priv_t *priv, int pid) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2075 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2076 ES_stream_t *tss; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2077 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2078 tss = malloc(sizeof(ES_stream_t)); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2079 if(! tss) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2080 return NULL; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2081 memset(tss, 0, sizeof(ES_stream_t)); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2082 tss->pid = pid; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2083 tss->last_cc = -1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2084 tss->type = UNKNOWN; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2085 tss->subtype = UNKNOWN; |
14981
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
2086 tss->is_synced = 0; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2087 tss->extradata = NULL; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2088 tss->extradata_alloc = tss->extradata_len = 0; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2089 priv->ts.pids[pid] = tss; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2090 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2091 return tss; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2092 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2093 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2094 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2095 static int parse_program_descriptors(pmt_t *pmt, uint8_t *buf, uint16_t len) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2096 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2097 uint16_t i = 0, k, olen = len; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2098 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2099 while(len > 0) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2100 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2101 mp_msg(MSGT_DEMUX, MSGL_V, "PROG DESCR, TAG=%x, LEN=%d(%x)\n", buf[i], buf[i+1], buf[i+1]); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2102 if(buf[i+1] > len-2) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2103 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2104 mp_msg(MSGT_DEMUX, MSGL_V, "ERROR, descriptor len is too long, skipping\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2105 return olen; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2106 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2107 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2108 if(buf[i] == 0x1d) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2109 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2110 if(buf[i+3] == 2) //buggy versions of vlc muxer make this non-standard mess (missing iod_scope) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2111 k = 3; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2112 else |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2113 k = 4; //this is standard compliant |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2114 parse_mp4_descriptors(pmt, &buf[i+k], (int) buf[i+1]-(k-2), NULL); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2115 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2116 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2117 len -= 2 + buf[i+1]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2118 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2119 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2120 return olen; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2121 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2122 |
11190 | 2123 static int parse_descriptors(struct pmt_es_t *es, uint8_t *ptr) |
2124 { | |
2125 int j, descr_len, len; | |
2126 | |
2127 j = 0; | |
2128 len = es->descr_length; | |
2129 while(len > 2) | |
2130 { | |
2131 descr_len = ptr[j+1]; | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2132 mp_msg(MSGT_DEMUX, MSGL_V, "...descr id: 0x%x, len=%d\n", ptr[j], descr_len); |
11190 | 2133 if(descr_len > len) |
2134 { | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2135 mp_msg(MSGT_DEMUX, MSGL_ERR, "INVALID DESCR LEN for tag %02x: %d vs %d max, EXIT LOOP\n", ptr[j], descr_len, len); |
11190 | 2136 return -1; |
2137 } | |
2138 | |
2139 | |
18563 | 2140 if(ptr[j] == 0x6a || ptr[j] == 0x7a) //A52 Descriptor |
11190 | 2141 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2142 if(es->type == 0x6) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2143 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2144 es->type = AUDIO_A52; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2145 mp_msg(MSGT_DEMUX, MSGL_DBG2, "DVB A52 Descriptor\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2146 } |
11190 | 2147 } |
24676 | 2148 else if(ptr[j] == 0x7b) //DVB DTS Descriptor |
2149 { | |
2150 if(es->type == 0x6) | |
2151 { | |
2152 es->type = AUDIO_DTS; | |
2153 mp_msg(MSGT_DEMUX, MSGL_DBG2, "DVB DTS Descriptor\n"); | |
2154 } | |
2155 } | |
11190 | 2156 else if(ptr[j] == 0x59) //Subtitling Descriptor |
2157 { | |
2158 uint8_t subtype; | |
2159 | |
2160 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Subtitling Descriptor\n"); | |
2161 if(descr_len < 8) | |
2162 { | |
2163 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Descriptor length too short for DVB Subtitle Descriptor: %d, SKIPPING\n", descr_len); | |
2164 } | |
2165 else | |
2166 { | |
2167 memcpy(es->lang, &ptr[j+2], 3); | |
2168 es->lang[3] = 0; | |
2169 subtype = ptr[j+5]; | |
2170 if( | |
2171 (subtype >= 0x10 && subtype <= 0x13) || | |
2172 (subtype >= 0x20 && subtype <= 0x23) | |
2173 ) | |
2174 { | |
2175 es->type = SPU_DVB; | |
2176 //page parameters: compo page 2 bytes, ancillary page 2 bytes | |
2177 } | |
2178 else | |
2179 es->type = UNKNOWN; | |
2180 } | |
2181 } | |
2182 else if(ptr[j] == 0x50) //Component Descriptor | |
2183 { | |
2184 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Component Descriptor\n"); | |
2185 memcpy(es->lang, &ptr[j+5], 3); | |
2186 es->lang[3] = 0; | |
2187 } | |
2188 else if(ptr[j] == 0xa) //Language Descriptor | |
2189 { | |
2190 memcpy(es->lang, &ptr[j+2], 3); | |
2191 es->lang[3] = 0; | |
2192 mp_msg(MSGT_DEMUX, MSGL_V, "Language Descriptor: %s\n", es->lang); | |
2193 } | |
2194 else if(ptr[j] == 0x5) //Registration Descriptor (looks like e fourCC :) ) | |
2195 { | |
2196 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Registration Descriptor\n"); | |
2197 if(descr_len < 4) | |
2198 { | |
2199 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Registration Descriptor length too short: %d, SKIPPING\n", descr_len); | |
2200 } | |
2201 else | |
2202 { | |
2203 char *d; | |
2204 memcpy(es->format_descriptor, &ptr[j+2], 4); | |
2205 es->format_descriptor[4] = 0; | |
2206 | |
2207 d = &ptr[j+2]; | |
2208 if(d[0] == 'A' && d[1] == 'C' && d[2] == '-' && d[3] == '3') | |
2209 { | |
2210 es->type = AUDIO_A52; | |
2211 } | |
23507 | 2212 else if(d[0] == 'D' && d[1] == 'T' && d[2] == 'S' && d[3] == '1') |
2213 { | |
2214 es->type = AUDIO_DTS; | |
2215 } | |
18565
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
2216 else if(d[0] == 'D' && d[1] == 'T' && d[2] == 'S' && d[3] == '2') |
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
2217 { |
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
2218 es->type = AUDIO_DTS; |
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
2219 } |
22162 | 2220 else if(d[0] == 'V' && d[1] == 'C' && d[2] == '-' && d[3] == '1') |
2221 { | |
23506
ad116ce6028c
1000000l, descriptor VC-1 identifies VIDEO_VC1, not AUDIO_DTS
nicodvb
parents:
23427
diff
changeset
|
2222 es->type = VIDEO_VC1; |
22162 | 2223 } |
11190 | 2224 else |
2225 es->type = UNKNOWN; | |
2226 mp_msg(MSGT_DEMUX, MSGL_DBG2, "FORMAT %s\n", es->format_descriptor); | |
2227 } | |
2228 } | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2229 else if(ptr[j] == 0x1e) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2230 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2231 es->mp4_es_id = (ptr[j+2] << 8) | ptr[j+3]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2232 mp_msg(MSGT_DEMUX, MSGL_V, "SL Descriptor: ES_ID: %d(%x), pid: %d\n", es->mp4_es_id, es->mp4_es_id, es->pid); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2233 } |
11190 | 2234 else |
2235 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Unknown descriptor 0x%x, SKIPPING\n", ptr[j]); | |
2236 | |
2237 len -= 2 + descr_len; | |
2238 j += 2 + descr_len; | |
2239 } | |
2240 | |
2241 return 1; | |
2242 } | |
2243 | |
24570 | 2244 static int parse_sl_section(pmt_t *pmt, ts_section_t *section, int is_start, unsigned char *buff, int size) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2245 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2246 int tid, len, skip; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2247 uint8_t *ptr; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2248 skip = collect_section(section, is_start, buff, size); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2249 if(! skip) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2250 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2251 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2252 ptr = &(section->buffer[skip]); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2253 tid = ptr[0]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2254 len = ((ptr[1] & 0x0f) << 8) | ptr[2]; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2255 mp_msg(MSGT_DEMUX, MSGL_V, "TABLEID: %d (av. %d), skip=%d, LEN: %d\n", tid, section->buffer_len, skip, len); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2256 if(len > 4093 || section->buffer_len < len || tid != 5) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2257 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2258 mp_msg(MSGT_DEMUX, MSGL_V, "SECTION TOO LARGE or wrong section type, EXIT\n"); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2259 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2260 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2261 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2262 if(! (ptr[5] & 1)) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2263 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2264 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2265 //8 is the current position, len - 9 is the amount of data available |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2266 parse_mp4_descriptors(pmt, &ptr[8], len - 9, NULL); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2267 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2268 return 1; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2269 } |
9610 | 2270 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2271 static int parse_pmt(ts_priv_t * priv, uint16_t progid, uint16_t pid, int is_start, unsigned char *buff, int size) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2272 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2273 unsigned char *base, *es_base; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2274 pmt_t *pmt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2275 int32_t idx, es_count, section_bytes; |
16934
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
2276 uint8_t m=0; |
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
2277 int skip; |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2278 pmt_t *tmp; |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2279 struct pmt_es_t *tmp_es; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2280 ts_section_t *section; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2281 ES_stream_t *tss; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2282 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2283 idx = progid_idx_in_pmt(priv, progid); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2284 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2285 if(idx == -1) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2286 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2287 int sz = (priv->pmt_cnt + 1) * sizeof(pmt_t); |
18475
23fedcdd08a0
where necesary, replaced all realloc() with realloc_struct() to prevent int oveflows
nicodvb
parents:
18474
diff
changeset
|
2288 tmp = realloc_struct(priv->pmt, priv->pmt_cnt + 1, sizeof(pmt_t)); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2289 if(tmp == NULL) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2290 { |
11190 | 2291 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT: COULDN'T REALLOC %d bytes, NEXT\n", sz); |
13187 | 2292 return 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2293 } |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2294 priv->pmt = tmp; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2295 idx = priv->pmt_cnt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2296 memset(&(priv->pmt[idx]), 0, sizeof(pmt_t)); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2297 priv->pmt_cnt++; |
16934
0c5f661011f0
fixed possible uint8 overflow; assign progid to the newly created pmt
nicodvb
parents:
16883
diff
changeset
|
2298 priv->pmt[idx].progid = progid; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2299 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2300 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2301 pmt = &(priv->pmt[idx]); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2302 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2303 section = &(pmt->section); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2304 skip = collect_section(section, is_start, buff, size); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2305 if(! skip) |
13187 | 2306 return 0; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2307 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2308 base = &(section->buffer[skip]); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2309 |
11190 | 2310 mp_msg(MSGT_DEMUX, MSGL_V, "FILL_PMT(prog=%d), PMT_len: %d, IS_START: %d, TS_PID: %d, SIZE=%d, M=%d, ES_CNT=%d, IDX=%d, PMT_PTR=%p\n", |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2311 progid, pmt->section.buffer_len, is_start, pid, size, m, pmt->es_cnt, idx, pmt); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2312 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2313 pmt->table_id = base[0]; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2314 if(pmt->table_id != 2) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2315 return -1; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2316 pmt->ssi = base[1] & 0x80; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2317 pmt->section_length = (((base[1] & 0xf) << 8 ) | base[2]); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2318 pmt->version_number = (base[5] >> 1) & 0x1f; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2319 pmt->curr_next = (base[5] & 1); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2320 pmt->section_number = base[6]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2321 pmt->last_section_number = base[7]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2322 pmt->PCR_PID = ((base[8] & 0x1f) << 8 ) | base[9]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2323 pmt->prog_descr_length = ((base[10] & 0xf) << 8 ) | base[11]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2324 if(pmt->prog_descr_length > pmt->section_length - 9) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2325 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2326 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_PMT, INVALID PROG_DESCR LENGTH (%d vs %d)\n", pmt->prog_descr_length, pmt->section_length - 9); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2327 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2328 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2329 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2330 if(pmt->prog_descr_length) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2331 parse_program_descriptors(pmt, &base[12], pmt->prog_descr_length); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2332 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2333 es_base = &base[12 + pmt->prog_descr_length]; //the beginning of th ES loop |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2334 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2335 section_bytes= pmt->section_length - 13 - pmt->prog_descr_length; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2336 es_count = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2337 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2338 while(section_bytes >= 5) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2339 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2340 int es_pid, es_type; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2341 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2342 es_type = es_base[0]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2343 es_pid = ((es_base[1] & 0x1f) << 8) | es_base[2]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2344 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2345 idx = es_pid_in_pmt(pmt, es_pid); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2346 if(idx == -1) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2347 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2348 int sz = sizeof(struct pmt_es_t) * (pmt->es_cnt + 1); |
18475
23fedcdd08a0
where necesary, replaced all realloc() with realloc_struct() to prevent int oveflows
nicodvb
parents:
18474
diff
changeset
|
2349 tmp_es = realloc_struct(pmt->es, pmt->es_cnt + 1, sizeof(struct pmt_es_t)); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2350 if(tmp_es == NULL) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2351 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2352 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT, COULDN'T ALLOCATE %d bytes for PMT_ES\n", sz); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2353 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2354 } |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2355 pmt->es = tmp_es; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2356 idx = pmt->es_cnt; |
11190 | 2357 memset(&(pmt->es[idx]), 0, sizeof(struct pmt_es_t)); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2358 pmt->es_cnt++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2359 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2360 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2361 pmt->es[idx].descr_length = ((es_base[3] & 0xf) << 8) | es_base[4]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2362 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2363 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2364 if(pmt->es[idx].descr_length > section_bytes - 5) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2365 { |
11190 | 2366 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_PMT, ES_DESCR_LENGTH TOO LARGE %d > %d, EXIT\n", |
2367 pmt->es[idx].descr_length, section_bytes - 5); | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2368 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2369 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2370 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2371 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2372 pmt->es[idx].pid = es_pid; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2373 if(es_type != 0x6) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2374 pmt->es[idx].type = UNKNOWN; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2375 else |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2376 pmt->es[idx].type = es_type; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2377 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2378 parse_descriptors(&pmt->es[idx], &es_base[5]); |
11190 | 2379 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2380 switch(es_type) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2381 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2382 case 1: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2383 pmt->es[idx].type = VIDEO_MPEG1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2384 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2385 case 2: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2386 pmt->es[idx].type = VIDEO_MPEG2; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2387 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2388 case 3: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2389 case 4: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2390 pmt->es[idx].type = AUDIO_MP2; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2391 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2392 case 6: |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2393 if(pmt->es[idx].type == 0x6) //this could have been ovrwritten by parse_descriptors |
11190 | 2394 pmt->es[idx].type = UNKNOWN; |
2395 break; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2396 case 0x10: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2397 pmt->es[idx].type = VIDEO_MPEG4; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2398 break; |
14571
512a57bbe68d
replaced bzero() with memset(); stream_type 0x0f is AAC
nicodvb
parents:
14046
diff
changeset
|
2399 case 0x0f: |
25837
643064afe2a4
in the PMT stream_type==0x11 indicates AAC in LATM streams, that now libfaad can decode; re-added
nicodvb
parents:
25707
diff
changeset
|
2400 case 0x11: |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2401 pmt->es[idx].type = AUDIO_AAC; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2402 break; |
14034
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
2403 case 0x1b: |
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
2404 pmt->es[idx].type = VIDEO_H264; |
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
2405 break; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2406 case 0x12: |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2407 pmt->es[idx].type = SL_PES_STREAM; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2408 break; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2409 case 0x13: |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2410 pmt->es[idx].type = SL_SECTION; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2411 break; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2412 case 0x81: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2413 pmt->es[idx].type = AUDIO_A52; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2414 break; |
18565
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
2415 case 0x8A: |
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
2416 pmt->es[idx].type = AUDIO_DTS; |
0eaccc94c90c
support for dts (identified only by the PMT, not from the bitstream)
nicodvb
parents:
18564
diff
changeset
|
2417 break; |
22162 | 2418 case 0xEA: |
2419 pmt->es[idx].type = VIDEO_VC1; | |
2420 break; | |
11190 | 2421 default: |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2422 mp_msg(MSGT_DEMUX, MSGL_DBG2, "UNKNOWN ES TYPE=0x%x\n", es_type); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2423 pmt->es[idx].type = UNKNOWN; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2424 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2425 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2426 tss = priv->ts.pids[es_pid]; //an ES stream |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2427 if(tss == NULL) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2428 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2429 tss = new_pid(priv, es_pid); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2430 if(tss) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2431 tss->type = pmt->es[idx].type; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2432 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2433 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2434 section_bytes -= 5 + pmt->es[idx].descr_length; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2435 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_PMT(%d INDEX %d), STREAM: %d, FOUND pid=0x%x (%d), type=0x%x, ES_DESCR_LENGTH: %d, bytes left: %d\n", |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2436 progid, idx, es_count, pmt->es[idx].pid, pmt->es[idx].pid, pmt->es[idx].type, pmt->es[idx].descr_length, section_bytes); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2437 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2438 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2439 es_base += 5 + pmt->es[idx].descr_length; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2440 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2441 es_count++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2442 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2443 |
11190 | 2444 mp_msg(MSGT_DEMUX, MSGL_V, "----------------------------\n"); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2445 return 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2446 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2447 |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2448 static pmt_t* pmt_of_pid(ts_priv_t *priv, int pid, mp4_decoder_config_t **mp4_dec) |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2449 { |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2450 int32_t i, j, k; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2451 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2452 if(priv->pmt) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2453 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2454 for(i = 0; i < priv->pmt_cnt; i++) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2455 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2456 if(priv->pmt[i].es && priv->pmt[i].es_cnt) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2457 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2458 for(j = 0; j < priv->pmt[i].es_cnt; j++) |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2459 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2460 if(priv->pmt[i].es[j].pid == pid) |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2461 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2462 //search mp4_es_id |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2463 if(priv->pmt[i].es[j].mp4_es_id) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2464 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2465 for(k = 0; k < priv->pmt[i].mp4es_cnt; k++) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2466 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2467 if(priv->pmt[i].mp4es[k].id == priv->pmt[i].es[j].mp4_es_id) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2468 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2469 *mp4_dec = &(priv->pmt[i].mp4es[k].decoder); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2470 break; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2471 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2472 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2473 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2474 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2475 return &(priv->pmt[i]); |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2476 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2477 } |
22231 | 2478 } |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2479 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2480 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2481 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2482 return NULL; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2483 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2484 |
9610 | 2485 |
11190 | 2486 static inline int32_t pid_type_from_pmt(ts_priv_t *priv, int pid) |
2487 { | |
2488 int32_t pmt_idx, pid_idx, i, j; | |
2489 | |
2490 pmt_idx = progid_idx_in_pmt(priv, priv->prog); | |
2491 | |
2492 if(pmt_idx != -1) | |
2493 { | |
2494 pid_idx = es_pid_in_pmt(&(priv->pmt[pmt_idx]), pid); | |
2495 if(pid_idx != -1) | |
2496 return priv->pmt[pmt_idx].es[pid_idx].type; | |
2497 } | |
2498 //else | |
2499 //{ | |
2500 for(i = 0; i < priv->pmt_cnt; i++) | |
2501 { | |
2502 pmt_t *pmt = &(priv->pmt[i]); | |
2503 for(j = 0; j < pmt->es_cnt; j++) | |
2504 if(pmt->es[j].pid == pid) | |
2505 return pmt->es[j].type; | |
2506 } | |
2507 //} | |
2508 | |
2509 return UNKNOWN; | |
2510 } | |
2511 | |
2512 | |
2513 static inline uint8_t *pid_lang_from_pmt(ts_priv_t *priv, int pid) | |
2514 { | |
2515 int32_t pmt_idx, pid_idx, i, j; | |
2516 | |
2517 pmt_idx = progid_idx_in_pmt(priv, priv->prog); | |
2518 | |
2519 if(pmt_idx != -1) | |
2520 { | |
2521 pid_idx = es_pid_in_pmt(&(priv->pmt[pmt_idx]), pid); | |
2522 if(pid_idx != -1) | |
2523 return priv->pmt[pmt_idx].es[pid_idx].lang; | |
2524 } | |
2525 else | |
2526 { | |
2527 for(i = 0; i < priv->pmt_cnt; i++) | |
2528 { | |
2529 pmt_t *pmt = &(priv->pmt[i]); | |
2530 for(j = 0; j < pmt->es_cnt; j++) | |
2531 if(pmt->es[j].pid == pid) | |
2532 return pmt->es[j].lang; | |
2533 } | |
2534 } | |
2535 | |
2536 return NULL; | |
2537 } | |
2538 | |
2539 | |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
2540 static int fill_packet(demuxer_t *demuxer, demux_stream_t *ds, demux_packet_t **dp, int *dp_offset, TS_stream_info *si) |
11190 | 2541 { |
2542 int ret = 0; | |
2543 | |
2544 if((*dp != NULL) && (*dp_offset > 0)) | |
2545 { | |
22231 | 2546 ret = *dp_offset; |
2547 resize_demux_packet(*dp, ret); //shrinked to the right size | |
2548 ds_add_packet(ds, *dp); | |
2549 mp_msg(MSGT_DEMUX, MSGL_DBG2, "ADDED %d bytes to %s fifo, PTS=%.3f\n", ret, (ds == demuxer->audio ? "audio" : (ds == demuxer->video ? "video" : "sub")), (*dp)->pts); | |
2550 if(si) | |
2551 { | |
2552 float diff = (*dp)->pts - si->last_pts; | |
2553 float dur; | |
2554 | |
2555 if(abs(diff) > 1) //1 second, there's a discontinuity | |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
2556 { |
22231 | 2557 si->duration += si->last_pts - si->first_pts; |
2558 si->first_pts = si->last_pts = (*dp)->pts; | |
2559 } | |
2560 else | |
2561 { | |
2562 si->last_pts = (*dp)->pts; | |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
2563 } |
22231 | 2564 si->size += ret; |
2565 dur = si->duration + (si->last_pts - si->first_pts); | |
2566 | |
2567 if(dur > 0 && ds == demuxer->video) | |
2568 { | |
2569 ts_priv_t * priv = (ts_priv_t*) demuxer->priv; | |
2570 if(dur > 1) //otherwise it may be unreliable | |
2571 priv->vbitrate = (uint32_t) ((float) si->size / dur); | |
2572 } | |
2573 } | |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2574 } |
11190 | 2575 |
2576 *dp = NULL; | |
2577 *dp_offset = 0; | |
2578 | |
2579 return ret; | |
2580 } | |
2581 | |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2582 static int fill_extradata(mp4_decoder_config_t * mp4_dec, ES_stream_t *tss) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2583 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2584 uint8_t *tmp; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2585 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2586 mp_msg(MSGT_DEMUX, MSGL_DBG2, "MP4_dec: %p, pid: %d\n", mp4_dec, tss->pid); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2587 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2588 if(mp4_dec->buf_size > tss->extradata_alloc) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2589 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2590 tmp = (uint8_t *) realloc(tss->extradata, mp4_dec->buf_size); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2591 if(!tmp) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2592 return 0; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2593 tss->extradata = tmp; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2594 tss->extradata_alloc = mp4_dec->buf_size; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2595 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2596 memcpy(tss->extradata, mp4_dec->buf, mp4_dec->buf_size); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2597 tss->extradata_len = mp4_dec->buf_size; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2598 mp_msg(MSGT_DEMUX, MSGL_V, "EXTRADATA: %p, alloc=%d, len=%d\n", tss->extradata, tss->extradata_alloc, tss->extradata_len); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2599 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2600 return tss->extradata_len; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2601 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2602 |
9610 | 2603 // 0 = EOF or no stream found |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2604 // else = [-] number of bytes written to the packet |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2605 static int ts_parse(demuxer_t *demuxer , ES_stream_t *es, unsigned char *packet, int probe) |
9610 | 2606 { |
10014 | 2607 ES_stream_t *tss; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2608 uint8_t done = 0; |
11190 | 2609 int buf_size, is_start, pid, base; |
2610 int len, cc, cc_ok, afc, retv = 0, is_video, is_audio, is_sub; | |
10014 | 2611 ts_priv_t * priv = (ts_priv_t*) demuxer->priv; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2612 stream_t *stream = demuxer->stream; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2613 char *p; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2614 demux_stream_t *ds = NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2615 demux_packet_t **dp = NULL; |
12518
996757299a82
removed unused and commented code; audio is pushed synchronously (reported to work better); pid 16 is not default PMT (100l); trails of data are add_packet()ed
nicodvb
parents:
12049
diff
changeset
|
2616 int *dp_offset = 0, *buffer_size = 0; |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2617 int32_t progid, pid_type, bad, ts_error; |
14992
d1d36694aa3d
consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL)
nicodvb
parents:
14981
diff
changeset
|
2618 int junk = 0, rap_flag = 0; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2619 pmt_t *pmt; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2620 mp4_decoder_config_t *mp4_dec; |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
2621 TS_stream_info *si; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2622 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2623 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2624 while(! done) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2625 { |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2626 bad = ts_error = 0; |
11190 | 2627 ds = (demux_stream_t*) NULL; |
2628 dp = (demux_packet_t **) NULL; | |
12518
996757299a82
removed unused and commented code; audio is pushed synchronously (reported to work better); pid 16 is not default PMT (100l); trails of data are add_packet()ed
nicodvb
parents:
12049
diff
changeset
|
2629 dp_offset = buffer_size = NULL; |
14992
d1d36694aa3d
consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL)
nicodvb
parents:
14981
diff
changeset
|
2630 rap_flag = 0; |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2631 mp4_dec = NULL; |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2632 es->is_synced = 0; |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
2633 si = NULL; |
11190 | 2634 |
13994
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
2635 junk = priv->ts.packet_size - TS_PACKET_SIZE; |
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
2636 buf_size = priv->ts.packet_size - junk; |
11190 | 2637 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2638 if(stream_eof(stream)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2639 { |
11190 | 2640 if(! probe) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2641 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2642 ts_dump_streams(priv); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2643 demuxer->filepos = stream_tell(demuxer->stream); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2644 } |
11190 | 2645 |
2646 return 0; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2647 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2648 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2649 |
11190 | 2650 if(! ts_sync(stream)) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2651 { |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2652 mp_msg(MSGT_DEMUX, MSGL_INFO, "TS_PARSE: COULDN'T SYNC\n"); |
11190 | 2653 return 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2654 } |
11190 | 2655 |
2656 len = stream_read(stream, &packet[1], 3); | |
2657 if (len != 3) | |
2658 return 0; | |
20490 | 2659 buf_size -= 4; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2660 |
11190 | 2661 if((packet[1] >> 7) & 0x01) //transport error |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2662 ts_error = 1; |
11190 | 2663 |
2664 | |
2665 is_start = packet[1] & 0x40; | |
2666 pid = ((packet[1] & 0x1f) << 8) | packet[2]; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2667 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2668 tss = priv->ts.pids[pid]; //an ES stream |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2669 if(tss == NULL) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2670 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2671 tss = new_pid(priv, pid); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2672 if(tss == NULL) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2673 continue; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2674 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2675 |
20490 | 2676 cc = (packet[3] & 0xf); |
2677 cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc)); | |
2678 tss->last_cc = cc; | |
2679 | |
2680 bad = ts_error; // || (! cc_ok); | |
2681 if(bad) | |
2682 { | |
2683 if(priv->keep_broken == 0) | |
2684 { | |
2685 stream_skip(stream, buf_size-1+junk); | |
2686 continue; | |
2687 } | |
2688 | |
2689 is_start = 0; //queued to the packet data | |
2690 } | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2691 |
20462 | 2692 if(is_start) |
2693 tss->is_synced = 1; | |
2694 | |
2695 if((!is_start && !tss->is_synced) || ((pid > 1) && (pid < 16)) || (pid == 8191)) //invalid pid | |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2696 { |
13994
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
2697 stream_skip(stream, buf_size-1+junk); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2698 continue; |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2699 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2700 |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2701 |
14992
d1d36694aa3d
consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL)
nicodvb
parents:
14981
diff
changeset
|
2702 afc = (packet[3] >> 4) & 3; |
20464 | 2703 if(! (afc % 2)) //no payload in this TS packet |
2704 { | |
2705 stream_skip(stream, buf_size-1+junk); | |
2706 continue; | |
2707 } | |
2708 | |
14992
d1d36694aa3d
consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL)
nicodvb
parents:
14981
diff
changeset
|
2709 if(afc > 1) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2710 { |
14992
d1d36694aa3d
consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL)
nicodvb
parents:
14981
diff
changeset
|
2711 int c; |
d1d36694aa3d
consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL)
nicodvb
parents:
14981
diff
changeset
|
2712 c = stream_read_char(stream); |
d1d36694aa3d
consider parse random_access_point from the adaption_field to determine if the payload is an access point (for SL)
nicodvb
parents:
14981
diff
changeset
|
2713 buf_size--; |
20487
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2714 if(c < 0 || c > 183) //broken from the stream layer or invalid |
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2715 { |
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2716 stream_skip(stream, buf_size-1+junk); |
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2717 continue; |
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2718 } |
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2719 |
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2720 //c==0 is allowed! |
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2721 if(c > 0) |
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2722 { |
20488 | 2723 rap_flag = (stream_read_char(stream) & 0x40) >> 6; |
2724 buf_size--; | |
2725 | |
2726 c--; | |
2727 stream_skip(stream, c); | |
2728 buf_size -= c; | |
2729 if(buf_size == 0) | |
2730 continue; | |
20487
5c953a55103f
1000l: fixed broken handling of the adaption field - part 2
nicodvb
parents:
20486
diff
changeset
|
2731 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2732 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2733 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2734 //find the program that the pid belongs to; if (it's the right one or -1) && pid_type==SL_SECTION |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2735 //call parse_sl_section() |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2736 pmt = pmt_of_pid(priv, pid, &mp4_dec); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2737 if(mp4_dec) |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2738 { |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2739 fill_extradata(mp4_dec, tss); |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2740 if(IS_VIDEO(mp4_dec->object_type) || IS_AUDIO(mp4_dec->object_type)) |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2741 { |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2742 tss->type = SL_PES_STREAM; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2743 tss->subtype = mp4_dec->object_type; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2744 } |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2745 } |
15045
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2746 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2747 |
11190 | 2748 //TABLE PARSING |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2749 |
11190 | 2750 base = priv->ts.packet_size - buf_size; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2751 |
11190 | 2752 priv->last_pid = pid; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2753 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2754 is_video = IS_VIDEO(tss->type) || (tss->type==SL_PES_STREAM && IS_VIDEO(tss->subtype)); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2755 is_audio = IS_AUDIO(tss->type) || (tss->type==SL_PES_STREAM && IS_AUDIO(tss->subtype)) || (tss->type == PES_PRIVATE1); |
11190 | 2756 is_sub = ((tss->type == SPU_DVD) || (tss->type == SPU_DVB)); |
2757 pid_type = pid_type_from_pmt(priv, pid); | |
2758 | |
2759 // PES CONTENT STARTS HERE | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2760 if(! probe) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2761 { |
21929
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
2762 if((is_video || is_audio) && is_start && !priv->ts.streams[pid].sh) |
145ca84ffbf7
unified creation of sh_audio and sh_video is ts_add_stream; patch by elupus
nicodvb
parents:
21531
diff
changeset
|
2763 ts_add_stream(demuxer, tss); |
20951 | 2764 |
11190 | 2765 if((pid == demuxer->sub->id)) //or the lang is right |
2766 { | |
2767 pid_type = SPU_DVD; | |
2768 } | |
2769 | |
20951 | 2770 if(is_video && (demuxer->video->id == priv->ts.streams[pid].id)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2771 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2772 ds = demuxer->video; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2773 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2774 dp = &priv->fifo[1].pack; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2775 dp_offset = &priv->fifo[1].offset; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2776 buffer_size = &priv->fifo[1].buffer_size; |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
2777 si = &priv->vstr; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2778 } |
18688 | 2779 else if(is_audio && (demuxer->audio->id == priv->ts.streams[pid].id)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2780 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2781 ds = demuxer->audio; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2782 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2783 dp = &priv->fifo[0].pack; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2784 dp_offset = &priv->fifo[0].offset; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2785 buffer_size = &priv->fifo[0].buffer_size; |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
2786 si = &priv->astr; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2787 } |
11190 | 2788 else if(is_sub |
2789 || (pid_type == SPU_DVD) || (pid_type == SPU_DVB)) | |
2790 { | |
2791 //SUBS are infrequent, so the initial detection may fail | |
2792 // and we may need to add them at play-time | |
2793 if(demuxer->sub->id == -1) | |
2794 { | |
2795 uint16_t p; | |
2796 p = progid_for_pid(priv, tss->pid, priv->prog); | |
2797 | |
2798 if(p == priv->prog) | |
2799 { | |
2800 int asgn = 0; | |
2801 uint8_t *lang; | |
2802 | |
16292
f779d1c1c593
Crash fix for: "[MPlayer-users] Crash of mencoder in demux_ts.c line 2728"
gpoirier
parents:
16175
diff
changeset
|
2803 if(dvdsub_lang) |
f779d1c1c593
Crash fix for: "[MPlayer-users] Crash of mencoder in demux_ts.c line 2728"
gpoirier
parents:
16175
diff
changeset
|
2804 { |
24424 | 2805 if ((lang = pid_lang_from_pmt(priv, pid))) |
20506
9324e1a02a8b
simplified assignment of subtitles stream in ts_parse()
nicodvb
parents:
20490
diff
changeset
|
2806 asgn = (strncmp(lang, dvdsub_lang, 3) == 0); |
16292
f779d1c1c593
Crash fix for: "[MPlayer-users] Crash of mencoder in demux_ts.c line 2728"
gpoirier
parents:
16175
diff
changeset
|
2807 } |
20506
9324e1a02a8b
simplified assignment of subtitles stream in ts_parse()
nicodvb
parents:
20490
diff
changeset
|
2808 else //no language specified with -slang |
9324e1a02a8b
simplified assignment of subtitles stream in ts_parse()
nicodvb
parents:
20490
diff
changeset
|
2809 asgn = 1; |
11190 | 2810 |
2811 if(asgn) | |
2812 { | |
2813 demuxer->sub->id = tss->pid; | |
2814 mp_msg(MSGT_DEMUX, MSGL_INFO, "CHOSEN SUBs pid 0x%x (%d) FROM PROG %d\n", tss->pid, tss->pid, priv->prog); | |
2815 } | |
2816 } | |
2817 } | |
2818 | |
2819 if(demuxer->sub->id == tss->pid) | |
2820 { | |
2821 ds = demuxer->sub; | |
2822 | |
2823 dp = &priv->fifo[2].pack; | |
2824 dp_offset = &priv->fifo[2].offset; | |
2825 buffer_size = &priv->fifo[2].buffer_size; | |
2826 } | |
2827 else | |
2828 { | |
13994
a3a16a50b314
added support for 192 packet size, remove junk data after 188 bytes. Patch by Marcus Metzler (mocm@mocm.de)
nicodvb
parents:
13957
diff
changeset
|
2829 stream_skip(stream, buf_size+junk); |
11190 | 2830 continue; |
2831 } | |
2832 } | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2833 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2834 //IS IT TIME TO QUEUE DATA to the dp_packet? |
11190 | 2835 if(is_start && (dp != NULL)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2836 { |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
2837 retv = fill_packet(demuxer, ds, dp, dp_offset, si); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2838 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2839 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2840 |
20508
f74eb19ac068
a previous commit introduced a bug that prevented tables
nicodvb
parents:
20506
diff
changeset
|
2841 if(dp && *dp == NULL) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2842 { |
18461
e98125844f2d
don't allocate (and demux_push() immediately) demux_packet()s > MAX_PACK_SIZE; releasing immediately audio packets (before the pes is complete) doesn't make any sense and deteriorates interleaving
nicodvb
parents:
18460
diff
changeset
|
2843 if(*buffer_size > MAX_PACK_BYTES) |
e98125844f2d
don't allocate (and demux_push() immediately) demux_packet()s > MAX_PACK_SIZE; releasing immediately audio packets (before the pes is complete) doesn't make any sense and deteriorates interleaving
nicodvb
parents:
18460
diff
changeset
|
2844 *buffer_size = MAX_PACK_BYTES; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2845 *dp = new_demux_packet(*buffer_size); //es->size |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2846 *dp_offset = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2847 if(! *dp) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2848 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2849 fprintf(stderr, "fill_buffer, NEW_ADD_PACKET(%d)FAILED\n", *buffer_size); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2850 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2851 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2852 mp_msg(MSGT_DEMUX, MSGL_DBG2, "CREATED DP(%d)\n", *buffer_size); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2853 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2854 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2855 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2856 |
20485
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2857 if(probe || !dp) //dp is NULL for tables and sections |
20478
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2858 { |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2859 p = &packet[base]; |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2860 } |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2861 else //feeding |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2862 { |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2863 if(*dp_offset + buf_size > *buffer_size) |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2864 { |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2865 *buffer_size = *dp_offset + buf_size + TS_FEC_PACKET_SIZE; |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2866 resize_demux_packet(*dp, *buffer_size); |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2867 } |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2868 p = &((*dp)->buffer[*dp_offset]); |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2869 } |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2870 |
20486
0cc36dd385ec
fixed mishandling of stream_read() (it doesn't necessarily return -1 in case of error)
nicodvb
parents:
20485
diff
changeset
|
2871 len = stream_read(stream, p, buf_size); |
0cc36dd385ec
fixed mishandling of stream_read() (it doesn't necessarily return -1 in case of error)
nicodvb
parents:
20485
diff
changeset
|
2872 if(len < buf_size) |
20478
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2873 { |
20486
0cc36dd385ec
fixed mishandling of stream_read() (it doesn't necessarily return -1 in case of error)
nicodvb
parents:
20485
diff
changeset
|
2874 mp_msg(MSGT_DEMUX, MSGL_DBG2, "\r\nts_parse() couldn't read enough data: %d < %d\r\n", len, buf_size); |
20478
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2875 continue; |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2876 } |
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2877 stream_skip(stream, junk); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2878 |
20485
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2879 if(pid == 0) |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2880 { |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2881 parse_pat(priv, is_start, p, buf_size); |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2882 continue; |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2883 } |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2884 else if((tss->type == SL_SECTION) && pmt) |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2885 { |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2886 int k, mp4_es_id = -1; |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2887 ts_section_t *section; |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2888 for(k = 0; k < pmt->mp4es_cnt; k++) |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2889 { |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2890 if(pmt->mp4es[k].decoder.object_type == MP4_OD && pmt->mp4es[k].decoder.stream_type == MP4_OD) |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2891 mp4_es_id = pmt->mp4es[k].id; |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2892 } |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2893 mp_msg(MSGT_DEMUX, MSGL_DBG2, "MP4ESID: %d\n", mp4_es_id); |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2894 for(k = 0; k < pmt->es_cnt; k++) |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2895 { |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2896 if(pmt->es[k].mp4_es_id == mp4_es_id) |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2897 { |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2898 section = &(tss->section); |
24570 | 2899 parse_sl_section(pmt, section, is_start, &packet[base], buf_size); |
20485
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2900 } |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2901 } |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2902 continue; |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2903 } |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2904 else |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2905 { |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2906 progid = prog_id_in_pat(priv, pid); |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2907 if(progid != -1) |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2908 { |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2909 if(pid != demuxer->video->id && pid != demuxer->audio->id && pid != demuxer->sub->id) |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2910 { |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2911 parse_pmt(priv, progid, pid, is_start, &packet[base], buf_size); |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2912 continue; |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2913 } |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2914 else |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2915 mp_msg(MSGT_DEMUX, MSGL_ERR, "Argh! Data pid %d used in the PMT, Skipping PMT parsing!\n", pid); |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2916 } |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2917 } |
8fb92804c652
ts_parse() move section handling after stream_read() rather than repeating it
nicodvb
parents:
20480
diff
changeset
|
2918 |
20508
f74eb19ac068
a previous commit introduced a bug that prevented tables
nicodvb
parents:
20506
diff
changeset
|
2919 if(!probe && !dp) |
f74eb19ac068
a previous commit introduced a bug that prevented tables
nicodvb
parents:
20506
diff
changeset
|
2920 continue; |
f74eb19ac068
a previous commit introduced a bug that prevented tables
nicodvb
parents:
20506
diff
changeset
|
2921 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2922 if(is_start) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2923 { |
20471
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2924 uint8_t *lang = NULL; |
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2925 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2926 mp_msg(MSGT_DEMUX, MSGL_DBG2, "IS_START\n"); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2927 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2928 len = pes_parse2(p, buf_size, es, pid_type, pmt, pid); |
20462 | 2929 if(! len) |
2930 { | |
2931 tss->is_synced = 0; | |
2932 continue; | |
2933 } | |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2934 es->pid = tss->pid; |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
2935 tss->is_synced |= es->is_synced || rap_flag; |
20471
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2936 tss->payload_size = es->payload_size; |
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2937 |
20472 | 2938 if(is_audio && (lang = pid_lang_from_pmt(priv, es->pid))) |
20471
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2939 { |
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2940 memcpy(es->lang, lang, 3); |
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2941 es->lang[3] = 0; |
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2942 } |
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2943 else |
0398b9cbd66d
unconditionally assign the language code when available;
nicodvb
parents:
20467
diff
changeset
|
2944 es->lang[0] = 0; |
14981
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
2945 |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2946 if(probe) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2947 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2948 if(es->type == UNKNOWN) |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2949 return 0; |
17724
b6b34e21941b
print ts_probe; 0x88 .. 0x8F in pes_private streams are not AC3 but DTS tracks (unsupported); save the size of the payload of the current PES packet in any case (used for ac3 detection)
nicodvb
parents:
17636
diff
changeset
|
2950 |
20467 | 2951 tss->type = es->type; |
2952 tss->subtype = es->subtype; | |
2953 | |
2954 return 1; | |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2955 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2956 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2957 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2958 if(es->pts == 0.0f) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2959 es->pts = tss->pts = tss->last_pts; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2960 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2961 tss->pts = tss->last_pts = es->pts; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2962 |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2963 mp_msg(MSGT_DEMUX, MSGL_DBG2, "ts_parse, NEW pid=%d, PSIZE: %u, type=%X, start=%p, len=%d\n", |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2964 es->pid, es->payload_size, es->type, es->start, es->size); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2965 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2966 demuxer->filepos = stream_tell(demuxer->stream) - es->size; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2967 |
20478
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
2968 memmove(p, es->start, es->size); |
20467 | 2969 *dp_offset += es->size; |
2970 (*dp)->flags = 0; | |
2971 (*dp)->pos = stream_tell(demuxer->stream); | |
2972 (*dp)->pts = es->pts; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2973 |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2974 if(retv > 0) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2975 return retv; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2976 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2977 continue; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2978 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2979 } |
10014 | 2980 else |
2981 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2982 uint16_t sz; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2983 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2984 es->pid = tss->pid; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2985 es->type = tss->type; |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2986 es->subtype = tss->subtype; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2987 es->pts = tss->pts = tss->last_pts; |
11190 | 2988 es->start = &packet[base]; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2989 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2990 |
11190 | 2991 if(tss->payload_size > 0) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2992 { |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21421
diff
changeset
|
2993 sz = FFMIN(tss->payload_size, buf_size); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2994 tss->payload_size -= sz; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2995 es->size = sz; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2996 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2997 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2998 { |
11190 | 2999 if(is_video) |
3000 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3001 sz = es->size = buf_size; |
11190 | 3002 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3003 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3004 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3005 continue; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3006 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3007 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3008 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3009 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3010 if(! probe) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3011 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3012 *dp_offset += sz; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3013 |
18461
e98125844f2d
don't allocate (and demux_push() immediately) demux_packet()s > MAX_PACK_SIZE; releasing immediately audio packets (before the pes is complete) doesn't make any sense and deteriorates interleaving
nicodvb
parents:
18460
diff
changeset
|
3014 if(*dp_offset >= MAX_PACK_BYTES) |
12518
996757299a82
removed unused and commented code; audio is pushed synchronously (reported to work better); pid 16 is not default PMT (100l); trails of data are add_packet()ed
nicodvb
parents:
12049
diff
changeset
|
3015 { |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
3016 (*dp)->pts = tss->last_pts; |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
3017 retv = fill_packet(demuxer, ds, dp, dp_offset, si); |
12518
996757299a82
removed unused and commented code; audio is pushed synchronously (reported to work better); pid 16 is not default PMT (100l); trails of data are add_packet()ed
nicodvb
parents:
12049
diff
changeset
|
3018 return 1; |
996757299a82
removed unused and commented code; audio is pushed synchronously (reported to work better); pid 16 is not default PMT (100l); trails of data are add_packet()ed
nicodvb
parents:
12049
diff
changeset
|
3019 } |
996757299a82
removed unused and commented code; audio is pushed synchronously (reported to work better); pid 16 is not default PMT (100l); trails of data are add_packet()ed
nicodvb
parents:
12049
diff
changeset
|
3020 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3021 continue; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3022 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3023 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3024 { |
20478
c8bc7d300bb3
in ts_parse() centralized stream_read()+stream_skip(); smaller and cleaner
nicodvb
parents:
20472
diff
changeset
|
3025 memcpy(es->start, p, sz); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3026 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3027 if(es->size) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3028 return es->size; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3029 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3030 continue; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3031 } |
10014 | 3032 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3033 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3034 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3035 return 0; |
9610 | 3036 } |
3037 | |
3038 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3039 extern void skip_audio_frame(sh_audio_t *sh_audio); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3040 |
11190 | 3041 static void reset_fifos(ts_priv_t* priv, int a, int v, int s) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3042 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3043 if(a) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3044 { |
11190 | 3045 if(priv->fifo[0].pack != NULL) |
3046 { | |
3047 free_demux_packet(priv->fifo[0].pack); | |
3048 priv->fifo[0].pack = NULL; | |
3049 } | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3050 priv->fifo[0].offset = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3051 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3052 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3053 if(v) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3054 { |
11190 | 3055 if(priv->fifo[1].pack != NULL) |
3056 { | |
3057 free_demux_packet(priv->fifo[1].pack); | |
3058 priv->fifo[1].pack = NULL; | |
3059 } | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3060 priv->fifo[1].offset = 0; |
11190 | 3061 } |
3062 | |
3063 if(s) | |
3064 { | |
3065 if(priv->fifo[2].pack != NULL) | |
3066 { | |
3067 free_demux_packet(priv->fifo[2].pack); | |
3068 priv->fifo[2].pack = NULL; | |
3069 } | |
3070 priv->fifo[2].offset = 0; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3071 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3072 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3073 |
11190 | 3074 |
17636 | 3075 static void demux_seek_ts(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3076 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3077 demux_stream_t *d_audio=demuxer->audio; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3078 demux_stream_t *d_video=demuxer->video; |
11190 | 3079 demux_stream_t *d_sub=demuxer->sub; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3080 sh_audio_t *sh_audio=d_audio->sh; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3081 sh_video_t *sh_video=d_video->sh; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3082 ts_priv_t * priv = (ts_priv_t*) demuxer->priv; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3083 int i, video_stats; |
11190 | 3084 off_t newpos; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3085 |
11190 | 3086 //================= seek in MPEG-TS ========================== |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3087 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3088 ts_dump_streams(demuxer->priv); |
11190 | 3089 reset_fifos(priv, sh_audio != NULL, sh_video != NULL, demuxer->sub->id > 0); |
3090 | |
3091 | |
3092 if(sh_audio != NULL) | |
3093 ds_free_packs(d_audio); | |
3094 if(sh_video != NULL) | |
3095 ds_free_packs(d_video); | |
3096 if(demuxer->sub->id > 0) | |
3097 ds_free_packs(d_sub); | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3098 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3099 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3100 video_stats = (sh_video != NULL); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3101 if(video_stats) |
16883
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
3102 { |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
3103 mp_msg(MSGT_DEMUX, MSGL_V, "IBPS: %d, vb: %d\r\n", sh_video->i_bps, priv->vbitrate); |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
3104 if(priv->vbitrate) |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
3105 video_stats = priv->vbitrate; |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
3106 else |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
3107 video_stats = sh_video->i_bps; |
1f45d7872c56
more precise seeking based on calculated average video bitrate; works quite well in case of a TS with only 1 video stream
nicodvb
parents:
16877
diff
changeset
|
3108 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3109 |
11190 | 3110 newpos = (flags & 1) ? demuxer->movi_start : demuxer->filepos; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3111 if(flags & 2) // float seek 0..1 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3112 newpos+=(demuxer->movi_end-demuxer->movi_start)*rel_seek_secs; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3113 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3114 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3115 // time seek (secs) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3116 if(! video_stats) // unspecified or VBR |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3117 newpos += 2324*75*rel_seek_secs; // 174.3 kbyte/sec |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3118 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3119 newpos += video_stats*rel_seek_secs; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3120 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3121 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3122 |
11190 | 3123 if(newpos < demuxer->movi_start) |
3124 newpos = demuxer->movi_start; //begininng of stream | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3125 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3126 stream_seek(demuxer->stream, newpos); |
14981
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
3127 for(i = 0; i < 8192; i++) |
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
3128 if(priv->ts.pids[i] != NULL) |
293d3dee2eae
SL payloads are pushed to audio and video fifo only when they are flagged with random_accesspoint or access_unit_start
nicodvb
parents:
14968
diff
changeset
|
3129 priv->ts.pids[i]->is_synced = 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3130 |
11190 | 3131 videobuf_code_len = 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3132 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3133 if(sh_video != NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3134 ds_fill_buffer(d_video); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3135 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3136 if(sh_audio != NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3137 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3138 ds_fill_buffer(d_audio); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3139 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3140 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3141 while(sh_video != NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3142 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3143 if(sh_audio && !d_audio->eof && d_video->pts && d_audio->pts) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3144 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3145 float a_pts=d_audio->pts; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3146 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; |
11190 | 3147 if(d_video->pts > a_pts) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3148 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3149 skip_audio_frame(sh_audio); // sync audio |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3150 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3151 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3152 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3153 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3154 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3155 i = sync_video_packet(d_video); |
11190 | 3156 if((sh_video->format == VIDEO_MPEG1) || (sh_video->format == VIDEO_MPEG2)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3157 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3158 if(i==0x1B3 || i==0x1B8) break; // found it! |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3159 } |
22231 | 3160 else if((sh_video->format == VIDEO_MPEG4) && (i==0x1B6)) |
3161 break; | |
22163
0e60f69c9dc4
when playing vc1 content sync to sequence or entry point header
nicodvb
parents:
22162
diff
changeset
|
3162 else if(sh_video->format == VIDEO_VC1 && (i==0x10E || i==0x10F)) |
0e60f69c9dc4
when playing vc1 content sync to sequence or entry point header
nicodvb
parents:
22162
diff
changeset
|
3163 break; |
14034
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
3164 else //H264 |
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
3165 { |
22165 | 3166 if((i & ~0x60) == 0x105) break; |
14034
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
3167 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3168 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3169 if(!i || !skip_video_packet(d_video)) break; // EOF? |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3170 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3171 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3172 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3173 |
16175 | 3174 static int demux_ts_fill_buffer(demuxer_t * demuxer, demux_stream_t *ds) |
9610 | 3175 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3176 ES_stream_t es; |
15075
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
3177 ts_priv_t *priv = (ts_priv_t *)demuxer->priv; |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
3178 |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
3179 return -ts_parse(demuxer, &es, priv->packet, 0); |
9610 | 3180 } |
3181 | |
3182 | |
16175 | 3183 static int ts_check_file_dmx(demuxer_t *demuxer) |
3184 { | |
3185 return ts_check_file(demuxer) ? DEMUXER_TYPE_MPEG_TS : 0; | |
3186 } | |
3187 | |
21006 | 3188 static int is_usable_program(ts_priv_t *priv, pmt_t *pmt) |
3189 { | |
3190 int j; | |
3191 | |
3192 for(j = 0; j < pmt->es_cnt; j++) | |
3193 { | |
3194 if(priv->ts.pids[pmt->es[j].pid] == NULL || priv->ts.streams[pmt->es[j].pid].sh == NULL) | |
3195 continue; | |
3196 if( | |
3197 priv->ts.streams[pmt->es[j].pid].type == TYPE_VIDEO || | |
3198 priv->ts.streams[pmt->es[j].pid].type == TYPE_AUDIO | |
3199 ) | |
3200 return 1; | |
3201 } | |
3202 | |
3203 return 0; | |
3204 } | |
3205 | |
18688 | 3206 static int demux_ts_control(demuxer_t *demuxer, int cmd, void *arg) |
3207 { | |
3208 ts_priv_t* priv = (ts_priv_t *)demuxer->priv; | |
3209 | |
3210 switch(cmd) | |
3211 { | |
3212 case DEMUXER_CTRL_SWITCH_AUDIO: | |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3213 case DEMUXER_CTRL_SWITCH_VIDEO: |
18688 | 3214 { |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3215 void *sh = NULL; |
18688 | 3216 int i, n; |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3217 int reftype, areset = 0, vreset = 0; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3218 demux_stream_t *ds; |
18688 | 3219 |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3220 if(cmd == DEMUXER_CTRL_SWITCH_VIDEO) |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3221 { |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3222 reftype = TYPE_VIDEO; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3223 ds = demuxer->video; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3224 vreset = 1; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3225 } |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3226 else |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3227 { |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3228 reftype = TYPE_AUDIO; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3229 ds = demuxer->audio; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3230 areset = 1; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3231 } |
18688 | 3232 n = *((int*)arg); |
21067
baf2e8bed3d1
during DEMUXER_CTRL_SWITCH_x *arg set to -2 identifies 'disable stream x'
nicodvb
parents:
21006
diff
changeset
|
3233 if(n == -2) |
baf2e8bed3d1
during DEMUXER_CTRL_SWITCH_x *arg set to -2 identifies 'disable stream x'
nicodvb
parents:
21006
diff
changeset
|
3234 { |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3235 reset_fifos(priv, areset, vreset, 0); |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3236 ds->id = -2; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3237 ds->sh = NULL; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3238 ds_free_packs(ds); |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3239 *((int*)arg) = ds->id; |
21067
baf2e8bed3d1
during DEMUXER_CTRL_SWITCH_x *arg set to -2 identifies 'disable stream x'
nicodvb
parents:
21006
diff
changeset
|
3240 return DEMUXER_CTRL_OK; |
baf2e8bed3d1
during DEMUXER_CTRL_SWITCH_x *arg set to -2 identifies 'disable stream x'
nicodvb
parents:
21006
diff
changeset
|
3241 } |
baf2e8bed3d1
during DEMUXER_CTRL_SWITCH_x *arg set to -2 identifies 'disable stream x'
nicodvb
parents:
21006
diff
changeset
|
3242 |
18688 | 3243 if(n < 0) |
3244 { | |
3245 for(i = 0; i < 8192; i++) | |
3246 { | |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3247 if(priv->ts.streams[i].id == ds->id && priv->ts.streams[i].type == reftype) |
18688 | 3248 break; |
3249 } | |
3250 | |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3251 while(!sh) |
18688 | 3252 { |
3253 i = (i+1) % 8192; | |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3254 if(priv->ts.streams[i].type == reftype) |
20954
bd634deaaec7
restored circular looping when changing audio and video stream (previously broken)
nicodvb
parents:
20952
diff
changeset
|
3255 { |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3256 if(priv->ts.streams[i].id == ds->id) //we made a complete loop |
20955 | 3257 break; |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3258 sh = priv->ts.streams[i].sh; |
20954
bd634deaaec7
restored circular looping when changing audio and video stream (previously broken)
nicodvb
parents:
20952
diff
changeset
|
3259 } |
18688 | 3260 } |
3261 } | |
21099
7901c90ac6ac
slight simplification in demux_control_ts: no need to check *arg with last_{aid,vid} (small bugfix, too)
nicodvb
parents:
21072
diff
changeset
|
3262 else //audio track <n> |
18688 | 3263 { |
3264 for(i = 0; i < 8192; i++) | |
3265 { | |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3266 if(priv->ts.streams[i].id == n && priv->ts.streams[i].type == reftype) |
18688 | 3267 { |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3268 sh = priv->ts.streams[i].sh; |
18688 | 3269 break; |
3270 } | |
3271 } | |
3272 } | |
3273 | |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3274 if(sh) |
20951 | 3275 { |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3276 if(ds->id != priv->ts.streams[i].id) |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3277 reset_fifos(priv, areset, vreset, 0); |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3278 ds->id = priv->ts.streams[i].id; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3279 ds->sh = sh; |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3280 ds_free_packs(ds); |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3281 mp_msg(MSGT_DEMUX, MSGL_V, "\r\ndemux_ts, switched to audio pid %d, id: %d, sh: %p\r\n", i, ds->id, sh); |
20951 | 3282 } |
21072
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3283 |
e45dc4e170a5
in demux_ts_control unified SWITCH_AUDIO and SWITCH_VIDEO (they were identical)
nicodvb
parents:
21067
diff
changeset
|
3284 *((int*)arg) = ds->id; |
20951 | 3285 return DEMUXER_CTRL_OK; |
3286 } | |
18688 | 3287 |
21006 | 3288 case DEMUXER_CTRL_IDENTIFY_PROGRAM: //returns in prog->{aid,vid} the new ids that comprise a program |
3289 { | |
3290 int i, j, cnt=0; | |
3291 int vid_done=0, aid_done=0; | |
3292 pmt_t *pmt = NULL; | |
3293 demux_program_t *prog = arg; | |
3294 | |
3295 if(priv->pmt_cnt < 2) | |
3296 return DEMUXER_CTRL_NOTIMPL; | |
3297 | |
3298 if(prog->progid == -1) | |
3299 { | |
3300 int cur_pmt_idx = 0; | |
3301 | |
3302 for(i = 0; i < priv->pmt_cnt; i++) | |
3303 if(priv->pmt[i].progid == priv->prog) | |
3304 { | |
3305 cur_pmt_idx = i; | |
3306 break; | |
3307 } | |
3308 | |
3309 i = (cur_pmt_idx + 1) % priv->pmt_cnt; | |
3310 while(i != cur_pmt_idx) | |
3311 { | |
3312 pmt = &priv->pmt[i]; | |
3313 cnt = is_usable_program(priv, pmt); | |
3314 if(cnt) | |
3315 break; | |
3316 i = (i + 1) % priv->pmt_cnt; | |
3317 } | |
3318 } | |
3319 else | |
3320 { | |
3321 for(i = 0; i < priv->pmt_cnt; i++) | |
3322 if(priv->pmt[i].progid == prog->progid) | |
3323 { | |
3324 pmt = &priv->pmt[i]; //required program | |
3325 cnt = is_usable_program(priv, pmt); | |
3326 } | |
3327 } | |
3328 | |
3329 if(!cnt) | |
3330 return DEMUXER_CTRL_NOTIMPL; | |
3331 | |
3332 //finally some food | |
3333 prog->aid = prog->vid = -2; //no audio and no video by default | |
3334 for(j = 0; j < pmt->es_cnt; j++) | |
3335 { | |
3336 if(priv->ts.pids[pmt->es[j].pid] == NULL || priv->ts.streams[pmt->es[j].pid].sh == NULL) | |
3337 continue; | |
3338 | |
3339 if(!vid_done && priv->ts.streams[pmt->es[j].pid].type == TYPE_VIDEO) | |
3340 { | |
3341 vid_done = 1; | |
3342 prog->vid = priv->ts.streams[pmt->es[j].pid].id; | |
3343 } | |
3344 else if(!aid_done && priv->ts.streams[pmt->es[j].pid].type == TYPE_AUDIO) | |
3345 { | |
3346 aid_done = 1; | |
3347 prog->aid = priv->ts.streams[pmt->es[j].pid].id; | |
3348 } | |
3349 } | |
3350 | |
3351 priv->prog = prog->progid = pmt->progid; | |
3352 return DEMUXER_CTRL_OK; | |
3353 } | |
3354 | |
18688 | 3355 default: |
3356 return DEMUXER_CTRL_NOTIMPL; | |
3357 } | |
3358 } | |
3359 | |
16175 | 3360 |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
25571
diff
changeset
|
3361 const demuxer_desc_t demuxer_desc_mpeg_ts = { |
16175 | 3362 "MPEG-TS demuxer", |
3363 "mpegts", | |
3364 "TS", | |
3365 "Nico Sabbi", | |
3366 "", | |
3367 DEMUXER_TYPE_MPEG_TS, | |
3368 0, // unsafe autodetect | |
3369 ts_check_file_dmx, | |
3370 demux_ts_fill_buffer, | |
3371 demux_open_ts, | |
3372 demux_close_ts, | |
3373 demux_seek_ts, | |
18688 | 3374 demux_ts_control |
16175 | 3375 }; |