IL/MMAL: Add I420 and YUVUV 10bpp formats
authorDave Stevenson <dave.stevenson@raspberrypi.org>
Fri, 8 Sep 2017 17:26:10 +0000 (18:26 +0100)
committerpopcornmix <popcornmix@gmail.com>
Fri, 8 Sep 2017 17:28:40 +0000 (18:28 +0100)
10bits per pixel packed in the least significant bits
of 16 bit words.
Not replicated in VC_IMAGE, and only supported by the ISP component.

interface/mmal/mmal_encodings.h
interface/mmal/util/mmal_il.c
interface/mmal/util/mmal_util.c
interface/vmcs_host/khronos/IL/OMX_IVCommon.h

index 75128275faa1b1e04336a94b505f5be542e7198a..ee642ab474f80c8eac356afcd952c844a8982c4f 100644 (file)
@@ -97,6 +97,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /** YUV 4:2:0 planar, 16bit/component.
 */
 #define MMAL_ENCODING_I420_16          MMAL_FOURCC('i','4','2','0')
+/** YUV 4:2:0 planar, 10bit/component as least sig 10bits of 16 bit words.
+*/
+#define MMAL_ENCODING_I420_10          MMAL_FOURCC('i','4','1','0')
 
 //Bayer formats
 //FourCC values copied from V4L2 where defined.
@@ -141,6 +144,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * of YUV_UV_16 video.
  */
 #define MMAL_ENCODING_YUVUV64_16      MMAL_FOURCC('S','A','1','6')
+/** 10 bit SAND Video format, packed as least sig 10 bits of 16 bit words.
+ */
+#define MMAL_ENCODING_YUVUV64_10      MMAL_FOURCC('S','A','1','0')
 
 /** VideoCore opaque image format, image handles are returned to
  * the host but not the actual image data.
index cbad425b21e45379147c8929e5ec5f7403ba04c3..8e0d8bb215abed88caf4ce37a375c706a53ee0cf 100644 (file)
@@ -741,6 +741,8 @@ static struct {
    {MMAL_ENCODING_OPAQUE,         OMX_COLOR_FormatBRCMOpaque},
    {MMAL_ENCODING_I420_16,        OMX_COLOR_FormatYUV420_16PackedPlanar},
    {MMAL_ENCODING_YUVUV64_16,     OMX_COLOR_FormatYUVUV64_16},
+   {MMAL_ENCODING_I420_10,        OMX_COLOR_FormatYUV420_10PackedPlanar},
+   {MMAL_ENCODING_YUVUV64_10,     OMX_COLOR_FormatYUVUV64_10},
    {MMAL_ENCODING_UNKNOWN,        OMX_COLOR_FormatUnused}
 };
 
index cf040dcbddeb7a49620b56dc8a393bb41dd8cb34..aa1f3f98b06e1f6e38f9d3d3c0dd375aa155c615 100644 (file)
@@ -87,6 +87,7 @@ static struct {
    {MMAL_ENCODING_BGR16, 2, 1, 1},
    {MMAL_ENCODING_BGR24, 3, 1, 1},
    {MMAL_ENCODING_I420_16, 2, 1, 1},
+   {MMAL_ENCODING_I420_10, 2, 1, 1},
 
    {MMAL_ENCODING_I420_SLICE,  1, 1, 1},
    {MMAL_ENCODING_I422_SLICE,  1, 1, 1},
@@ -131,6 +132,7 @@ static struct {
 
    /* {MMAL_ENCODING_YUVUV128, 1, 1}, That's a special case which must not be included */
    /* {MMAL_ENCODING_YUVUV64_16, 1, 1}, That's a special case which must not be included */
+   /* {MMAL_ENCODING_YUVUV64_10, 1, 1}, That's a special case which must not be included */
    {MMAL_ENCODING_UNKNOWN, 0, 0}
 };
 
@@ -424,7 +426,7 @@ char *mmal_4cc_to_string(char *buf, size_t len, uint32_t fourcc)
    return buf;
 }
 
-#define MAX_ENCODINGS_NUM 20
+#define MAX_ENCODINGS_NUM 25
 typedef struct {
    MMAL_PARAMETER_HEADER_T header;
    MMAL_FOURCC_T encodings[MAX_ENCODINGS_NUM];
@@ -434,6 +436,7 @@ typedef struct {
 int mmal_util_rgb_order_fixed(MMAL_PORT_T *port)
 {
    int new_fw = 0;
+   MMAL_STATUS_T ret;
    //Firmware support of RGB24 vs BGR24 colour ordering from camera
    //and video splitter components has been corrected as of June 2016.
    //New firmwares always report MMAL_ENCODING_RGB24 before BGR24, and
@@ -442,11 +445,16 @@ int mmal_util_rgb_order_fixed(MMAL_PORT_T *port)
    //the still port on querying MMAL_PARAMETER_SUPPORTED_ENCODINGS.
 
    MMAL_SUPPORTED_ENCODINGS_T sup_encodings = {{MMAL_PARAMETER_SUPPORTED_ENCODINGS, sizeof(sup_encodings)}, {0}};
-   if (mmal_port_parameter_get(port, &sup_encodings.header) == MMAL_SUCCESS)
+   ret = mmal_port_parameter_get(port, &sup_encodings.header);
+   if (ret == MMAL_SUCCESS || ret == MMAL_ENOSPC)
    {
+      //Allow ENOSPC error and hope that the desired formats are in the first
+      //MAX_ENCODINGS_NUM entries.
       int i;
       int num_encodings = (sup_encodings.header.size - sizeof(sup_encodings.header)) /
           sizeof(sup_encodings.encodings[0]);
+      if(num_encodings > MAX_ENCODINGS_NUM)
+         num_encodings = MAX_ENCODINGS_NUM;
       for (i=0; i<num_encodings; i++)
       {
          if (sup_encodings.encodings[i] == MMAL_ENCODING_BGR24)
index de4b86b9b5fc556c6f043db6223b670328eedf37..6ba98100b6b5473239d7c0df1d556773f8353482 100644 (file)
@@ -143,8 +143,10 @@ typedef enum OMX_COLOR_FORMATTYPE {
     OMX_COLOR_FormatYVU420PackedPlanar,
     OMX_COLOR_FormatYVU420PackedSemiPlanar,
     OMX_COLOR_FormatRawBayer16bit,
-    OMX_COLOR_FormatYUV420_16PackedPlanar,
-    OMX_COLOR_FormatYUVUV64_16,
+    OMX_COLOR_FormatYUV420_16PackedPlanar,  /**< YUV420, 16bit/component */
+    OMX_COLOR_FormatYUVUV64_16,             /**< YUVUV, 16bit/component */
+    OMX_COLOR_FormatYUV420_10PackedPlanar,  /**< YUV420, 10bit/component as least sig 10bits of 16 bit words */
+    OMX_COLOR_FormatYUVUV64_10,             /**< YUVUV, 10bit/component as least sig 10bits of 16 bit words */
     OMX_COLOR_FormatMax = 0x7FFFFFFF
 } OMX_COLOR_FORMATTYPE;