[FFmpeg-devel] [PATCH] pixdesc: put components always in the same order.

Nicolas George nicolas.george at normalesup.org
Sun Mar 18 10:15:36 CET 2012


Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavutil/pixdesc.c |   94 +++++++++++++++++++++++++-------------------------
 libavutil/pixdesc.h |    9 +++--
 2 files changed, 53 insertions(+), 50 deletions(-)


It does not seem to have any advert effect (on FATE anyway; I can run more
tests if necessary) and it makes the table much more useful.


diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 668d822..233b217 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -158,9 +158,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 2, 1, 0, 7 },        /* B */
-            { 0, 2, 2, 0, 7 },        /* G */
             { 0, 2, 3, 0, 7 },        /* R */
+            { 0, 2, 2, 0, 7 },        /* G */
+            { 0, 2, 1, 0, 7 },        /* B */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -323,9 +323,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 0, 1, 6, 1 },        /* B */
-            { 0, 0, 1, 3, 2 },        /* G */
             { 0, 0, 1, 0, 2 },        /* R */
+            { 0, 0, 1, 3, 2 },        /* G */
+            { 0, 0, 1, 6, 1 },        /* B */
         },
         .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
     },
@@ -335,9 +335,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 3, 1, 0, 0 },        /* B */
-            { 0, 3, 2, 0, 1 },        /* G */
             { 0, 3, 4, 0, 0 },        /* R */
+            { 0, 3, 2, 0, 1 },        /* G */
+            { 0, 3, 1, 0, 0 },        /* B */
         },
         .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
     },
@@ -347,9 +347,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 0, 1, 3, 0 },        /* B */
-            { 0, 0, 1, 1, 1 },        /* G */
             { 0, 0, 1, 0, 0 },        /* R */
+            { 0, 0, 1, 1, 1 },        /* G */
+            { 0, 0, 1, 3, 0 },        /* B */
         },
         .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
     },
@@ -408,8 +408,8 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_h = 1,
         .comp = {
             { 0, 0, 1, 0, 7 },        /* Y */
-            { 1, 1, 1, 0, 7 },        /* V */
             { 1, 1, 2, 0, 7 },        /* U */
+            { 1, 1, 1, 0, 7 },        /* V */
         },
         .flags = PIX_FMT_PLANAR,
     },
@@ -419,10 +419,10 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 3, 1, 0, 7 },        /* A */
             { 0, 3, 2, 0, 7 },        /* R */
             { 0, 3, 3, 0, 7 },        /* G */
             { 0, 3, 4, 0, 7 },        /* B */
+            { 0, 3, 1, 0, 7 },        /* A */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -445,10 +445,10 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 3, 1, 0, 7 },        /* A */
-            { 0, 3, 2, 0, 7 },        /* B */
-            { 0, 3, 3, 0, 7 },        /* G */
             { 0, 3, 4, 0, 7 },        /* R */
+            { 0, 3, 3, 0, 7 },        /* G */
+            { 0, 3, 2, 0, 7 },        /* B */
+            { 0, 3, 1, 0, 7 },        /* A */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -458,9 +458,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 3, 1, 0, 7 },        /* B */
-            { 0, 3, 2, 0, 7 },        /* G */
             { 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,
@@ -496,9 +496,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
         .comp = {
-            { 0, 3, 2, 0, 7 },        /* B */
-            { 0, 3, 3, 0, 7 },        /* G */
             { 0, 3, 4, 0, 7 },        /* R */
+            { 0, 3, 3, 0, 7 },        /* G */
+            { 0, 3, 2, 0, 7 },        /* B */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -508,9 +508,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
         .comp = {
-            { 0, 3, 1, 0, 7 },        /* B */
-            { 0, 3, 2, 0, 7 },        /* G */
             { 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,
@@ -666,7 +666,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
             { 0, 7, 1, 0, 15 },       /* R */
             { 0, 7, 3, 0, 15 },       /* G */
             { 0, 7, 5, 0, 15 },       /* B */
-            { 0, 7, 7, 0, 15 },       /* B */
+            { 0, 7, 7, 0, 15 },       /* A */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -748,9 +748,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 5, 1, 0, 15 },       /* B */
-            { 0, 5, 3, 0, 15 },       /* G */
             { 0, 5, 5, 0, 15 },       /* R */
+            { 0, 5, 3, 0, 15 },       /* G */
+            { 0, 5, 1, 0, 15 },       /* B */
         },
         .flags = PIX_FMT_BE | PIX_FMT_RGB,
     },
@@ -760,9 +760,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 5, 1, 0, 15 },       /* B */
-            { 0, 5, 3, 0, 15 },       /* G */
             { 0, 5, 5, 0, 15 },       /* R */
+            { 0, 5, 3, 0, 15 },       /* G */
+            { 0, 5, 1, 0, 15 },       /* B */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -772,9 +772,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
         .comp = {
-            { 0, 7, 1, 0, 15 },       /* B */
-            { 0, 7, 3, 0, 15 },       /* G */
             { 0, 7, 5, 0, 15 },       /* R */
+            { 0, 7, 3, 0, 15 },       /* G */
+            { 0, 7, 1, 0, 15 },       /* B */
             { 0, 7, 7, 0, 15 },       /* A */
         },
         .flags = PIX_FMT_BE,
@@ -785,9 +785,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
         .comp = {
-            { 0, 7, 1, 0, 15 },       /* B */
-            { 0, 7, 3, 0, 15 },       /* G */
             { 0, 7, 5, 0, 15 },       /* R */
+            { 0, 7, 3, 0, 15 },       /* G */
+            { 0, 7, 1, 0, 15 },       /* B */
             { 0, 7, 7, 0, 15 },       /* A */
         },
     },
