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>
This commit is contained in:
Andreas Rheinhardt
2021-03-17 22:43:32 +01:00
parent ab5803553b
commit 7b10083933
17 changed files with 53 additions and 122 deletions

View File

@@ -2091,3 +2091,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}
int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
{
buffer_size_t size;
const void *pal = av_packet_get_side_data(src, AV_PKT_DATA_PALETTE, &size);
if (pal && size == AVPALETTE_SIZE) {
memcpy(dst, pal, AVPALETTE_SIZE);
return 1;
} else if (pal) {
av_log(logctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
}
return 0;
}