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