dnxhdenc.c 2.36 KB
Newer Older
1 2 3 4 5 6
/*
 * VC3/DNxHD SIMD functions
 * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
 *
 * VC-3 encoder funded by the British Broadcasting Corporation
 *
7
 * This file is part of Libav.
8
 *
9
 * Libav is free software; you can redistribute it and/or
10 11 12 13
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
14
 * Libav is distributed in the hope that it will be useful,
15 16 17 18 19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
20
 * License along with Libav; if not, write to the Free Software
21 22 23
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

24
#include "libavutil/attributes.h"
25
#include "libavutil/x86/asm.h"
26
#include "libavutil/x86/cpu.h"
27 28
#include "libavcodec/dnxhdenc.h"

29
#if HAVE_SSE2_INLINE
30

Diego Biurrun's avatar
Diego Biurrun committed
31
static void get_pixels_8x4_sym_sse2(int16_t *block, const uint8_t *pixels, int line_size)
32 33
{
    __asm__ volatile(
34
        "pxor %%xmm5,      %%xmm5       \n\t"
35 36 37 38 39
        "movq (%0),        %%xmm0       \n\t"
        "add  %2,          %0           \n\t"
        "movq (%0),        %%xmm1       \n\t"
        "movq (%0, %2),    %%xmm2       \n\t"
        "movq (%0, %2,2),  %%xmm3       \n\t"
40 41 42 43
        "punpcklbw %%xmm5, %%xmm0       \n\t"
        "punpcklbw %%xmm5, %%xmm1       \n\t"
        "punpcklbw %%xmm5, %%xmm2       \n\t"
        "punpcklbw %%xmm5, %%xmm3       \n\t"
44 45 46 47 48 49 50 51 52 53 54 55 56
        "movdqa %%xmm0,      (%1)       \n\t"
        "movdqa %%xmm1,    16(%1)       \n\t"
        "movdqa %%xmm2,    32(%1)       \n\t"
        "movdqa %%xmm3,    48(%1)       \n\t"
        "movdqa %%xmm3 ,   64(%1)       \n\t"
        "movdqa %%xmm2 ,   80(%1)       \n\t"
        "movdqa %%xmm1 ,   96(%1)       \n\t"
        "movdqa %%xmm0,   112(%1)       \n\t"
        : "+r" (pixels)
        : "r" (block), "r" ((x86_reg)line_size)
    );
}

57
#endif /* HAVE_SSE2_INLINE */
58

59
av_cold void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx)
60
{
61
#if HAVE_SSE2_INLINE
62
    if (INLINE_SSE2(av_get_cpu_flags())) {
63 64
        if (ctx->cid_table->bit_depth == 8)
            ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2;
65
    }
66
#endif /* HAVE_SSE2_INLINE */
67
}