23 #include "libavutil/avassert.h"
24 #include "libavutil/channel_layout.h"
25 #include "libavutil/imgutils.h"
26 #include "libavutil/intreadwrite.h"
59 if ((p->
buf[0] ==
'F' || p->
buf[0] ==
'C') && p->
buf[1] ==
'W' &&
67 static int zlib_refill(
void *opaque,
uint8_t *
buf,
int buf_size)
71 z_stream *z = &swf->zstream;
79 z->next_in = swf->zbuf_in;
84 z->avail_out = buf_size;
86 ret = inflate(z, Z_NO_FLUSH);
89 if (ret == Z_STREAM_END)
92 if (buf_size - z->avail_out == 0)
95 return buf_size - z->avail_out;
108 if (tag ==
MKBETAG(
'C',
'W',
'S', 0)) {
114 zlib_refill, NULL, NULL);
115 if (!swf->zbuf_in || !swf->zbuf_out || !swf->zpb)
117 swf->zpb->seekable = 0;
118 if (inflateInit(&swf->zstream) != Z_OK) {
127 }
else if (tag !=
MKBETAG(
'F',
'W',
'S', 0))
131 len = (4 * nbits - 3 + 7) / 8;
143 int sample_rate_code, sample_size_code;
158 sample_rate_code = info>>2 & 3;
159 sample_size_code = info>>1 & 1;
171 AVStream *vst = NULL, *ast = NULL, *st = 0;
245 if (((v>>4) & 15) == 2) {
276 uint8_t *buf = NULL, *zbuf = NULL, *pal;
279 const int colormapbpp = 3 + alpha_bmp;
280 int linesize, colormapsize = 0;
283 const int bmp_fmt =
avio_r8(pb);
292 colormapsize =
avio_r8(pb) + 1;
296 linesize = width * 2;
299 linesize = width * 4;
303 goto bitmap_end_skip;
306 linesize =
FFALIGN(linesize, 4);
309 linesize >= INT_MAX / height ||
310 linesize * height >= INT_MAX - colormapsize * colormapbpp) {
312 goto bitmap_end_skip;
315 out_len = colormapsize * colormapbpp + linesize *
height;
317 av_dlog(s,
"bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
318 ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize);
328 if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) {
330 goto bitmap_end_skip;
351 st->codec->height =
height;
353 if ((res =
av_new_packet(pkt, out_len - colormapsize * colormapbpp)) < 0)
361 for (i = 0; i < colormapsize; i++)
362 if (alpha_bmp) colormap[i] = buf[3]<<24 |
AV_RB24(buf + 4*i);
363 else colormap[i] = 0xff
U <<24 |
AV_RB24(buf + 3*i);
381 if (linesize * height > pkt->
size) {
385 memcpy(pkt->
data, buf + colormapsize*colormapbpp, linesize * height);
471 inflateEnd(&s->zstream);
const AVCodecTag ff_swf_codec_tags[]
static int swf_probe(AVProbeData *p)
static int get_swf_tag(AVIOContext *pb, int *len_ptr)
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t pos
byte position in stream, -1 if unknown
AVCodecContext * codec
Codec context associated with this stream.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
#define AV_CH_LAYOUT_STEREO
int ctx_flags
Format-specific flags, see AVFMTCTX_xx.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define AV_PIX_FMT_RGB555
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
static av_cold int read_close(AVFormatContext *ctx)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVInputFormat ff_swf_demuxer
void * priv_data
Format private data.
#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
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
uint64_t channel_layout
Audio channel layout.
unsigned int nb_streams
A list of all streams in the file.
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...
static const AVCodecTag swf_audio_codec_tags[]
int width
picture width / height.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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_LOG_INFO
Standard information.
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
BYTE int const BYTE int int int height
This structure contains the data a format has to probe a file.
#define MKBETAG(a, b, c, d)
static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
#define AVERROR_INVALIDDATA
int channels
number of audio channels
#define av_assert0(cond)
assert() equivalent, that is always enabled.
8 bit with PIX_FMT_RGB32 palette
packed RGB 8:8:8, 32bpp, 0RGB0RGB...
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...