DNxHD: make get_pixel_8x4_sym accept ptrdiff_t as stride
[libav.git] / libavcodec / x86 / dnxhdenc.c
CommitLineData
193ce3ab
BC
1/*
2 * VC3/DNxHD SIMD functions
3 * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
4 *
5 * VC-3 encoder funded by the British Broadcasting Corporation
6 *
2912e87a 7 * This file is part of Libav.
193ce3ab 8 *
2912e87a 9 * Libav is free software; you can redistribute it and/or
193ce3ab
BC
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
2912e87a 14 * Libav is distributed in the hope that it will be useful,
193ce3ab
BC
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
2912e87a 20 * License along with Libav; if not, write to the Free Software
193ce3ab
BC
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
c9f933b5 24#include "libavutil/attributes.h"
c318626c 25#include "libavutil/x86/asm.h"
6369ba3c 26#include "libavutil/x86/cpu.h"
193ce3ab
BC
27#include "libavcodec/dnxhdenc.h"
28
1169f0d0 29#if HAVE_SSE2_INLINE
8123e090 30
67685620 31static void get_pixels_8x4_sym_sse2(int16_t *block, const uint8_t *pixels, ptrdiff_t line_size)
193ce3ab
BC
32{
33 __asm__ volatile(
4f9d25dd 34 "pxor %%xmm5, %%xmm5 \n\t"
193ce3ab
BC
35 "movq (%0), %%xmm0 \n\t"
36 "add %2, %0 \n\t"
37 "movq (%0), %%xmm1 \n\t"
38 "movq (%0, %2), %%xmm2 \n\t"
39 "movq (%0, %2,2), %%xmm3 \n\t"
4f9d25dd
RP
40 "punpcklbw %%xmm5, %%xmm0 \n\t"
41 "punpcklbw %%xmm5, %%xmm1 \n\t"
42 "punpcklbw %%xmm5, %%xmm2 \n\t"
43 "punpcklbw %%xmm5, %%xmm3 \n\t"
193ce3ab
BC
44 "movdqa %%xmm0, (%1) \n\t"
45 "movdqa %%xmm1, 16(%1) \n\t"
46 "movdqa %%xmm2, 32(%1) \n\t"
47 "movdqa %%xmm3, 48(%1) \n\t"
48 "movdqa %%xmm3 , 64(%1) \n\t"
49 "movdqa %%xmm2 , 80(%1) \n\t"
50 "movdqa %%xmm1 , 96(%1) \n\t"
51 "movdqa %%xmm0, 112(%1) \n\t"
52 : "+r" (pixels)
53 : "r" (block), "r" ((x86_reg)line_size)
54 );
55}
56
1169f0d0 57#endif /* HAVE_SSE2_INLINE */
8123e090 58
c9f933b5 59av_cold void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx)
193ce3ab 60{
1169f0d0 61#if HAVE_SSE2_INLINE
6369ba3c 62 if (INLINE_SSE2(av_get_cpu_flags())) {
5ab21439
JA
63 if (ctx->cid_table->bit_depth == 8)
64 ctx->get_pixels_8x4_sym = get_pixels_8x4_sym_sse2;
193ce3ab 65 }
1169f0d0 66#endif /* HAVE_SSE2_INLINE */
193ce3ab 67}