[FFmpeg-devel] [RFC] [PATCH] Indicate better when transposing zigzag scantables is needed in some codecs

Christophe GISQUET christophe.gisquet
Mon Jan 14 22:09:51 CET 2008

Forking this particular topic, as it involves more than vc1.

> > +          "m"(mm_rnd1), "m"(mm_rnd2), "m"(mm_shift)
> > > +    );
> > > +}
> > > +
> > > +static void vc1_inv_trans_8x8_mmx(DCTELEM block[64])
> > > +{
> > > +    transpose8x8_mmx(block);
> all initial permutations (here a transpose) MUST be merged into the
> scantable
> all other codecs do this too! vc1 wont become an exception

I understand that, yet not all codecs actually do it the same way.

ffmpeg has 2 methods for this:
- (mpegvideo) ff_init_table, idct_permutation_type and ScanTable stuff;
hardcoded to use 64 values
- (h264) explicit check for transform method, and if not c version,
loads zz scantable in a transposed way

Here's an snippet of the code for the second one:
    if(s->dsp.h264_idct_add == ff_h264_idct_add_c){ //FIXME little ugly
        memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));
        memcpy(h-> field_scan,  field_scan, 16*sizeof(uint8_t));
        for(i=0; i<16; i++){
#define T(x) (x>>2) | ((x<<2) & 0xF)
            h->zigzag_scan[i] = T(zigzag_scan[i]);
            h-> field_scan[i] = T( field_scan[i]);
#undef T

For such codec, it seems the mechanisms available with ScanTable are not

Either h264 way (2nd method) gets improved or the 1st method does.
Either way, it must allow specific optimizations, and address several
transforms at a time. An example would be that 4x4 transforms may not
need zz transpose while 8x8 needs it. h264 has 2 transforms, vc1 4.

If the 2nd method was extended, I would:
- use flags like ZZ_TRANSPOSE_H263_8X8, ZZ_TRANSPOSE_H264_8X8,
- indicate this with an additional value in the dsp context (could be
anywhere I guess, as dsp might not be exported), set by the dsp init

Although it is not future-proof, contradict the first method, I attached
a patch to clarify what I mean.

Once we have agreed on the shape the solution should take, then I'll
address the issue for h264 and, ultimately, vc1.

Best regards,
Christophe GISQUET
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zz-scantables-transpose.diff
Type: text/x-patch
Size: 4007 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080114/7d9c7b02/attachment.bin>

More information about the ffmpeg-devel mailing list