1 /*
2 * THP Demuxer
3 * Copyright (c) 2007 Marco Gerards
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
26
46
47
49 {
50 double d;
51 /* check file header */
53 return 0;
54
56 if (d < 0.1 || d > 1000 ||
isnan(d))
58
60 }
61
63 {
68 int i;
69
70 /* Read the file header. */
73
76
81 if(fsize>0 && (!pb->
maxsize || fsize < pb->maxsize))
83
88
91
92 /* Read the component structure. */
95
96 /* Read the list of component types. */
98
102 break;
103
104 /* Video component. */
106 if (!st)
108
109 /* The denominator and numerator are switched because 1/fps
110 is required. */
121
126 break;
127
128 /* Audio component. */
130 if (!st)
132
139
141
144 }
145 }
146
147 return 0;
148 }
149
152 {
156 int ret;
157
159 /* Terminate when last frame is reached. */
162
164
165 /* Locate the next frame and read out its size. */
168
169 avio_rb32(pb);
/* Previous total size. */
170 size =
avio_rb32(pb);
/* Total size of this frame. */
171
172 /* Store the audiosize so the next time this function is called,
173 the audio can be read. */
176 else
178
180 if (ret < 0)
181 return ret;
182 if (ret != size) {
185 }
186
188 } else {
190 if (ret < 0)
191 return ret;
195 }
196
200
203 }
204
205 return 0;
206 }
207
215 };
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int thp_read_header(AVFormatContext *s)
AVInputFormat ff_thp_demuxer
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
int index
stream index in AVFormatContext
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t maxsize
max filesize, used to limit allocations This field is internal to libavformat and access from outside...
unsigned int avio_rb32(AVIOContext *s)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
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_RB32
unsigned char components[16]
#define AVERROR_EOF
End of file.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int thp_probe(AVProbeData *p)
AVCodecContext * codec
Codec context associated with this stream.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
int width
picture width / height.
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
rational number numerator/denominator
This structure contains the data a format has to probe a file.
int64_t duration
Decoding: duration of the stream, in stream time base.
static int thp_read_packet(AVFormatContext *s, AVPacket *pkt)
int64_t nb_frames
number of frames in this stream if known or 0
int channels
number of audio channels
void * priv_data
Format private data.
#define MKTAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.