29#define MAGIC "Packed Animation File V1.0\n(c) 1992-96 Amazing Studio\x0a\x1a"
60 if ((p->buf_size >= strlen(
MAGIC)) &&
84 for (
i = 0;
i < count;
i++) {
99 int frame_ms, ret = 0;
146 if (p->buffer_size < 175 ||
147 p->max_audio_blks < 2 ||
148 p->max_video_blks < 1 ||
151 p->preload_count < 1 ||
152 p->buffer_size > 2048 ||
153 p->max_video_blks > 2048 ||
154 p->max_audio_blks > 2048 ||
155 p->nb_frames > INT_MAX /
sizeof(uint32_t) ||
156 p->frame_blks > INT_MAX /
sizeof(uint32_t))
160 sizeof(*p->blocks_count_table));
162 sizeof(*p->frames_offset_table));
164 sizeof(*p->blocks_offset_table));
166 p->video_size = p->max_video_blks * p->buffer_size;
169 p->audio_size = p->max_audio_blks * p->buffer_size;
171 p->temp_audio_frame =
av_mallocz(p->audio_size);
173 if (!p->blocks_count_table ||
174 !p->frames_offset_table ||
175 !p->blocks_offset_table ||
178 !p->temp_audio_frame)
183 ret =
read_table(
s, p->blocks_count_table, p->nb_frames);
186 ret =
read_table(
s, p->frames_offset_table, p->nb_frames);
189 ret =
read_table(
s, p->blocks_offset_table, p->frame_blks);
194 p->current_frame = 0;
195 p->current_frame_block = 0;
197 avio_seek(pb, p->start_offset, SEEK_SET);
209 if (p->current_frame >= p->nb_frames)
219 memcpy(
pkt->data, p->temp_audio_frame, p->audio_size);
222 pkt->stream_index = 1;
227 count = (p->current_frame == 0) ? p->preload_count
228 : p->blocks_count_table[p->current_frame - 1];
229 for (
i = 0;
i < count;
i++) {
230 if (p->current_frame_block >= p->frame_blks)
233 offset = p->blocks_offset_table[p->current_frame_block] & ~(1U << 31);
234 if (p->blocks_offset_table[p->current_frame_block] & (1U << 31)) {
235 if (
offset > p->audio_size - p->buffer_size)
239 if (
offset == (p->max_audio_blks - 2) * p->buffer_size) {
240 memcpy(p->temp_audio_frame, p->audio_frame, p->audio_size);
244 if (
offset > p->video_size - p->buffer_size)
249 p->current_frame_block++;
252 if (p->frames_offset_table[p->current_frame] >= p->video_size)
255 size = p->video_size - p->frames_offset_table[p->current_frame];
260 pkt->stream_index = 0;
262 memcpy(
pkt->data, p->video_frame + p->frames_offset_table[p->current_frame],
size);
263 if (
pkt->data[0] & 0x20)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
unsigned int avio_rl32(AVIOContext *s)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
Public libavutil channel layout APIs header.
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
static int read_header(FFV1Context *f, RangeCoder *c)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AV_CHANNEL_LAYOUT_STEREO
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
Memory handling functions.
static int read_table(AVFormatContext *s, uint32_t *table, uint32_t count)
static int read_close(AVFormatContext *s)
static int read_packet(AVFormatContext *s, AVPacket *pkt)
static int read_probe(const AVProbeData *p)
static int read_header(AVFormatContext *s)
#define PAF_SOUND_FRAME_SIZE
#define PAF_SOUND_SAMPLES
static const uint16_t table[]
An AVChannelLayout holds information about the channel layout of audio data.
int height
The height of the video frame in pixels.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
This structure stores compressed data.
This structure contains the data a format has to probe a file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t nb_frames
number of frames in this stream if known or 0
int64_t duration
Decoding: duration of the stream, in stream time base.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
uint32_t * blocks_count_table
uint32_t current_frame_count
uint32_t current_frame_block
uint32_t * frames_offset_table
uint8_t * temp_audio_frame
uint32_t * blocks_offset_table
#define av_malloc_array(a, b)