60 int len, xmin, xmax, ymin, ymax;
80 if (xmin || ymin || !xmax || !ymax)
83 if (p->
buf[3] >= 20 || xmax < 16 || ymax < 16)
90 static int zlib_refill(
void *opaque,
uint8_t *
buf,
int buf_size)
94 z_stream *z = &swf->zstream;
102 z->next_in = swf->zbuf_in;
107 z->avail_out = buf_size;
109 ret = inflate(z, Z_NO_FLUSH);
112 if (ret == Z_STREAM_END)
115 if (buf_size - z->avail_out == 0)
118 return buf_size - z->avail_out;
131 if (tag ==
MKBETAG(
'C',
'W',
'S', 0)) {
138 if (!swf->zbuf_in || !swf->zbuf_out || !swf->zpb)
140 swf->zpb->seekable = 0;
141 if (inflateInit(&swf->zstream) != Z_OK) {
150 }
else if (tag !=
MKBETAG(
'F',
'W',
'S', 0))
154 len = (4 * nbits - 3 + 7) / 8;
166 int sample_rate_code, sample_size_code;
181 sample_rate_code = info>>2 & 3;
182 sample_size_code = info>>1 & 1;
268 if (((v>>4) & 15) == 2) {
302 const int colormapbpp = 3 + alpha_bmp;
303 int linesize, colormapsize = 0;
306 const int bmp_fmt =
avio_r8(pb);
316 colormapsize =
avio_r8(pb) + 1;
320 linesize = width * 2;
323 linesize = width * 4;
327 goto bitmap_end_skip;
330 linesize =
FFALIGN(linesize, 4);
333 linesize >= INT_MAX / height ||
334 linesize * height >= INT_MAX - colormapsize * colormapbpp) {
336 goto bitmap_end_skip;
339 out_len = colormapsize * colormapbpp + linesize *
height;
341 av_dlog(s,
"bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
342 ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize);
352 if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) {
354 goto bitmap_end_skip;
375 if ((res =
av_new_packet(pkt, out_len - colormapsize * colormapbpp)) < 0)
377 if (!st->codec->width && !st->codec->height) {
379 st->codec->height =
height;
389 for (i = 0; i < colormapsize; i++)
390 if (alpha_bmp) colormap[i] = buf[3]<<24 |
AV_RB24(buf + 4*i);
391 else colormap[i] = 0xff
U <<24 |
AV_RB24(buf + 3*i);
408 if (st->codec->pix_fmt !=
AV_PIX_FMT_NONE && st->codec->pix_fmt != pix_fmt) {
415 if (linesize * height > pkt->
size) {
419 memcpy(pkt->
data, buf + colormapsize*colormapbpp, linesize * height);
493 if (res != pkt->
size) {
519 inflateEnd(&s->zstream);
const AVCodecTag ff_swf_codec_tags[]
static int swf_probe(AVProbeData *p)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
void av_free_packet(AVPacket *pkt)
Free a packet.
static int get_swf_tag(AVIOContext *pb, int *len_ptr)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t pos
byte position in stream, -1 if unknown
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
#define AV_CH_LAYOUT_STEREO
int ctx_flags
Flags signalling stream properties.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
8 bit with AV_PIX_FMT_RGB32 palette
unsigned int avio_rb32(AVIOContext *s)
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
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
AVStream ** streams
A list of all streams in the file.
#define AVERROR_EOF
End of file.
bitstream reader API header.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
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, 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.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVInputFormat ff_swf_demuxer
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
simple assert() macros that are a bit more flexible than ISO C assert().
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
uint64_t channel_layout
Audio channel layout.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
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.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
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...
audio channel layout utility functions
static const AVCodecTag swf_audio_codec_tags[]
int width
picture width / height.
static AVStream * create_new_audio_stream(AVFormatContext *s, int id, int info)
static int swf_read_header(AVFormatContext *s)
static int read_header(FFV1Context *f)
#define av_dlog(pctx,...)
av_dlog macros
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AV_LOG_INFO
Standard information.
enum AVMediaType codec_type
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_RB24
int sample_rate
samples per second
AVIOContext * pb
I/O context.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
BYTE int const BYTE int int int height
static void skip_bits(GetBitContext *s, int n)
This structure contains the data a format has to probe a file.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
unsigned int avio_rl16(AVIOContext *s)
#define AV_PIX_FMT_RGB555
#define MKBETAG(a, b, c, d)
int channels
number of audio channels
void * priv_data
Format private data.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
#define AV_CH_LAYOUT_MONO
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...