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
23
24 #define SUP_PGS_MAGIC 0x5047 /* "PG", big endian */
25
27 {
29 if (!st)
34
35 return 0;
36 }
37
39 {
42
44
47
50
53
58 // Many files have DTS set to 0 for all packets, so assume 0 means unset.
60
62 // The full packet size is stored as part of the packet.
64
67 }
68
69 return 0;
70 }
71
73 {
74 unsigned char *buf = p->
buf;
76 int nb_packets;
77
78 for (nb_packets = 0; nb_packets < 10; nb_packets++) {
79 size_t full_packet_size;
80 if (buf_size < 10 + 3)
81 break;
83 return 0;
84 full_packet_size =
AV_RB16(buf + 10 + 1) + 10 + 3;
85 if (buf_size < full_packet_size)
86 break;
87 buf += full_packet_size;
88 buf_size -= full_packet_size;
89 }
90 if (!nb_packets)
91 return 0;
92 if (nb_packets < 2)
94 if (nb_packets < 4)
96 if (nb_packets < 10)
99 }
100
104 .p.extensions = "sup",
105 .p.mime_type = "application/x-pgs",
110 };