73 static int zlib_refill(
void *opaque,
uint8_t *
buf,
int buf_size)
77 z_stream *z = &swf->zstream;
85 z->next_in = swf->zbuf_in;
90 z->avail_out = buf_size;
92 ret = inflate(z, Z_NO_FLUSH);
95 if (ret == Z_STREAM_END)
98 if (buf_size - z->avail_out == 0)
101 return buf_size - z->avail_out;
114 if (tag ==
MKBETAG(
'C',
'W',
'S', 0)) {
120 zlib_refill, NULL, NULL);
121 if (!swf->zbuf_in || !swf->zbuf_out || !swf->zpb)
123 swf->zpb->seekable = 0;
124 if (inflateInit(&swf->zstream) != Z_OK) {
133 }
else if (tag !=
MKBETAG(
'F',
'W',
'S', 0))
137 len = (4 * nbits - 3 + 7) / 8;
149 int sample_rate_code, sample_size_code;
164 sample_rate_code = info>>2 & 3;
165 sample_size_code = info>>1 & 1;
177 AVStream *vst = NULL, *ast = NULL, *st = 0;
251 if (((v>>4) & 15) == 2) {
282 uint8_t *buf = NULL, *zbuf = NULL, *pal;
285 const int colormapbpp = 3 + alpha_bmp;
286 int linesize, colormapsize = 0;
289 const int bmp_fmt =
avio_r8(pb);
299 colormapsize =
avio_r8(pb) + 1;
303 linesize = width * 2;
306 linesize = width * 4;
310 goto bitmap_end_skip;
313 linesize =
FFALIGN(linesize, 4);
316 linesize >= INT_MAX / height ||
317 linesize * height >= INT_MAX - colormapsize * colormapbpp) {
319 goto bitmap_end_skip;
322 out_len = colormapsize * colormapbpp + linesize *
height;
324 av_dlog(s,
"bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
325 ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize);
335 if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) {
337 goto bitmap_end_skip;
358 if ((res =
av_new_packet(pkt, out_len - colormapsize * colormapbpp)) < 0)
360 if (!st->codec->width && !st->codec->height) {
362 st->codec->height =
height;
372 for (i = 0; i < colormapsize; i++)
373 if (alpha_bmp) colormap[i] = buf[3]<<24 |
AV_RB24(buf + 4*i);
374 else colormap[i] = 0xff
U <<24 |
AV_RB24(buf + 3*i);
391 if (st->codec->pix_fmt !=
AV_PIX_FMT_NONE && st->codec->pix_fmt != pix_fmt) {
398 if (linesize * height > pkt->
size) {
402 memcpy(pkt->
data, buf + colormapsize*colormapbpp, linesize * height);
476 if (res != pkt->
size) {
502 inflateEnd(&s->zstream);