ico: ignore IconEntry.bpp value, and favour BITMAPHEADER.NumColors value over that in IconEntry
Fixes ticket 905. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		
							parent
							
								
									bd3a12d68d
								
							
						
					
					
						commit
						90dbd08127
					
				@ -79,10 +79,7 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap)
 | 
			
		||||
        if (ico->images[i].nb_pal == 255)
 | 
			
		||||
            ico->images[i].nb_pal = 0;
 | 
			
		||||
 | 
			
		||||
        avio_skip(pb, 3);
 | 
			
		||||
        st->codec->bits_per_coded_sample = avio_rl16(pb);
 | 
			
		||||
        if (st->codec->bits_per_coded_sample <= 8 && !ico->images[i].nb_pal)
 | 
			
		||||
            ico->images[i].nb_pal = 1 << st->codec->bits_per_coded_sample;
 | 
			
		||||
        avio_skip(pb, 5);
 | 
			
		||||
 | 
			
		||||
        ico->images[i].size   = avio_rl32(pb);
 | 
			
		||||
        ico->images[i].offset = avio_rl32(pb);
 | 
			
		||||
@ -117,6 +114,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 | 
			
		||||
    IcoDemuxContext *ico = s->priv_data;
 | 
			
		||||
    IcoImage *image;
 | 
			
		||||
    AVIOContext *pb = s->pb;
 | 
			
		||||
    AVStream *st = s->streams[0];
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    if (ico->current_image >= ico->nb_images)
 | 
			
		||||
@ -142,15 +140,25 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 | 
			
		||||
        bytestream_put_le32(&buf, pkt->size);
 | 
			
		||||
        bytestream_put_le16(&buf, 0);
 | 
			
		||||
        bytestream_put_le16(&buf, 0);
 | 
			
		||||
        bytestream_put_le32(&buf, 14 + 40 + image->nb_pal * 4);
 | 
			
		||||
        bytestream_put_le32(&buf, 0);
 | 
			
		||||
 | 
			
		||||
        if ((ret = avio_read(pb, buf, image->size)) < 0)
 | 
			
		||||
            return ret;
 | 
			
		||||
 | 
			
		||||
        AV_WL32(buf + 8, AV_RL32(buf + 8) / 2);
 | 
			
		||||
        st->codec->bits_per_coded_sample = AV_RL16(buf + 14);
 | 
			
		||||
 | 
			
		||||
        if (AV_RL32(buf + 32))
 | 
			
		||||
            image->nb_pal = AV_RL32(buf + 32);
 | 
			
		||||
 | 
			
		||||
        if (st->codec->bits_per_coded_sample <= 8 && !image->nb_pal) {
 | 
			
		||||
            image->nb_pal = 1 << st->codec->bits_per_coded_sample;
 | 
			
		||||
            AV_WL32(buf + 32, image->nb_pal);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        AV_WL32(buf - 4, 14 + 40 + image->nb_pal * 4);
 | 
			
		||||
        AV_WL32(buf + 8, AV_RL32(buf + 8) / 2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pkt->stream_index = ico->current_image++;
 | 
			
		||||
    pkt->flags |= AV_PKT_FLAG_KEY;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user