Browse code

avutil/pixdesc: deprecate AV_PIX_FMT_FLAG_PSEUDOPAL

PSEUDOPAL pixel formats are not paletted, but carried a palette with the
intention of allowing code to treat unpaletted formats as paletted. The
palette simply mapped the byte values to the resulting RGB values,
making it some sort of LUT for RGB conversion.

It was used for 1 byte formats only: RGB4_BYTE, BGR4_BYTE, RGB8, BGR8,
GRAY8. The first 4 are awfully obscure, used only by some ancient bitmap
formats. The last one, GRAY8, is more common, but its treatment is
grossly incorrect. It considers full range GRAY8 only, so GRAY8 coming
from typical Y video planes was not mapped to the correct RGB values.
This cannot be fixed, because AVFrame.color_range can be freely changed
at runtime, and there is nothing to ensure the pseudo palette is
updated.

Also, nothing actually used the PSEUDOPAL palette data, except xwdenc
(trivially changed in the previous commit). All other code had to treat
it as a special case, just to ignore or to propagate palette data.

In conclusion, this was just a very strange old mechnaism that has no
real justification to exist anymore (although it may have been nice and
useful in the past). Now it's an artifact that makes the API harder to
use: API users who allocate their own pixel data have to be aware that
they need to allocate the palette, or FFmpeg will crash on them in
_some_ situations. On top of this, there was no API to allocate the
pseuo palette outside of av_frame_get_buffer().

This patch not only deprecates AV_PIX_FMT_FLAG_PSEUDOPAL, but also makes
the pseudo palette optional. Nothing accesses it anymore, though if it's
set, it's propagated. It's still allocated and initialized for
compatibility with API users that rely on this feature. But new API
users do not need to allocate it. This was an explicit goal of this
patch.

Most changes replace AV_PIX_FMT_FLAG_PSEUDOPAL with FF_PSEUDOPAL. I
first tried #ifdefing all code, but it was a mess. The FF_PSEUDOPAL
macro reduces the mess, and still allows defining FF_API_PSEUDOPAL to 0.

Passes FATE with FF_API_PSEUDOPAL enabled and disabled. In addition,
FATE passes with FF_API_PSEUDOPAL set to 1, but with allocation
functions manually changed to not allocating a palette.

wm4 authored on 2018/03/29 22:18:28
Showing 19 changed files
... ...
@@ -15,6 +15,10 @@ libavutil:     2017-10-21
15 15
 
16 16
 API changes, most recent first:
17 17
 
18
+2018-04-03 - xxxxxxx - lavu 56.13.100 - pixdesc.h
19
+  Deprecate AV_PIX_FMT_FLAG_PSEUDOPAL and make allocating a pseudo palette
20
+  optional for API users (see AV_PIX_FMT_FLAG_PSEUDOPAL doxygen for details).
21
+
18 22
 2018-04-01 - xxxxxxx - lavc 58.17.100 - avcodec.h
19 23
   Add av_packet_make_refcounted().
20 24
 
... ...
@@ -3118,7 +3118,9 @@ static void ffprobe_show_pixel_formats(WriterContext *w)
3118 3118
             PRINT_PIX_FMT_FLAG(HWACCEL,   "hwaccel");
3119 3119
             PRINT_PIX_FMT_FLAG(PLANAR,    "planar");
3120 3120
             PRINT_PIX_FMT_FLAG(RGB,       "rgb");
3121
+#if FF_API_PSEUDOPAL
3121 3122
             PRINT_PIX_FMT_FLAG(PSEUDOPAL, "pseudopal");
3123
+#endif
3122 3124
             PRINT_PIX_FMT_FLAG(ALPHA,     "alpha");
3123 3125
             writer_print_section_footer(w);
3124 3126
         }
... ...
@@ -1614,7 +1614,7 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
1614 1614
         pic->linesize[i] = 0;
1615 1615
     }
1616 1616
     if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
