summaryrefslogtreecommitdiff
path: root/libavcodec/rscc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-03-17 22:43:32 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-03-22 02:43:04 +0100
commit7b100839330ace3b4846ee4a1fc5caf4b8f8a34e (patch)
tree5743c922bd05a372bfbe733cf7ee482153d8e55d /libavcodec/rscc.c
parentab5803553b3932da3227647ae27f2e2795cc5752 (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/rscc.c')
-rw-r--r--libavcodec/rscc.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
index 79b02da441..7b27127bf5 100644
--- a/libavcodec/rscc.c
+++ b/libavcodec/rscc.c
@@ -43,6 +43,7 @@
#include "avcodec.h"
#include "bytestream.h"
+#include "decode.h"
#include "internal.h"
#define TILE_SIZE 8
@@ -346,17 +347,8 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
/* Palette handling */
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
- buffer_size_t size;
- const uint8_t *palette = av_packet_get_side_data(avpkt,
- AV_PKT_DATA_PALETTE,
- &size);
- if (palette && size == AVPALETTE_SIZE) {
- frame->palette_has_changed = 1;
- memcpy(ctx->palette, palette, AVPALETTE_SIZE);
- } else if (palette) {
- av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
- }
- memcpy (frame->data[1], ctx->palette, AVPALETTE_SIZE);
+ frame->palette_has_changed = ff_copy_palette(ctx->palette, avpkt, avctx);
+ memcpy(frame->data[1], ctx->palette, AVPALETTE_SIZE);
}
// We only return a picture when enough of it is undamaged, this avoids copying nearly broken frames around
if (ctx->valid_pixels < ctx->inflated_size)