Example #1
0
Bool
rdpSimdInit(ScreenPtr pScreen, ScrnInfoPtr pScrn)
{
    rdpPtr dev;

    dev = XRDPPTR(pScrn);
    /* assign functions */
    LLOGLN(0, ("rdpSimdInit: assigning yuv functions"));
    dev->yv12_to_rgb32 = YV12_to_RGB32;
    dev->i420_to_rgb32 = I420_to_RGB32;
    dev->yuy2_to_rgb32 = YUY2_to_RGB32;
    dev->uyvy_to_rgb32 = UYVY_to_RGB32;
    dev->a8r8g8b8_to_a8b8g8r8_box = a8r8g8b8_to_a8b8g8r8_box;
#if SIMD_USE_ACCEL
    if (g_simd_use_accel)
    {
#if defined(__x86_64__) || defined(__AMD64__) || defined (_M_AMD64)
        int ax, bx, cx, dx;
        cpuid_amd64(1, 0, &ax, &bx, &cx, &dx);
        LLOGLN(0, ("rdpSimdInit: cpuid ax 1 cx 0 return ax 0x%8.8x bx "
                   "0x%8.8x cx 0x%8.8x dx 0x%8.8x", ax, bx, cx, dx));
        if (dx & (1 << 26)) /* SSE 2 */
        {
            dev->yv12_to_rgb32 = yv12_to_rgb32_amd64_sse2;
            dev->i420_to_rgb32 = i420_to_rgb32_amd64_sse2;
            dev->yuy2_to_rgb32 = yuy2_to_rgb32_amd64_sse2;
            dev->uyvy_to_rgb32 = uyvy_to_rgb32_amd64_sse2;
            dev->a8r8g8b8_to_a8b8g8r8_box = a8r8g8b8_to_a8b8g8r8_box_amd64_sse2;
            LLOGLN(0, ("rdpSimdInit: sse2 amd64 yuv functions assigned"));
        }
#elif defined(__x86__) || defined(_M_IX86) || defined(__i386__)
        int ax, bx, cx, dx;
        cpuid_x86(1, 0, &ax, &bx, &cx, &dx);
        LLOGLN(0, ("rdpSimdInit: cpuid ax 1 cx 0 return ax 0x%8.8x bx "
                   "0x%8.8x cx 0x%8.8x dx 0x%8.8x", ax, bx, cx, dx));
        if (dx & (1 << 26)) /* SSE 2 */
        {
            dev->yv12_to_rgb32 = yv12_to_rgb32_x86_sse2;
            dev->i420_to_rgb32 = i420_to_rgb32_x86_sse2;
            dev->yuy2_to_rgb32 = yuy2_to_rgb32_x86_sse2;
            dev->uyvy_to_rgb32 = uyvy_to_rgb32_x86_sse2;
            dev->a8r8g8b8_to_a8b8g8r8_box = a8r8g8b8_to_a8b8g8r8_box_x86_sse2;
            LLOGLN(0, ("rdpSimdInit: sse2 x86 yuv functions assigned"));
        }
#endif
    }
#endif
    return 1;
}
Example #2
0
int
rfxcodec_encode_create_ex(int width, int height, int format, int flags,
                          void **handle)
{
    struct rfxencode *enc;
    int ax;
    int bx;
    int cx;
    int dx;

    enc = (struct rfxencode *) calloc(1, sizeof(struct rfxencode));
    if (enc == NULL)
    {
        return 1;
    }

    enc->dwt_buffer = (sint16 *) (((size_t) (enc->dwt_buffer_a)) & ~15);
    enc->dwt_buffer1 = (sint16 *) (((size_t) (enc->dwt_buffer1_a)) & ~15);
    enc->dwt_buffer2 = (sint16 *) (((size_t) (enc->dwt_buffer2_a)) & ~15);

#if defined(RFX_USE_ACCEL_X86)
    cpuid_x86(1, 0, &ax, &bx, &cx, &dx);
#elif defined(RFX_USE_ACCEL_AMD64)
    cpuid_amd64(1, 0, &ax, &bx, &cx, &dx);
#else
    ax = 0;
    bx = 0;
    cx = 0;
    dx = 0;
#endif
    if (dx & (1 << 26)) /* SSE 2 */
    {
        printf("rfxcodec_encode_create: got sse2\n");
        enc->got_sse2 = 1;
    }
    if (cx & (1 << 0)) /* SSE 3 */
    {
        printf("rfxcodec_encode_create: got sse3\n");
        enc->got_sse3 = 1;
    }
    if (cx & (1 << 19)) /* SSE 4.1 */
    {
        printf("rfxcodec_encode_create: got sse4.1\n");
        enc->got_sse41 = 1;
    }
    if (cx & (1 << 20)) /* SSE 4.2 */
    {
        printf("rfxcodec_encode_create: got sse4.2\n");
        enc->got_sse42 = 1;
    }
    if (cx & (1 << 23)) /* popcnt */
    {
        printf("rfxcodec_encode_create: got popcnt\n");
        enc->got_popcnt = 1;
    }
#if defined(RFX_USE_ACCEL_X86)
    cpuid_x86(0x80000001, 0, &ax, &bx, &cx, &dx);
#elif defined(RFX_USE_ACCEL_AMD64)
    cpuid_amd64(0x80000001, 0, &ax, &bx, &cx, &dx);
#else
    ax = 0;
    bx = 0;
    cx = 0;
    dx = 0;
#endif
    if (cx & (1 << 5)) /* lzcnt */
    {
        printf("rfxcodec_encode_create: got lzcnt\n");
        enc->got_lzcnt = 1;
    }
    if (cx & (1 << 6)) /* SSE 4.a */
    {
        printf("rfxcodec_encode_create: got sse4.a\n");
        enc->got_sse4a = 1;
    }

    enc->width = width;
    enc->height = height;
    enc->mode = RLGR3;
    if (flags & RFX_FLAGS_RLGR1)
    {
        enc->mode = RLGR1;
    }
    switch (format)
    {
        case RFX_FORMAT_BGRA:
            enc->bits_per_pixel = 32;
            break;
        case RFX_FORMAT_RGBA:
            enc->bits_per_pixel = 32;
            break;
        case RFX_FORMAT_BGR:
            enc->bits_per_pixel = 24;
            break;
        case RFX_FORMAT_RGB:
            enc->bits_per_pixel = 24;
            break;
        case RFX_FORMAT_YUV:
            enc->bits_per_pixel = 32;
            break;
        default:
            free(enc);
            return 2;
    }
    enc->format = format;
    enc->rfx_encode_rgb_to_yuv = rfx_encode_rgb_to_yuv;
    enc->rfx_encode_argb_to_yuva = rfx_encode_argb_to_yuva;
    /* assign encoding functions */
    if (flags & RFX_FLAGS_NOACCEL)
    {
        if (enc->mode == RLGR3)
        {
            printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3\n");
            enc->rfx_encode = rfx_encode_component_rlgr3; /* rfxencode_tile.c */
        }
        else
        {
            printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1\n");
            enc->rfx_encode = rfx_encode_component_rlgr1; /* rfxencode_tile.c */
        }
    }
    else
    {
#if defined(RFX_USE_ACCEL_X86)
        if (enc->got_sse41)
        {
            if (enc->mode == RLGR3)
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3_x86_sse41\n");
                enc->rfx_encode = rfx_encode_component_rlgr3_x86_sse41; /* rfxencode_tile.c */
            }
            else
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1_x86_sse41\n");
                enc->rfx_encode = rfx_encode_component_rlgr1_x86_sse41; /* rfxencode_tile.c */
            }
        }
        else if (enc->got_sse2)
        {
            if (enc->mode == RLGR3)
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3_x86_sse2\n");
                enc->rfx_encode = rfx_encode_component_rlgr3_x86_sse2; /* rfxencode_tile.c */
            }
            else
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1_x86_sse2\n");
                enc->rfx_encode = rfx_encode_component_rlgr1_x86_sse2; /* rfxencode_tile.c */
            }
        }
        else
        {
            if (enc->mode == RLGR3)
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3\n");
                enc->rfx_encode = rfx_encode_component_rlgr3; /* rfxencode_tile.c */
            }
            else
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1\n");
                enc->rfx_encode = rfx_encode_component_rlgr1; /* rfxencode_tile.c */
            }
        }
