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;
40 int ret;
41
43
46
49
51 return ret;
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
65 return ret;
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 };
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t pos
byte position in stream, -1 if unknown
AVInputFormat ff_sup_demuxer
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
unsigned int avio_rb16(AVIOContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
static int sup_probe(AVProbeData *p)
static int sup_read_header(AVFormatContext *s)
unsigned int avio_rb32(AVIOContext *s)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVMediaType codec_type
General type of the encoded data.
int flags
A combination of AV_PKT_FLAG values.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
AVIOContext * pb
I/O context.
This structure contains the data a format has to probe a file.
static int sup_read_packet(AVFormatContext *s, AVPacket *pkt)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.