1617
-        desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
1617
+        ((desc->flags & FF_PSEUDOPAL) && pic->data[1]))
1618 1618
         avpriv_set_systematic_pal2((uint32_t *)pic->data[1], pic->format);
1619 1619
 
1620 1620
     if (s->debug & FF_DEBUG_BUFFERS)
... ...
@@ -1782,9 +1782,6 @@ static void validate_avframe_allocation(AVCodecContext *avctx, AVFrame *frame)
1782 1782
         for (i = 0; i < num_planes; i++) {
1783 1783
             av_assert0(frame->data[i]);
1784 1784
         }
1785
-        // For now do not enforce anything for palette of pseudopal formats
1786
-        if (num_planes == 1 && (flags & AV_PIX_FMT_FLAG_PSEUDOPAL))
1787
-            num_planes = 2;
1788 1785
         // For formats without data like hwaccel allow unused pointers to be non-NULL.
1789 1786
         for (i = num_planes; num_planes > 0 && i < FF_ARRAY_ELEMS(frame->data); i++) {
1790 1787
             if (frame->data[i])
... ...
@@ -950,7 +950,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
950 950
 
951 951
             }
952 952
             if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
953
-                desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
953
+                desc->flags & FF_PSEUDOPAL) {
954 954
                 dst[1] = p->data[1];
955 955
                 src[1] = f->last_picture.f->data[1];
956 956
             }
... ...
@@ -92,12 +92,14 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
92 92
         return AVERROR(EINVAL);
93 93
     }
94 94
 
95
-    if (desc->flags & (AV_PIX_FMT_FLAG_PAL | AV_PIX_FMT_FLAG_PSEUDOPAL)) {
95
+    if (desc->flags & (AV_PIX_FMT_FLAG_PAL | FF_PSEUDOPAL)) {
96 96
         context->palette = av_buffer_alloc(AVPALETTE_SIZE);
97 97
         if (!context->palette)
98 98
             return AVERROR(ENOMEM);
99
+#if FF_API_PSEUDOPAL
99 100
         if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
100 101
             avpriv_set_systematic_pal2((uint32_t*)context->palette->data, avctx->pix_fmt);
102
+#endif
101 103
         else {
102 104
             memset(context->palette->data, 0, AVPALETTE_SIZE);
103 105
             if (avctx->bits_per_coded_sample == 1)
... ...
@@ -423,7 +425,7 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
423 423
     }
424 424
 
425 425
     if ((avctx->pix_fmt == AV_PIX_FMT_PAL8 && buf_size < context->frame_size) ||
426
-        (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)) {
426
+        (desc->flags & FF_PSEUDOPAL)) {
427 427
         frame->buf[1]  = av_buffer_ref(context->palette);
428 428
         if (!frame->buf[1]) {
429 429
             av_buffer_unref(&frame->buf[0]);
... ...
@@ -71,7 +71,7 @@ static inline void smv_img_pnt(uint8_t *dst_data[4], uint8_t *src_data[4],
71 71
             src_linesizes[i], h, nlines);
72 72
     }
73 73
     if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
74
-        desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
74
+        desc->flags & FF_PSEUDOPAL)
75 75
         dst_data[1] = src_data[1];
76 76
 }
77 77
 
... ...
@@ -184,7 +184,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
184 184
 
185 185
     if (!desc || !desc->name)
186 186
         return AVERROR(EINVAL);
187
-    if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL | AV_PIX_FMT_FLAG_ALPHA))
187
+    if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL | AV_PIX_FMT_FLAG_ALPHA))
188 188
         return AVERROR(ENOSYS);
189 189
     if (format == AV_PIX_FMT_P010LE || format == AV_PIX_FMT_P010BE || format == AV_PIX_FMT_P016LE || format == AV_PIX_FMT_P016BE)
190 190
         return AVERROR(ENOSYS);
... ...
@@ -103,7 +103,7 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(int size),
103 103
     }
104 104
 
105 105
     if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
