On Fri, 26 Apr 2013, Hendrik Leppkes wrote:

On Fri, Apr 26, 2013 at 3:22 PM, Janne Grunau <[email protected]>wrote:

---
 libavutil/pixdesc.c | 28 ++++++++++++++++++++++++++++
 libavutil/pixdesc.h |  7 +++++++
 libavutil/version.h |  2 +-
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 67f9c43..8a55b1f 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1512,3 +1512,31 @@ int av_pix_fmt_count_planes(enum AVPixelFormat
pix_fmt)
         ret += planes[i];
     return ret;
 }
+
+
+int av_pix_fmt_equal_except_endianness(enum AVPixelFormat fmt_a,
+                                       enum AVPixelFormat fmt_b)
+{
+    int i;
+    const AVPixFmtDescriptor *desc_a = av_pix_fmt_desc_get(fmt_a);
+    const AVPixFmtDescriptor *desc_b = av_pix_fmt_desc_get(fmt_b);
+
+    if (!desc_a || !desc_b)
+        return 0;
+
+    if (desc_a->flags & ~PIX_FMT_BE != desc_b->flags & ~PIX_FMT_BE)
+        return 0;
+    if (desc_a->nb_components       != desc_b->nb_components)
+        return 0;
+    if (desc_a->log2_chroma_w       != desc_b->log2_chroma_w)
+        return 0;
+    if (desc_a->log2_chroma_h       != desc_b->log2_chroma_h)
+        return 0;
+
+    for (i = 0; i < desc_a->nb_components; i++) {
+        if (memcmp(&desc_a->comp[i], &desc_b->comp[i],
sizeof(desc_a->comp[i])))
+            return 0;
+    }
+
+    return 1;
+}
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index ef93bfe..1871fe1 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -226,4 +226,11 @@ int av_pix_fmt_get_chroma_sub_sample(enum
AVPixelFormat pix_fmt,
 int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);


+/**
+ * @return 1 if both pixel formats are equal ignoring endianness, 0
otherwise.
+ */
+int av_pix_fmt_equal_except_endianness(enum AVPixelFormat fmt_a,
+                                       enum AVPixelFormat fmt_b);
+
+
 #endif /* AVUTIL_PIXDESC_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index 6e8daa2..948a28f 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -38,7 +38,7 @@

 #define LIBAVUTIL_VERSION_MAJOR 52
 #define LIBAVUTIL_VERSION_MINOR 10
-#define LIBAVUTIL_VERSION_MICRO  0
+#define LIBAVUTIL_VERSION_MICRO  1

 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \
--
1.8.2.1


Not sure if it matters in the end, but this function is not fool proof.

yuv420 == yuvj420
nv12 == nv21
argb == rgba == abgr == bgra

and probably more.

For this particular use in swscale, it doesn't matter since it's only called for pixel formats that are marked as supporting endianness conversion. But it does feel a bit awkward to add a public function which doesn't really do what it's supposed to.

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to