[FFmpeg-devel] [PATCH] H.264 predictive lossless: again

Michael Niedermayer michaelni
Sun Nov 30 17:31:14 CET 2008


On Sat, Nov 29, 2008 at 02:08:02PM -0800, Jason Garrett-Glaser wrote:
> > what i actually had in mind was that the new prediction function would just
> > do 1 subtract more and thus revert the effect of the existing prediction.
> > This actually should be less code.
> 
> Explain?
> 
> Do you mean "do normal prediction, then remove it later"?  

yes


> This seems
> wasteful

maybe, maybe not, it adds a few simple instructions and avoids a check and
branch.
In the same light your suggestion of zeroing a block, then reading the zeros,
adding the residual to it, reading it again to apply the righ/downprediction
is similarly doing things that arent needed.

Also being wastefull is relative, that is for lossy h264 and the old lossless
mode, the removed branch is always a win, while the extra prediction removial
is never executed, for the new lossless mode it may be a loss or a win
depending on what is faster and what modes are actually used / how branch
prediction likes the code ...

Iam definitly not asking you to change code to be slower, i rather think
it isnt slower

Also the add_pixels code could be replaced to do the down/right prediction
of the residual on top of the already predicted block, this would avoid
the prediction removal.


> and I don't see how it will work, as you'd have to repeat the
> prediction again to know exactly how much to subtract.

static void inline pred4x4_predictive_vertical_c(uint8_t *src, int stride){
    int i;
    int a= src[0-stride];
    int b= src[1-stride];
    int c= src[2-stride];
    int d= src[3-stride];
    for(i=0; i<3; i++){
        src+= stride;
        src[0]+= src[0-stride] - a;
        src[1]+= src[1-stride] - b;
        src[2]+= src[2-stride] - c;
        src[3]+= src[3-stride] - d;
    }
}

[note, above is ONLY for 4x4 and with SIMD should be very fast]

Anyway, in the end id like simple and fast code, no matter whos variant that
is ...

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- 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/20081130/a2b8b6f8/attachment.pgp>



More information about the ffmpeg-devel mailing list