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)) {
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;
187 int sample_rate_code;
203 ast->codec->channels = 2;
206 ast->codec->channels = 1;
210 ast->codec->codec_id =
ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
212 sample_rate_code= (v>>2) & 3;
213 ast->codec->sample_rate = 44100 >> (3 - sample_rate_code);
218 int sample_rate_code;
236 ast->codec->channels = 1 + (v&1);
238 ast->codec->codec_id =
ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15);
240 sample_rate_code= (v>>2) & 3;
241 ast->codec->sample_rate = 44100 >> (3 - sample_rate_code);
244 if (((v>>4) & 15) == 2) {
278 const int colormapbpp = 3 + alpha_bmp;
279 int linesize, colormapsize = 0;
282 const int bmp_fmt =
avio_r8(pb);
291 colormapsize =
avio_r8(pb) + 1;
295 linesize = width * 2;
298 linesize = width * 4;
302 goto bitmap_end_skip;
305 linesize =
FFALIGN(linesize, 4);
308 linesize >= INT_MAX / height ||
309 linesize * height >= INT_MAX - colormapsize * colormapbpp) {
311 goto bitmap_end_skip;
314 out_len = colormapsize * colormapbpp + linesize *
height;
316 av_dlog(s,
"bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n",
317 ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize);
327 if (len < 0 || (res = uncompress(buf, &out_len, zbuf, len)) != Z_OK) {
329 goto bitmap_end_skip;
350 st->codec->height =
height;
352 if ((res =
av_new_packet(pkt, out_len - colormapsize * colormapbpp)) < 0)
360 for (i = 0; i < colormapsize; i++)
361 if (alpha_bmp) colormap[i] = buf[3]<<24 |
AV_RB24(buf + 4*i);
362 else colormap[i] = 0xff
U <<24 |
AV_RB24(buf + 3*i);
380 if (linesize * height > pkt->
size) {
384 memcpy(pkt->
data, buf + colormapsize*colormapbpp, linesize * height);
470 inflateEnd(&s->zstream);