Revision 23f40a07 libavformat/avidec.c

View differences:

libavformat/avidec.c
590 590
                    /* This code assumes that extradata contains only palette. */
591 591
                    /* This is true for all paletted codecs implemented in Libav. */
592 592
                    if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
593
                        int pal_size = (1 << st->codec->bits_per_coded_sample) << 2;
594
                        const uint8_t *pal_src;
595

  
596
                        pal_size = FFMIN(pal_size, st->codec->extradata_size);
597
                        pal_src = st->codec->extradata + st->codec->extradata_size - pal_size;
593 598
#if HAVE_BIGENDIAN
594
                        for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
595
                            ast->pal[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]);
599
                        for (i = 0; i < pal_size/4; i++)
600
                            ast->pal[i] = av_bswap32(((uint32_t*)pal_src)[i]);
596 601
#else
597
                        memcpy(ast->pal, st->codec->extradata,
598
                               FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
602
                        memcpy(ast->pal, pal_src, pal_size);
599 603
#endif
600 604
                        ast->has_pal = 1;
601 605
                    }

Also available in: Unified diff