annotate libmpdemux/demux_ty.c @ 18894:3ff839da886b

Sync with 18818
author jheryan
date Tue, 04 Jul 2006 09:12:33 +0000
parents 1b42df5780e3
children a8e681ad7c90
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1 /*
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
2 * tivo@wingert.org, February 2003
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
3 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
4 * Copyright (C) 2003 Christopher R. Wingert
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
5 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
6 * The license covers the portions of this file regarding TiVo additions.
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
7 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
8 * Olaf Beck and Tridge (indirectly) were essential at providing
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
9 * information regarding the format of the TiVo streams.
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
10 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
11 * However, no code in the following subsection is directly copied from
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
12 * either author.
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
13 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
14 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
15 * This program is free software; you can redistribute it and/or
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
16 * modify it under the terms of the GNU General Public License
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
17 * as published by the Free Software Foundation; either version 2
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
18 * of the License, or (at your option) any later version.
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
19 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
20 * This program is distributed in the hope that it will be useful,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
23 * GNU General Public License for more details.
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
24 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
25 * You should have received a copy of the GNU General Public License
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
26 * along with this program; if not, write to the Free Software
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
28 *
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
29 */
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
30
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
31
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
32 #include <stdio.h>
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
33 #include <stdlib.h>
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
34 #include <unistd.h>
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
35 #include <time.h>
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
36 #include <stdarg.h>
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
37
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
38 #include "config.h"
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
39 #include "mp_msg.h"
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
40 #include "help_mp.h"
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
41
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
42 #include "stream.h"
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
43 #include "demuxer.h"
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
44 #include "parse_es.h"
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
45 #include "stheader.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16877
diff changeset
46 #include "sub_cc.h"
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
47
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
48 extern void skip_audio_frame( sh_audio_t *sh_audio );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
49 extern int sub_justify;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
50
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
51 // 2/c0: audio data
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
52 // 3/c0: audio packet header (PES header)
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
53 // 4/c0: audio data (S/A only?)
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
54 // 9/c0: audio packet header, AC-3 audio
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
55 // 2/e0: video data
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
56 // 6/e0: video packet header (PES header)
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
57 // 7/e0: video sequence header start
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
58 // 8/e0: video I-frame header start
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
59 // a/e0: video P-frame header start
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
60 // b/e0: video B-frame header start
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
61 // c/e0: video GOP header start
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
62 // e/01: closed-caption data
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
63 // e/02: Extended data services data
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
64
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
65
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
66 #define TIVO_PES_FILEID ( 0xf5467abd )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
67 #define TIVO_PART_LENGTH ( 0x20000000 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
68
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
69 #define CHUNKSIZE ( 128 * 1024 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
70 #define MAX_AUDIO_BUFFER ( 16 * 1024 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
71
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
72 #define PTS_MHZ ( 90 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
73 #define PTS_KHZ ( PTS_MHZ * 1000 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
74
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
75 #define TY_V ( 1 )
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
76 #define TY_A ( 2 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
77
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
78 typedef struct stmf_fileParts
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
79 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
80 int fileNo;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
81 off_t fileSize;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
82 int chunks;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
83 off_t startOffset;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
84 } tmf_fileParts;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
85
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
86 #define MAX_TMF_PARTS ( 16 )
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
87
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
88 typedef struct sTivoInfo
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
89 {
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
90 int whichChunk;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
91
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
92 unsigned char lastAudio[ MAX_AUDIO_BUFFER ];
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
93 int lastAudioEnd;
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
94
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
95 int tivoType; // 1 = SA, 2 = DTiVo
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
96
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
97 float firstAudioPTS;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
98 float firstVideoPTS;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
99
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
100 float lastAudioPTS;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
101 float lastVideoPTS;
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
102
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
103 int headerOk;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
104 unsigned int pesFileId; // Should be 0xf5467abd
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
105 int streamType; // Should be 0x02
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
106 int chunkSize; // Should always be 128k
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
107 off_t size;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
108 int readHeader;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
109
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
110 int tmf;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
111 tmf_fileParts tmfparts[ MAX_TMF_PARTS ];
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
112 int tmf_totalparts;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
113 off_t tmf_totalsize;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
114 off_t tmf_totalchunks;
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
115
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
116 } TiVoInfo;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
117
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
118 off_t vstream_streamsize( );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
119 void ty_ClearOSD( int start );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
120
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
121 // ===========================================================================
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
122 #define TMF_SIG "showing.xml"
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
123
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
124 int ty_octaltodecimal( char *num )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
125 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
126 int i;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
127 int result = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
128 int len;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
129 int mult;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
130
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
131 len = strlen( num );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
132 mult = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
133
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
134 for ( i = ( len - 1 ) ; i >= 0 ; i-- )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
135 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
136 result += ( ( num[ i ] - '0') * mult );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
137 mult *= 8;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
138 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
139 return( result );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
140 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
141
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
142
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
143
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
144 // ===========================================================================
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
145 int ty_extensionis( char *name, char *ext )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
146 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
147 char *ptr;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
148
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
149 if ( strlen( ext ) > strlen( name ) ) return( 0 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
150 ptr = name;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
151 ptr += ( strlen( name ) - strlen( ext ) );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
152 if ( strcmp( ptr, ext ) == 0 ) return( 1 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
153 return( 0 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
154 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
155
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
156
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
157 // ===========================================================================
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
158 int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
159 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
160 char header[ 512 ];
17784
1b42df5780e3 name array is too small, use strlcpy instead of strncpy
reimar
parents: 17636
diff changeset
161 char name[ 100 ];
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
162 char sizestr[ 80 ];
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
163 int size;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
164 int count;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
165 int blocks;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
166 int done;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
167 off_t offset;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
168 off_t totalsize;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
169 off_t skip;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
170 int error = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
171 int parts = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
172 int isty;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
173 int index;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
174 int ok;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
175
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
176 offset = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
177 totalsize = demux->stream->end_pos;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
178
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
179 done = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
180 mp_msg( MSGT_DEMUX, MSGL_DBG3, "Dumping tar contents\n" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
181 while ( done == 0 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
182 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
183 ok = stream_seek( demux->stream, offset );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
184 if ( ( offset + 512 ) == totalsize )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
185 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
186 done = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
187 break;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
188 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
189 if ( ok == 0 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
190 {
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
191 mp_msg( MSGT_DEMUX, MSGL_DBG3, "Seek bad %"PRId64"\n", (int64_t)offset );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
192 done = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
193 error = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
194 break;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
195 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
196 count = stream_read( demux->stream, header, 512 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
197 if ( count < 512 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
198 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
199 mp_msg( MSGT_DEMUX, MSGL_DBG3, "Read bad\n" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
200 done = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
201 error = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
202 break;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
203 }
17784
1b42df5780e3 name array is too small, use strlcpy instead of strncpy
reimar
parents: 17636
diff changeset
204 strlcpy( name, &header[ 0 ], 100 );
1b42df5780e3 name array is too small, use strlcpy instead of strncpy
reimar
parents: 17636
diff changeset
205 strlcpy( sizestr, &header[ 124 ], 12 );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
206 size = ty_octaltodecimal( sizestr );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
207
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
208 blocks = size / 512;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
209 if ( ( size % 512 ) > 0 ) blocks++;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
210 skip = ( blocks + 1 ) * 512;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
211
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
212 if ( ( offset + skip ) > totalsize )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
213 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
214 size = totalsize - offset;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
215 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
216
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
217 isty = ty_extensionis( name, ".ty" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
218
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
219 mp_msg( MSGT_DEMUX, MSGL_DBG3, "name %-20.20s size %-12.12s %d %d\n",
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
220 name, sizestr, size, isty );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
221
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
222 if ( isty )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
223 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
224 tivo->tmfparts[ parts ].fileNo = parts;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
225 // HACK - Ignore last chunk of a Part File
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
226 // Why? I have no idea.
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
227 tivo->tmfparts[ parts ].fileSize = size - 0x20000;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
228 tivo->tmfparts[ parts ].startOffset = offset + 512;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
229 tivo->tmfparts[ parts ].chunks =
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
230 ( tivo->tmfparts[ parts ].fileSize / CHUNKSIZE );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
231 mp_msg
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
232 (
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
233 MSGT_DEMUX, MSGL_DBG3,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
234 "tmf_filetoparts(): index %d, file %d, chunks %d\n",
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
235 parts,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
236 tivo->tmfparts[ parts ].fileNo,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
237 tivo->tmfparts[ parts ].chunks
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
238 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
239 mp_msg
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
240 (
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
241 MSGT_DEMUX, MSGL_DBG3,
16750
0a31740dd5e6 Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents: 16346
diff changeset
242 "tmf_filetoparts(): size %"PRId64"\n",
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
243 tivo->tmfparts[ parts ].fileSize
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
244 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
245 mp_msg
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
246 (
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
247 MSGT_DEMUX, MSGL_DBG3,
16750
0a31740dd5e6 Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents: 16346
diff changeset
248 "tmf_filetoparts(): startOffset %"PRId64"\n",
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
249 tivo->tmfparts[ parts ].startOffset
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
250 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
251 parts++;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
252 if ( parts > MAX_TMF_PARTS )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
253 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
254 mp_msg( MSGT_DEMUX, MSGL_ERR, "ty:tmf too big\n" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
255 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
256 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
257
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
258 if ( ( offset + skip ) > totalsize )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
259 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
260 done = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
261 error = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
262 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
263 else
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
264 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
265 offset += skip;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
266 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
267 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
268 if ( error )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
269 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
270 mp_msg( MSGT_DEMUX, MSGL_DBG3,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
271 "WARNING : tmf parse error, not intact\n" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
272 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
273 tivo->tmf_totalparts = parts;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
274 mp_msg( MSGT_DEMUX, MSGL_DBG3,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
275 "tmf_filetoparts(): No More Part Files %d\n", parts );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
276
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
277 tivo->tmf_totalsize = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
278 tivo->tmf_totalchunks = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
279 for( index = 0 ; index < tivo->tmf_totalparts ; index++ )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
280 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
281 tivo->tmf_totalsize += tivo->tmfparts[ index ].fileSize;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
282 tivo->tmf_totalchunks += ( tivo->tmfparts[ index ].fileSize / CHUNKSIZE );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
283 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
284 mp_msg( MSGT_DEMUX, MSGL_DBG3,
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
285 "tmf_filetoparts():total size %"PRId64"\n", (int64_t)tivo->tmf_totalsize );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
286 mp_msg( MSGT_DEMUX, MSGL_DBG3,
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
287 "tmf_filetoparts():total chunks %"PRId64"\n", (int64_t)tivo->tmf_totalchunks );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
288
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
289 return( 1 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
290 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
291
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
292
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
293 // ===========================================================================
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
294 void tmf_filetooffset( TiVoInfo *tivo, int chunk, off_t *offset )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
295 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
296 int index;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
297
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
298 *offset = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
299
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
300 for( index = 0 ; index < tivo->tmf_totalparts ; index++ )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
301 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
302 if ( chunk >= tivo->tmfparts[ index ].chunks )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
303 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
304 chunk -= tivo->tmfparts[ index ].chunks;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
305 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
306 else
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
307 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
308 break;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
309 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
310 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
311 if ( chunk < tivo->tmfparts[ index ].chunks )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
312 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
313 *offset = tivo->tmfparts[ index ].startOffset +
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
314 ( chunk * CHUNKSIZE );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
315 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
316 mp_msg
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
317 (
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
318 MSGT_DEMUX, MSGL_DBG3,
16750
0a31740dd5e6 Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents: 16346
diff changeset
319 "tmf_filetooffset() offset %"PRIx64"\n", *offset
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
320 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
321 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
322
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
323
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
324 // ===========================================================================
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
325 int tmf_load_chunk( demuxer_t *demux, TiVoInfo *tivo,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
326 unsigned char *buff, int size, int readChunk )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
327 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
328 off_t fileoffset;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
329 int count;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
330
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
331 mp_msg( MSGT_DEMUX, MSGL_DBG3, "\ntmf_load_chunk() begin %d\n",
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
332 readChunk );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
333
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
334 if ( tivo->tmf_totalparts <= 0 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
335 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
336 return( 0 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
337 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
338
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
339 if ( readChunk >= tivo->tmf_totalchunks )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
340 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
341 mp_msg( MSGT_DEMUX, MSGL_ERR, "Read past EOF()\n" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
342 return( 0 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
343 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
344
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
345 tmf_filetooffset( tivo, readChunk, &fileoffset );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
346
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
347 if ( stream_seek( demux->stream, fileoffset ) != 1 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
348 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
349 mp_msg( MSGT_DEMUX, MSGL_ERR, "Read past EOF()\n" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
350 return( 0 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
351 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
352 count = stream_read( demux->stream, buff, size );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
353 demux->filepos = stream_tell( demux->stream );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
354
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
355 mp_msg( MSGT_DEMUX, MSGL_DBG3, "tmf_load_chunk() count %x\n",
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
356 count );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
357
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
358 mp_msg( MSGT_DEMUX, MSGL_DBG3,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
359 "tmf_load_chunk() bytes %x %x %x %x %x %x %x %x\n",
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
360 buff[ 0 ], buff[ 1 ], buff[ 2 ], buff[ 3 ],
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
361 buff[ 4 ], buff[ 5 ], buff[ 6 ], buff[ 7 ] );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
362
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
363 mp_msg( MSGT_DEMUX, MSGL_DBG3, "tmf_load_chunk() end\n" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
364
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
365 return( count );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
366 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
367
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
368 // ===========================================================================
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
369
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
370 // DTiVo MPEG 336, 480, 576, 768
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
371 // SA TiVo 864
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
372 // DTiVo AC-3 1550
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
373 //
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
374 #define SERIES1_PTS_LENGTH ( 11 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
375 #define SERIES1_PTS_OFFSET ( 6 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
376 #define SERIES2_PTS_LENGTH ( 16 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
377 #define SERIES2_PTS_OFFSET ( 9 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
378 #define AC3_PTS_LENGTH ( 16 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
379 #define AC3_PTS_OFFSET ( 9 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
380
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
381 #define NUMBER_DIFFERENT_AUDIO_SIZES ( 7 )
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
382 static int Series1AudioWithPTS[ NUMBER_DIFFERENT_AUDIO_SIZES ] =
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
383 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
384 336 + SERIES1_PTS_LENGTH,
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
385 384 + SERIES1_PTS_LENGTH,
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
386 480 + SERIES1_PTS_LENGTH,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
387 576 + SERIES1_PTS_LENGTH,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
388 768 + SERIES1_PTS_LENGTH,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
389 864 + SERIES1_PTS_LENGTH
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
390 };
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
391 static int Series2AudioWithPTS[ NUMBER_DIFFERENT_AUDIO_SIZES ] =
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
392 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
393 336 + SERIES2_PTS_LENGTH,
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
394 384 + SERIES2_PTS_LENGTH,
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
395 480 + SERIES2_PTS_LENGTH,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
396 576 + SERIES2_PTS_LENGTH,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
397 768 + SERIES2_PTS_LENGTH,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
398 864 + SERIES2_PTS_LENGTH
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
399 };
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
400
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
401 static int IsValidAudioPacket( int size, int *ptsOffset, int *ptsLen )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
402 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
403 int count;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
404
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
405 *ptsOffset = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
406 *ptsLen = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
407
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
408 // AC-3
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
409 if ( ( size == 1550 ) || ( size == 1552 ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
410 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
411 *ptsOffset = AC3_PTS_OFFSET;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
412 *ptsLen = AC3_PTS_LENGTH;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
413 return( 1 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
414 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
415
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
416 // MPEG
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
417 for( count = 0 ; count < NUMBER_DIFFERENT_AUDIO_SIZES ; count++ )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
418 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
419 if ( size == Series1AudioWithPTS[ count ] )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
420 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
421 *ptsOffset = SERIES1_PTS_OFFSET;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
422 *ptsLen = SERIES1_PTS_LENGTH;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
423 break;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
424 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
425 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
426 if ( *ptsOffset == 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
427 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
428 for( count = 0 ; count < NUMBER_DIFFERENT_AUDIO_SIZES ; count++ )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
429 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
430 if ( size == Series2AudioWithPTS[ count ] )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
431 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
432 *ptsOffset = SERIES2_PTS_OFFSET;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
433 *ptsLen = SERIES2_PTS_LENGTH;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
434 break;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
435 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
436 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
437 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
438 if ( *ptsOffset == 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
439 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
440 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Tossing Audio Packet Size %d\n",
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
441 size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
442 return( 0 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
443 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
444 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
445 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
446 return( 1 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
447 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
448 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
449
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
450
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
451 static float get_ty_pts( unsigned char *buf )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
452 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
453 float result = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
454 unsigned char temp;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
455
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
456 temp = ( buf[ 0 ] & 0xE ) >> 1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
457 result = ( (float) temp ) * ( (float) ( 1L << 30 ) ) / ( (float)PTS_KHZ );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
458 temp = buf[ 1 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
459 result += ( (float) temp ) * ( (float) ( 1L << 22 ) ) / ( (float)PTS_KHZ );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
460 temp = ( buf[ 2 ] & 0xFE ) >> 1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
461 result += ( (float) temp ) * ( (float) ( 1L << 15 ) ) / ( (float)PTS_KHZ );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
462 temp = buf[ 3 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
463 result += ( (float) temp ) * ( (float) ( 1L << 7 ) ) / ( (float)PTS_KHZ );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
464 temp = ( buf[ 4 ] & 0xFE ) >> 1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
465 result += ( (float) temp ) / ( (float)PTS_MHZ );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
466
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
467 return result;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
468 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
469
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
470 static void demux_ty_AddToAudioBuffer( TiVoInfo *tivo, unsigned char *buffer,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
471 int size )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
472 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
473 if ( ( tivo->lastAudioEnd + size ) < MAX_AUDIO_BUFFER )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
474 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
475 memcpy( &( tivo->lastAudio[ tivo->lastAudioEnd ] ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
476 buffer, size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
477 tivo->lastAudioEnd += size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
478 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
479 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
480 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
481 mp_msg( MSGT_DEMUX, MSGL_ERR,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
482 "ty:WARNING - Would have blown my audio buffer\n" );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
483 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
484 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
485
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
486 static void demux_ty_CopyToDemuxPacket( int type, TiVoInfo *tivo, demux_stream_t *ds,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
487 unsigned char *buffer, int size, off_t pos, float pts )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
488 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
489 demux_packet_t *dp;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
490
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
491 // mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Calling ds_add_packet() %7.1f\n", pts );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
492 // printf( "%x %x %x %x\n",
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
493 // buffer[ 0 ], buffer[ 1 ], buffer[ 2 ], buffer[ 3 ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
494
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
495 dp = new_demux_packet( size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
496 memcpy( dp->buffer, buffer, size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
497 dp->pts = pts;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
498 dp->pos = pos;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
499 dp->flags = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
500 ds_add_packet( ds, dp );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
501 ds->pts = pts;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
502 if ( type == TY_V )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
503 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
504 if ( tivo->firstVideoPTS == -1 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
505 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
506 tivo->firstVideoPTS = pts;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
507 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
508 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
509 if ( type == TY_A )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
510 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
511 if ( tivo->firstAudioPTS == -1 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
512 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
513 tivo->firstAudioPTS = pts;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
514 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
515 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
516 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
517
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
518 static int demux_ty_FindESHeader( unsigned char *header, int headerSize,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
519 unsigned char *buffer, int bufferSize, int *esOffset1 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
520 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
521 int count;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
522
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
523 *esOffset1 = -1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
524 for( count = 0 ; count < bufferSize ; count++ )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
525 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
526 if ( ( buffer[ count + 0 ] == header[ 0 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
527 ( buffer[ count + 1 ] == header[ 1 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
528 ( buffer[ count + 2 ] == header[ 2 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
529 ( buffer[ count + 3 ] == header[ 3 ] ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
530 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
531 *esOffset1 = count;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
532 return( 1 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
533 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
534 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
535 return( -1 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
536 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
537
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
538 static void demux_ty_FindESPacket( unsigned char *header, int headerSize,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
539 unsigned char *buffer, int bufferSize, int *esOffset1, int *esOffset2 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
540 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
541 int count;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
542
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
543 *esOffset1 = -1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
544 *esOffset2 = -1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
545
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
546 for( count = 0 ; count < bufferSize ; count++ )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
547 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
548 if ( ( buffer[ count + 0 ] == header[ 0 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
549 ( buffer[ count + 1 ] == header[ 1 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
550 ( buffer[ count + 2 ] == header[ 2 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
551 ( buffer[ count + 3 ] == header[ 3 ] ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
552 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
553 *esOffset1 = count;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
554 break;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
555 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
556 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
557
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
558 if ( *esOffset1 != -1 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
559 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
560 for( count = *esOffset1 + 1 ;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
561 count < bufferSize ; count++ )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
562 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
563 if ( ( buffer[ count + 0 ] == header[ 0 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
564 ( buffer[ count + 1 ] == header[ 1 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
565 ( buffer[ count + 2 ] == header[ 2 ] ) &&
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
566 ( buffer[ count + 3 ] == header[ 3 ] ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
567 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
568 *esOffset2 = count;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
569 break;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
570 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
571 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
572 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
573 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
574
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
575 static int tivobuffer2hostlong( unsigned char *buffer )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
576 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
577 return
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
578 (
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
579 buffer[ 0 ] << 24 | buffer[ 1 ] << 16 | buffer[ 2 ] << 8 | buffer[ 3 ]
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
580 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
581 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
582
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
583 static unsigned char ty_VideoPacket[] = { 0x00, 0x00, 0x01, 0xe0 };
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
584 static unsigned char ty_MPEGAudioPacket[] = { 0x00, 0x00, 0x01, 0xc0 };
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
585 static unsigned char ty_AC3AudioPacket[] = { 0x00, 0x00, 0x01, 0xbd };
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
586
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
587 static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
588 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
589 int invalidType = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
590 int errorHeader = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
591 int recordsDecoded = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
592 off_t filePos = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
593
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
594 unsigned char chunk[ CHUNKSIZE ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
595 int whichChunk;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
596 int readSize;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
597 unsigned int pesFileId = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
598
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
599 int numberRecs;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
600 unsigned char *recPtr;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
601 int offset;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
602 int size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
603
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
604 int type;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
605 int nybbleType;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
606
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
607 int counter;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
608
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
609 int aid;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
610 demux_stream_t *ds = NULL;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
611
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
612 int esOffset1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
613 int esOffset2;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
614
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
615 unsigned char lastCC[ 16 ];
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
616 unsigned char lastXDS[ 16 ];
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
617
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
618 TiVoInfo *tivo = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
619
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
620 if ( demux->stream->type == STREAMTYPE_DVD )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
621 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
622 return( 0 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
623 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
624
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
625 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty processing\n" );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
626 if ( ( demux->a_streams[ MAX_A_STREAMS - 1 ] ) == 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
627 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
628 demux->a_streams[ MAX_A_STREAMS - 1 ] = malloc( sizeof( TiVoInfo ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
629 tivo = demux->a_streams[ MAX_A_STREAMS - 1 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
630 memset( tivo, 0, sizeof( TiVoInfo ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
631 tivo->firstAudioPTS = -1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
632 tivo->firstVideoPTS = -1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
633 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
634 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
635 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
636 tivo = demux->a_streams[ MAX_A_STREAMS - 1 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
637 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
638
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
639 if( demux->stream->eof ) return 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
640
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
641 // ======================================================================
11000
6e35326c742f many small typo and grammar fixes
gabucino
parents: 10263
diff changeset
642 // If we haven't figured out the size of the stream, let's do so
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
643 // ======================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
644 #ifdef STREAMTYPE_STREAM_TY
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
645 if ( demux->stream->type == STREAMTYPE_STREAM_TY )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
646 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
647 // The vstream code figures out the exact size of the stream
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
648 demux->movi_start = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
649 demux->movi_end = vstream_streamsize();
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
650 tivo->size = vstream_streamsize();
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
651 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
652 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
653 #endif
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
654 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
655 // If its a local file, try to find the Part Headers, so we can
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
656 // calculate the ACTUAL stream size
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
657 // If we can't find it, go off with the file size and hope the
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
658 // extract program did the "right thing"
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
659 if ( tivo->readHeader == 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
660 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
661 tivo->readHeader = 1;
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
662 tivo->size = demux->stream->end_pos;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
663
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
664 filePos = demux->filepos;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
665 stream_seek( demux->stream, 0 );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
666
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
667 // mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
668 // "ty:Reading a chunk %d\n", __LINE__ );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
669
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
670 readSize = stream_read( demux->stream, chunk, CHUNKSIZE );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
671
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
672 if ( memcmp( chunk, TMF_SIG, sizeof( TMF_SIG ) ) == 0 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
673 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
674 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Detected a tmf\n" );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
675 tivo->tmf = 1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
676 ty_tmf_filetoparts( demux, tivo );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
677 readSize = tmf_load_chunk( demux, tivo, chunk, CHUNKSIZE, 0 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
678 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
679
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
680 if ( readSize == CHUNKSIZE )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
681 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
682 tivo->pesFileId = tivobuffer2hostlong( &chunk[ 0x00 ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
683 tivo->streamType = tivobuffer2hostlong( &chunk[ 0x04 ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
684 tivo->chunkSize = tivobuffer2hostlong( &chunk[ 0x08 ] );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
685
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
686 if ( tivo->pesFileId == TIVO_PES_FILEID )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
687 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
688 off_t numberParts;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
689
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
690 readSize = 0;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
691
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
692 if ( tivo->tmf != 1 )
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
693 {
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
694 off_t size;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
695 off_t offset;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
696
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
697 numberParts = demux->stream->end_pos / TIVO_PART_LENGTH;
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
698 offset = numberParts * TIVO_PART_LENGTH;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
699
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
700 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty/ty+Number Parts %"PRId64"\n",
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
701 (int64_t)numberParts );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
702
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
703 if ( ( offset + CHUNKSIZE ) < demux->stream->end_pos )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
704 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
705 stream_seek( demux->stream, offset );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
706 readSize = stream_read( demux->stream, chunk, CHUNKSIZE );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
707 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
708 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
709 else
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
710 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
711 numberParts = tivo->tmf_totalparts;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
712 offset = numberParts * TIVO_PART_LENGTH;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
713 readSize = tmf_load_chunk( demux, tivo, chunk, CHUNKSIZE,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
714 ( numberParts * ( TIVO_PART_LENGTH - 0x20000 ) /
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
715 CHUNKSIZE ) );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
716 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
717
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
718 if ( readSize == CHUNKSIZE )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
719 {
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
720 pesFileId = tivobuffer2hostlong( &chunk[ 0x00 ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
721 if ( pesFileId == TIVO_PES_FILEID )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
722 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
723 size = tivobuffer2hostlong( &chunk[ 0x0c ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
724 size /= 256;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
725 size -= 4;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
726 size *= CHUNKSIZE;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
727 tivo->size = numberParts * TIVO_PART_LENGTH;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
728 tivo->size += size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
729 mp_msg( MSGT_DEMUX, MSGL_DBG3,
16750
0a31740dd5e6 Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents: 16346
diff changeset
730 "ty:Header Calc Stream Size %"PRId64"\n", tivo->size );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
731 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
732 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
733 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
734 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
735 if ( tivo->size > demux->stream->end_pos )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
736 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
737 tivo->size = demux->stream->end_pos;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
738 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
739
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
740 if ( demux->stream->start_pos > 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
741 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
742 filePos = demux->stream->start_pos;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
743 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
744 stream_seek( demux->stream, filePos );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
745 demux->filepos = stream_tell( demux->stream );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
746 tivo->whichChunk = ( filePos / CHUNKSIZE );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
747 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
748 demux->movi_start = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
749 demux->movi_end = tivo->size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
750 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
751
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
752 // ======================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
753 // Give a clue as to where we are in the stream
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
754 // ======================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
755 mp_msg( MSGT_DEMUX, MSGL_DBG3,
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
756 "ty:ty header size %"PRIx64"\n", (int64_t)tivo->size );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
757 mp_msg( MSGT_DEMUX, MSGL_DBG3,
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
758 "ty:ty which Chunk %d\n", tivo->whichChunk );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
759 mp_msg( MSGT_DEMUX, MSGL_DBG3,
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
760 "ty:file end_pos %"PRIx64"\n", (int64_t)demux->stream->end_pos );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
761 mp_msg( MSGT_DEMUX, MSGL_DBG3,
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17174
diff changeset
762 "\nty:wanted current offset %"PRIx64"\n", (int64_t)stream_tell( demux->stream ) );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
763
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
764 if ( tivo->size > 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
765 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
766 if ( stream_tell( demux->stream ) > tivo->size )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
767 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
768 demux->stream->eof = 1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
769 return( 0 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
770 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
771 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
772
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
773 if ( tivo->tmf != 1 )
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
774 {
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
775 // Make sure we are on a 128k boundary
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
776 if ( ( demux->filepos % CHUNKSIZE ) != 0 )
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
777 {
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
778 whichChunk = demux->filepos / CHUNKSIZE;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
779 if ( ( demux->filepos % CHUNKSIZE ) > ( CHUNKSIZE / 2 ) )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
780 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
781 whichChunk++;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
782 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
783 stream_seek( demux->stream, ( whichChunk * CHUNKSIZE ) );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
784 }
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
785
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
786 demux->filepos = stream_tell( demux->stream );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
787 tivo->whichChunk = demux->filepos / CHUNKSIZE;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
788 readSize = stream_read( demux->stream, chunk, CHUNKSIZE );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
789 if ( readSize != CHUNKSIZE )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
790 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
791 return( 0 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
792 }
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
793 }
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
794 else
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
795 {
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
796 readSize = tmf_load_chunk( demux, tivo, chunk, CHUNKSIZE,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
797 tivo->whichChunk );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
798 if ( readSize != CHUNKSIZE )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
799 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
800 return( 0 );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
801 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
802 tivo->whichChunk++;
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
803 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
804
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
805 // We found a part header, skip it
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
806 pesFileId = tivobuffer2hostlong( &chunk[ 0x00 ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
807 if( pesFileId == TIVO_PES_FILEID )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
808 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
809 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Skipping PART Header\n" );
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
810 if ( tivo->tmf != 1 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
811 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
812 demux->filepos = stream_tell( demux->stream );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
813 readSize = stream_read( demux->stream, chunk, CHUNKSIZE );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
814 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
815 else
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
816 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
817 readSize = tmf_load_chunk( demux, tivo, chunk, CHUNKSIZE,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
818 tivo->whichChunk );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
819 tivo->whichChunk++;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
820 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
821
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
822 if ( readSize != CHUNKSIZE )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
823 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
824 return( 0 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
825 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
826 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
827 mp_msg( MSGT_DEMUX, MSGL_DBG3,
16750
0a31740dd5e6 Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents: 16346
diff changeset
828 "\nty:actual current offset %"PRIx64"\n", ( stream_tell( demux->stream ) -
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
829 0x20000 ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
830
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
831
12860
03d3ab9f6400 embarassing typo
diego
parents: 11000
diff changeset
832 // Let's make a Video Demux Stream for MPlayer
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
833 aid = 0x0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
834 if( !demux->v_streams[ aid ] ) new_sh_video( demux, aid );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
835 if( demux->video->id == -1 ) demux->video->id = aid;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
836 if( demux->video->id == aid )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
837 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
838 ds = demux->video;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
839 if( !ds->sh ) ds->sh = demux->v_streams[ aid ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
840 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
841
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
842 // ======================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
843 // Finally, we get to actually parse the chunk
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
844 // ======================================================================
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
845 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty parsing a chunk\n" );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
846 numberRecs = chunk[ 0 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
847 recPtr = &chunk[ 4 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
848 offset = ( numberRecs * 16 ) + 4;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
849 for ( counter = 0 ; counter < numberRecs ; counter++ )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
850 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
851 size = ( recPtr[ 0 ] << 8 | recPtr[ 1 ] ) << 4 | ( recPtr[ 2 ] >> 4 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
852 type = recPtr[ 3 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
853 nybbleType = recPtr[ 2 ] & 0x0f;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
854 recordsDecoded++;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
855
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
856 mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
857 "ty:Record Type %x/%x %d\n", nybbleType, type, size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
858
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
859 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
860 // Video Parsing
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
861 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
862 if ( type == 0xe0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
863 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
864 if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
865 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
866 #if 0
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
867 printf( "Video Chunk Header " );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
868 for( count = 0 ; count < 24 ; count++ )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
869 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
870 printf( "%2.2x ", chunk[ offset + count ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
871 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
872 printf( "\n" );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
873 #endif
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
874 demux_ty_FindESHeader( ty_VideoPacket, 4, &chunk[ offset ],
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
875 size, &esOffset1 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
876 if ( esOffset1 != -1 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
877 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
878 tivo->lastVideoPTS = get_ty_pts(
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
879 &chunk[ offset + esOffset1 + 9 ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
880 mp_msg( MSGT_DEMUX, MSGL_DBG3, "Video PTS %7.1f\n",
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
881 tivo->lastVideoPTS );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
882 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
883
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
884 // Do NOT Pass the PES Header onto the MPEG2 Decode
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
885 if( nybbleType != 0x06 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
886 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
887 demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
888 &chunk[ offset ], size, ( demux->filepos + offset ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
889 tivo->lastVideoPTS );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
890 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
891 offset += size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
892 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
893 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
894 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
895 errorHeader++;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
896 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
897 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
898 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
899 // Audio Parsing
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
900 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
901 else if ( type == 0xc0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
902 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
903 if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
904 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
905 #if 0
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
906 printf( "Audio Chunk Header " );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
907 for( count = 0 ; count < 24 ; count++ )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
908 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
909 printf( "%2.2x ", chunk[ offset + count ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
910 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
911 printf( "\n" );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
912 #endif
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
913
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
914 if( demux->audio->id == -1 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
915 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
916 if ( nybbleType == 0x02 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
917 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
918 continue; // DTiVo inconclusive, wait for more
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
919 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
920 else if ( nybbleType == 0x09 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
921 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
922 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Setting AC-3 Audio\n" );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
923 aid = 0x80; // AC-3
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
924 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
925 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
926 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
927 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Setting MPEG Audio\n" );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
928 aid = 0x0; // MPEG Audio
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
929 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
930
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
931 demux->audio->id = aid;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
932 if( !demux->a_streams[ aid ] ) new_sh_audio( demux, aid );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
933 if( demux->audio->id == aid )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
934 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
935 ds = demux->audio;
15580
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
936 if( !ds->sh ) {
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
937 sh_audio_t* sh_a;
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
938 ds->sh = demux->a_streams[ aid ];
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
939 sh_a = (sh_audio_t*)ds->sh;
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
940 switch(aid & 0xE0){ // 1110 0000 b (high 3 bit: type low 5: id)
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
941 case 0x00: sh_a->format=0x50;break; // mpeg
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
942 case 0xA0: sh_a->format=0x10001;break; // dvd pcm
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
943 case 0x80: if((aid & 0xF8) == 0x88) sh_a->format=0x2001;//dts
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
944 else sh_a->format=0x2000;break; // ac3
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
945 }
fa5573007038 fix audio init crash
joey
parents: 14502
diff changeset
946 }
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
947 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
948 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
949
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
950 aid = demux->audio->id;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
951
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
952
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
953 // SA DTiVo Audio Data, no PES
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
954 // ================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
955 if ( nybbleType == 0x02 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
956 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
957 if ( tivo->tivoType == 2 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
958 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
959 demux_ty_AddToAudioBuffer( tivo, &chunk[ offset ], size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
960 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
961 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
962 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
963
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
964 mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
965 "ty:Adding Audio Packet Size %d\n", size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
966 demux_ty_CopyToDemuxPacket( TY_A, tivo, demux->audio,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
967 &chunk[ offset ], size, ( demux->filepos + offset ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
968 tivo->lastAudioPTS );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
969 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
970 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
971
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
972 // MPEG Audio with PES Header, either SA or DTiVo
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
973 // ================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
974 if ( nybbleType == 0x03 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
975 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
976 demux_ty_FindESHeader( ty_MPEGAudioPacket, 4, &chunk[ offset ],
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
977 size, &esOffset1 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
978
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
979 // SA PES Header, No Audio Data
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
980 // ================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
981 if ( ( esOffset1 == 0 ) && ( size == 16 ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
982 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
983 tivo->tivoType = 1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
984 tivo->lastAudioPTS = get_ty_pts( &chunk[ offset +
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
985 SERIES2_PTS_OFFSET ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
986 mp_msg( MSGT_DEMUX, MSGL_DBG3, "SA Audio PTS %7.1f\n",
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
987 tivo->lastAudioPTS );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
988 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
989 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
990 // DTiVo Audio with PES Header
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
991 // ================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
992 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
993 tivo->tivoType = 2;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
994
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
995 demux_ty_AddToAudioBuffer( tivo, &chunk[ offset ], size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
996 demux_ty_FindESPacket( ty_MPEGAudioPacket, 4,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
997 tivo->lastAudio, tivo->lastAudioEnd, &esOffset1,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
998 &esOffset2 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
999
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1000 if ( ( esOffset1 != -1 ) && ( esOffset2 != -1 ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1001 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1002 int packetSize = esOffset2 - esOffset1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1003 int headerSize;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1004 int ptsOffset;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1005
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1006 if ( IsValidAudioPacket( packetSize, &ptsOffset,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1007 &headerSize ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1008 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1009 mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1010 "ty:Adding DTiVo Audio Packet Size %d\n",
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1011 packetSize );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1012
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1013 tivo->lastAudioPTS = get_ty_pts(
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1014 &tivo->lastAudio[ esOffset1 + ptsOffset ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1015 mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1016 "MPEG Audio PTS %7.1f\n", tivo->lastAudioPTS );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1017
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1018 demux_ty_CopyToDemuxPacket
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1019 (
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1020 TY_A,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1021 tivo,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1022 demux->audio,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1023 &( tivo->lastAudio[ esOffset1 + headerSize ] ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1024 ( packetSize - headerSize ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1025 ( demux->filepos + offset ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1026 tivo->lastAudioPTS
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1027 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1028
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1029 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1030
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1031 // Collapse the Audio Buffer
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1032 memmove( &(tivo->lastAudio[ 0 ] ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1033 &( tivo->lastAudio[ esOffset2 ] ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1034 ( tivo->lastAudioEnd - esOffset2 ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1035 tivo->lastAudioEnd -= esOffset2;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1036 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1037 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1038 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1039
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1040 // SA Audio with no PES Header
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1041 // ================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1042 if ( nybbleType == 0x04 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1043 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1044 mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1045 "ty:Adding Audio Packet Size %d\n", size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1046 demux_ty_CopyToDemuxPacket( TY_A, tivo, demux->audio,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1047 &chunk[ offset ], size, ( demux->filepos + offset ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1048 tivo->lastAudioPTS );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1049 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1050
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1051 // DTiVo AC3 Audio Data with PES Header
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1052 // ================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1053 if ( nybbleType == 0x09 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1054 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1055 tivo->tivoType = 2;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1056
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1057 demux_ty_AddToAudioBuffer( tivo, &chunk[ offset ], size );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1058 demux_ty_FindESPacket( ty_AC3AudioPacket, 4,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1059 tivo->lastAudio, tivo->lastAudioEnd, &esOffset1,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1060 &esOffset2 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1061
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1062 if ( ( esOffset1 != -1 ) && ( esOffset2 != -1 ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1063 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1064 int packetSize = esOffset2 - esOffset1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1065 int headerSize;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1066 int ptsOffset;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1067
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1068 if ( IsValidAudioPacket( packetSize, &ptsOffset,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1069 &headerSize ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1070 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1071 mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1072 "ty:Adding DTiVo Audio Packet Size %d\n",
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1073 packetSize );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1074
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1075 tivo->lastAudioPTS = get_ty_pts(
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1076 &tivo->lastAudio[ esOffset1 + ptsOffset ] );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1077 mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1078 "AC3 Audio PTS %7.1f\n", tivo->lastAudioPTS );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1079
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1080 // AC3 Decoder WANTS the PTS
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1081 demux_ty_CopyToDemuxPacket
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1082 (
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1083 TY_A,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1084 tivo,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1085 demux->audio,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1086 &( tivo->lastAudio[ esOffset1 ] ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1087 ( packetSize ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1088 ( demux->filepos + offset ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1089 tivo->lastAudioPTS
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1090 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1091
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1092 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1093
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1094 // Collapse the Audio Buffer
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1095 memmove( &(tivo->lastAudio[ 0 ] ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1096 &( tivo->lastAudio[ esOffset2 ] ),
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1097 ( tivo->lastAudioEnd - esOffset2 ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1098 tivo->lastAudioEnd -= esOffset2;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1099 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1100 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1101 offset += size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1102 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1103 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1104 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1105 errorHeader++;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1106 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1107 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1108 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1109 // Closed Caption
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1110 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1111 else if ( type == 0x01 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1112 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1113 unsigned char b1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1114 unsigned char b2;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1115 unsigned char buffer[ 16 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1116
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1117 b1 = ( ( ( recPtr[ 0 ] & 0x0f ) << 4 ) |
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1118 ( ( recPtr[ 1 ] & 0xf0 ) >> 4 ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1119 b1 &= 0x7f;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1120 b2 = ( ( ( recPtr[ 1 ] & 0x0f ) << 4 ) |
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1121 ( ( recPtr[ 2 ] & 0xf0 ) >> 4 ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1122 b2 &= 0x7f;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1123
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1124 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:CC %x %x\n", b1, b2 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1125
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1126 lastCC[ 0x00 ] = 0x00;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1127 lastCC[ 0x01 ] = 0x00;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1128 lastCC[ 0x02 ] = 0x01;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1129 lastCC[ 0x03 ] = 0xb2;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1130 lastCC[ 0x04 ] = 'T';
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1131 lastCC[ 0x05 ] = 'Y';
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1132 lastCC[ 0x06 ] = 0x01;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1133 lastCC[ 0x07 ] = b1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1134 lastCC[ 0x08 ] = b2;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1135 if ( subcc_enabled )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1136 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1137 demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video, lastCC, 0x09,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1138 ( demux->filepos + offset ), tivo->lastVideoPTS );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1139 }
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1140 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1141 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1142 // Extended Data Services
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1143 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1144 else if ( type == 0x02 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1145 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1146 unsigned char b1;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1147 unsigned char b2;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1148 unsigned char buffer[ 16 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1149
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1150 b1 = ( ( ( recPtr[ 0 ] & 0x0f ) << 4 ) |
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1151 ( ( recPtr[ 1 ] & 0xf0 ) >> 4 ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1152 b1 &= 0x7f;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1153 b2 = ( ( ( recPtr[ 1 ] & 0x0f ) << 4 ) |
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1154 ( ( recPtr[ 2 ] & 0xf0 ) >> 4 ) );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1155 b2 &= 0x7f;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1156
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1157 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:XDS %x %x\n", b1, b2 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1158
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1159 lastXDS[ 0x00 ] = 0x00;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1160 lastXDS[ 0x01 ] = 0x00;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1161 lastXDS[ 0x02 ] = 0x01;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1162 lastXDS[ 0x03 ] = 0xb2;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1163 lastXDS[ 0x04 ] = 'T';
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1164 lastXDS[ 0x05 ] = 'Y';
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1165 lastXDS[ 0x06 ] = 0x02;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1166 lastXDS[ 0x07 ] = b1;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1167 lastXDS[ 0x08 ] = b2;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1168 if ( subcc_enabled )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1169 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1170 demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video, lastXDS, 0x09,
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1171 ( demux->filepos + offset ), tivo->lastVideoPTS );
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1172 }
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1173 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1174 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1175 // Found a 0x03 on Droid's TiVo, I have no idea what it is
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1176 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1177 else if ( type == 0x03 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1178 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1179 if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1180 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1181 offset += size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1182 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1183 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1184 // ================================================================
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1185 // Found a 0x03 on Hermit's TiVo, I have no idea what it is
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1186 // ================================================================
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1187 else if ( type == 0x03 )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1188 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1189 if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) )
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1190 {
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1191 offset += size;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1192 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1193 }
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1194 // ================================================================
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1195 // Unknown
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1196 // ================================================================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1197 else if ( type == 0x05 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1198 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1199 if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1200 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1201 offset += size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1202 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1203 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1204 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1205 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1206 if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1207 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1208 offset += size;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1209 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1210 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Invalid Type %x\n", type );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1211 invalidType++;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1212 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1213 recPtr += 16;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1214 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1215
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1216 if ( errorHeader > 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1217 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1218 mp_msg( MSGT_DEMUX, MSGL_DBG3,
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1219 "ty:Error Check - Records %d, Parsed %d, Errors %d\n",
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1220 numberRecs, recordsDecoded, errorHeader );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1221
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1222 // Invalid MPEG ES Size Check
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1223 if ( errorHeader > ( numberRecs / 2 ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1224 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1225 return( 0 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1226 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1227
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1228 // Invalid MPEG Stream Type Check
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1229 if ( invalidType > ( numberRecs / 2 ) )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1230 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1231 return( 0 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1232 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1233 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1234
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1235 demux->filepos = stream_tell( demux->stream );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1236
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1237 return( 1 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1238 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1239
17636
b849a99cdc3c Second-try commit of this patch.
corey
parents: 17569
diff changeset
1240 static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags )
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1241 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1242 demux_stream_t *d_audio = demuxer->audio;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1243 demux_stream_t *d_video = demuxer->video;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1244 sh_audio_t *sh_audio = d_audio->sh;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1245 sh_video_t *sh_video = d_video->sh;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1246 off_t newpos;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1247 off_t res;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1248 TiVoInfo *tivo = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1249
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1250 mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Seeking to %7.1f\n", rel_seek_secs );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1251
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1252 if ( ( demuxer->a_streams[ MAX_A_STREAMS - 1 ] ) != 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1253 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1254 tivo = demuxer->a_streams[ MAX_A_STREAMS - 1 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1255 tivo->lastAudioEnd = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1256 tivo->lastAudioPTS = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1257 tivo->lastVideoPTS = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1258 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1259 //
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1260 //================= seek in MPEG ==========================
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1261 demuxer->filepos = stream_tell( demuxer->stream );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1262
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1263 newpos = ( flags & 1 ) ? demuxer->movi_start : demuxer->filepos;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1264
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1265 if( flags & 2 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1266 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1267 // float seek 0..1
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1268 newpos += ( demuxer->movi_end - demuxer->movi_start ) * rel_seek_secs;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1269 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1270 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1271 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1272 // time seek (secs)
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1273 if( ! sh_video->i_bps ) // unspecified or VBR
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1274 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1275 newpos += 2324 * 75 * rel_seek_secs; // 174.3 kbyte/sec
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1276 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1277 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1278 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1279 newpos += sh_video->i_bps * rel_seek_secs;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1280 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1281 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1282
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1283 if ( newpos < demuxer->movi_start )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1284 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1285 if( demuxer->stream->type != STREAMTYPE_VCD ) demuxer->movi_start = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1286 if( newpos < demuxer->movi_start ) newpos = demuxer->movi_start;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1287 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1288
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1289 res = newpos / CHUNKSIZE;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1290 if ( rel_seek_secs >= 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1291 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1292 newpos = ( res + 1 ) * CHUNKSIZE;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1293 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1294 else
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1295 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1296 newpos = res * CHUNKSIZE;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1297 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1298
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1299 if ( newpos < 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1300 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1301 newpos = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1302 }
15581
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1303
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1304 tivo->whichChunk = newpos / CHUNKSIZE;
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1305
2e621c99354d a cleaned-up version of ty demuxer improvements found in tivo-mplayer fork.
joey
parents: 15580
diff changeset
1306 stream_seek( demuxer->stream, newpos );
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1307
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1308 // re-sync video:
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1309 videobuf_code_len = 0; // reset ES stream buffer
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1310
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1311 ds_fill_buffer( d_video );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1312 if( sh_audio )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1313 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1314 ds_fill_buffer( d_audio );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1315 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1316
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1317 while( 1 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1318 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1319 int i;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1320 if( sh_audio && !d_audio->eof && d_video->pts && d_audio->pts )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1321 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1322 float a_pts = d_audio->pts;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1323 a_pts += ( ds_tell_pts( d_audio ) - sh_audio->a_in_buffer_len ) /
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1324 (float)sh_audio->i_bps;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1325 if( d_video->pts > a_pts )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1326 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1327 skip_audio_frame( sh_audio ); // sync audio
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1328 continue;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1329 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1330 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1331 i = sync_video_packet( d_video );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1332 if( i == 0x1B3 || i == 0x1B8 ) break; // found it!
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1333 if( !i || !skip_video_packet( d_video ) ) break; // EOF?
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1334 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1335 if ( subcc_enabled )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1336 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1337 ty_ClearOSD( 0 );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1338 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1339 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1340
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1341 int demux_ty_control( demuxer_t *demuxer,int cmd, void *arg )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1342 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1343 demux_stream_t *d_video = demuxer->video;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1344 sh_video_t *sh_video = d_video->sh;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1345
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1346 switch(cmd)
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1347 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1348 case DEMUXER_CTRL_GET_TIME_LENGTH:
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1349 if(!sh_video->i_bps) // unspecified or VBR
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1350 return DEMUXER_CTRL_DONTKNOW;
16346
6ff303d2876b Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents: 16175
diff changeset
1351 *((double *)arg)=
6ff303d2876b Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents: 16175
diff changeset
1352 ((double)demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1353 return DEMUXER_CTRL_GUESS;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1354
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1355 case DEMUXER_CTRL_GET_PERCENT_POS:
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1356 return DEMUXER_CTRL_DONTKNOW;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1357 default:
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1358 return DEMUXER_CTRL_NOTIMPL;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1359 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1360 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1361
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1362
17174
83a8c738be89 make demuxer seek and close functions return void, patch by Dominik Mierzejewski
wanderer
parents: 17012
diff changeset
1363 static void demux_close_ty( demuxer_t *demux )
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1364 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1365 TiVoInfo *tivo = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1366
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1367 if ( ( demux->a_streams[ MAX_A_STREAMS - 1 ] ) != 0 )
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1368 {
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1369 tivo = demux->a_streams[ MAX_A_STREAMS - 1 ];
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1370 free( tivo );
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1371 demux->a_streams[ MAX_A_STREAMS - 1 ] = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1372 sub_justify = 0;
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1373 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1374 }
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1375
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents:
diff changeset
1376
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1377 static int ty_check_file(demuxer_t* demuxer)
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1378 {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1379 return ds_fill_buffer(demuxer->video) ? DEMUXER_TYPE_MPEG_TY : 0;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1380 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1381
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1382
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1383 static demuxer_t* demux_open_ty(demuxer_t* demuxer)
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1384 {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1385 sh_audio_t *sh_audio=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1386 sh_video_t *sh_video=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1387
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1388 sh_video=demuxer->video->sh;sh_video->ds=demuxer->video;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1389
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1390 if(demuxer->audio->id!=-2) {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1391 if(!ds_fill_buffer(demuxer->audio)){
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1392 mp_msg(MSGT_DEMUXER,MSGL_INFO,"MPEG: " MSGTR_MissingAudioStream);
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1393 demuxer->audio->sh=NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1394 } else {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1395 sh_audio=demuxer->audio->sh;sh_audio->ds=demuxer->audio;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1396 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1397 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1398
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1399 return demuxer;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1400 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1401
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1402
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1403 demuxer_desc_t demuxer_desc_mpeg_ty = {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1404 "TiVo demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1405 "tivo",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1406 "TiVo",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1407 "Christopher R. Wingert",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1408 "Demux streams from TiVo",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1409 DEMUXER_TYPE_MPEG_TY,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1410 0, // unsafe autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1411 ty_check_file,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1412 demux_ty_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1413 demux_open_ty,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1414 demux_close_ty,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1415 demux_seek_ty,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1416 demux_ty_control
6b86089c2edd Demuxer modularization
rtognimp
parents: 15581
diff changeset
1417 };