]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/pixdesc.c
avutil/pixdesc: support for self-checking the descriptors
[ffmpeg] / libavutil / pixdesc.c
index c17eae50e4914ed0adb431931879a94c0a38bc46..c03964faef9c29cbd4b698201d07b4cf1157f3b3 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "avassert.h"
 #include "common.h"
 #include "pixfmt.h"
 #include "pixdesc.h"
@@ -498,7 +499,6 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
             { 0, 3, 1, 0, 7 },        /* R */
             { 0, 3, 2, 0, 7 },        /* G */
             { 0, 3, 3, 0, 7 },        /* B */
-            { 0, 3, 4, 0, 7 },        /* A */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -523,7 +523,6 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
             { 0, 3, 3, 0, 7 },        /* R */
             { 0, 3, 2, 0, 7 },        /* G */
             { 0, 3, 1, 0, 7 },        /* B */
-            { 0, 3, 4, 0, 7 },        /* A */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -1830,3 +1829,27 @@ int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
         ret += planes[i];
     return ret;
 }
+
+void ff_check_pixfmt_descriptors(void){
+    int i, j;
+
+    for (i=0; i<FF_ARRAY_ELEMS(av_pix_fmt_descriptors); i++) {
+        const AVPixFmtDescriptor *d = &av_pix_fmt_descriptors[i];
+
+        if (!d->name && !d->nb_components && !d->log2_chroma_w && !d->log2_chroma_h && !d->flags)
+            continue;
+//         av_log(NULL, AV_LOG_DEBUG, "Checking: %s\n", d->name);
+        av_assert0(d->log2_chroma_w <= 3);
+        av_assert0(d->log2_chroma_h <= 3);
+        av_assert0(d->nb_components <= 4);
+        av_assert0(d->name && d->name[0]);
+        av_assert0((d->nb_components==4 || d->nb_components==2) == !!(d->flags & PIX_FMT_ALPHA));
+        av_assert2(av_get_pix_fmt(d->name) == i);
+
+        for (j=0; j<FF_ARRAY_ELEMS(d->comp); j++) {
+            const AVComponentDescriptor *c = &d->comp[j];
+            if(j>=d->nb_components)
+                av_assert0(!c->plane && !c->step_minus1 && !c->offset_plus1 && !c->shift && !c->depth_minus1);
+        }
+    }
+}