Check that palctrl is available on init instead of crashing when trying to use
[ffmpeg.git] / libavcodec / pixdesc.c
index f2d1dd1..a313c95 100644 (file)
@@ -511,4 +511,86 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
             {0,1,1,0,4},        /* R */
         },
     },
+    [PIX_FMT_YUV420PLE] = {
+        .name = "yuv420ple",
+        .nb_channels  = 3,
+        .log2_chroma_w= 1,
+        .log2_chroma_h= 1,
+        .comp = {
+            {0,1,1,0,15},        /* Y */
+            {1,1,1,0,15},        /* U */
+            {2,1,1,0,15},        /* V */
+        },
+    },
+    [PIX_FMT_YUV420PBE] = {
+        .name = "yuv420pbe",
+        .nb_channels  = 3,
+        .log2_chroma_w= 1,
+        .log2_chroma_h= 1,
+        .comp = {
+            {0,1,1,0,15},        /* Y */
+            {1,1,1,0,15},        /* U */
+            {2,1,1,0,15},        /* V */
+        },
+        .flags = PIX_FMT_BE,
+    },
+    [PIX_FMT_YUV422PLE] = {
+        .name = "yuv422ple",
+        .nb_channels  = 3,
+        .log2_chroma_w= 1,
+        .log2_chroma_h= 0,
+        .comp = {
+            {0,1,1,0,15},        /* Y */
+            {1,1,1,0,15},        /* U */
+            {2,1,1,0,15},        /* V */
+        },
+    },
+    [PIX_FMT_YUV422PBE] = {
+        .name = "yuv422pbe",
+        .nb_channels  = 3,
+        .log2_chroma_w= 1,
+        .log2_chroma_h= 0,
+        .comp = {
+            {0,1,1,0,15},        /* Y */
+            {1,1,1,0,15},        /* U */
+            {2,1,1,0,15},        /* V */
+        },
+        .flags = PIX_FMT_BE,
+    },
+    [PIX_FMT_YUV444PLE] = {
+        .name = "yuv444ple",
+        .nb_channels  = 3,
+        .log2_chroma_w= 0,
+        .log2_chroma_h= 0,
+        .comp = {
+            {0,1,1,0,15},        /* Y */
+            {1,1,1,0,15},        /* U */
+            {2,1,1,0,15},        /* V */
+        },
+    },
+    [PIX_FMT_YUV444PBE] = {
+        .name = "yuv444pbe",
+        .nb_channels  = 3,
+        .log2_chroma_w= 0,
+        .log2_chroma_h= 0,
+        .comp = {
+            {0,1,1,0,15},        /* Y */
+            {1,1,1,0,15},        /* U */
+            {2,1,1,0,15},        /* V */
+        },
+        .flags = PIX_FMT_BE,
+    },
 };
+
+int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
+{
+    int c, bits = 0;
+    int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
+
+    for (c = 0; c < pixdesc->nb_channels; c++) {
+        int s = c==1 || c==2 ? 0 : log2_pixels;
+        bits += (pixdesc->comp[c].depth_minus1+1) << s;
+    }
+
+    return bits >> log2_pixels;
+}