1 /*
2 * TechnoTrend PVA (.pva) demuxer
3 * Copyright (c) 2007, 2008 Ivo van Poorten
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
25
26 #define PVA_MAX_PAYLOAD_LENGTH 0x17f8
27 #define PVA_VIDEO_PAYLOAD 0x01
28 #define PVA_AUDIO_PAYLOAD 0x02
29 #define PVA_MAGIC (('A' << 8) + 'V')
30
34
39 return -1;
40 return length + 8;
41 }
42
44 const unsigned char *
buf = pd->
buf;
46
47 if (len < 0)
48 return 0;
49
53
55 }
56
59
67
75
76 /* the parameters will be extracted from the compressed bitstream */
77 return 0;
78 }
79
80 #define pva_log if (read_packet) av_log
81
86 int syncword, streamid, reserved,
flags,
length, pts_flag;
88
89 recover:
91
94 avio_r8(pb);
/* counter not used */
98
99 pts_flag = flags & 0x10;
100
104 }
108 }
109 if (reserved != 0x55) {
111 }
115 }
116
119 length -= 4;
121 /* PVA Audio Packets either start with a signaled PES packet or
122 * are a continuation of the previous PES packet. New PES packets
123 * always start at the beginning of a PVA Packet, never somewhere in
124 * the middle. */
126 int pes_signal, pes_header_data_length, pes_packet_length,
127 pes_flags;
128 unsigned char pes_header_data[256];
129
134 pes_header_data_length =
avio_r8(pb);
135
136 if (pes_signal != 1) {
138 "trying to recover\n");
140 if (!read_packet)
142 goto recover;
143 }
144
145 avio_read(pb, pes_header_data, pes_header_data_length);
146 length -= 9 + pes_header_data_length;
147
148 pes_packet_length -= 3 + pes_header_data_length;
149
151
152 if (pes_flags & 0x80 && (pes_header_data[0] & 0xf0) == 0x20)
154 }
155
157
161 }
162 }
163
166
167 *pts = pva_pts;
169 *strid = streamid;
170 return 0;
171 }
172
175 int64_t pva_pts;
177
181
184
186 }
187
189 int64_t *pos, int64_t pos_limit) {
194
196
197 while (*pos < pos_limit) {
200
203 (*pos)++;
204 continue;
205 }
208 continue;
209 }
210 break;
211 }
212
215 }
216
225 };