#elif defined(RFX_USE_ACCEL_AMD64)
        if (enc->got_sse41)
        {
            if (enc->mode == RLGR3)
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3_amd64_sse41\n");
                enc->rfx_encode = rfx_encode_component_rlgr3_amd64_sse41; /* rfxencode_tile.c */
            }
            else
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1_amd64_sse41\n");
                enc->rfx_encode = rfx_encode_component_rlgr1_amd64_sse41; /* rfxencode_tile.c */
            }
        }
        else if (enc->got_sse2)
        {
            if (enc->mode == RLGR3)
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3_amd64_sse2\n");
                enc->rfx_encode = rfx_encode_component_rlgr3_amd64_sse2; /* rfxencode_tile.c */
            }
            else
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1_amd64_sse2\n");
                enc->rfx_encode = rfx_encode_component_rlgr1_amd64_sse2; /* rfxencode_tile.c */
            }
        }
        else
        {
            if (enc->mode == RLGR3)
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3\n");
                enc->rfx_encode = rfx_encode_component_rlgr3; /* rfxencode_tile.c */
            }
            else
            {
                printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1\n");
                enc->rfx_encode = rfx_encode_component_rlgr1; /* rfxencode_tile.c */
            }
        }
#else
        if (enc->mode == RLGR3)
        {
            printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr3\n");
            enc->rfx_encode = rfx_encode_component_rlgr3; /* rfxencode_tile.c */
        }
        else
        {
            printf("rfxcodec_encode_create: rfx_encode set to rfx_encode_component_rlgr1\n");
            enc->rfx_encode = rfx_encode_component_rlgr1; /* rfxencode_tile.c */
        }
#endif
    }
    if (ax == 0)
    {
    }
    if (bx == 0)
    {
    }
    *handle = enc;
    return 0;
}