|
|
@ -289,6 +289,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
const int bmp_fmt = avio_r8(pb); |
|
|
|
const int bmp_fmt = avio_r8(pb); |
|
|
|
const int width = avio_rl16(pb); |
|
|
|
const int width = avio_rl16(pb); |
|
|
|
const int height = avio_rl16(pb); |
|
|
|
const int height = avio_rl16(pb); |
|
|
|
|
|
|
|
int pix_fmt; |
|
|
|
|
|
|
|
|
|
|
|
len -= 2+1+2+2; |
|
|
|
len -= 2+1+2+2; |
|
|
|
|
|
|
|
|
|
|
@ -367,7 +368,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
|
|
|
|
|
|
|
|
switch (bmp_fmt) { |
|
|
|
switch (bmp_fmt) { |
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
st->codec->pix_fmt = AV_PIX_FMT_PAL8; |
|
|
|
pix_fmt = AV_PIX_FMT_PAL8; |
|
|
|
for (i = 0; i < colormapsize; i++) |
|
|
|
for (i = 0; i < colormapsize; i++) |
|
|
|
if (alpha_bmp) colormap[i] = buf[3]<<24 | AV_RB24(buf + 4*i); |
|
|
|
if (alpha_bmp) colormap[i] = buf[3]<<24 | AV_RB24(buf + 4*i); |
|
|
|
else colormap[i] = 0xffU <<24 | AV_RB24(buf + 3*i); |
|
|
|
else colormap[i] = 0xffU <<24 | AV_RB24(buf + 3*i); |
|
|
@ -379,14 +380,20 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
memcpy(pal, colormap, AVPALETTE_SIZE); |
|
|
|
memcpy(pal, colormap, AVPALETTE_SIZE); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
case 4: |
|
|
|
st->codec->pix_fmt = AV_PIX_FMT_RGB555; |
|
|
|
pix_fmt = AV_PIX_FMT_RGB555; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
case 5: |
|
|
|
st->codec->pix_fmt = alpha_bmp ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB; |
|
|
|
pix_fmt = alpha_bmp ? AV_PIX_FMT_ARGB : AV_PIX_FMT_0RGB; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
av_assert0(0); |
|
|
|
av_assert0(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (st->codec->pix_fmt != AV_PIX_FMT_NONE && st->codec->pix_fmt != pix_fmt) { |
|
|
|
|
|
|
|
av_log(s, AV_LOG_ERROR, "pixel format change unsupported\n"); |
|
|
|
|
|
|
|
res = AVERROR_PATCHWELCOME; |
|
|
|
|
|
|
|
goto bitmap_end; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
st->codec->pix_fmt = pix_fmt; |
|
|
|
|
|
|
|
|
|
|
|
if (linesize * height > pkt->size) { |
|
|
|
if (linesize * height > pkt->size) { |
|
|
|
res = AVERROR_INVALIDDATA; |
|
|
|
res = AVERROR_INVALIDDATA; |
|
|
|