Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-16 16:16:03 +0400
committerMichael Niedermayer <michaelni@gmx.at>2013-04-16 16:27:14 +0400
commit20e99a9c10cdbe9ad659dce5bdec569d744f8219 (patch)
treefac1c840c0bd1db4343c89b36c26f91ad2dcae14 /libavutil
parent1314f534e54d13cfe7a0280614e7ca6655072b80 (diff)
avutil/pixdesc: support for self-checking the descriptors
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/pixdesc.c25
-rw-r--r--libavutil/pixdesc.h1
-rw-r--r--libavutil/utils.c3
3 files changed, 29 insertions, 0 deletions
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index d3cec170ea..c03964faef 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
+#include "avassert.h"
#include "common.h"
#include "pixfmt.h"
#include "pixdesc.h"
@@ -1828,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);
+ }
+ }
+}
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index 0947fd1f88..538e6a55d2 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -239,5 +239,6 @@ int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
*/
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);
+void ff_check_pixfmt_descriptors(void);
#endif /* AVUTIL_PIXDESC_H */
diff --git a/libavutil/utils.c b/libavutil/utils.c
index 291c736454..8f83c02d83 100644
--- a/libavutil/utils.c
+++ b/libavutil/utils.c
@@ -20,6 +20,7 @@
#include "avutil.h"
#include "avassert.h"
#include "samplefmt.h"
+#include "pixdesc.h"
/**
* @file
@@ -40,6 +41,8 @@ unsigned avutil_version(void)
abort();
}
+ ff_check_pixfmt_descriptors();
+
return LIBAVUTIL_VERSION_INT;
}