aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-03-16 19:37:52 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-19 11:12:17 +0100
commit2c328a907978b61949fd20f7c991803174337855 (patch)
treec9b35c50f10bcdcd85ec28cc25ee8b8904c3b8dc
parente5c32d6da7836c7c9bb8393cb4de7e0997a4363b (diff)
downloadffmpeg-2c328a907978b61949fd20f7c991803174337855.tar.gz
pixdesc: add a function for counting planes in a pixel format.
-rw-r--r--doc/APIchanges3
-rw-r--r--libavutil/pixdesc.c15
-rw-r--r--libavutil/pixdesc.h6
-rw-r--r--libavutil/version.h2
4 files changed, 25 insertions, 1 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index 2c08af44af..91bbeecfa0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2012-10-22
API changes, most recent first:
+2013-xx-xx - lavu 52.9.0 - pixdesc.h
+ Add av_pix_fmt_count_planes() function for counting planes in a pixel format.
+
2013-xx-xx - lavfi 3.6.0
Add AVFilterGraph.nb_filters, deprecate AVFilterGraph.filter_count.
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index df906ac15a..e1fa87eee9 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1473,3 +1473,18 @@ int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
return 0;
}
+
+int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
+{
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
+ int i, planes[4] = { 0 }, ret = 0;
+
+ if (!desc)
+ return AVERROR(EINVAL);
+
+ for (i = 0; i < desc->nb_components; i++)
+ planes[desc->comp[i].plane] = 1;
+ for (i = 0; i < FF_ARRAY_ELEMS(planes); i++)
+ ret += planes[i];
+ return ret;
+}
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index 47e6bb838d..ef93bfed82 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -219,5 +219,11 @@ enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc);
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
int *h_shift, int *v_shift);
+/**
+ * @return number of planes in pix_fmt, a negative AVERROR if pix_fmt is not a
+ * valid pixel format.
+ */
+int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);
+
#endif /* AVUTIL_PIXDESC_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index d519b50c78..6cbe7ef66d 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -37,7 +37,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR 8
+#define LIBAVUTIL_VERSION_MINOR 9
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \