1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
22
23 #define SUP_PGS_MAGIC 0x5047 /* "PG", big endian */
24
26 {
28 if (!st)
33
34 return 0;
35 }
36
38 {
39 int64_t
pts, dts, pos;
41
43
46
49
52
57 // Many files have DTS set to 0 for all packets, so assume 0 means unset.
59
61 // The full packet size is stored as part of the packet.
63
66 }
67
68 return 0;
69 }
70
72 {
73 unsigned char *
buf = p->
buf;
75 int nb_packets;
76
77 for (nb_packets = 0; nb_packets < 10; nb_packets++) {
78 size_t full_packet_size;
79 if (buf_size < 10 + 3)
80 break;
82 return 0;
83 full_packet_size =
AV_RB16(buf + 10 + 1) + 10 + 3;
84 if (buf_size < full_packet_size)
85 break;
86 buf += full_packet_size;
87 buf_size -= full_packet_size;
88 }
89 if (!nb_packets)
90 return 0;
91 if (nb_packets < 2)
93 if (nb_packets < 4)
95 if (nb_packets < 10)
98 }
99
103 .extensions = "sup",
104 .mime_type = "application/x-pgs",
109 };