Revision 22da339f

View differences:

libavcodec/bmp.c
231 231
    }
232 232

  
233 233
    if(avctx->pix_fmt == PIX_FMT_PAL8){
234
        int colors = 1 << depth;
235
        if(ihsize >= 36){
236
            int t;
237
            buf = buf0 + 46;
238
            t = bytestream_get_le32(&buf);
239
            if(t < 0 || t > (1 << depth)){
240
                av_log(avctx, AV_LOG_ERROR, "Incorrect number of colors - %X for bitdepth %d\n", t, depth);
241
            }else if(t){
242
                colors = t;
243
            }
244
        }
234 245
        buf = buf0 + 14 + ihsize; //palette location
235
        if((hsize-ihsize-14)>>depth < 4){ // OS/2 bitmap, 3 bytes per palette entry
236
            for(i = 0; i < (1 << depth); i++)
246
        if((hsize-ihsize-14) < (colors << 2)){ // OS/2 bitmap, 3 bytes per palette entry
247
            for(i = 0; i < colors; i++)
237 248
                ((uint32_t*)p->data[1])[i] = bytestream_get_le24(&buf);
238 249
        }else{
239
            for(i = 0; i < (1 << depth); i++)
250
            for(i = 0; i < colors; i++)
240 251
                ((uint32_t*)p->data[1])[i] = bytestream_get_le32(&buf);
241 252
        }
242 253
        buf = buf0 + hsize;

Also available in: Unified diff