annotate libmpdemux/demux_ts.c @ 18237:4231482179b6

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