Subject: [Cellar] FFV1 JPEG 2000 RCT and chroma subsampling

From: Jerome Martinez <[email-masked]>
Date: Thu, 9 Jun 2016 23:22:14 +0200

I have mixed feelings about a theoretical case, when the spec could be 
slightly adapted in order to support this case but we have no decoder 
able to decode it for the moment.

- colorspace_type == 1 (JPEG 2000 RCT, lines are interleaved Y, Cb, Cr, 
Alpha for line 0 then Y, Cb, Cr, Alpha for line 1...)
- h_chroma_subsample not 1 or v_chroma_subsample not 1

If h_chroma_subsample is not 1, I think it will be handled the same way 
as with colorspace_type == 0, I see no difficulty about it.
If v_chroma_subsample is not 1, the algorithm in SliceContent() is wrong 
because height is not same for all planes.
So either we explicitly forbid this case or we adapt the algorithm 
without decoder for decoding it.

Which option do you prefer?

* in v_chroma_subsample definition, we add "if colorspace_type is 1, 
v_chroma_subsample MUST be 1"

* We change

         for( y = 0; y < height; y++ )
             for( p = 0; p < primary_color_count; p++ )
                 Line( p, y )

to something like:

         for( y = 0; y < height; y++ )
             for( p = 0; p < primary_color_count; p++ )
                 if ( p == luma || p == alpha || height%v_chroma_subsample )
                     Line( p, y )

e.g. for 4:4:0 (full horizontal sampling, ½ vertical sampling, ), we 
would have:
Y1, Cb, Cr, Alpha1, Y2, Alpha2

Note: this would be not the first case without decoder e.g. there is no 
decoder for gray+alpha more than 8-bit.