[PATCH 6/6] Implement test for getting the codec tag per each pixel format.

Stefano Sabatini stefano.sabatini-lala
Sat May 8 02:03:22 CEST 2010


---
 libavcodec/raw.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/libavcodec/raw.c b/libavcodec/raw.c
index c2ce3bc..8299dc8 100644
--- a/libavcodec/raw.c
+++ b/libavcodec/raw.c
@@ -83,3 +83,56 @@ unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat fmt)
     }
     return 0;
 }
+
+#ifdef TEST
+
+#undef printf
+
+#include "libavutil/avstring.h"
+#include "libavutil/pixdesc.h"
+
+static char *get_codec_tag_string(char *codec_tag_string,
+                                  unsigned int codec_tag_string_size,
+                                  int codec_tag)
+{
+    char a, b, c, d;
+
+    *codec_tag_string = 0;
+
+    a = codec_tag     & 0xff;
+    b = codec_tag>>8  & 0xff;
+    c = codec_tag>>16 & 0xff;
+    d = codec_tag>>24 & 0xff;
+
+#define CATCODE(c)                                                      \
+    if (isprint(c)) av_strlcatf(codec_tag_string, codec_tag_string_size,  "%c" , c); \
+    else            av_strlcatf(codec_tag_string, codec_tag_string_size, "[%d]", c)
+
+    CATCODE(a);
+    CATCODE(b);
+    CATCODE(c);
+    CATCODE(d);
+
+    return codec_tag_string;
+}
+
+int main(void)
+{
+    enum PixelFormat pixfmt;
+    char codec_tag_string[16];
+    int codec_tag;
+
+    for (pixfmt = 0; pixfmt < PIX_FMT_NB; pixfmt++) {
+        if (av_pix_fmt_descriptors[pixfmt].flags & PIX_FMT_HWACCEL) continue;
+
+        codec_tag = avcodec_pix_fmt_to_codec_tag(pixfmt);
+        printf("%s -> %s\n", av_pix_fmt_descriptors[pixfmt].name,
+               codec_tag ?
+                   get_codec_tag_string(codec_tag_string, sizeof(codec_tag_string), codec_tag) :
+                   "none");
+    }
+
+    return 0;
+}
+
+#endif  /* TEST */
-- 
1.7.0


--7iMSBzlTiPOCCT2k--



More information about the ffmpeg-devel mailing list