annotate libmpdemux/demux_ts.c @ 36491:c28bad343706

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