From 985c0dac674846721ec8ff23344c16ac7d1c9a1e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 14 Apr 2021 01:46:26 +0200 Subject: [PATCH] avutil/pixdesc: Remove deprecated AV_PIX_FMT_FLAG_PSEUDOPAL Deprecated in d6fc031caf64eed921bbdef86d79d56bfc2633b0. Signed-off-by: Andreas Rheinhardt Signed-off-by: James Almer --- libavcodec/decode.c | 5 +---- libavcodec/ffv1dec.c | 3 +-- libavcodec/rawdec.c | 17 +++++------------ libavfilter/drawutils.c | 2 +- libavfilter/framepool.c | 6 ++---- libavfilter/vf_crop.c | 2 +- libavfilter/vf_pixdesctest.c | 3 +-- libavfilter/vf_scale.c | 3 +-- libavfilter/vf_untile.c | 2 +- libavutil/frame.c | 2 +- libavutil/imgutils.c | 15 ++++----------- libavutil/internal.h | 9 --------- libavutil/pixdesc.c | 9 ++++----- libavutil/pixdesc.h | 20 -------------------- libavutil/version.h | 3 --- tests/ref/fate/imgutils | 10 +++++----- 16 files changed, 28 insertions(+), 83 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 1a7c37043ee..9e5230ae1d3 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1425,8 +1425,7 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) pic->data[i] = NULL; pic->linesize[i] = 0; } - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - ((desc->flags & FF_PSEUDOPAL) && pic->data[1])) + if (desc->flags & AV_PIX_FMT_FLAG_PAL) avpriv_set_systematic_pal2((uint32_t *)pic->data[1], pic->format); if (s->debug & FF_DEBUG_BUFFERS) @@ -1589,8 +1588,6 @@ static void validate_avframe_allocation(AVCodecContext *avctx, AVFrame *frame) int flags = desc ? desc->flags : 0; if (num_planes == 1 && (flags & AV_PIX_FMT_FLAG_PAL)) num_planes = 2; - if ((flags & FF_PSEUDOPAL) && frame->data[1]) - num_planes = 2; for (i = 0; i < num_planes; i++) { av_assert0(frame->data[i]); } diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 8516fef5d74..14879779fa1 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -952,8 +952,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac (fs->slice_y >> sv) + ((fs->slice_x >> sh) << pixshift); } - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { dst[1] = p->data[1]; src[1] = f->last_picture.f->data[1]; } diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index d3756328bab..a13f88b148a 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -93,19 +93,13 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx) return AVERROR(EINVAL); } - if (desc->flags & (AV_PIX_FMT_FLAG_PAL | FF_PSEUDOPAL)) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { context->palette = av_buffer_alloc(AVPALETTE_SIZE); if (!context->palette) return AVERROR(ENOMEM); -#if FF_API_PSEUDOPAL - if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) - avpriv_set_systematic_pal2((uint32_t*)context->palette->data, avctx->pix_fmt); -#endif - else { - memset(context->palette->data, 0, AVPALETTE_SIZE); - if (avctx->bits_per_coded_sample == 1) - memset(context->palette->data, 0xff, 4); - } + memset(context->palette->data, 0, AVPALETTE_SIZE); + if (avctx->bits_per_coded_sample == 1) + memset(context->palette->data, 0xff, 4); } if ((avctx->extradata_size >= 9 && @@ -416,8 +410,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, frame->linesize[1] = FFALIGN(frame->linesize[1], linesize_align); } - if ((avctx->pix_fmt == AV_PIX_FMT_PAL8 && buf_size < context->frame_size) || - (desc->flags & FF_PSEUDOPAL)) { + if (avctx->pix_fmt == AV_PIX_FMT_PAL8 && buf_size < context->frame_size) { frame->buf[1] = av_buffer_ref(context->palette); if (!frame->buf[1]) { av_buffer_unref(&frame->buf[0]); diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c index 0a59ff99873..f95e12091b3 100644 --- a/libavfilter/drawutils.c +++ b/libavfilter/drawutils.c @@ -91,7 +91,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) if (!desc || !desc->name) return AVERROR(EINVAL); - if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL | AV_PIX_FMT_FLAG_ALPHA)) + if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA)) return AVERROR(ENOSYS); if (format == AV_PIX_FMT_P010LE || format == AV_PIX_FMT_P010BE || format == AV_PIX_FMT_P016LE || format == AV_PIX_FMT_P016BE) return AVERROR(ENOSYS); diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c index dab8891524b..5f67fa170a8 100644 --- a/libavfilter/framepool.c +++ b/libavfilter/framepool.c @@ -102,8 +102,7 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(buffer_size_t size), goto fail; } - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { pool->pools[1] = av_buffer_pool_init(AVPALETTE_SIZE, alloc); if (!pool->pools[1]) goto fail; @@ -226,8 +225,7 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) frame->data[i] = frame->buf[i]->data; } - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { enum AVPixelFormat format = pool->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : pool->format; diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index 3d5cb95f786..dffb6dab5e6 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -300,7 +300,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) frame->data[0] += s->y * frame->linesize[0]; frame->data[0] += s->x * s->max_step[0]; - if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & FF_PSEUDOPAL)) { + if (!(desc->flags & AV_PIX_FMT_FLAG_PAL)) { for (i = 1; i < 3; i ++) { if (frame->data[i]) { frame->data[i] += (s->y >> s->vsub) * frame->linesize[i]; diff --git a/libavfilter/vf_pixdesctest.c b/libavfilter/vf_pixdesctest.c index 680d1a772ab..066b8a02906 100644 --- a/libavfilter/vf_pixdesctest.c +++ b/libavfilter/vf_pixdesctest.c @@ -80,8 +80,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } /* copy palette */ - if (priv->pix_desc->flags & AV_PIX_FMT_FLAG_PAL || - ((priv->pix_desc->flags & FF_PSEUDOPAL) && out->data[1] && in->data[1])) + if (priv->pix_desc->flags & AV_PIX_FMT_FLAG_PAL) memcpy(out->data[1], in->data[1], AVPALETTE_SIZE); for (c = 0; c < priv->pix_desc->nb_components; c++) { diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 5ad9334d02c..3add31bace4 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -510,8 +510,7 @@ static int config_props(AVFilterLink *outlink) scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL; if (outfmt == AV_PIX_FMT_PAL8) outfmt = AV_PIX_FMT_BGR8; - scale->output_is_pal = av_pix_fmt_desc_get(outfmt)->flags & AV_PIX_FMT_FLAG_PAL || - av_pix_fmt_desc_get(outfmt)->flags & FF_PSEUDOPAL; + scale->output_is_pal = av_pix_fmt_desc_get(outfmt)->flags & AV_PIX_FMT_FLAG_PAL; if (scale->sws) sws_freeContext(scale->sws); diff --git a/libavfilter/vf_untile.c b/libavfilter/vf_untile.c index 9a2eb249010..154b92d08c4 100644 --- a/libavfilter/vf_untile.c +++ b/libavfilter/vf_untile.c @@ -136,7 +136,7 @@ static int activate(AVFilterContext *ctx) out->height = outlink->h; out->data[0] += y * out->linesize[0]; out->data[0] += x * s->max_step[0]; - if (!(s->desc->flags & AV_PIX_FMT_FLAG_PAL || s->desc->flags & FF_PSEUDOPAL)) { + if (!(s->desc->flags & AV_PIX_FMT_FLAG_PAL)) { for (i = 1; i < 3; i ++) { if (out->data[i]) { out->data[i] += (y >> s->desc->log2_chroma_w) * out->linesize[i]; diff --git a/libavutil/frame.c b/libavutil/frame.c index 7d5a36b2f1e..5bc8ab36df9 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -741,7 +741,7 @@ static int calc_cropping_offsets(size_t offsets[4], const AVFrame *frame, int shift_x = (i == 1 || i == 2) ? desc->log2_chroma_w : 0; int shift_y = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; - if (desc->flags & (AV_PIX_FMT_FLAG_PAL | FF_PSEUDOPAL) && i == 1) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL && i == 1) { offsets[i] = 0; break; } diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index bd1333170ac..53faad889a2 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -123,8 +123,7 @@ int av_image_fill_plane_sizes(size_t sizes[4], enum AVPixelFormat pix_fmt, return AVERROR(EINVAL); sizes[0] = linesizes[0] * (size_t)height; - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { sizes[1] = 256 * 4; /* palette is stored here as 256 32 bits words */ return 0; } @@ -250,7 +249,7 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4], av_free(buf); return ret; } - if (desc->flags & AV_PIX_FMT_FLAG_PAL || (desc->flags & FF_PSEUDOPAL && pointers[1])) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt); if (align < 4) { av_log(NULL, AV_LOG_ERROR, "Formats with a palette require a minimum alignment of 4\n"); @@ -259,8 +258,7 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4], } } - if ((desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) && pointers[1] && + if (desc->flags & AV_PIX_FMT_FLAG_PAL && pointers[1] && pointers[1] - pointers[0] > linesizes[0] * h) { /* zero-initialize the padding before the palette */ memset(pointers[0] + linesizes[0] * h, 0, @@ -388,8 +386,7 @@ static void image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4], if (!desc || desc->flags & AV_PIX_FMT_FLAG_HWACCEL) return; - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { copy_plane(dst_data[0], dst_linesizes[0], src_data[0], src_linesizes[0], width, height); @@ -478,10 +475,6 @@ int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, if (ret < 0) return ret; - // do not include palette for these pseudo-paletted formats - if (desc->flags & FF_PSEUDOPAL) - return FFALIGN(width, align) * height; - ret = av_image_fill_linesizes(linesize, pix_fmt, width); if (ret < 0) return ret; diff --git a/libavutil/internal.h b/libavutil/internal.h index 2ed1c2abb16..854e9cbed23 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -292,15 +292,6 @@ void ff_check_pixfmt_descriptors(void); */ int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp); -// Helper macro for AV_PIX_FMT_FLAG_PSEUDOPAL deprecation. Code inside FFmpeg -// should always use FF_PSEUDOPAL. Once the public API flag gets removed, all -// code using it is dead code. -#if FF_API_PSEUDOPAL -#define FF_PSEUDOPAL AV_PIX_FMT_FLAG_PSEUDOPAL -#else -#define FF_PSEUDOPAL 0 -#endif - // Temporary typedef to simplify porting all AVBufferRef users to size_t #if FF_API_BUFFER_SIZE_T typedef int buffer_size_t; diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index e701005bc08..751843e9915 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -341,7 +341,6 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .comp = { { 0, 1, 0, 0, 8 }, /* Y */ }, - .flags = FF_PSEUDOPAL, .alias = "gray8,y8", }, [AV_PIX_FMT_MONOWHITE] = { @@ -446,7 +445,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { { 0, 1, 0, 3, 3 }, /* G */ { 0, 1, 0, 6, 2 }, /* B */ }, - .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL, + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BGR4] = { .name = "bgr4", @@ -470,7 +469,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { { 0, 1, 0, 1, 2 }, /* G */ { 0, 1, 0, 3, 1 }, /* B */ }, - .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL, + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_RGB8] = { .name = "rgb8", @@ -482,7 +481,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { { 0, 1, 0, 3, 3 }, /* G */ { 0, 1, 0, 0, 3 }, /* B */ }, - .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL, + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_RGB4] = { .name = "rgb4", @@ -506,7 +505,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { { 0, 1, 0, 1, 2 }, /* G */ { 0, 1, 0, 0, 1 }, /* B */ }, - .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL, + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_NV12] = { .name = "nv12", diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h index 81b51b767f8..9e7cfad9837 100644 --- a/libavutil/pixdesc.h +++ b/libavutil/pixdesc.h @@ -136,26 +136,6 @@ typedef struct AVPixFmtDescriptor { */ #define AV_PIX_FMT_FLAG_RGB (1 << 5) -#if FF_API_PSEUDOPAL -/** - * The pixel format is "pseudo-paletted". This means that it contains a - * fixed palette in the 2nd plane but the palette is fixed/constant for each - * PIX_FMT. This allows interpreting the data as if it was PAL8, which can - * in some cases be simpler. Or the data can be interpreted purely based on - * the pixel format without using the palette. - * An example of a pseudo-paletted format is AV_PIX_FMT_GRAY8 - * - * @deprecated This flag is deprecated, and will be removed. When it is removed, - * the extra palette allocation in AVFrame.data[1] is removed as well. Only - * actual paletted formats (as indicated by AV_PIX_FMT_FLAG_PAL) will have a - * palette. Starting with FFmpeg versions which have this flag deprecated, the - * extra "pseudo" palette is already ignored, and API users are not required to - * allocate a palette for AV_PIX_FMT_FLAG_PSEUDOPAL formats (it was required - * before the deprecation, though). - */ -#define AV_PIX_FMT_FLAG_PSEUDOPAL (1 << 6) -#endif - /** * The pixel format has an alpha channel. This is set on all formats that * support alpha in some way, including AV_PIX_FMT_PAL8. The alpha is always diff --git a/libavutil/version.h b/libavutil/version.h index 47cec351f0f..b78ff1acec0 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -105,9 +105,6 @@ * @{ */ -#ifndef FF_API_PSEUDOPAL -#define FF_API_PSEUDOPAL (LIBAVUTIL_VERSION_MAJOR < 57) -#endif #ifndef FF_API_CHILD_CLASS_NEXT #define FF_API_CHILD_CLASS_NEXT (LIBAVUTIL_VERSION_MAJOR < 57) #endif diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index c968ea0e853..f510150ea16 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -62,7 +62,7 @@ yuv422p planes: 3, linesizes: 64 32 32 0, plane_sizes: 3072 1536 yuv444p planes: 3, linesizes: 64 64 64 0, plane_sizes: 3072 3072 3072 0, plane_offsets: 3072 3072 0, total_size: 9216 yuv410p planes: 3, linesizes: 64 16 16 0, plane_sizes: 3072 192 192 0, plane_offsets: 3072 192 0, total_size: 3456 yuv411p planes: 3, linesizes: 64 16 16 0, plane_sizes: 3072 768 768 0, plane_offsets: 3072 768 0, total_size: 4608 -gray planes: 2, linesizes: 64 0 0 0, plane_sizes: 3072 1024 0 0, plane_offsets: 3072 0 0, total_size: 4096 +gray planes: 1, linesizes: 64 0 0 0, plane_sizes: 3072 0 0 0, plane_offsets: 0 0 0, total_size: 3072 monow planes: 1, linesizes: 8 0 0 0, plane_sizes: 384 0 0 0, plane_offsets: 0 0 0, total_size: 384 monob planes: 1, linesizes: 8 0 0 0, plane_sizes: 384 0 0 0, plane_offsets: 0 0 0, total_size: 384 pal8 planes: 2, linesizes: 64 0 0 0, plane_sizes: 3072 1024 0 0, plane_offsets: 3072 0 0, total_size: 4096 @@ -71,12 +71,12 @@ yuvj422p planes: 3, linesizes: 64 32 32 0, plane_sizes: 3072 1536 yuvj444p planes: 3, linesizes: 64 64 64 0, plane_sizes: 3072 3072 3072 0, plane_offsets: 3072 3072 0, total_size: 9216 uyvy422 planes: 1, linesizes: 128 0 0 0, plane_sizes: 6144 0 0 0, plane_offsets: 0 0 0, total_size: 6144 uyyvyy411 planes: 1, linesizes: 96 0 0 0, plane_sizes: 4608 0 0 0, plane_offsets: 0 0 0, total_size: 4608 -bgr8 planes: 2, linesizes: 64 0 0 0, plane_sizes: 3072 1024 0 0, plane_offsets: 3072 0 0, total_size: 4096 +bgr8 planes: 1, linesizes: 64 0 0 0, plane_sizes: 3072 0 0 0, plane_offsets: 0 0 0, total_size: 3072 bgr4 planes: 1, linesizes: 32 0 0 0, plane_sizes: 1536 0 0 0, plane_offsets: 0 0 0, total_size: 1536 -bgr4_byte planes: 2, linesizes: 64 0 0 0, plane_sizes: 3072 1024 0 0, plane_offsets: 3072 0 0, total_size: 4096 -rgb8 planes: 2, linesizes: 64 0 0 0, plane_sizes: 3072 1024 0 0, plane_offsets: 3072 0 0, total_size: 4096 +bgr4_byte planes: 1, linesizes: 64 0 0 0, plane_sizes: 3072 0 0 0, plane_offsets: 0 0 0, total_size: 3072 +rgb8 planes: 1, linesizes: 64 0 0 0, plane_sizes: 3072 0 0 0, plane_offsets: 0 0 0, total_size: 3072 rgb4 planes: 1, linesizes: 32 0 0 0, plane_sizes: 1536 0 0 0, plane_offsets: 0 0 0, total_size: 1536 -rgb4_byte planes: 2, linesizes: 64 0 0 0, plane_sizes: 3072 1024 0 0, plane_offsets: 3072 0 0, total_size: 4096 +rgb4_byte planes: 1, linesizes: 64 0 0 0, plane_sizes: 3072 0 0 0, plane_offsets: 0 0 0, total_size: 3072 nv12 planes: 2, linesizes: 64 64 0 0, plane_sizes: 3072 1536 0 0, plane_offsets: 3072 0 0, total_size: 4608 nv21 planes: 2, linesizes: 64 64 0 0, plane_sizes: 3072 1536 0 0, plane_offsets: 3072 0 0, total_size: 4608 argb planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 -- 2.39.2