[FFmpeg-devel] [PATCH] MMX implementation of VC-1 inverse transforms

Michael Niedermayer michaelni
Sat Jan 19 14:34:04 CET 2008


On Sat, Jan 19, 2008 at 01:38:52PM +0100, Christophe GISQUET wrote:
> Michael Niedermayer a ?crit :
> > i think, the following is safe
> >
> >         t1 = src[0] + src[2];
> >         t2 = src[0] - src[2];
> >         t1= 8*t1 + (t1>>1);
> >         t2= 8*t2 + (t2>>1);
> >
> >         t3 = 11 * src[1] + 5 * src[3];
> >         t4 = 11 * src[3] - 5 * src[1];
> >
> >         dst[0] = (t1 + t3 + 2) >> 2;
> >         dst[1] = (t2 - t4 + 2) >> 2;
> >         dst[2] = (t2 + t4 + 2) >> 2;
> >         dst[3] = (t1 - t3 + 2) >> 2;
> 
> Of course, the bias would be merged with the (t[1,2]>>1).
> 
> > the spec requires dst>>4 to be within -512 .. 510
> > so the triplet sums are limited to -32768 .. 32703
> > hence the value prior to the >>2 fits in 16bit
> > the values before the >>1 are also limited to +-8192 per spec so they
> > are fine as well
> 
> I don't have the specs, and if you didn't guess them, I'd be interested
> in them, because the dst>>7 in the 2nd stage seemed to need to be in
> -127..128.

i just have a draft (s421m.pdf) freely downloaded from smpte.org a while ago,
iam not sure though if its still freely available  ...
anyway heres what it says (copy and paste with special char cleanup as that
didnt survive the c&p):
------------------------------
A.1 Inverse Transform
The inverse transform is similar, but not identical, to an IDCT. The transform matrices defined in Figure 157 and
Figure 158 shall be used for an 8 point inverse transformation and a 4 point inverse transformation respectively. The
formula in Figure 159 shall be used to compute the inverse transform of 8x8, 8x4, 4x8, and 4x4 blocks.
                                      12  12  12  12  12  12  12  12 
                                      16  15   9   4 - 4 - 9 -15 -16
                                      16   6 - 6 -16 -16 - 6   6  16 
                                      15 - 4 - 16 -9   9  16   4 -15
?                                 T8 =12 - 12 -12 12  12 -12 -12  12 
                                       9 - 16  4  15 -15 - 4  16 - 9
                                       6 - 16 16 - 6 - 6  16 -16   6
                                       4 - 9  15 -16  16 -15   9 - 4
                                 Figure 157: Matrix for 1-D 8-point Inverse Transform
                                                     17  17  17  17 
                                                     22  10 -10 -22
                                               T4 =  17 -17 -17  17 
                                                     10 -22  22 -10 
                                 Figure 158: Matrix for 1-D 4-point Inverse Transform
                                          EMxN = ( DMxN . TM + 4) >> 3
                                  RMxN = (T?N . EMxN + CN . 1M + 64) >> 7
          where
           M , N in {4, 8}
          operator .  represents matrix multiplication
          operator >> represents arithmetic right shift, performed entry-wise on a matrix
          operator ?  represents matrix transpose
          T8 is a constant matrix as in Figure 157
          T4 is a constant matrix as in Figure 158


C8 = (0 0 0 0 1 1 1 1)?

C4 is a zero column vector of length 4

1M is an M length row vector of ones

 D8x8 , D8x4 , D4x8 , D4x4 are inverse quantized transform coefficient blocks (input).
The inverse quantized transform coefficient values shall not exceed the signed 12 bit range, i.e.
entries of these matrices shall be limited to the range  >=-2048 and < 2047.

 E8x8 , E8x4 , E4x8 , E4x4   are intermediate matrices. The values in the intermediate matrices
shall be limited to the range >=-4096 and <4095.

 R8x8 , R8x4 , R4x8 , R4x4 are inverse transformed blocks (output). The inverse transformed
values shall be limited to the range >=-512 and <511.
                              Figure 159: Definition of Inverse Transform


---------------------

one could now argue that the limiting is a little unclearly defined. But IMO
the equations clearly define the relation between input and output and they
dont contain any limiting themselfs so the encoder has to ensure that the
limits are not violated.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080119/65249bdb/attachment.pgp>



More information about the ffmpeg-devel mailing list