Subject: [Cellar] [PATCH] ffv1.md: Add support for more planes beyond RGBA / YCbCrA

From: Michael Niedermayer <[email-masked]>
Date: Fri, 12 Jan 2018 17:22:31 +0100

Idea-from: https://github.com/FFmpeg/FFV1/issues/47

Signed-off-by: Michael Niedermayer <[email-masked]>
---
 ffv1.md | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/ffv1.md b/ffv1.md
index e57ab3e..c6a8433 100644
--- a/ffv1.md
+++ b/ffv1.md
@@ -836,7 +836,7 @@ Inferred to be 1 if not present.
 
 ### quant_table_set_index_count
 
-`quant_table_set_index_count` is defined as `1 + ( ( chroma_planes || version \<= 3 ) ? 1 : 0 ) + ( alpha_plane ? 1 : 0 )`.
+`quant_table_set_index_count` is defined as `1 + ( ( chroma_planes || version \<= 3 ) ? 1 : 0 ) + ( alpha_plane ? 1 : 0 ) + hamming_weight(extra_plane_mask)`.
 
 ### quant_table_set_index
 
@@ -904,7 +904,7 @@ SliceContent( ) {                                             |
 
 ### primary_color_count
 
-`primary_color_count` is defined as 1 + ( chroma_planes ? 2 : 0 ) + ( alpha_plane ? 1 : 0 ).
+`primary_color_count` is defined as 1 + ( chroma_planes ? 2 : 0 ) + ( alpha_plane ? 1 : 0 ) + hamming_weight(extra_plane_mask).
 
 ### plane_pixel_height
 
@@ -1036,6 +1036,9 @@ Parameters( ) {                                               |
         ec                                                    | ur
         intra                                                 | ur
     }                                                         |
+    if (version >= 4) {                                       |
+        extra_plane_mask                                      | ur
+    }                                                         |
 }                                                             |
 ```
 
@@ -1147,6 +1150,21 @@ RFC:`log2_v_chroma_subsample` indicates the subsample factor, stored in powers t
 | 0     | transparency plane is not present|
 | 1     | transparency plane is present    |
 
+### extra_plane_mask
+
+`extra_plane_mask` is a bitmask indicating additional planes beyond RGBA / YCbCrA.
+Each 1 bit indicates one additional plane.
+
+|bit    | color space used                 |
+|-------|:---------------------------------|
+| 0     | Near infra red                   |
+| 1     | Mid infra red                    |
+| 2     | Far infra red                    |
+| 3     | Near ultra violet                |
+| 4     | Mid ultra violet                 |
+| 5     | Far ultra violet                 |
+| 24-31 | User defined planes              |
+
 ### num_h_slices
 
 `num_h_slices` indicates the number of horizontal elements of the slice raster.  
-- 
2.15.1

---

From: Dave Rice <[email-masked]>
Date: Fri, 12 Jan 2018 11:34:10 -0500

Hi Michael,

> On Jan 12, 2018, at 11:22 AM, Michael Niedermayer <[email-masked]> wrote:
> 

The hamming_weight function needs to be defined.

> +`primary_color_count` is defined as 1 + ( chroma_planes ? 2 : 0 ) + ( alpha_plane ? 1 : 0 ) + hamming_weight(extra_plane_mask).

nit: equation should be backtick-quoted

> +`extra_plane_mask` is a bitmask indicating additional planes beyond RGBA / YCbCrA.

The color space section may need to be updated to acknowledge the possibility an extra planes. For instance "An FFV1 Frame using YCbCr MUST use one of the following arrangements” or perhaps in color space there should be an acknowledge that FFV1 permits storage an extra planes that are not part of the defined transformations.

> +|bit    | color space used                 |

Is this list based on any source?

> +| 24-31 | User defined planes              |

Perhaps some reserved values rather than letting all remaining values to user definition.

> `num_h_slices` indicates the number of horizontal elements of the slice raster.  

Thanks,
Dave Rice

---

From: Michael Niedermayer <[email-masked]>
Date: Fri, 12 Jan 2018 17:54:51 +0100

Hi
> nit: equation should be backtick-quoted

will fix

> The color space section may need to be updated to acknowledge the possibility an extra planes. For instance "An FFV1 Frame using YCbCr MUST use one of the following arrangements” or perhaps in colo…

will update

> Is this list based on any source?

no, it was just a random idea to start some discussion.
I actually will post an alternative idea in a moment

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch