82 int len, xmin, xmax, ymin, ymax;
106 if (xmin || ymin || !xmax || !ymax)
109 if (p->buf[3] >= 20 || xmax < 16 || ymax < 16)
116static int zlib_refill(
void *opaque, uint8_t *buf,
int buf_size)
120 z_stream *z = &swf->zstream;
125 int n =
avio_read(
s->pb, swf->zbuf_in, ZBUF_SIZE);
128 z->next_in = swf->zbuf_in;
133 z->avail_out = buf_size;
136 if (ret == Z_STREAM_END)
141 if (buf_size - z->avail_out == 0)
144 return buf_size - z->avail_out;
162 if (inflateInit(&swf->zstream) != Z_OK) {
166 if (!(swf->zbuf_in =
av_malloc(ZBUF_SIZE)) ||
167 !(swf->zbuf_out =
av_malloc(ZBUF_SIZE)) ||
173 swf->zpb->seekable = 0;
183 len = (4 * nbits - 3 + 7) / 8;
195 int sample_rate_code, sample_size_code;
204 sample_rate_code = info>>2 & 3;
205 sample_size_code = info>>1 & 1;
238 for (
i=0;
i<
s->nb_streams;
i++) {
260 for (
i=0;
i<
s->nb_streams;
i++) {
277 for (
i=0;
i<
s->nb_streams;
i++) {
291 if (((v>>4) & 15) == 2) {
299 pkt->stream_index = ast->index;
304 for(
i=0;
i<
s->nb_streams;
i++) {
323 pkt->stream_index = st->index;
324 pkt->flags |= pkt_flags;
331 uint8_t *buf =
NULL, *zbuf =
NULL, *pal;
334 const int colormapbpp = 3 + alpha_bmp;
335 int linesize, colormapsize = 0;
338 const int bmp_fmt =
avio_r8(pb);
348 colormapsize =
avio_r8(pb) + 1;
352 linesize =
width * 2;
355 linesize =
width * 4;
359 goto bitmap_end_skip;
362 linesize =
FFALIGN(linesize, 4);
365 linesize >= INT_MAX /
height ||
366 linesize *
height >= INT_MAX - colormapsize * colormapbpp) {
368 goto bitmap_end_skip;
371 out_len = colormapsize * colormapbpp + linesize *
height;
373 ff_dlog(
s,
"bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
374 ch_id, bmp_fmt,
width,
height, linesize,
len, out_len, colormapsize);
376 if (
len * 17373LL < out_len)
377 goto bitmap_end_skip;
387 goto bitmap_end_skip;
394 if ((res = uncompress(buf, &out_len, zbuf,
len)) != Z_OK) {
396 goto bitmap_end_skip;
399 for (
i = 0;
i <
s->nb_streams;
i++) {
404 if (
i ==
s->nb_streams) {
419 if (!st->codecpar->width && !st->codecpar->height) {
420 st->codecpar->width =
width;
421 st->codecpar->height =
height;
426 pkt->stream_index = st->index;
436 for (
i = 0;
i < colormapsize;
i++)
437 if (alpha_bmp) colormap[
i] = buf[3]<<24 |
AV_RB24(buf + 4*
i);
438 else colormap[
i] = 0xffU <<24 |
AV_RB24(buf + 3*
i);
458 st->codecpar->format =
pix_fmt;
460 memcpy(
pkt->data, buf + colormapsize*colormapbpp, linesize *
height);
475 for (
i = 0;
i <
s->nb_streams;
i++) {
492 pkt->stream_index = st->index;
497 for (
i=0;
i<
s->nb_streams;
i++) {
502 if (
i ==
s->nb_streams) {
526 memset(
pkt->data+
pkt->size, 0, 4);
533 if (res !=
pkt->size) {
541 pkt->stream_index = st->index;
558 inflateEnd(&
s->zstream);
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
unsigned int avio_rl16(AVIOContext *s)
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, const uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
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)
void avio_context_free(AVIOContext **s)
Free the supplied IO context and everything associated with it.
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
Public libavutil channel layout APIs header.
int ff_add_param_change(AVPacket *pkt, int32_t channels, uint64_t channel_layout, int32_t sample_rate, int32_t width, int32_t height)
Add side data to a packet for changing parameters to the given values.
static enum AVPixelFormat pix_fmt
static int read_header(FFV1Context *f, RangeCoder *c)
#define FLV_VIDEO_FRAMETYPE_MASK
@ FLV_FRAME_KEY
key frame (for AVC, a seekable frame)
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
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.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
common internal API header
#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)
#define MKBETAG(a, b, c, d)
Memory handling functions.
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
#define AV_PIX_FMT_RGB555
AVChannelLayout ch_layout
The channel layout and number of channels.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
void * priv_data
Format private data.
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.
int id
Format-specific stream ID.
int skip_samples
Number of samples to skip at the start of the frame decoded from the next packet.
enum AVStreamParseType need_parsing
const AVCodecTag ff_swf_codec_tags[]
@ TAG_DEFINEBITSLOSSLESS2
static int swf_read_header(AVFormatContext *s)
static int get_swf_tag(AVIOContext *pb, int *len_ptr)
static const AVCodecTag swf_audio_codec_tags[]
static int swf_probe(const AVProbeData *p)
static AVStream * create_new_audio_stream(AVFormatContext *s, int id, int info)
static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)