106
-        desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
106
+        desc->flags & FF_PSEUDOPAL) {
107 107
         pool->pools[1] = av_buffer_pool_init(AVPALETTE_SIZE, alloc);
108 108
         if (!pool->pools[1])
109 109
             goto fail;
... ...
@@ -227,7 +227,7 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
227 227
         }
228 228
 
229 229
         if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
230
-            desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
230
+            desc->flags & FF_PSEUDOPAL) {
231 231
             enum AVPixelFormat format =
232 232
                 pool->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : pool->format;
233 233
 
... ...
@@ -288,7 +288,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
288 288
     frame->data[0] += s->y * frame->linesize[0];
289 289
     frame->data[0] += s->x * s->max_step[0];
290 290
 
291
-    if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)) {
291
+    if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & FF_PSEUDOPAL)) {
292 292
         for (i = 1; i < 3; i ++) {
293 293
             if (frame->data[i]) {
294 294
                 frame->data[i] += (s->y >> s->vsub) * frame->linesize[i];
... ...
@@ -81,7 +81,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
81 81
 
82 82
     /* copy palette */
83 83
     if (priv->pix_desc->flags & AV_PIX_FMT_FLAG_PAL ||
84
-        priv->pix_desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
84
+        ((priv->pix_desc->flags & FF_PSEUDOPAL) && out->data[1] && in->data[1]))
85 85
         memcpy(out->data[1], in->data[1], AVPALETTE_SIZE);
86 86
 
87 87
     for (c = 0; c < priv->pix_desc->nb_components; c++) {
... ...
@@ -261,11 +261,10 @@ static int config_props(AVFilterLink *outlink)
261 261
 
262 262
     /* TODO: make algorithm configurable */
263 263
 
264
-    scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL ||
265
-                          desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL;
264
+    scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL;
266 265
     if (outfmt == AV_PIX_FMT_PAL8) outfmt = AV_PIX_FMT_BGR8;
267 266
     scale->output_is_pal = av_pix_fmt_desc_get(outfmt)->flags & AV_PIX_FMT_FLAG_PAL ||
268
-                           av_pix_fmt_desc_get(outfmt)->flags & AV_PIX_FMT_FLAG_PSEUDOPAL;
267
+                           av_pix_fmt_desc_get(outfmt)->flags & FF_PSEUDOPAL;
269 268
 
270 269
     if (scale->sws)
271 270
         sws_freeContext(scale->sws);
... ...
@@ -69,7 +69,7 @@ static av_cold int shuffleplanes_config_input(AVFilterLink *inlink)
69 69
         }
70 70
 
71 71
         if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
72
-             desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
72
+             desc->flags & FF_PSEUDOPAL) &&
73 73
             (i == 1) != (s->map[i] == 1)) {
74 74
             av_log(ctx, AV_LOG_ERROR,
75 75
                    "Cannot map between a palette plane and a data plane.\n");
... ...
@@ -247,7 +247,7 @@ static int get_video_buffer(AVFrame *frame, int align)
247 247
 
248 248
         frame->data[i] = frame->buf[i]->data;
249 249
     }
250
-    if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
250
+    if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & FF_PSEUDOPAL) {
251 251
         av_buffer_unref(&frame->buf[1]);
252 252
         frame->buf[1] = av_buffer_alloc(AVPALETTE_SIZE);
253 253
         if (!frame->buf[1])
... ...
@@ -848,7 +848,7 @@ static int calc_cropping_offsets(size_t offsets[4], const AVFrame *frame,
848 848
         int shift_x = (i == 1 || i == 2) ? desc->log2_chroma_w : 0;
849 849
         int shift_y = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
850 850
 
851
-        if (desc->flags & (AV_PIX_FMT_FLAG_PAL | AV_PIX_FMT_FLAG_PSEUDOPAL) && i == 1) {
851
+        if (desc->flags & (AV_PIX_FMT_FLAG_PAL | FF_PSEUDOPAL) && i == 1) {
852 852
             offsets[i] = 0;
853 853
             break;
854 854
         }
... ...
@@ -125,7 +125,7 @@ int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei
125 125
     size[0] = linesizes[0] * height;
126 126
 
127 127
     if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
128
-        desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
128
+        desc->flags & FF_PSEUDOPAL) {
129 129
         data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */
130 130
         return size[0] + 256 * 4;
131 131
     }
... ...
@@ -216,7 +216,7 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
216 216
         av_free(buf);
217 217
         return ret;
218 218
     }
219
-    if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
219
+    if (desc->flags & AV_PIX_FMT_FLAG_PAL || (desc->flags & FF_PSEUDOPAL && pointers[1])) {
220 220
         avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
221 221
         if (align < 4) {
222 222
             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],
225 225
     }
226 226
 
227 227
     if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
228
-         desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
228
+         desc->flags & FF_PSEUDOPAL) && pointers[1] &&
229 229
         pointers[1] - pointers[0] > linesizes[0] * h) {
230 230
         /* zero-initialize the padding before the palette */
231 231
         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],
