Example #1
0
        private static int getPadding(int isize, int ksize, int channels)
        {
            if (typeof(T) != typeof(float))
            {
                return(0);
            }

            int inc    = channels == 3 ? 4 : (ksize >= 8 ? HWIntrinsics.VectorCount <T>() : 4) / channels;
            int pad    = MathUtil.DivCeiling(ksize, inc) * inc - ksize;
            int thresh = channels == 4 ? 1 : HWIntrinsics.IsSupported || channels == 1 ? 2 : 3;

            return(ksize < thresh || ksize + pad > isize ? 0 : pad);
        }
            unsafe private static void convertFloat(byte *ipstart, byte *opstart, float *igtstart, int cb)
            {
                byte * ip = ipstart, ipe = ipstart + cb;
                float *op = (float *)opstart, igt = igtstart;

#if HWINTRINSICS
                if (Avx2.IsSupported && cb >= HWIntrinsics.VectorCount <byte>())
                {
                    convertFloatAvx2(ip, ipe, op, igt);
                }
                else
#endif
                convertFloatScalar(ip, ipe, op, igt);
            }