- avpriv_set_systematic_pal2(context->palette, avctx->pix_fmt);
- if ((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
- avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
- (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))) {
- context->length = avpicture_get_size(avctx->pix_fmt,
- FFALIGN(avctx->width, 16),
- avctx->height);
- if (context->length < 0)
- return context->length;
- context->buffer = av_malloc(context->length);
- if (!context->buffer)
+ if (desc->flags & (PIX_FMT_PAL | PIX_FMT_PSEUDOPAL)) {
+ context->palette = av_buffer_alloc(AVPALETTE_SIZE);
+ if (!context->palette)