354 354
         return;
355 355
 
356 356
     if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
357
-        desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
357
+        desc->flags & FF_PSEUDOPAL) {
358 358
         copy_plane(dst_data[0], dst_linesizes[0],
359 359
                    src_data[0], src_linesizes[0],
360 360
                    width, height);
361 361
         /* copy the palette */
362
-        memcpy(dst_data[1], src_data[1], 4*256);
362
+        if ((desc->flags & AV_PIX_FMT_FLAG_PAL) || (dst_data[1] && src_data[1]))
363
+            memcpy(dst_data[1], src_data[1], 4*256);
363 364
     } else {
364 365
         int i, planes_nb = 0;
365 366
 
... ...
@@ -442,7 +443,7 @@ int av_image_get_buffer_size(enum AVPixelFormat pix_fmt,
442 442
         return ret;
443 443
 
444 444
     // do not include palette for these pseudo-paletted formats
445
-    if (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL)
445
+    if (desc->flags & FF_PSEUDOPAL)
446 446
         return FFALIGN(width, align) * height;
447 447
 
448 448
     return av_image_fill_arrays(data, linesize, NULL, pix_fmt,
... ...
@@ -360,4 +360,13 @@ void ff_check_pixfmt_descriptors(void);
360 360
  */
361 361
 int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp);
362 362
 
363
+// Helper macro for AV_PIX_FMT_FLAG_PSEUDOPAL deprecation. Code inside FFmpeg
364
+// should always use FF_PSEUDOPAL. Once the public API flag gets removed, all
365
+// code using it is dead code.
366
+#if FF_API_PSEUDOPAL
367
+#define FF_PSEUDOPAL AV_PIX_FMT_FLAG_PSEUDOPAL
368
+#else
369
+#define FF_PSEUDOPAL 0
370
+#endif
371
+
363 372
 #endif /* AVUTIL_INTERNAL_H */
... ...
@@ -257,7 +257,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
257 257
         .comp = {
258 258
             { 0, 1, 0, 0, 8, 0, 7, 1 },        /* Y */
259 259
         },
260
-        .flags = AV_PIX_FMT_FLAG_PSEUDOPAL,
260
+        .flags = FF_PSEUDOPAL,
261 261
         .alias = "gray8,y8",
262 262
     },
263 263
     [AV_PIX_FMT_MONOWHITE] = {
... ...
@@ -362,7 +362,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
362 362
             { 0, 1, 0, 3, 3, 0, 2, 1 },        /* G */
363 363
             { 0, 1, 0, 6, 2, 0, 1, 1 },        /* B */
364 364
         },
365
-        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
365
+        .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL,
366 366
     },
