[FFmpeg-devel] [PATCH 3/5] avcodec: Factor updating palette out
James Almer
jamrial at gmail.com
Thu Mar 18 03:28:13 EET 2021
On 3/17/2021 8:59 PM, Andreas Rheinhardt wrote:
> 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.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> libavcodec/8bps.c | 11 +----------
> libavcodec/cinepak.c | 9 +--------
> libavcodec/decode.c | 14 ++++++++++++++
> libavcodec/gdv.c | 5 +----
> libavcodec/idcinvideo.c | 9 +--------
> libavcodec/imx.c | 5 +----
> libavcodec/internal.h | 9 +++++++++
> libavcodec/interplayvideo.c | 9 +--------
> libavcodec/kmvc.c | 8 +-------
> libavcodec/msrle.c | 11 ++---------
> libavcodec/msvideo1.c | 10 +---------
> libavcodec/qpeg.c | 9 +--------
> libavcodec/qtrle.c | 10 +---------
> libavcodec/rawdec.c | 13 ++-----------
> libavcodec/rscc.c | 13 ++-----------
> libavcodec/smc.c | 9 +--------
> libavcodec/tscc.c | 10 +---------
> 17 files changed, 41 insertions(+), 123 deletions(-)
>
[...]
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 5a00aeedae..efa8a9ac8d 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -2051,3 +2051,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
>
> return 0;
> }
> +
> +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
All the arguments for dst are uint8_t*.
> +{
> + buffer_size_t size;
> + const void *pal = av_packet_get_side_data(src, AV_PKT_DATA_PALETTE, &size);
Same, av_packet_get_side_data() returns an uint8_t*.
> +
> + 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;
> +}
[...]
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index b57b996816..0fb3107979 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -393,6 +393,15 @@ int ff_int_from_list_or_default(void *ctx, const char * val_name, int val,
>
> void ff_dvdsub_parse_palette(uint32_t *palette, const char *p);
>
> +/**
> + * Check whether the side-data of src contains a palette of
> + * size AVPALETTE_SIZE; if so, copy it to dst and return 1;
> + * else return 0.
> + * Also emit an error message upon encountering a palette
> + * with invalid size.
> + */
> +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx);
Should be in libavcodec/decode.h instead.
Or maybe avpacket.c and packet_internal.h, for that matter.
> +
> #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec)
> # define av_export_avcodec __declspec(dllimport)
> #else
More information about the ffmpeg-devel
mailing list