[FFmpeg-devel] swscale : add bitexact conv for grayf32 and gray16 to f32 conv

Martin Vignali martin.vignali at gmail.com
Sun Sep 16 22:25:14 EEST 2018


> you can just use something like (possibly with more or less 0 or a
> magnitude
> related value)
> #define assert_stable_int(x) av_assert(llrintf(x+0.0001) ==
> llrintf(x-0.0001))
> #define assert_stable_float(x) av_assert((float)(x+0.000000000001) ==
> (float)(x-0.000000000001))
>
> and then place this where rounding happens, then you can see easily if
> any test gets close to problematic values. No need for special HW
>
> Hello,

Do you mean something like that ? (which raise the assert for 8b and 16
bits)

#define assert_stable_float(x)
av_assert0((float)(x+0.0000000000000000000000000001) ==
(float)(x-0.0000000000000000000000000001))

static void inline fill_uint_to_float_lut(SwsContext *c, int bitdepth) {
    static const double float_mult8 = 1.0 / 255.0;
    static const double float_mult16 = 1.0 / 65535.0;
    int i;
    double tmp;

    if (bitdepth == 8) { /*! fill uint8 to float lut */
        for (i = 0; i < 256; ++i){
            tmp = (double) i * float_mult8;
            assert_stable_float(tmp);
            c->uint2float_lut[i] = (float)tmp;
        }
    } else if (bitdepth == 16) { /*! fill uint16 to float lut */
        for (i = 0; i < 65536; ++i){
            tmp = (double) i * float_mult16;
            assert_stable_float(tmp);
            c->uint2float_lut[i] = (float)tmp;
        }
    } else { /*! unsupported bitdepth */
        av_assert0(0);
    }
}

Martin


More information about the ffmpeg-devel mailing list