367 367
     [AV_PIX_FMT_BGR4] = {
368 368
         .name = "bgr4",
... ...
@@ -386,7 +386,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
386 386
             { 0, 1, 0, 1, 2, 0, 1, 1 },        /* G */
387 387
             { 0, 1, 0, 3, 1, 0, 0, 1 },        /* B */
388 388
         },
389
-        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
389
+        .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL,
390 390
     },
391 391
     [AV_PIX_FMT_RGB8] = {
392 392
         .name = "rgb8",
... ...
@@ -398,7 +398,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
398 398
             { 0, 1, 0, 3, 3, 0, 2, 1 },        /* G */
399 399
             { 0, 1, 0, 0, 3, 0, 2, 1 },        /* B */
400 400
         },
401
-        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
401
+        .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL,
402 402
     },
403 403
     [AV_PIX_FMT_RGB4] = {
404 404
         .name = "rgb4",
... ...
@@ -422,7 +422,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
422 422
             { 0, 1, 0, 1, 2, 0, 1, 1 },        /* G */
423 423
             { 0, 1, 0, 0, 1, 0, 0, 1 },        /* B */
424 424
         },
425
-        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PSEUDOPAL,
425
+        .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL,
426 426
     },
427 427
     [AV_PIX_FMT_NV12] = {
428 428
         .name = "nv12",
... ...
@@ -154,6 +154,14 @@ typedef struct AVPixFmtDescriptor {
154 154
  * in some cases be simpler. Or the data can be interpreted purely based on
155 155
  * the pixel format without using the palette.
156 156
  * An example of a pseudo-paletted format is AV_PIX_FMT_GRAY8
157
+ *
158
+ * @deprecated This flag is deprecated, and will be removed. When it is removed,
159
+ * the extra palette allocation in AVFrame.data[1] is removed as well. Only
160
+ * actual paletted formats (as indicated by AV_PIX_FMT_FLAG_PAL) will have a
161
+ * palette. Starting with FFmpeg versions which have this flag deprecated, the
162
+ * extra "pseudo" palette is already ignored, and API users are not required to
163
+ * allocate a palette for AV_PIX_FMT_FLAG_PSEUDOPAL formats (it was required
164
+ * before the deprecation, though).
157 165
  */
158 166
 #define AV_PIX_FMT_FLAG_PSEUDOPAL    (1 << 6)
159 167
 
... ...
@@ -79,7 +79,7 @@
79 79
  */
80 80
 
81 81
 #define LIBAVUTIL_VERSION_MAJOR  56
82
-#define LIBAVUTIL_VERSION_MINOR  12
82
+#define LIBAVUTIL_VERSION_MINOR  13
83 83
 #define LIBAVUTIL_VERSION_MICRO 100
84 84
 
85 85
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
... ...
@@ -126,6 +126,9 @@
126 126
 #ifndef FF_API_FRAME_GET_SET
127 127
 #define FF_API_FRAME_GET_SET            (LIBAVUTIL_VERSION_MAJOR < 57)
128 128
 #endif
129
+#ifndef FF_API_PSEUDOPAL
130
+#define FF_API_PSEUDOPAL                (LIBAVUTIL_VERSION_MAJOR < 57)
131
+#endif
129 132
 
130 133
 
131 134
 /**
... ...
@@ -806,9 +806,17 @@ static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
806 806
 
807 807
 static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
808 808
 {
809
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
810
-    av_assert0(desc);
811
-    return (desc->flags & AV_PIX_FMT_FLAG_PAL) || (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL);
809
+    switch (pix_fmt) {
810
+    case AV_PIX_FMT_PAL8:
811
+    case AV_PIX_FMT_BGR4_BYTE:
812
+    case AV_PIX_FMT_BGR8:
813
+    case AV_PIX_FMT_GRAY8:
814
+    case AV_PIX_FMT_RGB4_BYTE:
815
+    case AV_PIX_FMT_RGB8:
816
+        return 1;
817
+    default:
818
+        return 0;
819
+    }
812 820
 }
813 821
 
814 822
 extern const uint64_t ff_dither4[2];