diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-03-17 22:43:32 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-03-22 02:43:04 +0100 |
commit | 7b100839330ace3b4846ee4a1fc5caf4b8f8a34e (patch) | |
tree | 5743c922bd05a372bfbe733cf7ee482153d8e55d /libavcodec/rawdec.c | |
parent | ab5803553b3932da3227647ae27f2e2795cc5752 (diff) |
avcodec: Factor updating palette out
Because the properties of frames returned from ff_get/reget_buffer
are not reset at all, lots of returned frames had palette_has_changed
wrongly set to 1. This has been changed, too.
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/rawdec.c')
-rw-r--r-- | libavcodec/rawdec.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index c18c3dd3e1..1badb69180 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -367,16 +367,8 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, } if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { - buffer_size_t pal_size; - const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, - &pal_size); int ret; - if (pal && pal_size != AVPALETTE_SIZE) { - av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size); - pal = NULL; - } - if (!context->palette) context->palette = av_buffer_alloc(AVPALETTE_SIZE); if (!context->palette) { @@ -389,15 +381,14 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, return ret; } - if (pal) { - memcpy(context->palette->data, pal, AVPALETTE_SIZE); + if (ff_copy_palette(context->palette->data, avpkt, avctx)) { frame->palette_has_changed = 1; } else if (context->is_nut_pal8) { int vid_size = avctx->width * avctx->height; int pal_size = avpkt->size - vid_size; if (avpkt->size > vid_size && pal_size <= AVPALETTE_SIZE) { - pal = avpkt->data + vid_size; + const uint8_t *pal = avpkt->data + vid_size; memcpy(context->palette->data, pal, pal_size); frame->palette_has_changed = 1; } |