@@ -797,9 +797,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 1, 0, 3, 4 },        /* B */
-            { 0, 1, 1, 5, 5 },        /* G */
             { 0, 1, 1, 0, 4 },        /* R */
+            { 0, 1, 1, 5, 5 },        /* G */
+            { 0, 1, 0, 3, 4 },        /* B */
         },
         .flags = PIX_FMT_BE | PIX_FMT_RGB,
     },
@@ -809,9 +809,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 1, 2, 3, 4 },        /* B */
-            { 0, 1, 1, 5, 5 },        /* G */
             { 0, 1, 1, 0, 4 },        /* R */
+            { 0, 1, 1, 5, 5 },        /* G */
+            { 0, 1, 2, 3, 4 },        /* B */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -821,9 +821,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 1, 0, 2, 4 },       /* B */
-            { 0, 1, 1, 5, 4 },       /* G */
             { 0, 1, 1, 0, 4 },       /* R */
+            { 0, 1, 1, 5, 4 },       /* G */
+            { 0, 1, 0, 2, 4 },       /* B */
         },
         .flags = PIX_FMT_BE | PIX_FMT_RGB,
      },
@@ -833,9 +833,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 1, 2, 2, 4 },        /* B */
-            { 0, 1, 1, 5, 4 },        /* G */
             { 0, 1, 1, 0, 4 },        /* R */
+            { 0, 1, 1, 5, 4 },        /* G */
+            { 0, 1, 2, 2, 4 },        /* B */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -845,9 +845,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 1, 0, 0, 3 },       /* B */
-            { 0, 1, 1, 4, 3 },       /* G */
             { 0, 1, 1, 0, 3 },       /* R */
+            { 0, 1, 1, 4, 3 },       /* G */
+            { 0, 1, 0, 0, 3 },       /* B */
         },
         .flags = PIX_FMT_BE | PIX_FMT_RGB,
      },
@@ -857,9 +857,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
-            { 0, 1, 2, 0, 3 },        /* B */
-            { 0, 1, 1, 4, 3 },        /* G */
             { 0, 1, 1, 0, 3 },        /* R */
+            { 0, 1, 1, 4, 3 },        /* G */
+            { 0, 1, 2, 0, 3 },        /* B */
         },
         .flags = PIX_FMT_RGB,
     },
@@ -1123,9 +1123,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
+            { 2, 0, 1, 0, 7 },        /* R */
             { 0, 0, 1, 0, 7 },        /* G */
             { 1, 0, 1, 0, 7 },        /* B */
-            { 2, 0, 1, 0, 7 },        /* R */
         },
         .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
     },
@@ -1135,9 +1135,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
+            { 2, 1, 1, 0, 8 },        /* R */
             { 0, 1, 1, 0, 8 },        /* G */
             { 1, 1, 1, 0, 8 },        /* B */
-            { 2, 1, 1, 0, 8 },        /* R */
         },
         .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
     },
@@ -1147,9 +1147,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
+            { 2, 1, 1, 0, 8 },        /* R */
             { 0, 1, 1, 0, 8 },        /* G */
             { 1, 1, 1, 0, 8 },        /* B */
-            { 2, 1, 1, 0, 8 },        /* R */
         },
         .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
     },
@@ -1159,9 +1159,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
+            { 2, 1, 1, 0, 9 },        /* R */
             { 0, 1, 1, 0, 9 },        /* G */
             { 1, 1, 1, 0, 9 },        /* B */
-            { 2, 1, 1, 0, 9 },        /* R */
         },
         .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
     },
@@ -1171,9 +1171,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
+            { 2, 1, 1, 0, 9 },        /* R */
             { 0, 1, 1, 0, 9 },        /* G */
             { 1, 1, 1, 0, 9 },        /* B */
-            { 2, 1, 1, 0, 9 },        /* R */
         },
         .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
     },
@@ -1183,9 +1183,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
+            { 2, 1, 1, 0, 15 },       /* R */
             { 0, 1, 1, 0, 15 },       /* G */
             { 1, 1, 1, 0, 15 },       /* B */
-            { 2, 1, 1, 0, 15 },       /* R */
         },
         .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
     },
@@ -1195,9 +1195,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
         .log2_chroma_w = 0,
         .log2_chroma_h = 0,
         .comp = {
+            { 2, 1, 1, 0, 15 },       /* R */
             { 0, 1, 1, 0, 15 },       /* G */
             { 1, 1, 1, 0, 15 },       /* B */
-            { 2, 1, 1, 0, 15 },       /* R */
         },
         .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
     },
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index 0730f5b..f1a2dde 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -76,9 +76,12 @@ typedef struct AVPixFmtDescriptor{
     uint8_t flags;
 
     /**
-     * Parameters that describe how pixels are packed. If the format
-     * has chroma components, they must be stored in comp[1] and
-     * comp[2].
+     * Parameters that describe how pixels are packed.
+     * If the format has 2 or 4 components, then alpha is last.
+     * If the format has 1 or 2 components, then luma is 0.
+     * If the format has 3 or 4 components,
+     * if the RGB flag is set then 0 is red, 1 is green and 2 is blue;
+     * otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V.
      */
     AVComponentDescriptor comp[4];
 }AVPixFmtDescriptor;
-- 
1.7.9.1



More information about the ffmpeg-devel mailing list