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