[FFmpeg-devel] [PATCH] 10-bit DNxHD support v4 review request

Michael Niedermayer michaelni at gmx.at
Thu Apr 7 13:16:42 CEST 2011


On Thu, Apr 07, 2011 at 08:56:31AM +0000, Joseph Artsimovich wrote:
> Baptiste Coudurier wrote:
[...]
> > >>> +static av_always_inline void dnxhd_10bit_get_pixels_8x8(DCTELEM
> > >>> +*restrict block, const uint16_t *pixels, int line_size) {
> > >>> +    for (int i = 0; i < 8; ++i) {
> > >>> +        for (int j = 0; j < 8; ++j) {
> > >>> +            block[j] = (DCTELEM)floor((float)pixels[j] * (1023.0f /
> > >>> +65535.0f) + 0.5f);
> > >>
> > >> Btw, why are you using floats here ?
> > > Hoping a compiler might vectorize this code.
> > 
> > We prefer using ints here, to avoid rounding difference on different archs.
> 
> I heard integer divison is quite expensive - more expensive than floating point multiplication + rounding.
> Note that we are dividing by (2^16 - 1) not by 2^16, so it can't be replaced by a shift.
> As for rounding, in the latest version of my patch I use lrintf().
> This article http://www.mega-nerd.com/FPcast/ led me to believe it's safe to assume it always rounds towards the nearest whole number.  Are there platforms where that's not the case?

use integers with:
(i*65473U + (1<<21))>>22
if you want it to be exactly what the float code does

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

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110407/6b89e669/attachment.asc>


More information about the ffmpeg-devel mailing list