summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/frame.c4
-rw-r--r--libavutil/imgutils.c13
-rw-r--r--libavutil/internal.h9
-rw-r--r--libavutil/pixdesc.c10
-rw-r--r--libavutil/pixdesc.h8
-rw-r--r--libavutil/version.h5
6 files changed, 35 insertions, 14 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c
index ea13cd3ed6..00215ac29a 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -247,7 +247,7 @@ static int get_video_buffer(AVFrame *frame, int align)
frame->data[i] = frame->buf[i]->data;
}
- if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
+ if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & FF_PSEUDOPAL) {
av_buffer_unref(&frame->buf[1]);
frame->buf[1] = av_buffer_alloc(AVPALETTE_SIZE);
if (!frame->buf[1])
@@ -848,7 +848,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 | AV_PIX_FMT_FLAG_PSEUDOPAL) && i == 1) {
+ if (desc->flags & (AV_PIX_FMT_FLAG_PAL | FF_PSEUDOPAL) && i == 1) {
offsets[i] = 0;
break;
}
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 5af4fc20a0..4938a7ef67 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -125,7 +125,7 @@ int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei
size[0] = linesizes[0] * height;
if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
- desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
+ desc->flags & FF_PSEUDOPAL) {
data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */
return size[0] + 256 * 4;
}
@@ -216,7 +216,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 & AV_PIX_FMT_FLAG_PSEUDOPAL) {
+ if (desc->flags & AV_PIX_FMT_FLAG_PAL || (desc->flags & FF_PSEUDOPAL && pointers[1])) {
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");
@@ -225,7 +225,7 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
}
if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
- desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
+ desc->flags & FF_PSEUDOPAL) && pointers[1] &&
pointers[1] - pointers[0] > linesizes[0] * h) {
/* zero-initialize the padding before the palette */
memset(pointers[0] + linesizes[0] * h, 0,
@@ -354,12 +354,13 @@ static void image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
return;
if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
- desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
+ desc->flags & FF_PSEUDOPAL) {
copy_plane(dst_data[0], dst_linesizes[0],
src_data[0], src_linesizes[0],
width, height);
/* copy the palette */
- memcpy(dst_data[1], src_data[1], 4*256);
+ if ((desc->flags & AV_PIX_FMT_FLAG_PAL) || (dst_data[1] && src_data[1]))
+ memcpy(dst_data[1], src_data[1], 4*256);
} else {
int i, planes_nb = 0;
@@ -442,7 +443,7 @@ int av_image_get_buffer_size(enum AVPixelFormat pix_fmt,
return ret;
// do not include palette for these pseudo-paletted formats
- if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
+ if (desc->flags & FF_PSEUDOPAL)
return FFALIGN(width, align) * height;
return av_image_fill_arrays(data, linesize, NULL, pix_fmt,
diff --git a/libavutil/internal.h b/libavutil/internal.h
index c77dfa7d3c..06bd561e82 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -360,4 +360,13 @@ 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
+
#endif /* AVUTIL_INTERNAL_H */
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index e77d5f44b9..8ed52751c1 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -257,7 +257,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
.comp = {
{ 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */
},
- .flags = AV_PIX_FMT_FLAG_PSEUDOPAL,
+ .flags = FF_PSEUDOPAL,
.alias = "gray8,y8",
},
[AV_PIX_FMT_MONOWHITE] = {
@@ -362,7 +362,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 1, 0, 3, 3, 0, 2, 1 }, /* G */
{ 0, 1, 0, 6, 2, 0, 1, 1 }, /* B */
},
- .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
+ .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL,
},
[AV_PIX_FMT_BGR4] = {
.name = "bgr4",
@@ -386,7 +386,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 1, 0, 1, 2, 0, 1, 1 }, /* G */
{ 0, 1, 0, 3, 1, 0, 0, 1 }, /* B */
},
- .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
+ .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL,
},
[AV_PIX_FMT_RGB8] = {
.name = "rgb8",
@@ -398,7 +398,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 1, 0, 3, 3, 0, 2, 1 }, /* G */
{ 0, 1, 0, 0, 3, 0, 2, 1 }, /* B */
},
- .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
+ .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL,
},
[AV_PIX_FMT_RGB4] = {
.name = "rgb4",
@@ -422,7 +422,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 1, 0, 1, 2, 0, 1, 1 }, /* G */
{ 0, 1, 0, 0, 1, 0, 0, 1 }, /* B */
},
- .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
+ .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL,
},
[AV_PIX_FMT_NV12] = {
.name = "nv12",
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index ea046033a3..1ab372782a 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -154,6 +154,14 @@ typedef struct AVPixFmtDescriptor {
* 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)
diff --git a/libavutil/version.h b/libavutil/version.h
index d3dd2df544..d81d51011b 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR 12
+#define LIBAVUTIL_VERSION_MINOR 13
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -126,6 +126,9 @@
#ifndef FF_API_FRAME_GET_SET
#define FF_API_FRAME_GET_SET (LIBAVUTIL_VERSION_MAJOR < 57)
#endif
+#ifndef FF_API_PSEUDOPAL
+#define FF_API_PSEUDOPAL (LIBAVUTIL_VERSION_MAJOR < 57)
+#endif
/**