Mercurial > mplayer.hg
annotate libmpdemux/demux_ts.c @ 15414:acc0d6793965
Sync with 1.963
author | gpoirier |
---|---|
date | Wed, 11 May 2005 19:38:10 +0000 |
parents | 737cc83784fb |
children | d283a96c0ecb |
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 | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
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 | |
37 #include "bswap.h" | |
11190 | 38 #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
|
39 #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
|
40 #include "mpeg_hdr.h" |
9610 | 41 |
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
|
42 #define TS_PH_PACKET_SIZE 192 |
9610 | 43 #define TS_FEC_PACKET_SIZE 204 |
44 #define TS_PACKET_SIZE 188 | |
45 #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
|
46 |
9610 | 47 #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
|
48 #define MAX_CHECK_SIZE 65535 |
11190 | 49 #define TS_MAX_PROBE_SIZE 2000000 /* dont forget to change this in cfg-common.h too */ |
10014 | 50 #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
|
51 #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
|
52 #define MAX_A52_FRAME_SIZE 3840 |
9610 | 53 |
54 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
55 int ts_prog; |
11190 | 56 int ts_keep_broken=0; |
57 off_t ts_probe = TS_MAX_PROBE_SIZE; | |
58 extern char *dvdsub_lang, *audio_lang; //for -alang | |
14046
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
59 extern int demux_aid_vid_mismatch; |
9610 | 60 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
61 typedef enum |
9610 | 62 { |
63 UNKNOWN = -1, | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
64 VIDEO_MPEG1 = 0x10000001, |
9610 | 65 VIDEO_MPEG2 = 0x10000002, |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
66 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
|
67 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
|
68 VIDEO_AVC = mmioFOURCC('a', 'v', 'c', '1'), |
9610 | 69 AUDIO_MP2 = 0x50, |
70 AUDIO_A52 = 0x2000, | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
71 AUDIO_LPCM_BE = 0x10001, |
11190 | 72 AUDIO_AAC = mmioFOURCC('M', 'P', '4', 'A'), |
9610 | 73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 MP4_OD = 0xD200000, |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
79 } es_stream_type_t; |
9610 | 80 |
14968
b5fb8b0b07c5
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 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
|
82 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
|
83 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
|
84 } ts_section_t; |
9610 | 85 |
86 typedef struct { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
87 int size; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
88 unsigned char *start; |
10014 | 89 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
|
90 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
|
91 float pts, last_pts; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
92 int pid; |
11190 | 93 char lang[4]; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 } sl; |
10014 | 102 } ES_stream_t; |
103 | |
9610 | 104 |
10014 | 105 typedef struct MpegTSContext { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
106 int packet_size; // raw packet size, including FEC if present e.g. 188 bytes |
10014 | 107 ES_stream_t *pids[NB_PID_MAX]; |
108 } MpegTSContext; | |
9610 | 109 |
10014 | 110 |
111 typedef struct { | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
112 demux_stream_t *ds; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
113 demux_packet_t *pack; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
114 int offset, buffer_size; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
115 } av_fifo_t; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
116 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
117 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
|
118 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
|
119 int32_t stream_type; //video, audio etc. |
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
|
120 uint8_t buf[4096]; |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
121 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
|
122 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
|
123 } 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
|
124 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
125 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
|
126 //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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
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 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
|
138 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
|
139 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
|
140 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
|
141 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
|
142 } 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
|
143 |
b5fb8b0b07c5
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 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 } 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
|
150 |
b5fb8b0b07c5
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 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 } 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
|
157 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
158 typedef struct { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
159 uint8_t skip; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
160 uint8_t table_id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
161 uint8_t ssi; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
162 uint16_t section_length; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
163 uint16_t ts_id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
164 uint8_t version_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
165 uint8_t curr_next; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
166 uint8_t section_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
167 uint8_t last_section_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
168 struct pat_progs_t { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
169 uint16_t id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
170 uint16_t pmt_pid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
171 } *progs; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
172 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
|
173 ts_section_t section; |
11190 | 174 } pat_t; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
175 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
176 typedef struct { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
177 uint16_t progid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
178 uint8_t skip; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
179 uint8_t table_id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
180 uint8_t ssi; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
181 uint16_t section_length; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
182 uint8_t version_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
183 uint8_t curr_next; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
184 uint8_t section_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
185 uint8_t last_section_number; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
186 uint16_t PCR_PID; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
187 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
|
188 ts_section_t section; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
189 uint16_t es_cnt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
190 struct pmt_es_t { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
191 uint16_t pid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
192 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
|
193 uint16_t descr_length; |
11190 | 194 uint8_t format_descriptor[5]; |
195 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
|
196 uint16_t mp4_es_id; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
197 } *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
|
198 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
|
199 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
|
200 int od_cnt, mp4es_cnt; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
201 } pmt_t; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
202 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
203 typedef struct { |
10014 | 204 MpegTSContext ts; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
205 int last_pid; |
11190 | 206 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
|
207 pat_t pat; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
208 pmt_t *pmt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
209 uint16_t pmt_cnt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
210 uint32_t prog; |
11190 | 211 int keep_broken; |
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
|
212 char packet[TS_FEC_PACKET_SIZE]; |
10014 | 213 } ts_priv_t; |
214 | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
215 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
216 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
|
217 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
|
218 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
|
219 } 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
|
220 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
221 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
222 #define IS_AUDIO(x) (((x) == AUDIO_MP2) || ((x) == AUDIO_A52) || ((x) == AUDIO_LPCM_BE) || ((x) == AUDIO_AAC)) |
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
|
223 #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
|
224 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
225 static int ts_parse(demuxer_t *demuxer, ES_stream_t *es, unsigned char *packet, int probe); |
10310
68e714ed669f
fix one missing #include, one missing extern and one 10l error.
rathann
parents:
10259
diff
changeset
|
226 extern void resync_audio_stream( sh_audio_t *sh_audio ); |
9610 | 227 |
228 static uint8_t get_packet_size(const unsigned char *buf, int size) | |
229 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
230 int i; |
9610 | 231 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
232 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
|
233 return 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
234 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
235 for(i=0; i<NUM_CONSECUTIVE_TS_PACKETS; i++) |
9610 | 236 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
237 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
|
238 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
239 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
|
240 goto try_fec; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
241 } |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
242 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
243 return TS_PACKET_SIZE; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
244 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
245 try_fec: |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
246 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
|
247 { |
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
|
248 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
|
249 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
|
250 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
|
251 } |
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
|
252 } |
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
|
253 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
|
254 |
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
|
255 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
|
256 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
|
257 { |
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
|
258 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
|
259 return 0; |
9610 | 260 } |
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
|
261 return TS_PH_PACKET_SIZE; |
9610 | 262 } |
263 | |
264 | |
265 | |
266 int ts_check_file(demuxer_t * demuxer) | |
267 { | |
268 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
|
269 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
|
270 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
|
271 int cc[NB_PID_MAX], last_cc[NB_PID_MAX], pid, cc_ok, c, good, bad; |
9610 | 272 uint8_t size = 0; |
273 off_t pos = 0; | |
11190 | 274 off_t init_pos; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
275 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
276 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
|
277 |
11190 | 278 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
|
279 is_ts = 0; |
9610 | 280 while(! done) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
281 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
282 i = 1; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
283 c = 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
284 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
285 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
|
286 && (c >= 0) |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
287 && (i < MAX_CHECK_SIZE) |
10014 | 288 && ! demuxer->stream->eof |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
289 ) i++; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
290 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
291 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
292 if(c != 0x47) |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
293 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
294 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
|
295 is_ts = 0; |
10014 | 296 done = 1; |
297 continue; | |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
298 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
299 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
300 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
|
301 buf[0] = c; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
302 _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
|
303 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
304 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
|
305 { |
10014 | 306 mp_msg(MSGT_DEMUX, MSGL_V, "COULDN'T READ ENOUGH DATA, EXITING TS_CHECK\n"); |
307 stream_reset(demuxer->stream); | |
308 return 0; | |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
309 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
310 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
311 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
|
312 if(size) |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
313 { |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
314 done = 1; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
315 is_ts = 1; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
316 } |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
317 |
11190 | 318 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
|
319 { |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
320 done = 1; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
321 is_ts = 0; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
322 } |
10014 | 323 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
324 |
11190 | 325 mp_msg(MSGT_DEMUX, MSGL_V, "TRIED UP TO POSITION %llu, FOUND %x, packet_size= %d, SEEMS A TS? %d\n", (uint64_t) pos, c, size, is_ts); |
10014 | 326 stream_seek(demuxer->stream, pos); |
327 | |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
328 if(! is_ts) |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
329 return 0; |
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
330 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
331 //LET'S CHECK continuity counters |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
332 good = bad = 0; |
10014 | 333 for(count = 0; count < NB_PID_MAX; count++) |
334 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
335 cc[count] = last_cc[count] = -1; |
9610 | 336 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
337 |
10014 | 338 for(count = 0; count < NUM_CONSECUTIVE_TS_PACKETS; count++) |
339 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
340 ptr = &(buf[size * count]); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
341 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
|
342 mp_msg(MSGT_DEMUX, MSGL_DBG2, "BUF: %02x %02x %02x %02x, PID %d, SIZE: %d \n", |
10014 | 343 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
|
344 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
345 if((pid == 8191) || (pid < 16)) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
346 continue; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
347 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
348 cc[pid] = (ptr[3] & 0xf); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
349 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
|
350 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
|
351 if(! cc_ok) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
352 //return 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
353 bad++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
354 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
355 good++; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
356 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
357 last_cc[pid] = cc[pid]; |
10014 | 358 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
359 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
360 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
|
361 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
362 if(good >= bad) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
363 return size; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
364 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
365 return 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
366 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
367 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
368 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
369 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
|
370 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
371 int x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
372 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
373 if(priv->pmt == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
374 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
375 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
376 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
|
377 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
378 if(priv->pmt[x].progid == progid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
379 return x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
380 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
381 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
382 return -1; |
9610 | 383 } |
384 | |
385 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
386 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
|
387 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
388 int i, j; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
389 pmt_t *pmt; |
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 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
392 if(priv->pmt == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
393 return -1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
394 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
395 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
396 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
|
397 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
398 pmt = &(priv->pmt[i]); |
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(pmt->es == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
401 return -1; |
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 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
|
404 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
405 if(pmt->es[j].pid == pid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
406 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
407 if((req == 0) || (req == pmt->progid)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
408 return pmt->progid; |
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 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
411 |
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 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
414 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
415 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
416 |
11190 | 417 static inline int pid_match_lang(ts_priv_t *priv, uint16_t pid, char *lang) |
9610 | 418 { |
11190 | 419 uint16_t i, j; |
420 pmt_t *pmt; | |
421 | |
422 if(priv->pmt == NULL) | |
423 return -1; | |
424 | |
425 for(i=0; i < priv->pmt_cnt; i++) | |
426 { | |
427 pmt = &(priv->pmt[i]); | |
428 | |
429 if(pmt->es == NULL) | |
430 return -1; | |
431 | |
432 for(j = 0; j < pmt->es_cnt; j++) | |
433 { | |
434 if(pmt->es[j].pid != pid) | |
435 continue; | |
436 | |
437 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); | |
438 if(strncmp(pmt->es[j].lang, lang, 3) == 0) | |
439 { | |
440 return 1; | |
441 } | |
442 } | |
443 | |
444 } | |
445 | |
446 return -1; | |
447 } | |
448 | |
449 typedef struct { | |
450 int32_t atype, vtype, stype; //types | |
451 int32_t apid, vpid, spid; //stream ids | |
452 char slang[4], alang[4]; //languages | |
453 int16_t prog; | |
454 off_t probe; | |
455 } tsdemux_init_t; | |
456 | |
13608 | 457 //stripped down version of a52_syncinfo() from liba52 |
458 //copyright belongs to Michel Lespinasse <walken@zoy.org> and Aaron Holtzman <aholtzma@ess.engr.uvic.ca> | |
459 static int a52_framesize(uint8_t * buf) | |
460 { | |
461 int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112, | |
462 128, 160, 192, 224, 256, 320, 384, 448, | |
463 512, 576, 640 | |
464 }; | |
465 uint8_t halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3}; | |
466 int frmsizecod, bitrate, half; | |
467 | |
468 if((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */ | |
469 return 0; | |
470 | |
471 if(buf[5] >= 0x60) /* bsid >= 12 */ | |
472 return 0; | |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
473 |
13608 | 474 half = halfrate[buf[5] >> 3]; |
475 | |
476 frmsizecod = buf[4] & 63; | |
477 if(frmsizecod >= 38) | |
478 return 0; | |
479 | |
480 bitrate = rate[frmsizecod >> 1]; | |
481 | |
482 switch(buf[4] & 0xc0) | |
483 { | |
484 case 0: /* 48 KHz */ | |
485 return 4 * bitrate; | |
486 case 0x40: /* 44.1 KHz */ | |
487 return 2 * (320 * bitrate / 147 + (frmsizecod & 1)); | |
488 case 0x80: /* 32 KHz */ | |
489 return 6 * bitrate; | |
490 } | |
491 | |
492 return 0; | |
493 } | |
494 | |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
495 //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
|
496 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
|
497 { |
13608 | 498 int cnt, frame_length, ok; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
499 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
500 cnt = ok = 0; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
501 if(len < 8) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
502 return 0; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
503 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
504 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
|
505 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
506 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
|
507 { |
13608 | 508 frame_length = a52_framesize(&buf[cnt]); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
509 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
|
510 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
511 cnt += frame_length; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
512 ok++; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
513 } |
13581
ffed770f7564
fixed a bug that makes the demuxer loop forever probing a52 audio when a52_syncinfo() returns 0
nicodvb
parents:
13579
diff
changeset
|
514 else |
ffed770f7564
fixed a bug that makes the demuxer loop forever probing a52 audio when a52_syncinfo() returns 0
nicodvb
parents:
13579
diff
changeset
|
515 cnt++; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
516 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
517 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
518 cnt++; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
519 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
520 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
521 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
|
522 return ok; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
523 } |
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 |
11190 | 526 static off_t ts_detect_streams(demuxer_t *demuxer, tsdemux_init_t *param) |
527 { | |
528 int video_found = 0, audio_found = 0, sub_found = 0, i, num_packets = 0, req_apid, req_vpid, req_spid; | |
529 int is_audio, is_video, is_sub, has_tables; | |
530 int32_t p, chosen_pid = 0; | |
531 off_t pos=0, ret = 0, init_pos; | |
10014 | 532 ES_stream_t es; |
9610 | 533 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
|
534 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
|
535 struct { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
536 char *buf; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
537 int pos; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
538 } pes_priv1[8192], *pptr; |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
539 char *tmpbuf; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
540 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
541 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
|
542 |
11190 | 543 req_apid = param->apid; |
544 req_vpid = param->vpid; | |
545 req_spid = param->spid; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
546 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
547 has_tables = 0; |
14571
512a57bbe68d
replaced bzero() with memset(); stream_type 0x0f is AAC
nicodvb
parents:
14046
diff
changeset
|
548 memset(pes_priv1, 0, sizeof(pes_priv1)); |
11190 | 549 init_pos = stream_tell(demuxer->stream); |
550 mp_msg(MSGT_DEMUXER, MSGL_INFO, "PROBING UP TO %llu, PROG: %d\n", (uint64_t) param->probe, param->prog); | |
551 while((pos <= init_pos + param->probe) && (! demuxer->stream->eof)) | |
9610 | 552 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
553 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
|
554 if(ts_parse(demuxer, &es, tmp, 1)) |
9610 | 555 { |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
556 //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
|
557 //in this case we try to find at least 3 A52 syncwords |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
558 if((es.type == PES_PRIVATE1) && (! audio_found)) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
559 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
560 pptr = &pes_priv1[es.pid]; |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
561 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
|
562 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
|
563 { |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
564 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
|
565 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
|
566 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
|
567 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
|
568 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
569 param->atype = AUDIO_A52; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
570 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
|
571 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
572 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
573 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
574 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
575 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
|
576 is_video = IS_VIDEO(es.type) || ((es.type==SL_PES_STREAM) && IS_VIDEO(es.subtype)); |
11190 | 577 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
|
578 |
11190 | 579 |
580 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
|
581 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
582 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
583 if(is_video) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
584 { |
14046
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
585 if (identify) |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
586 mp_msg(MSGT_GLOBAL, MSGL_INFO, "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
|
587 chosen_pid = (req_vpid == es.pid); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
588 if((! chosen_pid) && (req_vpid > 0)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
589 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
590 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
591 else if(is_audio) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
592 { |
14046
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
593 if (identify) |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
594 { |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
595 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", es.pid); |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
596 if (es.lang[0] > 0) |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
597 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AID_%d_LANG=%s\n", es.pid, es.lang); |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
598 } |
11190 | 599 if(req_apid > 0) |
600 { | |
601 chosen_pid = (req_apid == es.pid); | |
602 if(! chosen_pid) | |
603 continue; | |
604 } | |
605 else if(param->alang[0] > 0) | |
606 { | |
607 if(pid_match_lang(priv, es.pid, param->alang) == -1) | |
608 continue; | |
609 | |
610 chosen_pid = 1; | |
611 param->apid = req_apid = es.pid; | |
612 } | |
613 } | |
614 else if(is_sub) | |
615 { | |
14046
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
616 if (identify) |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
617 { |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
618 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", es.pid); |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
619 if (es.lang[0] > 0) |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
620 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SID_%d_LANG=%s\n", es.pid, es.lang); |
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
621 } |
11190 | 622 chosen_pid = (req_spid == es.pid); |
623 if((! chosen_pid) && (req_spid > 0)) | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
624 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
625 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
626 |
11190 | 627 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
|
628 chosen_pid = 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
629 |
11190 | 630 if((ret == 0) && chosen_pid) |
631 { | |
632 ret = stream_tell(demuxer->stream); | |
633 } | |
634 | |
635 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
|
636 if(p != -1) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
637 has_tables++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
638 |
11190 | 639 if((param->prog == 0) && (p != -1)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
640 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
641 if(chosen_pid) |
11190 | 642 param->prog = p; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
643 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
644 |
11190 | 645 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
|
646 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
647 if(audio_found) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
648 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
649 if(is_video && (req_vpid == es.pid)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
650 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
651 param->vtype = IS_VIDEO(es.type) ? es.type : es.subtype; |
11190 | 652 param->vpid = es.pid; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
653 video_found = 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
654 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
655 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
656 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
657 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
658 if(video_found) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
659 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
660 if(is_audio && (req_apid == es.pid)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
661 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
662 param->atype = IS_AUDIO(es.type) ? es.type : es.subtype; |
11190 | 663 param->apid = es.pid; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
664 audio_found = 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
665 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
666 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
667 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
668 |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
669 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
670 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
671 } |
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 |
11190 | 674 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
|
675 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
676 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
677 if(is_video) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
678 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
679 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
|
680 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
681 param->vtype = IS_VIDEO(es.type) ? es.type : es.subtype; |
11190 | 682 param->vpid = es.pid; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
683 video_found = 1; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
684 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
685 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
686 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
687 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
688 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
|
689 { |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
690 //novideo or we have at least 348 audio packets (64 KB) without video (TS with audio only) |
11190 | 691 param->vtype = 0; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
692 break; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
693 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
694 |
11190 | 695 if(is_sub) |
696 { | |
697 if((req_spid == -1) || (req_spid == es.pid)) | |
698 { | |
699 param->stype = es.type; | |
700 param->spid = es.pid; | |
701 sub_found = 1; | |
702 } | |
703 } | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
704 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
705 if(is_audio) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
706 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
707 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
|
708 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
709 param->atype = IS_AUDIO(es.type) ? es.type : es.subtype; |
11190 | 710 param->apid = es.pid; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
711 audio_found = 1; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
712 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
713 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
714 |
11190 | 715 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
|
716 num_packets++; |
10259
b60e89268837
- discard soon non TS files (previously it took too long, as in the case
arpi
parents:
10253
diff
changeset
|
717 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
718 if((req_apid == -2) && video_found) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
719 { |
11190 | 720 param->atype = 0; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
721 break; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
722 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
723 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
724 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
|
725 break; |
9610 | 726 } |
727 } | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
728 |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
729 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
|
730 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
731 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
|
732 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
733 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
|
734 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
|
735 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
|
736 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
737 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
738 |
9610 | 739 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
|
740 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
741 if(param->vtype == VIDEO_MPEG1) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
742 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO MPEG1(pid=%d)", param->vpid); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
743 else if(param->vtype == VIDEO_MPEG2) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
744 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO MPEG2(pid=%d)", param->vpid); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
745 else if(param->vtype == VIDEO_MPEG4) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
746 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO MPEG4(pid=%d)...", param->vpid); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
747 else if(param->vtype == VIDEO_H264) |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
748 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO H264(pid=%d)...", param->vpid); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
749 else if(param->vtype == 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
|
750 mp_msg(MSGT_DEMUXER, MSGL_INFO, "VIDEO AVC(NAL-H264, pid=%d)...", param->vpid); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
751 } |
9610 | 752 else |
753 { | |
11190 | 754 param->vtype = UNKNOWN; |
755 //WE DIDN'T MATCH ANY VIDEO STREAM | |
756 mp_msg(MSGT_DEMUXER, MSGL_INFO, "NO VIDEO! "); | |
9610 | 757 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
758 |
11190 | 759 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
|
760 mp_msg(MSGT_DEMUXER, MSGL_INFO, "AUDIO MPA(pid=%d)", param->apid); |
11190 | 761 else if(param->atype == AUDIO_A52) |
762 mp_msg(MSGT_DEMUXER, MSGL_INFO, "AUDIO A52(pid=%d)", param->apid); | |
763 else if(param->atype == AUDIO_LPCM_BE) | |
764 mp_msg(MSGT_DEMUXER, MSGL_INFO, "AUDIO LPCM(pid=%d)", param->apid); | |
765 else if(param->atype == AUDIO_AAC) | |
766 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
|
767 else |
9610 | 768 { |
11190 | 769 audio_found = 0; |
770 param->atype = UNKNOWN; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
771 //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
|
772 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
|
773 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
774 |
11190 | 775 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
|
776 mp_msg(MSGT_DEMUXER, MSGL_INFO, " SUB %s(pid=%d) ", (param->stype==SPU_DVD ? "DVD" : "DVB"), param->spid); |
11190 | 777 else |
778 { | |
779 param->stype = UNKNOWN; | |
780 mp_msg(MSGT_DEMUXER, MSGL_INFO, " NO SUBS (yet)! "); | |
781 } | |
782 | |
783 if(video_found || audio_found) | |
784 { | |
785 if(demuxer->stream->eof && (ret == 0)) | |
786 ret = init_pos; | |
787 mp_msg(MSGT_DEMUXER, MSGL_INFO, " PROGRAM N. %d\n", param->prog); | |
788 } | |
789 else | |
790 mp_msg(MSGT_DEMUXER, MSGL_INFO, "\n"); | |
791 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
792 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
793 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
|
794 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
795 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
|
796 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
797 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
|
798 priv->ts.pids[i]->pts = priv->ts.pids[i]->last_pts = 0; |
11190 | 799 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
|
800 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
|
801 } |
9610 | 802 } |
11190 | 803 |
804 return ret; | |
9610 | 805 } |
806 | |
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
|
807 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
|
808 { |
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
|
809 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
|
810 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
|
811 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
|
812 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
|
813 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
|
814 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
|
815 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
|
816 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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 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
|
822 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
|
823 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
|
824 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
|
825 *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
|
826 *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
|
827 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
|
828 } |
9610 | 829 |
10014 | 830 demuxer_t *demux_open_ts(demuxer_t * demuxer) |
831 { | |
832 int i; | |
833 uint8_t packet_size; | |
834 sh_video_t *sh_video; | |
835 sh_audio_t *sh_audio; | |
11190 | 836 off_t start_pos; |
837 tsdemux_init_t params; | |
10014 | 838 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
|
839 |
11190 | 840 mp_msg(MSGT_DEMUX, MSGL_INFO, "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
|
841 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
|
842 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
843 |
10014 | 844 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
|
845 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
846 |
10014 | 847 stream_reset(demuxer->stream); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
848 |
10014 | 849 packet_size = ts_check_file(demuxer); |
850 if(!packet_size) | |
851 return NULL; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
852 |
10014 | 853 priv = malloc(sizeof(ts_priv_t)); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
854 if(priv == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
855 { |
11190 | 856 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
|
857 return NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
858 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
859 |
10014 | 860 for(i=0; i < 8192; i++) |
861 priv->ts.pids[i] = NULL; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
862 priv->pat.progs = NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
863 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
|
864 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
|
865 priv->pat.section.buffer_len = 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
866 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
867 priv->pmt = NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
868 priv->pmt_cnt = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
869 |
11190 | 870 priv->keep_broken = ts_keep_broken; |
10014 | 871 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
|
872 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
873 |
10014 | 874 demuxer->priv = priv; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
875 if(demuxer->stream->type != STREAMTYPE_FILE) |
11190 | 876 demuxer->seekable = 1; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
877 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
878 demuxer->seekable = 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
879 |
11190 | 880 |
881 params.atype = params.vtype = params.stype = UNKNOWN; | |
882 params.apid = demuxer->audio->id; | |
883 params.vpid = demuxer->video->id; | |
884 params.spid = demuxer->sub->id; | |
885 params.prog = ts_prog; | |
886 params.probe = ts_probe; | |
887 | |
888 if(dvdsub_lang != NULL) | |
889 { | |
890 strncpy(params.slang, dvdsub_lang, 3); | |
891 params.slang[3] = 0; | |
892 } | |
893 else | |
894 memset(params.slang, 0, 4); | |
895 | |
896 if(audio_lang != NULL) | |
897 { | |
898 strncpy(params.alang, audio_lang, 3); | |
899 params.alang[3] = 0; | |
900 } | |
901 else | |
902 memset(params.alang, 0, 4); | |
903 | |
904 start_pos = ts_detect_streams(demuxer, ¶ms); | |
905 | |
906 demuxer->audio->id = params.apid; | |
907 demuxer->video->id = params.vpid; | |
908 demuxer->sub->id = params.spid; | |
909 priv->prog = params.prog; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
910 |
14046
4802041ab8e3
Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
mosu
parents:
14034
diff
changeset
|
911 demux_aid_vid_mismatch = 1; // don't identify in new_sh_* since ids don't match |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
912 |
11190 | 913 if(params.vtype != UNKNOWN) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
914 { |
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
|
915 ES_stream_t *es = priv->ts.pids[params.vpid]; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
916 sh_video = new_sh_video(demuxer, 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
|
917 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
|
918 { |
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
|
919 int w = 0, h = 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
|
920 sh_video->bih = (BITMAPINFOHEADER *) calloc(1, sizeof(BITMAPINFOHEADER) + 4096); |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
921 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
|
922 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
|
923 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
|
924 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
|
925 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
|
926 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
|
927 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
|
928 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
|
929 { |
737cc83784fb
set width, height and biCompression when the video stream contains avc1; reuse a private member rather than a in-stack packet[204]; set pes_es->is_synced =1 when au_start=1 (SL); update PMT when setting mp4es codec (SL); fix tss->is_synced assignment (don't forget the value when it was previously set)
nicodvb
parents:
15067
diff
changeset
|
930 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
|
931 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
|
932 } |
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
|
933 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
934 sh_video->ds = demuxer->video; |
11190 | 935 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
|
936 demuxer->video->sh = sh_video; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
937 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
938 |
11190 | 939 if(params.atype != UNKNOWN) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
940 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
941 sh_audio = new_sh_audio(demuxer, 0); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
942 sh_audio->ds = demuxer->audio; |
11190 | 943 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
|
944 demuxer->audio->sh = sh_audio; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
945 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
946 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
947 |
11190 | 948 mp_msg(MSGT_DEMUXER,MSGL_INFO, "Opened TS demuxer, audio: %x(pid %d), video: %x(pid %d)...POS=%llu\n", params.atype, demuxer->audio->id, params.vtype, demuxer->video->id, (uint64_t) start_pos); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
949 |
10014 | 950 |
11190 | 951 start_pos = (start_pos <= priv->ts.packet_size ? 0 : start_pos - priv->ts.packet_size); |
952 demuxer->movi_start = start_pos; | |
953 stream_reset(demuxer->stream); | |
954 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
|
955 |
11190 | 956 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
957 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
|
958 |
11190 | 959 for(i = 0; i < 3; i++) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
960 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
961 priv->fifo[i].pack = NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
962 priv->fifo[i].offset = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
963 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
964 priv->fifo[0].ds = demuxer->audio; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
965 priv->fifo[1].ds = demuxer->video; |
11190 | 966 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
|
967 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
968 priv->fifo[0].buffer_size = 1536; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
969 priv->fifo[1].buffer_size = 32767; |
11190 | 970 priv->fifo[2].buffer_size = 32767; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
971 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
972 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
|
973 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
|
974 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
|
975 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
976 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
|
977 return demuxer; |
10014 | 978 } |
979 | |
9610 | 980 void demux_close_ts(demuxer_t * demuxer) |
981 { | |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
982 uint16_t i; |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
983 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
|
984 |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
985 if(priv) |
9610 | 986 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
987 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
|
988 free(priv->pat.section.buffer); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
989 if(priv->pat.progs) |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
990 free(priv->pat.progs); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
991 |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
992 if(priv->pmt) |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
993 { |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
994 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
|
995 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
996 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
|
997 free(priv->pmt[i].section.buffer); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
998 if(priv->pmt[i].es) |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
999 free(priv->pmt[i].es); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1000 } |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1001 free(priv->pmt); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1002 } |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1003 free(priv); |
9610 | 1004 } |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1005 demuxer->priv=NULL; |
9610 | 1006 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1007 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1008 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1009 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
|
1010 #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
|
1011 |
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
|
1012 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
|
1013 { |
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
|
1014 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
|
1015 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
|
1016 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
|
1017 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
|
1018 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
|
1019 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
|
1020 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
|
1021 |
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
|
1022 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
|
1023 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
|
1024 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
|
1025 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
|
1026 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1027 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
|
1028 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1029 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
|
1030 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
|
1031 } |
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
|
1032 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
|
1033 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
|
1034 |
b5fb8b0b07c5
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 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
|
1036 { |
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
|
1037 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
|
1038 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
|
1039 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1040 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
|
1041 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
|
1042 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1043 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
|
1044 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1045 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
|
1046 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
|
1047 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
|
1048 |
b5fb8b0b07c5
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 //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
|
1050 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
|
1051 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1052 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
|
1053 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
|
1054 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
|
1055 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
|
1056 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
|
1057 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
|
1058 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
|
1059 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1060 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
|
1061 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1062 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
|
1063 } |
b5fb8b0b07c5
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 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
|
1065 |
b5fb8b0b07c5
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(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
|
1068 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
|
1069 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
|
1070 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
|
1071 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
|
1072 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
|
1073 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
|
1074 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1075 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
|
1076 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
|
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 |
b5fb8b0b07c5
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 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
|
1080 { |
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
|
1081 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
|
1082 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
|
1083 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 //(! 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
|
1086 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
|
1087 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
|
1088 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
|
1089 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
|
1090 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
|
1091 |
b5fb8b0b07c5
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 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
|
1093 { |
b5fb8b0b07c5
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 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
|
1095 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
|
1096 } |
b5fb8b0b07c5
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(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
|
1099 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
|
1100 |
b5fb8b0b07c5
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 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
|
1102 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
|
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 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
|
1105 |
b5fb8b0b07c5
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 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
|
1107 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
|
1108 |
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
|
1109 //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
|
1110 //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
|
1111 //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
|
1112 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
|
1113 |
14968
b5fb8b0b07c5
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 += 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
|
1115 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
|
1116 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
|
1117 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
|
1118 { |
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
|
1119 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
|
1120 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
|
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 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
|
1123 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
|
1124 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
|
1125 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
|
1126 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
|
1127 { |
b5fb8b0b07c5
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->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
|
1129 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
|
1130 } |
b5fb8b0b07c5
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 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
|
1132 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
|
1133 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
|
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 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
|
1136 |
b5fb8b0b07c5
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 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
|
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 m = min(8, sl->ts_len - 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
|
1140 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
|
1141 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
|
1142 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
|
1143 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
|
1144 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
|
1145 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
|
1146 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
|
1147 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1148 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1149 pes_es->pts = (float) v / (float) sl->ts_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
|
1150 mp_msg(MSGT_DEMUXER,MSGL_DBG2, "CTS: %d bits, value: %llu/%d = %.3f\n", sl->ts_len, v, sl->ts_resolution, pes_es->pts); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1151 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
1155 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
|
1156 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
|
1157 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1158 m = min(8, sl->au_len - 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
|
1159 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
|
1160 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
|
1161 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
|
1162 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
|
1163 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
|
1164 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
|
1165 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
|
1166 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1167 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
|
1168 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
|
1169 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
|
1170 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
1173 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
|
1174 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
|
1175 |
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
|
1176 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
|
1177 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
|
1178 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1179 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
|
1180 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1181 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1182 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 | 1183 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1184 unsigned char *p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1185 uint32_t header_len; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1186 int64_t pts; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1187 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
|
1188 uint32_t pkt_len, pes_is_aligned; |
9610 | 1189 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1190 //Here we are always at the start of a PES packet |
11190 | 1191 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2(%p, %d): \n", buf, (uint32_t) packet_len); |
9610 | 1192 |
14968
b5fb8b0b07c5
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 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
|
1194 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1195 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
|
1196 return 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1197 } |
9610 | 1198 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1199 p = buf; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1200 pkt_len = packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1201 |
9610 | 1202 |
10014 | 1203 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
|
1204 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
|
1205 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1206 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
|
1207 return 0 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1208 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1209 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1210 packet_len -= 6; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1211 if(packet_len==0) |
11190 | 1212 { |
1213 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
|
1214 return 0; |
11190 | 1215 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1216 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1217 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
|
1218 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
|
1219 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1220 stream_id = p[3]; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1221 |
9610 | 1222 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1223 if (p[7] & 0x80) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1224 { /* pts available */ |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1225 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
|
1226 pts |= p[10] << 22 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1227 pts |= (p[11] & 0xFE) << 14 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1228 pts |= p[12] << 7 ; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1229 pts |= (p[13] & 0xFE) >> 1 ; |
9610 | 1230 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1231 es->pts = pts / 90000.0f; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1232 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1233 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1234 es->pts = 0.0f; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1235 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1236 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1237 header_len = p[8]; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1238 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1239 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1240 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
|
1241 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1242 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
|
1243 return 0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1244 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1245 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1246 p += header_len + 9; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1247 packet_len -= header_len + 3; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1248 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1249 if(es->payload_size) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1250 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
|
1251 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1252 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1253 if (stream_id == 0xbd) |
9610 | 1254 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1255 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
|
1256 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
|
1257 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1258 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1259 /* |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1260 * we check the descriptor tag first because some stations |
11190 | 1261 * 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
|
1262 * 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
|
1263 */ |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1264 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1265 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1266 if( |
11190 | 1267 (type_from_pmt == AUDIO_A52) || /* A52 - raw */ |
1268 (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
|
1269 ) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1270 { |
11190 | 1271 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
|
1272 es->start = p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1273 es->size = packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1274 es->type = AUDIO_A52; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1275 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1276 |
11190 | 1277 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1278 } |
11190 | 1279 /* SPU SUBS */ |
1280 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
|
1281 ((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
|
1282 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1283 es->start = p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1284 es->size = packet_len; |
11190 | 1285 es->type = SPU_DVB; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1286 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1287 |
11190 | 1288 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1289 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1290 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
|
1291 { |
11190 | 1292 //DVD SUBS |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1293 es->start = p+1; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1294 es->size = packet_len-1; |
11190 | 1295 es->type = SPU_DVD; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1296 es->payload_size -= packet_len; |
9610 | 1297 |
11190 | 1298 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1299 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1300 else if ((p[0] & 0xF0) == 0x80) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1301 { |
11190 | 1302 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
|
1303 es->start = p+4; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1304 es->size = packet_len - 4; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1305 es->type = AUDIO_A52; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1306 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1307 |
11190 | 1308 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1309 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1310 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
|
1311 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1312 int pcm_offset; |
9610 | 1313 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1314 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
|
1315 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1316 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
|
1317 { /* START */ |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1318 pcm_offset += 2; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1319 break; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1320 } |
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 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1323 es->start = p + pcm_offset; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1324 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
|
1325 es->type = AUDIO_LPCM_BE; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1326 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1327 |
11190 | 1328 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1329 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1330 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1331 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1332 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
|
1333 es->start = p; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1334 es->size = packet_len; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1335 es->type = PES_PRIVATE1; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1336 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
|
1337 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1338 return 1; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
1339 } |
9610 | 1340 } |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1341 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
|
1342 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1343 es->start = p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1344 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
|
1345 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
|
1346 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
|
1347 else |
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
1348 es->type = VIDEO_MPEG2; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1349 if(es->payload_size) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1350 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1351 |
11190 | 1352 mp_msg(MSGT_DEMUX, MSGL_DBG2, "pes_parse2: M2V size %d\n", es->size); |
1353 return 1; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1354 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1355 else if ((stream_id == 0xfa)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1356 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1357 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
|
1358 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1359 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
|
1360 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1361 es->start = p; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1362 es->size = packet_len; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1363 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
|
1364 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1365 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
|
1366 { |
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
|
1367 //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
|
1368 //{ |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1369 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
|
1370 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
|
1371 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
|
1372 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1373 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
|
1374 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
|
1375 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1376 //} |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1377 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1378 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
|
1379 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
|
1380 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1381 |
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
|
1382 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
|
1383 es->payload_size -= packet_len; |
11190 | 1384 return 1; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1385 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1386 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1387 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
|
1388 { |
11190 | 1389 int profile = 0, srate = 0, channels = 0; |
1390 uint32_t hdr, l = 0; | |
9610 | 1391 |
11190 | 1392 hdr = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; |
14571
512a57bbe68d
replaced bzero() with memset(); stream_type 0x0f is AAC
nicodvb
parents:
14046
diff
changeset
|
1393 if(pes_is_aligned && ((hdr & 0xfff00000) == 0xfff00000)) |
11190 | 1394 { |
1395 // ADTS AAC shows with MPA layer 4 (00 in the layer bitstream) | |
1396 l = 4 - ((hdr & 0x00060000) >> 17); | |
1397 profile = ((hdr & 0x0000C000) >> 14); | |
1398 srate = ((hdr & 0x00003c00) >> 10); | |
1399 channels = ((hdr & 0x000001E0) >> 5); | |
1400 } | |
1401 mp_msg(MSGT_DEMUX, MSGL_DBG2, "\n\naudio header: %2X %2X %2X %2X\nLAYER: %d, PROFILE: %d, SRATE=%d, CHANNELS=%d\n\n", p[0], p[1], p[3], p[4], l, profile, srate, channels); | |
1402 | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1403 es->start = p; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1404 es->size = packet_len; |
11190 | 1405 |
1406 | |
14571
512a57bbe68d
replaced bzero() with memset(); stream_type 0x0f is AAC
nicodvb
parents:
14046
diff
changeset
|
1407 if((type_from_pmt == AUDIO_AAC) || (l == 4)) //see in parse_pmt() |
11190 | 1408 es->type = AUDIO_AAC; |
1409 else | |
1410 es->type = AUDIO_MP2; | |
1411 | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1412 es->payload_size -= packet_len; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1413 |
11190 | 1414 return 1; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1415 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1416 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
|
1417 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1418 es->start = p; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1419 es->size = packet_len; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1420 es->type = type_from_pmt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1421 es->payload_size -= packet_len; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1422 |
11190 | 1423 return 1; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1424 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1425 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1426 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1427 mp_msg(MSGT_DEMUX, MSGL_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
|
1428 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1429 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1430 return 0; |
9610 | 1431 } |
1432 | |
1433 | |
1434 | |
1435 | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1436 static int ts_sync(stream_t *stream) |
9610 | 1437 { |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1438 int c=0; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1439 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1440 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
|
1441 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1442 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
|
1443 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1444 if(c == 0x47) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1445 return c; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1446 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
1447 return 0; |
9610 | 1448 } |
1449 | |
1450 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1451 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
|
1452 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1453 int i; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1454 |
11190 | 1455 for(i = 0; i < 3; i++) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1456 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1457 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
|
1458 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1459 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
|
1460 ds_add_packet(priv->fifo[i].ds, priv->fifo[i].pack); |
11190 | 1461 priv->fifo[i].offset = 0; |
1462 priv->fifo[i].pack = NULL; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1463 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1464 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1465 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1466 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1467 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1468 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
|
1469 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1470 int x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1471 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1472 if(priv->pat.progs == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1473 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1474 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1475 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
|
1476 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1477 if(priv->pat.progs[x].id == progid) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1478 return x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1479 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1480 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1481 return -1; |
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 |
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 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
|
1486 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1487 int x; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1488 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1489 if(priv->pat.progs == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1490 return -1; |
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 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
|
1493 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1494 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
|
1495 return priv->pat.progs[x].id; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1496 } |
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 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1499 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1500 |
11190 | 1501 /* |
1502 DON'T REMOVE, I'LL NEED IT IN THE (NEAR) FUTURE) | |
1503 static int check_crc32(uint32_t val, uint8_t *ptr, uint16_t len, uint8_t *vbase) | |
1504 { | |
1505 uint32_t tab_crc32, calc_crc32; | |
1506 | |
1507 calc_crc32 = CalcCRC32(val, ptr, len); | |
1508 | |
1509 tab_crc32 = (vbase[0] << 24) | (vbase[1] << 16) | (vbase[2] << 8) | vbase[3]; | |
1510 | |
1511 printf("CRC32, TAB: %x, CALC: %x, eq: %x\n", tab_crc32, calc_crc32, tab_crc32 == calc_crc32); | |
1512 return (tab_crc32 == calc_crc32); | |
1513 | |
1514 } | |
1515 */ | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1516 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1517 static uint8_t collect_section(ts_section_t *section, 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
|
1518 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1519 uint8_t skip = 0, *ptr, tid; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1520 uint16_t 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
|
1521 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1522 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
|
1523 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
|
1524 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1525 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
|
1526 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1527 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
|
1528 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1529 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
|
1530 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
|
1531 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
|
1532 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1533 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
|
1534 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
1537 { |
b5fb8b0b07c5
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 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
|
1539 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
|
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 |
b5fb8b0b07c5
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 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
|
1543 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
|
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 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
|
1546 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
|
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 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
|
1549 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
|
1550 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
|
1551 |
b5fb8b0b07c5
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 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
|
1553 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
|
1554 tlen = ((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
|
1555 mp_msg(MSGT_DEMUX, MSGL_V, "SKIP: %d+1, TID: %d, TLEN: %d\n", skip, tid, 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
|
1556 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
|
1557 { |
b5fb8b0b07c5
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 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
|
1559 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
|
1560 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
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 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1565 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
|
1566 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1567 uint8_t skip; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1568 unsigned char *ptr; |
11190 | 1569 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
|
1570 int entries, i; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1571 uint16_t progid; |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1572 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
|
1573 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
|
1574 |
b5fb8b0b07c5
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 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
|
1576 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
|
1577 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
|
1578 return 0; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1579 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1580 ptr = &(section->buffer[skip]); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1581 //PARSING |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1582 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
|
1583 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
|
1584 return 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1585 priv->pat.ssi = (ptr[1] >> 7) & 0x1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1586 priv->pat.curr_next = ptr[5] & 0x01; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1587 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
|
1588 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
|
1589 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
|
1590 priv->pat.section_number = ptr[6]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1591 priv->pat.last_section_number = ptr[7]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1592 |
11190 | 1593 //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
|
1594 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 | 1595 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1596 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
|
1597 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1598 for(i=0; i < entries; i++) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1599 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1600 int32_t idx; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1601 base = &ptr[8 + i*4]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1602 progid = (base[0] << 8) | base[1]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1603 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1604 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
|
1605 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1606 int sz = sizeof(struct pat_progs_t) * (priv->pat.progs_cnt+1); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1607 tmp = (struct pat_progs_t*) realloc(priv->pat.progs, sz); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1608 if(tmp == NULL) |
10686
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 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
|
1611 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1612 } |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
1613 priv->pat.progs = tmp; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1614 idx = priv->pat.progs_cnt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1615 priv->pat.progs_cnt++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1616 } |
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 priv->pat.progs[idx].id = progid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1619 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
|
1620 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
|
1621 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1622 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1623 return 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1624 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1625 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1626 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1627 static inline int32_t 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
|
1628 { |
11190 | 1629 uint16_t i; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1630 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1631 if(pmt == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1632 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1633 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1634 if(pmt->es == NULL) |
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 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
|
1638 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1639 if(pmt->es[i].pid == pid) |
11190 | 1640 return (int32_t) i; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1641 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1642 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1643 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
1644 } |
9610 | 1645 |
1646 | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1647 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
|
1648 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1649 //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
|
1650 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
|
1651 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1652 mp_msg(MSGT_DEMUX, MSGL_DBG2, "PARSE_MP4_DESC_LEN(%d), bytes: ", *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
|
1653 j = min(*len, 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
|
1654 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
|
1655 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1656 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
|
1657 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
|
1658 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
|
1659 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
|
1660 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
|
1661 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
|
1662 } |
b5fb8b0b07c5
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 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
|
1664 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1665 *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
|
1666 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
|
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 |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
1671 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1672 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
|
1673 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
|
1674 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
|
1675 |
b5fb8b0b07c5
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 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
|
1677 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
|
1678 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
|
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 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
|
1681 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
|
1682 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1683 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
|
1684 |
b5fb8b0b07c5
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 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
|
1686 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
|
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 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
|
1689 { |
b5fb8b0b07c5
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 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
|
1691 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
|
1692 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
|
1693 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
|
1694 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
|
1695 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
|
1696 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
|
1697 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
|
1698 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
|
1699 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
|
1700 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
|
1701 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
|
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->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
|
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->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
|
1706 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
|
1707 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
|
1708 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
|
1709 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
|
1710 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1711 } |
b5fb8b0b07c5
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 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
|
1713 { |
b5fb8b0b07c5
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 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
|
1715 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
|
1716 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
|
1717 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
|
1718 } |
b5fb8b0b07c5
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 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
|
1720 { |
b5fb8b0b07c5
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 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
|
1722 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
|
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 |
b5fb8b0b07c5
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; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1727 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
|
1728 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
1731 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
|
1732 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
|
1733 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
|
1734 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
|
1735 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
|
1736 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
|
1737 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
|
1738 |
b5fb8b0b07c5
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 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
|
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 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
|
1742 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
|
1743 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
|
1744 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
|
1745 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
|
1746 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
|
1747 } |
b5fb8b0b07c5
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 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
|
1749 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
|
1750 |
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
|
1751 mp_msg(MSGT_DEMUX, MSGL_V, "MP4SLCONFIG(len=0x%x), predef: %d, flags: %x, use_ts: %d, tslen: %d, timescale: %d, dts: %llu, cts: %llu\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
|
1752 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
|
1753 |
b5fb8b0b07c5
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 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
|
1755 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
1758 |
b5fb8b0b07c5
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 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
|
1760 { |
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
|
1761 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
|
1762 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
|
1763 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
|
1764 |
b5fb8b0b07c5
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 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
|
1766 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
|
1767 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
|
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 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
|
1770 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
|
1771 } |
b5fb8b0b07c5
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 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
|
1773 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1774 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
|
1775 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
|
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 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
|
1778 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1779 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
|
1780 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
|
1781 } |
b5fb8b0b07c5
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 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
|
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 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
|
1785 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
|
1786 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
|
1787 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
|
1788 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
|
1789 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
|
1790 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
|
1791 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
|
1792 /*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
|
1793 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
|
1794 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
|
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 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
|
1797 { |
b5fb8b0b07c5
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 == 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
|
1799 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
|
1800 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
|
1801 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
|
1802 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
|
1803 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
|
1804 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
|
1805 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
|
1806 } |
b5fb8b0b07c5
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 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
|
1808 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
|
1809 |
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
|
1810 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
|
1811 { |
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
|
1812 //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
|
1813 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
|
1814 { |
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
|
1815 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
|
1816 { |
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 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
|
1818 } |
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
|
1819 } |
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
|
1820 } |
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
|
1821 |
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
|
1822 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
|
1823 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
|
1824 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1825 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
|
1826 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1827 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
|
1828 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1829 |
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
|
1830 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
|
1831 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1832 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
|
1833 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
|
1834 |
20ea036e5f0d
allocate and fill 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 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
|
1836 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
|
1837 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
|
1838 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
1839 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
|
1840 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
|
1841 } |
20ea036e5f0d
allocate and fill 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 |
20ea036e5f0d
allocate and fill 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 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
|
1844 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
|
1845 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
|
1846 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
|
1847 |
20ea036e5f0d
allocate and fill 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 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
|
1849 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
|
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 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
|
1852 } |
20ea036e5f0d
allocate and fill 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 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1854 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
|
1855 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1856 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
|
1857 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
|
1858 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
|
1859 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1860 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
|
1861 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
|
1862 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
|
1863 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1864 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
|
1865 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
|
1866 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
|
1867 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
|
1868 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
|
1869 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
|
1870 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
|
1871 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
|
1872 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
|
1873 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
|
1874 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
|
1875 |
b5fb8b0b07c5
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 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
|
1877 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
|
1878 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
|
1879 { |
b5fb8b0b07c5
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 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
|
1881 //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
|
1882 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
|
1883 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1884 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
|
1885 { |
b5fb8b0b07c5
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 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
|
1887 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
|
1888 } |
b5fb8b0b07c5
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 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
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 tmp = (mp4_es_descr_t *) realloc(pmt->mp4es, sizeof(mp4_es_descr_t)*(pmt->mp4es_cnt+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
|
1894 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
|
1895 { |
b5fb8b0b07c5
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 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
|
1897 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
|
1898 } |
b5fb8b0b07c5
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 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
|
1900 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
|
1901 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
|
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 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
|
1904 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
|
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 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
|
1908 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1910 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
|
1911 } |
b5fb8b0b07c5
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 |
15067 | 1913 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
|
1914 { |
b5fb8b0b07c5
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 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
|
1916 |
b5fb8b0b07c5
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 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
|
1918 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
|
1919 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
|
1920 { |
b5fb8b0b07c5
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 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
|
1922 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
|
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 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
|
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 i = 2; |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1927 |
b5fb8b0b07c5
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 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
|
1929 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1930 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
|
1931 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
|
1932 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
|
1933 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1934 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1935 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1936 |
b5fb8b0b07c5
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 |
15067 | 1938 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
|
1939 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1940 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
|
1941 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
|
1942 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1943 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
|
1944 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
|
1945 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
|
1946 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
|
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 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
|
1949 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
|
1950 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1951 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
|
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 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
|
1954 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
|
1955 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1956 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
|
1957 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
|
1958 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
|
1959 } |
b5fb8b0b07c5
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 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1962 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1963 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
|
1964 { |
b5fb8b0b07c5
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 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
|
1966 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1967 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
|
1968 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
|
1969 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
|
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 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
|
1972 { |
b5fb8b0b07c5
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 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
|
1974 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
|
1975 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
|
1976 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
|
1977 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
|
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 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
|
1980 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
|
1981 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
1982 i += 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
|
1983 |
b5fb8b0b07c5
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 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
|
1985 { |
b5fb8b0b07c5
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 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
|
1987 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
|
1988 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
|
1989 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
|
1990 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
|
1991 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
|
1992 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
|
1993 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
|
1994 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
|
1995 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
|
1996 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
|
1997 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
|
1998 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
|
1999 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
|
2000 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
|
2001 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
|
2002 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
|
2003 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
|
2004 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
|
2005 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
|
2006 } |
b5fb8b0b07c5
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 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
|
2008 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2009 |
b5fb8b0b07c5
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 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
|
2011 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2012 |
b5fb8b0b07c5
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 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
|
2014 { |
b5fb8b0b07c5
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 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
|
2016 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2017 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
|
2018 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
|
2019 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
|
2020 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
|
2021 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
|
2022 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
|
2023 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
|
2024 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
|
2025 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
|
2026 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
|
2027 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
|
2028 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
|
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 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
|
2031 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2032 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2033 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2034 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
|
2035 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2036 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
|
2037 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2038 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
|
2039 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2040 mp_msg(MSGT_DEMUX, MSGL_V, "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
|
2041 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
|
2042 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2043 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
|
2044 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
|
2045 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2046 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2047 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
|
2048 { |
b5fb8b0b07c5
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 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
|
2050 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
|
2051 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
|
2052 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
|
2053 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
|
2054 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2055 |
b5fb8b0b07c5
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 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
|
2057 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2058 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2059 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
|
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 |
11190 | 2062 static int parse_descriptors(struct pmt_es_t *es, uint8_t *ptr) |
2063 { | |
2064 int j, descr_len, len; | |
2065 | |
2066 j = 0; | |
2067 len = es->descr_length; | |
2068 while(len > 2) | |
2069 { | |
2070 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
|
2071 mp_msg(MSGT_DEMUX, MSGL_V, "...descr id: 0x%x, len=%d\n", ptr[j], descr_len); |
11190 | 2072 if(descr_len > len) |
2073 { | |
14968
b5fb8b0b07c5
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 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 | 2075 return -1; |
2076 } | |
2077 | |
2078 | |
2079 if(ptr[j] == 0x6a) //A52 Descriptor | |
2080 { | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2081 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
|
2082 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2083 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
|
2084 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
|
2085 } |
11190 | 2086 } |
2087 else if(ptr[j] == 0x59) //Subtitling Descriptor | |
2088 { | |
2089 uint8_t subtype; | |
2090 | |
2091 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Subtitling Descriptor\n"); | |
2092 if(descr_len < 8) | |
2093 { | |
2094 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Descriptor length too short for DVB Subtitle Descriptor: %d, SKIPPING\n", descr_len); | |
2095 } | |
2096 else | |
2097 { | |
2098 memcpy(es->lang, &ptr[j+2], 3); | |
2099 es->lang[3] = 0; | |
2100 subtype = ptr[j+5]; | |
2101 if( | |
2102 (subtype >= 0x10 && subtype <= 0x13) || | |
2103 (subtype >= 0x20 && subtype <= 0x23) | |
2104 ) | |
2105 { | |
2106 es->type = SPU_DVB; | |
2107 //page parameters: compo page 2 bytes, ancillary page 2 bytes | |
2108 } | |
2109 else | |
2110 es->type = UNKNOWN; | |
2111 } | |
2112 } | |
2113 else if(ptr[j] == 0x50) //Component Descriptor | |
2114 { | |
2115 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Component Descriptor\n"); | |
2116 memcpy(es->lang, &ptr[j+5], 3); | |
2117 es->lang[3] = 0; | |
2118 } | |
2119 else if(ptr[j] == 0xa) //Language Descriptor | |
2120 { | |
2121 memcpy(es->lang, &ptr[j+2], 3); | |
2122 es->lang[3] = 0; | |
2123 mp_msg(MSGT_DEMUX, MSGL_V, "Language Descriptor: %s\n", es->lang); | |
2124 } | |
2125 else if(ptr[j] == 0x5) //Registration Descriptor (looks like e fourCC :) ) | |
2126 { | |
2127 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Registration Descriptor\n"); | |
2128 if(descr_len < 4) | |
2129 { | |
2130 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Registration Descriptor length too short: %d, SKIPPING\n", descr_len); | |
2131 } | |
2132 else | |
2133 { | |
2134 char *d; | |
2135 memcpy(es->format_descriptor, &ptr[j+2], 4); | |
2136 es->format_descriptor[4] = 0; | |
2137 | |
2138 d = &ptr[j+2]; | |
2139 if(d[0] == 'A' && d[1] == 'C' && d[2] == '-' && d[3] == '3') | |
2140 { | |
2141 es->type = AUDIO_A52; | |
2142 } | |
2143 else | |
2144 es->type = UNKNOWN; | |
2145 mp_msg(MSGT_DEMUX, MSGL_DBG2, "FORMAT %s\n", es->format_descriptor); | |
2146 } | |
2147 } | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2148 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
|
2149 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2150 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
|
2151 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
|
2152 } |
11190 | 2153 else |
2154 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Unknown descriptor 0x%x, SKIPPING\n", ptr[j]); | |
2155 | |
2156 len -= 2 + descr_len; | |
2157 j += 2 + descr_len; | |
2158 } | |
2159 | |
2160 return 1; | |
2161 } | |
2162 | |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2163 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
|
2164 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2165 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
|
2166 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
|
2167 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
|
2168 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
|
2169 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
|
2170 |
b5fb8b0b07c5
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 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
|
2172 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
|
2173 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
|
2174 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
|
2175 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
|
2176 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2177 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
|
2178 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
|
2179 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2180 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2181 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
|
2182 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
|
2183 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2184 //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
|
2185 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
|
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 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
|
2188 } |
9610 | 2189 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2190 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
|
2191 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2192 unsigned char *base, *es_base; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2193 pmt_t *pmt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2194 int32_t idx, es_count, section_bytes; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2195 uint8_t skip, m=0; |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2196 pmt_t *tmp; |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2197 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
|
2198 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
|
2199 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
|
2200 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2201 idx = progid_idx_in_pmt(priv, progid); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2202 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2203 if(idx == -1) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2204 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2205 int sz = (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
|
2206 tmp = (pmt_t *) realloc(priv->pmt, sz); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2207 if(tmp == NULL) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2208 { |
11190 | 2209 mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT: COULDN'T REALLOC %d bytes, NEXT\n", sz); |
13187 | 2210 return 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2211 } |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2212 priv->pmt = tmp; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2213 idx = priv->pmt_cnt; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2214 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
|
2215 priv->pmt_cnt++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2216 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2217 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2218 pmt = &(priv->pmt[idx]); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2219 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2220 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
|
2221 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
|
2222 if(! skip) |
13187 | 2223 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
|
2224 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2225 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
|
2226 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2227 pmt->progid = progid; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2228 |
11190 | 2229 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
|
2230 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
|
2231 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2232 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
|
2233 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
|
2234 return -1; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2235 pmt->ssi = base[1] & 0x80; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2236 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
|
2237 pmt->version_number = (base[5] >> 1) & 0x1f; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2238 pmt->curr_next = (base[5] & 1); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2239 pmt->section_number = base[6]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2240 pmt->last_section_number = base[7]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2241 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
|
2242 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
|
2243 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
|
2244 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2245 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
|
2246 return -1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2247 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2248 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2249 if(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
|
2250 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
|
2251 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2252 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
|
2253 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2254 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
|
2255 es_count = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2256 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2257 while(section_bytes >= 5) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2258 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2259 int es_pid, es_type; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2260 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2261 es_type = es_base[0]; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2262 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
|
2263 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2264 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
|
2265 if(idx == -1) |
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 int sz = sizeof(struct pmt_es_t) * (pmt->es_cnt + 1); |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2268 tmp_es = (struct pmt_es_t *) realloc(pmt->es, sz); |
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2269 if(tmp_es == NULL) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2270 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2271 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
|
2272 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2273 } |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2274 pmt->es = tmp_es; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2275 idx = pmt->es_cnt; |
11190 | 2276 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
|
2277 pmt->es_cnt++; |
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 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2280 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
|
2281 |
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 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
|
2284 { |
11190 | 2285 mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_PMT, ES_DESCR_LENGTH TOO LARGE %d > %d, EXIT\n", |
2286 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
|
2287 return -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 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2290 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2291 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
|
2292 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
|
2293 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
|
2294 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
|
2295 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
|
2296 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2297 parse_descriptors(&pmt->es[idx], &es_base[5]); |
11190 | 2298 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2299 switch(es_type) |
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 case 1: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2302 pmt->es[idx].type = VIDEO_MPEG1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2303 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2304 case 2: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2305 pmt->es[idx].type = VIDEO_MPEG2; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2306 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2307 case 3: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2308 case 4: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2309 pmt->es[idx].type = AUDIO_MP2; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2310 break; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2311 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
|
2312 if(pmt->es[idx].type == 0x6) //this could have been ovrwritten by parse_descriptors |
11190 | 2313 pmt->es[idx].type = UNKNOWN; |
2314 break; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2315 case 0x10: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2316 pmt->es[idx].type = VIDEO_MPEG4; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2317 break; |
14571
512a57bbe68d
replaced bzero() with memset(); stream_type 0x0f is AAC
nicodvb
parents:
14046
diff
changeset
|
2318 case 0x0f: |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2319 case 0x11: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2320 pmt->es[idx].type = AUDIO_AAC; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2321 break; |
14034
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
2322 case 0x1b: |
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
2323 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
|
2324 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
|
2325 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
|
2326 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
|
2327 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
|
2328 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
|
2329 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
|
2330 break; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2331 case 0x81: |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2332 pmt->es[idx].type = AUDIO_A52; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2333 break; |
11190 | 2334 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
|
2335 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
|
2336 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
|
2337 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2338 |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2339 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
|
2340 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
|
2341 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2342 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
|
2343 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
|
2344 tss->type = pmt->es[idx].type; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2345 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2346 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2347 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
|
2348 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
|
2349 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
|
2350 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2351 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2352 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
|
2353 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2354 es_count++; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2355 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2356 |
11190 | 2357 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
|
2358 return 1; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2359 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2360 |
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
|
2361 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
|
2362 { |
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
|
2363 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
|
2364 |
b5fb8b0b07c5
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(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
|
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 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
|
2368 { |
b5fb8b0b07c5
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 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
|
2370 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2371 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
|
2372 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2373 if(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
|
2374 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2375 //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
|
2376 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
|
2377 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2378 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
|
2379 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2380 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
|
2381 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2382 *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
|
2383 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
|
2384 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2385 } |
20ea036e5f0d
allocate and fill 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 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2387 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2388 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
|
2389 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2390 } |
14968
b5fb8b0b07c5
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 } |
b5fb8b0b07c5
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 |
b5fb8b0b07c5
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 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
|
2396 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2397 |
9610 | 2398 |
11190 | 2399 static inline int32_t pid_type_from_pmt(ts_priv_t *priv, int pid) |
2400 { | |
2401 int32_t pmt_idx, pid_idx, i, j; | |
2402 | |
2403 pmt_idx = progid_idx_in_pmt(priv, priv->prog); | |
2404 | |
2405 if(pmt_idx != -1) | |
2406 { | |
2407 pid_idx = es_pid_in_pmt(&(priv->pmt[pmt_idx]), pid); | |
2408 if(pid_idx != -1) | |
2409 return priv->pmt[pmt_idx].es[pid_idx].type; | |
2410 } | |
2411 //else | |
2412 //{ | |
2413 for(i = 0; i < priv->pmt_cnt; i++) | |
2414 { | |
2415 pmt_t *pmt = &(priv->pmt[i]); | |
2416 for(j = 0; j < pmt->es_cnt; j++) | |
2417 if(pmt->es[j].pid == pid) | |
2418 return pmt->es[j].type; | |
2419 } | |
2420 //} | |
2421 | |
2422 return UNKNOWN; | |
2423 } | |
2424 | |
2425 | |
2426 static inline uint8_t *pid_lang_from_pmt(ts_priv_t *priv, int pid) | |
2427 { | |
2428 int32_t pmt_idx, pid_idx, i, j; | |
2429 | |
2430 pmt_idx = progid_idx_in_pmt(priv, priv->prog); | |
2431 | |
2432 if(pmt_idx != -1) | |
2433 { | |
2434 pid_idx = es_pid_in_pmt(&(priv->pmt[pmt_idx]), pid); | |
2435 if(pid_idx != -1) | |
2436 return priv->pmt[pmt_idx].es[pid_idx].lang; | |
2437 } | |
2438 else | |
2439 { | |
2440 for(i = 0; i < priv->pmt_cnt; i++) | |
2441 { | |
2442 pmt_t *pmt = &(priv->pmt[i]); | |
2443 for(j = 0; j < pmt->es_cnt; j++) | |
2444 if(pmt->es[j].pid == pid) | |
2445 return pmt->es[j].lang; | |
2446 } | |
2447 } | |
2448 | |
2449 return NULL; | |
2450 } | |
2451 | |
2452 | |
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
|
2453 static int fill_packet(demuxer_t *demuxer, demux_stream_t *ds, demux_packet_t **dp, int *dp_offset) |
11190 | 2454 { |
2455 int ret = 0; | |
2456 | |
2457 if((*dp != NULL) && (*dp_offset > 0)) | |
2458 { | |
2459 ret = *dp_offset; | |
2460 resize_demux_packet(*dp, ret); //shrinked to the right size | |
2461 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
|
2462 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); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2463 } |
11190 | 2464 |
2465 *dp = NULL; | |
2466 *dp_offset = 0; | |
2467 | |
2468 return ret; | |
2469 } | |
2470 | |
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
|
2471 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
|
2472 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2473 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
|
2474 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2475 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
|
2476 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2477 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
|
2478 { |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2479 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
|
2480 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
|
2481 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
|
2482 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
|
2483 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
|
2484 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2485 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
|
2486 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
|
2487 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
|
2488 |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2489 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
|
2490 } |
20ea036e5f0d
allocate and fill extradata field for video_avc (raw nal units, extradata contains sps+pps); fixed payload_size assignment for SL payloads
nicodvb
parents:
14993
diff
changeset
|
2491 |
9610 | 2492 // 0 = EOF or no stream found |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2493 // 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
|
2494 static int ts_parse(demuxer_t *demuxer , ES_stream_t *es, unsigned char *packet, int probe) |
9610 | 2495 { |
10014 | 2496 ES_stream_t *tss; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2497 uint8_t done = 0; |
11190 | 2498 int buf_size, is_start, pid, base; |
2499 int len, cc, cc_ok, afc, retv = 0, is_video, is_audio, is_sub; | |
10014 | 2500 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
|
2501 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
|
2502 char *p; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2503 demux_stream_t *ds = NULL; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2504 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
|
2505 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
|
2506 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
|
2507 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
|
2508 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
|
2509 mp4_decoder_config_t *mp4_dec; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2510 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2511 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2512 while(! done) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2513 { |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2514 bad = ts_error = 0; |
11190 | 2515 ds = (demux_stream_t*) NULL; |
2516 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
|
2517 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
|
2518 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
|
2519 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
|
2520 es->is_synced = 0; |
11190 | 2521 |
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
|
2522 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
|
2523 buf_size = priv->ts.packet_size - junk; |
11190 | 2524 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2525 if(stream_eof(stream)) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2526 { |
11190 | 2527 if(! probe) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2528 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2529 ts_dump_streams(priv); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2530 demuxer->filepos = stream_tell(demuxer->stream); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2531 } |
11190 | 2532 |
2533 return 0; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2534 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2535 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2536 |
11190 | 2537 if(! ts_sync(stream)) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2538 { |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2539 mp_msg(MSGT_DEMUX, MSGL_INFO, "TS_PARSE: COULDN'T SYNC\n"); |
11190 | 2540 return 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2541 } |
11190 | 2542 |
2543 len = stream_read(stream, &packet[1], 3); | |
2544 if (len != 3) | |
2545 return 0; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2546 |
11190 | 2547 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
|
2548 ts_error = 1; |
11190 | 2549 |
2550 buf_size -= 4; | |
2551 | |
2552 is_start = packet[1] & 0x40; | |
2553 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
|
2554 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2555 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
|
2556 if(tss == NULL) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2557 { |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2558 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
|
2559 if(tss == NULL) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2560 continue; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2561 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2562 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2563 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2564 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2565 if(((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
|
2566 { |
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
|
2567 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
|
2568 continue; |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2569 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2570 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2571 cc = (packet[3] & 0xf); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2572 cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc)); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2573 tss->last_cc = cc; |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2574 |
14825
a2d03a8ea065
50000l: fixed various memleaks; CC discontibuities aren't necessarily error conditions
nicodvb
parents:
14571
diff
changeset
|
2575 bad = ts_error; // || (! cc_ok); |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2576 |
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
|
2577 afc = (packet[3] >> 4) & 3; |
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
|
2578 if(afc > 1) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2579 { |
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
|
2580 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
|
2581 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
|
2582 buf_size--; |
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
|
2583 rap_flag = (stream_read_char(stream) & 0x40) >> 6; |
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
|
2584 buf_size--; |
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
|
2585 |
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
|
2586 c = min(c-1, buf_size); |
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
|
2587 stream_skip(stream, 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
|
2588 buf_size -= 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
|
2589 if(buf_size == 0) |
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
|
2590 continue; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2591 } |
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
|
2592 |
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
|
2593 if(! (afc % 2)) //no payload in this TS packet |
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
|
2594 { |
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
|
2595 stream_skip(stream, buf_size-1+junk); |
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
|
2596 continue; |
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
|
2597 } |
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
|
2598 |
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
|
2599 if(bad) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2600 { |
11190 | 2601 // logically this packet should be dropped, but if I do it |
2602 // certain streams play corrupted. Maybe the decoders know | |
2603 // how to deal with it, but at least I consider the packet | |
2604 // as "not initial" | |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2605 mp_msg(MSGT_DEMUX, MSGL_V, "ts_parse: PID=%d, Transport error: %d, CC_OK: %s\n\n", tss->pid, ts_error, (cc_ok ? "yes" : "no")); |
11190 | 2606 |
2607 if(priv->keep_broken == 0) | |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2608 { |
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
|
2609 stream_skip(stream, buf_size-1+junk); |
11190 | 2610 continue; |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2611 } |
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2612 |
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2613 is_start = 0; //queued to the packet data |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2614 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2615 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2616 //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
|
2617 //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
|
2618 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
|
2619 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
|
2620 { |
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
|
2621 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
|
2622 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
|
2623 { |
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
|
2624 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
|
2625 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
|
2626 } |
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
|
2627 } |
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
|
2628 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2629 |
11190 | 2630 //TABLE PARSING |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2631 |
11190 | 2632 base = priv->ts.packet_size - buf_size; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2633 if(pid == 0) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2634 { |
11190 | 2635 stream_read(stream,&packet[base], buf_size); |
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
|
2636 stream_skip(stream, junk); |
11190 | 2637 parse_pat(priv, is_start, &packet[base], buf_size); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2638 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2639 } |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2640 else if((tss->type == SL_SECTION) && 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
|
2641 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2642 int k, ok=0, mp4_es_id = -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
|
2643 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
|
2644 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
|
2645 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2646 if(pmt->mp4es[k].decoder.object_type == MP4_OD && pmt->mp4es[k].decoder.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
|
2647 mp4_es_id = pmt->mp4es[k].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
|
2648 } |
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
|
2649 mp_msg(MSGT_DEMUX, MSGL_DBG2, "MP4ESID: %d\n", 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
|
2650 for(k = 0; k < pmt->es_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
|
2651 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2652 if(pmt->es[k].mp4_es_id == mp4_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
|
2653 ok = 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
|
2654 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2655 stream_read(stream,&packet[base], buf_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
|
2656 stream_skip(stream, junk); |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2657 if(ok) |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2658 { |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2659 section = &(tss->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
|
2660 parse_sl_section(pmt, section, progid, pid, is_start, &packet[base], buf_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
|
2661 } |
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2662 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
|
2663 } |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2664 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2665 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2666 progid = prog_id_in_pat(priv, pid); |
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
|
2667 if(progid != -1) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2668 { |
11190 | 2669 if(pid != demuxer->video->id && pid != demuxer->audio->id && pid != demuxer->sub->id) |
2670 { | |
2671 stream_read(stream,&packet[base], buf_size); | |
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
|
2672 stream_skip(stream, junk); |
11190 | 2673 parse_pmt(priv, progid, pid, is_start, &packet[base], buf_size); |
2674 continue; | |
2675 } | |
2676 else | |
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
|
2677 mp_msg(MSGT_DEMUX, MSGL_ERR, "Argh! Data pid %d used in the PMT, Skipping PMT parsing!\n", pid); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2678 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2679 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2680 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2681 |
11190 | 2682 priv->last_pid = pid; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2683 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2684 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
|
2685 is_audio = IS_AUDIO(tss->type) || (tss->type==SL_PES_STREAM && IS_AUDIO(tss->subtype)) || (tss->type == PES_PRIVATE1); |
11190 | 2686 is_sub = ((tss->type == SPU_DVD) || (tss->type == SPU_DVB)); |
2687 pid_type = pid_type_from_pmt(priv, pid); | |
2688 | |
2689 // PES CONTENT STARTS HERE | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2690 if(! probe) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2691 { |
11190 | 2692 if((pid == demuxer->sub->id)) //or the lang is right |
2693 { | |
2694 pid_type = SPU_DVD; | |
2695 } | |
2696 | |
2697 if(is_video && (demuxer->video->id == tss->pid)) | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2698 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2699 ds = demuxer->video; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2700 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2701 dp = &priv->fifo[1].pack; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2702 dp_offset = &priv->fifo[1].offset; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2703 buffer_size = &priv->fifo[1].buffer_size; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2704 } |
11190 | 2705 else if(is_audio && (demuxer->audio->id == tss->pid)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2706 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2707 ds = demuxer->audio; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2708 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2709 dp = &priv->fifo[0].pack; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2710 dp_offset = &priv->fifo[0].offset; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2711 buffer_size = &priv->fifo[0].buffer_size; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2712 } |
11190 | 2713 else if(is_sub |
2714 || (pid_type == SPU_DVD) || (pid_type == SPU_DVB)) | |
2715 { | |
2716 //SUBS are infrequent, so the initial detection may fail | |
2717 // and we may need to add them at play-time | |
2718 if(demuxer->sub->id == -1) | |
2719 { | |
2720 uint16_t p; | |
2721 p = progid_for_pid(priv, tss->pid, priv->prog); | |
2722 | |
2723 if(p == priv->prog) | |
2724 { | |
2725 int asgn = 0; | |
2726 uint8_t *lang; | |
2727 | |
2728 if(!strcmp(dvdsub_lang, "")) | |
2729 asgn = 1; | |
2730 else | |
2731 { | |
2732 lang = pid_lang_from_pmt(priv, pid); | |
2733 if(lang != NULL) | |
2734 asgn = (strncmp(lang, dvdsub_lang, 3) == 0); | |
2735 else | |
2736 asgn = 0; | |
2737 } | |
2738 | |
2739 if(asgn) | |
2740 { | |
2741 demuxer->sub->id = tss->pid; | |
2742 mp_msg(MSGT_DEMUX, MSGL_INFO, "CHOSEN SUBs pid 0x%x (%d) FROM PROG %d\n", tss->pid, tss->pid, priv->prog); | |
2743 } | |
2744 } | |
2745 else | |
2746 { | |
2747 mp_msg(MSGT_DEMUX, MSGL_V, "DISCARDED SUBs pid 0x%x (%d) NOT CHOSEN OR NOT IN PROG %d\n", tss->pid, tss->pid, priv->prog); | |
2748 } | |
2749 } | |
2750 | |
2751 if(demuxer->sub->id == tss->pid) | |
2752 { | |
2753 ds = demuxer->sub; | |
2754 | |
2755 dp = &priv->fifo[2].pack; | |
2756 dp_offset = &priv->fifo[2].offset; | |
2757 buffer_size = &priv->fifo[2].buffer_size; | |
2758 } | |
2759 else | |
2760 { | |
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
|
2761 stream_skip(stream, buf_size+junk); |
11190 | 2762 continue; |
2763 } | |
2764 } | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2765 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2766 { |
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
|
2767 stream_skip(stream, buf_size+junk); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2768 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2769 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2770 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2771 //IS IT TIME TO QUEUE DATA to the dp_packet? |
11190 | 2772 if(is_start && (dp != NULL)) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2773 { |
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
|
2774 retv = fill_packet(demuxer, ds, dp, dp_offset); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2775 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2776 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2777 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2778 if(*dp == NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2779 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2780 *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
|
2781 *dp_offset = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2782 if(! *dp) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2783 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2784 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
|
2785 continue; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2786 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2787 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
|
2788 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2789 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2790 mp_msg(MSGT_DEMUX, MSGL_DBG2, "NOW PACKET_SIZE = %d, DP_OFFSET = %d\n", *buffer_size, *dp_offset); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2791 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2792 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2793 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2794 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2795 if(is_start) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2796 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2797 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
|
2798 |
11190 | 2799 p = &packet[base]; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2800 stream_read(stream, p, buf_size); |
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
|
2801 stream_skip(stream, junk); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2802 |
14968
b5fb8b0b07c5
initial support for SL packetized data, with certain limitations; partly reworked the tables management for a better code reuse
nicodvb
parents:
14825
diff
changeset
|
2803 len = pes_parse2(p, buf_size, es, pid_type, pmt, pid); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2804 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
|
2805 tss->is_synced |= es->is_synced || rap_flag; |
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
|
2806 |
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
|
2807 if(es->type==SL_PES_STREAM && !tss->is_synced) |
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
|
2808 { |
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
|
2809 if(probe) |
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
|
2810 return 0; |
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
|
2811 else |
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
|
2812 continue; |
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
|
2813 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2814 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2815 if(probe) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2816 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2817 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
|
2818 return 0; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2819 if(len == 0) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2820 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2821 if(tss->type != UNKNOWN) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2822 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2823 es->size = buf_size; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2824 es->start = p; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2825 return 1; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2826 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2827 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2828 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2829 { |
13957
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2830 uint8_t *lang = NULL; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2831 tss->type = es->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
|
2832 tss->subtype = es->subtype; |
13957
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2833 |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2834 if(is_audio) |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2835 lang = pid_lang_from_pmt(priv, es->pid); |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2836 if(lang != NULL) |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2837 { |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2838 memcpy(es->lang, lang, 3); |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2839 es->lang[3] = 0; |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2840 } |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2841 else |
f3dada6ab8e4
added language identifier (if any) to the caller during probing phase
nicodvb
parents:
13608
diff
changeset
|
2842 es->lang[0] = 0; |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2843 return 1; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2844 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2845 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2846 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2847 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2848 if(len == 0) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2849 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2850 if(tss->type != UNKNOWN) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2851 { |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2852 len = es->size = buf_size; //push the whole packet to the fifo |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2853 //(we already learned what it is during the probe phase) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2854 es->start = p; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2855 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2856 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2857 continue; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2858 } |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2859 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2860 if(es->pts == 0.0f) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2861 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
|
2862 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2863 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
|
2864 |
12049
5da6a113b6af
fix wrong detection of mpeg4 as mpeg2 and wrong handling of discontinuities/transport error bit
nicodvb
parents:
11412
diff
changeset
|
2865 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
|
2866 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
|
2867 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2868 tss->payload_size = es->payload_size; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2869 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2870 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
|
2871 |
11190 | 2872 if(*dp_offset + es->size > *buffer_size) |
2873 { | |
2874 *buffer_size = *dp_offset + es->size + TS_FEC_PACKET_SIZE; | |
2875 resize_demux_packet(*dp, *buffer_size); | |
2876 //we'll skip at least one RESIZE() in the next iteration of ts_parse() | |
2877 mp_msg(MSGT_DEMUX, MSGL_DBG2, "RESIZE DP TO %d\n", *buffer_size); | |
2878 } | |
2879 memcpy(&((*dp)->buffer[*dp_offset]), es->start, es->size); | |
2880 *dp_offset += es->size; | |
2881 (*dp)->flags = 0; | |
2882 (*dp)->pos = stream_tell(demuxer->stream); | |
2883 (*dp)->pts = es->pts; | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2884 |
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
|
2885 if(is_audio) |
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
|
2886 { |
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
|
2887 retv = fill_packet(demuxer, ds, dp, dp_offset); |
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
|
2888 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
|
2889 } |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2890 |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2891 if(retv > 0) |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2892 return retv; |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2893 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2894 continue; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2895 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2896 } |
10014 | 2897 else |
2898 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2899 uint16_t sz; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2900 |
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
|
2901 if((tss->type == UNKNOWN) || (tss->type==SL_PES_STREAM && !tss->is_synced)) |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2902 { |
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
|
2903 stream_skip(stream, buf_size+junk); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2904 if(probe) |
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
|
2905 return (is_video || is_audio || is_sub); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2906 else |
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2907 continue; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2908 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2909 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2910 |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2911 es->pid = tss->pid; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2912 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
|
2913 es->subtype = tss->subtype; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2914 es->pts = tss->pts = tss->last_pts; |
11190 | 2915 es->start = &packet[base]; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2916 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2917 |
11190 | 2918 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
|
2919 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2920 sz = min(tss->payload_size, buf_size); |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2921 tss->payload_size -= sz; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2922 es->size = sz; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2923 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2924 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2925 { |
11190 | 2926 if(is_video) |
2927 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2928 sz = es->size = buf_size; |
11190 | 2929 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2930 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2931 { |
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
|
2932 stream_skip(stream, buf_size+junk); |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2933 continue; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2934 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2935 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2936 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2937 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2938 if(! probe) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2939 { |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2940 if(*dp_offset + sz > *buffer_size) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2941 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2942 *buffer_size = *dp_offset + sz + TS_FEC_PACKET_SIZE; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2943 resize_demux_packet(*dp, *buffer_size); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2944 //we'll skip at least one RESIZE() in the next iteration of ts_parse() |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2945 mp_msg(MSGT_DEMUX, MSGL_DBG2, "RESIZE DP TO %d\n", *buffer_size); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2946 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2947 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2948 stream_read(stream, &((*dp)->buffer[*dp_offset]), sz); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2949 *dp_offset += sz; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2950 |
11190 | 2951 if(buf_size - sz > 0) |
2952 { | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2953 stream_skip(stream, buf_size - sz); |
11190 | 2954 } |
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
|
2955 stream_skip(stream, junk); |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2956 |
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
|
2957 if(is_audio) |
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
|
2958 { |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2959 (*dp)->pts = tss->last_pts; |
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
|
2960 retv = fill_packet(demuxer, ds, dp, dp_offset); |
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
|
2961 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
|
2962 } |
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
|
2963 |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2964 continue; |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2965 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2966 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2967 { |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2968 stream_read(stream, es->start, sz); |
12612
a731d98a3382
added support for ac3 in non-pes aligned private1 streams; removed useless and commented code
nicodvb
parents:
12518
diff
changeset
|
2969 if(buf_size - sz) stream_skip(stream, buf_size-sz); |
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
|
2970 stream_skip(stream, junk); |
10253
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 if(es->size) |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2973 return es->size; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2974 else |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2975 continue; |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2976 } |
10014 | 2977 } |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2978 } |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2979 |
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
2980 return 0; |
9610 | 2981 } |
2982 | |
2983 | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2984 extern void resync_audio_stream(sh_audio_t *sh_audio); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2985 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
|
2986 |
11190 | 2987 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
|
2988 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2989 if(a) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2990 { |
11190 | 2991 if(priv->fifo[0].pack != NULL) |
2992 { | |
2993 free_demux_packet(priv->fifo[0].pack); | |
2994 priv->fifo[0].pack = NULL; | |
2995 } | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2996 priv->fifo[0].offset = 0; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2997 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2998 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
2999 if(v) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3000 { |
11190 | 3001 if(priv->fifo[1].pack != NULL) |
3002 { | |
3003 free_demux_packet(priv->fifo[1].pack); | |
3004 priv->fifo[1].pack = NULL; | |
3005 } | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3006 priv->fifo[1].offset = 0; |
11190 | 3007 } |
3008 | |
3009 if(s) | |
3010 { | |
3011 if(priv->fifo[2].pack != NULL) | |
3012 { | |
3013 free_demux_packet(priv->fifo[2].pack); | |
3014 priv->fifo[2].pack = NULL; | |
3015 } | |
3016 priv->fifo[2].offset = 0; | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3017 } |
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 |
11190 | 3020 extern int videobuf_code_len; |
3021 extern int sync_video_packet(demux_stream_t *); | |
3022 extern int skip_video_packet(demux_stream_t *); | |
3023 | |
3024 void demux_seek_ts(demuxer_t *demuxer, float rel_seek_secs, int flags) | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3025 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3026 demux_stream_t *d_audio=demuxer->audio; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3027 demux_stream_t *d_video=demuxer->video; |
11190 | 3028 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
|
3029 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
|
3030 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
|
3031 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
|
3032 int i, video_stats; |
11190 | 3033 off_t newpos; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3034 |
11190 | 3035 //================= seek in MPEG-TS ========================== |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3036 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3037 ts_dump_streams(demuxer->priv); |
11190 | 3038 reset_fifos(priv, sh_audio != NULL, sh_video != NULL, demuxer->sub->id > 0); |
3039 | |
3040 | |
3041 if(sh_audio != NULL) | |
3042 ds_free_packs(d_audio); | |
3043 if(sh_video != NULL) | |
3044 ds_free_packs(d_video); | |
3045 if(demuxer->sub->id > 0) | |
3046 ds_free_packs(d_sub); | |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3047 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3048 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3049 video_stats = (sh_video != NULL); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3050 if(video_stats) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3051 video_stats = sh_video->i_bps; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3052 |
11190 | 3053 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
|
3054 if(flags & 2) // float seek 0..1 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3055 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
|
3056 else |
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 // time seek (secs) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3059 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3060 if(! video_stats) // unspecified or VBR |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3061 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
|
3062 else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3063 newpos += video_stats*rel_seek_secs; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3064 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3065 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3066 |
11190 | 3067 if(newpos < demuxer->movi_start) |
3068 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
|
3069 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3070 #ifdef _LARGEFILE_SOURCE |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3071 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
|
3072 #else |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3073 newpos &= ~(STREAM_BUFFER_SIZE - 1); /* sector boundary */ |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3074 #endif |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3075 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3076 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
|
3077 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
|
3078 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
|
3079 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
|
3080 |
11190 | 3081 videobuf_code_len = 0; |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3082 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3083 if(sh_video != NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3084 ds_fill_buffer(d_video); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3085 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3086 if(sh_audio != NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3087 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3088 ds_fill_buffer(d_audio); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3089 resync_audio_stream(sh_audio); |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3090 } |
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 while(sh_video != NULL) |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3093 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3094 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
|
3095 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3096 float a_pts=d_audio->pts; |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3097 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; |
11190 | 3098 if(d_video->pts > a_pts) |
10686
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3099 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3100 skip_audio_frame(sh_audio); // sync audio |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3101 continue; |
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 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3104 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3105 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3106 i = sync_video_packet(d_video); |
11190 | 3107 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
|
3108 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3109 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
|
3110 } |
14034
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
3111 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
|
3112 { |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3113 if(i==0x1B6) break; // found it! |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3114 } |
14034
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
3115 else //H264 |
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
3116 { |
7ac60a1c576e
merged DEMUXER_TYPE_MPEG4_ES in the ordinary TS; added support for H264 in TS
nicodvb
parents:
13994
diff
changeset
|
3117 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
|
3118 } |
10686
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(!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
|
3121 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3122 } |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3123 |
8eb690f0e342
- seek() is always synchronized to keyframes, so the decoders don't
arpi
parents:
10310
diff
changeset
|
3124 |
9610 | 3125 int demux_ts_fill_buffer(demuxer_t * demuxer) |
3126 { | |
10253
978b12dcb9ef
- open new_ds_[audio | video] only when the relative streams are really available
arpi
parents:
10242
diff
changeset
|
3127 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
|
3128 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
|
3129 |
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
|
3130 return -ts_parse(demuxer, &es, priv->packet, 0); |
9610 | 3131 } |
3132 | |
3133 | |
3134 |