mirror of https://github.com/FFmpeg/FFmpeg.git
parent
0569a7e0bd
commit
f46bb608d9
26 changed files with 621 additions and 386 deletions
@ -0,0 +1,76 @@ |
||||
/* |
||||
* Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
|
||||
* |
||||
* This file is part of Libav. |
||||
* |
||||
* Libav is free software; you can redistribute it and/or
|
||||
* 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. |
||||
* |
||||
* Libav is distributed in the hope that it will be useful, |
||||
* 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 |
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "libavutil/arm/asm.S" |
||||
|
||||
function ff_get_pixels_armv6, export=1 |
||||
pld [r1, r2] |
||||
push {r4-r8, lr} |
||||
mov lr, #8 |
||||
1: |
||||
ldrd_post r4, r5, r1, r2 |
||||
subs lr, lr, #1 |
||||
uxtb16 r6, r4 |
||||
uxtb16 r4, r4, ror #8 |
||||
uxtb16 r12, r5 |
||||
uxtb16 r8, r5, ror #8 |
||||
pld [r1, r2] |
||||
pkhbt r5, r6, r4, lsl #16 |
||||
pkhtb r6, r4, r6, asr #16 |
||||
pkhbt r7, r12, r8, lsl #16 |
||||
pkhtb r12, r8, r12, asr #16 |
||||
stm r0!, {r5,r6,r7,r12} |
||||
bgt 1b |
||||
|
||||
pop {r4-r8, pc} |
||||
endfunc |
||||
|
||||
function ff_diff_pixels_armv6, export=1 |
||||
pld [r1, r3] |
||||
pld [r2, r3] |
||||
push {r4-r9, lr} |
||||
mov lr, #8 |
||||
1: |
||||
ldrd_post r4, r5, r1, r3 |
||||
ldrd_post r6, r7, r2, r3 |
||||
uxtb16 r8, r4 |
||||
uxtb16 r4, r4, ror #8 |
||||
uxtb16 r9, r6 |
||||
uxtb16 r6, r6, ror #8 |
||||
pld [r1, r3] |
||||
ssub16 r9, r8, r9 |
||||
ssub16 r6, r4, r6 |
||||
uxtb16 r8, r5 |
||||
uxtb16 r5, r5, ror #8 |
||||
pld [r2, r3] |
||||
pkhbt r4, r9, r6, lsl #16 |
||||
pkhtb r6, r6, r9, asr #16 |
||||
uxtb16 r9, r7 |
||||
uxtb16 r7, r7, ror #8 |
||||
ssub16 r9, r8, r9 |
||||
ssub16 r5, r5, r7 |
||||
subs lr, lr, #1 |
||||
pkhbt r8, r9, r5, lsl #16 |
||||
pkhtb r9, r5, r9, asr #16 |
||||
stm r0!, {r4,r6,r8,r9} |
||||
bgt 1b |
||||
|
||||
pop {r4-r9, pc} |
||||
endfunc |
@ -0,0 +1,42 @@ |
||||
/*
|
||||
* This file is part of Libav. |
||||
* |
||||
* Libav is free software; you can redistribute it and/or |
||||
* 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. |
||||
* |
||||
* Libav is distributed in the hope that it will be useful, |
||||
* 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 |
||||
* License along with Libav; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include <stdint.h> |
||||
|
||||
#include "libavutil/attributes.h" |
||||
#include "libavutil/cpu.h" |
||||
#include "libavutil/arm/cpu.h" |
||||
#include "libavcodec/avcodec.h" |
||||
#include "libavcodec/pixblockdsp.h" |
||||
|
||||
void ff_get_pixels_armv6(int16_t *block, const uint8_t *pixels, int stride); |
||||
void ff_diff_pixels_armv6(int16_t *block, const uint8_t *s1, |
||||
const uint8_t *s2, int stride); |
||||
|
||||
av_cold void ff_pixblockdsp_init_arm(PixblockDSPContext *c, |
||||
AVCodecContext *avctx, |
||||
unsigned high_bit_depth) |
||||
{ |
||||
int cpu_flags = av_get_cpu_flags(); |
||||
|
||||
if (have_armv6(cpu_flags)) { |
||||
if (!high_bit_depth) |
||||
c->get_pixels = ff_get_pixels_armv6; |
||||
c->diff_pixels = ff_diff_pixels_armv6; |
||||
} |
||||
} |
@ -0,0 +1,76 @@ |
||||
/*
|
||||
* This file is part of Libav. |
||||
* |
||||
* Libav is free software; you can redistribute it and/or |
||||
* 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. |
||||
* |
||||
* Libav is distributed in the hope that it will be useful, |
||||
* 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 |
||||
* License along with Libav; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include <stdint.h> |
||||
|
||||
#include "config.h" |
||||
#include "libavutil/attributes.h" |
||||
#include "avcodec.h" |
||||
#include "pixblockdsp.h" |
||||
|
||||
#define BIT_DEPTH 16 |
||||
#include "pixblockdsp_template.c" |
||||
#undef BIT_DEPTH |
||||
|
||||
#define BIT_DEPTH 8 |
||||
#include "pixblockdsp_template.c" |
||||
|
||||
static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1, |
||||
const uint8_t *s2, int stride) |
||||
{ |
||||
int i; |
||||
|
||||
/* read the pixels */ |
||||
for (i = 0; i < 8; i++) { |
||||
block[0] = s1[0] - s2[0]; |
||||
block[1] = s1[1] - s2[1]; |
||||
block[2] = s1[2] - s2[2]; |
||||
block[3] = s1[3] - s2[3]; |
||||
block[4] = s1[4] - s2[4]; |
||||
block[5] = s1[5] - s2[5]; |
||||
block[6] = s1[6] - s2[6]; |
||||
block[7] = s1[7] - s2[7]; |
||||
s1 += stride; |
||||
s2 += stride; |
||||
block += 8; |
||||
} |
||||
} |
||||
|
||||
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx) |
||||
{ |
||||
const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; |
||||
|
||||
c->diff_pixels = diff_pixels_c; |
||||
|
||||
switch (avctx->bits_per_raw_sample) { |
||||
case 9: |
||||
case 10: |
||||
c->get_pixels = get_pixels_16_c; |
||||
break; |
||||
default: |
||||
c->get_pixels = get_pixels_8_c; |
||||
break; |
||||
} |
||||
|
||||
if (ARCH_ARM) |
||||
ff_pixblockdsp_init_arm(c, avctx, high_bit_depth); |
||||
if (ARCH_PPC) |
||||
ff_pixblockdsp_init_ppc(c, avctx, high_bit_depth); |
||||
if (ARCH_X86) |
||||
ff_pixblockdsp_init_x86(c, avctx, high_bit_depth); |
||||
} |
@ -0,0 +1,44 @@ |
||||
/*
|
||||
* This file is part of Libav. |
||||
* |
||||
* Libav is free software; you can redistribute it and/or |
||||
* 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. |
||||
* |
||||
* Libav is distributed in the hope that it will be useful, |
||||
* 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 |
||||
* License along with Libav; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#ifndef AVCODEC_PIXBLOCKDSP_H |
||||
#define AVCODEC_PIXBLOCKDSP_H |
||||
|
||||
#include <stdint.h> |
||||
|
||||
#include "avcodec.h" |
||||
|
||||
typedef struct PixblockDSPContext { |
||||
void (*get_pixels)(int16_t *block /* align 16 */, |
||||
const uint8_t *pixels /* align 8 */, |
||||
int line_size); |
||||
void (*diff_pixels)(int16_t *block /* align 16 */, |
||||
const uint8_t *s1 /* align 8 */, |
||||
const uint8_t *s2 /* align 8 */, |
||||
int stride); |
||||
} PixblockDSPContext; |
||||
|
||||
void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx); |
||||
void ff_pixblockdsp_init_arm(PixblockDSPContext *c, AVCodecContext *avctx, |
||||
unsigned high_bit_depth); |
||||
void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, AVCodecContext *avctx, |
||||
unsigned high_bit_depth); |
||||
void ff_pixblockdsp_init_x86(PixblockDSPContext *c, AVCodecContext *avctx, |
||||
unsigned high_bit_depth); |
||||
|
||||
#endif /* AVCODEC_PIXBLOCKDSP_H */ |
@ -0,0 +1,153 @@ |
||||
/*
|
||||
* Copyright (c) 2002 Brian Foley |
||||
* Copyright (c) 2002 Dieter Shirley |
||||
* Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org> |
||||
* |
||||
* This file is part of Libav. |
||||
* |
||||
* Libav is free software; you can redistribute it and/or |
||||
* 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. |
||||
* |
||||
* Libav is distributed in the hope that it will be useful, |
||||
* 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 |
||||
* License along with Libav; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "config.h" |
||||
#if HAVE_ALTIVEC_H |
||||
#include <altivec.h> |
||||
#endif |
||||
|
||||
#include "libavutil/attributes.h" |
||||
#include "libavutil/cpu.h" |
||||
#include "libavutil/ppc/cpu.h" |
||||
#include "libavutil/ppc/types_altivec.h" |
||||
#include "libavutil/ppc/util_altivec.h" |
||||
#include "libavcodec/avcodec.h" |
||||
#include "libavcodec/pixblockdsp.h" |
||||
|
||||
#if HAVE_ALTIVEC |
||||
|
||||
static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, |
||||
int line_size) |
||||
{ |
||||
int i; |
||||
vector unsigned char perm = vec_lvsl(0, pixels); |
||||
const vector unsigned char zero = |
||||
(const vector unsigned char) vec_splat_u8(0); |
||||
|
||||
for (i = 0; i < 8; i++) { |
||||
/* Read potentially unaligned pixels.
|
||||
* We're reading 16 pixels, and actually only want 8, |
||||
* but we simply ignore the extras. */ |
||||
vector unsigned char pixl = vec_ld(0, pixels); |
||||
vector unsigned char pixr = vec_ld(7, pixels); |
||||
vector unsigned char bytes = vec_perm(pixl, pixr, perm); |
||||
|
||||
// Convert the bytes into shorts.
|
||||
vector signed short shorts = (vector signed short) vec_mergeh(zero, |
||||
bytes); |
||||
|
||||
// Save the data to the block, we assume the block is 16-byte aligned.
|
||||
vec_st(shorts, i * 16, (vector signed short *) block); |
||||
|
||||
pixels += line_size; |
||||
} |
||||
} |
||||
|
||||
static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1, |
||||
const uint8_t *s2, int stride) |
||||
{ |
||||
int i; |
||||
vector unsigned char perm1 = vec_lvsl(0, s1); |
||||
vector unsigned char perm2 = vec_lvsl(0, s2); |
||||
const vector unsigned char zero = |
||||
(const vector unsigned char) vec_splat_u8(0); |
||||
vector signed short shorts1, shorts2; |
||||
|
||||
for (i = 0; i < 4; i++) { |
||||
/* Read potentially unaligned pixels.
|
||||
* We're reading 16 pixels, and actually only want 8, |
||||
* but we simply ignore the extras. */ |
||||
vector unsigned char pixl = vec_ld(0, s1); |
||||
vector unsigned char pixr = vec_ld(15, s1); |
||||
vector unsigned char bytes = vec_perm(pixl, pixr, perm1); |
||||
|
||||
// Convert the bytes into shorts.
|
||||
shorts1 = (vector signed short) vec_mergeh(zero, bytes); |
||||
|
||||
// Do the same for the second block of pixels.
|
||||
pixl = vec_ld(0, s2); |
||||
pixr = vec_ld(15, s2); |
||||
bytes = vec_perm(pixl, pixr, perm2); |
||||
|
||||
// Convert the bytes into shorts.
|
||||
shorts2 = (vector signed short) vec_mergeh(zero, bytes); |
||||
|
||||
// Do the subtraction.
|
||||
shorts1 = vec_sub(shorts1, shorts2); |
||||
|
||||
// Save the data to the block, we assume the block is 16-byte aligned.
|
||||
vec_st(shorts1, 0, (vector signed short *) block); |
||||
|
||||
s1 += stride; |
||||
s2 += stride; |
||||
block += 8; |
||||
|
||||
/* The code below is a copy of the code above...
|
||||
* This is a manual unroll. */ |
||||
|
||||
/* Read potentially unaligned pixels.
|
||||
* We're reading 16 pixels, and actually only want 8, |
||||
* but we simply ignore the extras. */ |
||||
pixl = vec_ld(0, s1); |
||||
pixr = vec_ld(15, s1); |
||||
bytes = vec_perm(pixl, pixr, perm1); |
||||
|
||||
// Convert the bytes into shorts.
|
||||
shorts1 = (vector signed short) vec_mergeh(zero, bytes); |
||||
|
||||
// Do the same for the second block of pixels.
|
||||
pixl = vec_ld(0, s2); |
||||
pixr = vec_ld(15, s2); |
||||
bytes = vec_perm(pixl, pixr, perm2); |
||||
|
||||
// Convert the bytes into shorts.
|
||||
shorts2 = (vector signed short) vec_mergeh(zero, bytes); |
||||
|
||||
// Do the subtraction.
|
||||
shorts1 = vec_sub(shorts1, shorts2); |
||||
|
||||
// Save the data to the block, we assume the block is 16-byte aligned.
|
||||
vec_st(shorts1, 0, (vector signed short *) block); |
||||
|
||||
s1 += stride; |
||||
s2 += stride; |
||||
block += 8; |
||||
} |
||||
} |
||||
|
||||
#endif /* HAVE_ALTIVEC */ |
||||
|
||||
av_cold void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, |
||||
AVCodecContext *avctx, |
||||
unsigned high_bit_depth) |
||||
{ |
||||
#if HAVE_ALTIVEC |
||||
if (!PPC_ALTIVEC(av_get_cpu_flags())) |
||||
return; |
||||
|
||||
c->diff_pixels = diff_pixels_altivec; |
||||
|
||||
if (!high_bit_depth) { |
||||
c->get_pixels = get_pixels_altivec; |
||||
} |
||||
#endif /* HAVE_ALTIVEC */ |
||||
} |
@ -0,0 +1,110 @@ |
||||
;***************************************************************************** |
||||
;* SIMD-optimized pixel operations |
||||
;***************************************************************************** |
||||
;* Copyright (c) 2000, 2001 Fabrice Bellard |
||||
;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> |
||||
;* |
||||
;* This file is part of Libav. |
||||
;* |
||||
;* Libav is free software; you can redistribute it and/or |
||||
;* 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. |
||||
;* |
||||
;* Libav is distributed in the hope that it will be useful, |
||||
;* 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 |
||||
;* License along with Libav; if not, write to the Free Software |
||||
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
;***************************************************************************** |
||||
|
||||
%include "libavutil/x86/x86util.asm" |
||||
|
||||
SECTION .text |
||||
|
||||
INIT_MMX mmx |
||||
; void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size) |
||||
cglobal get_pixels, 3,4 |
||||
movsxdifnidn r2, r2d |
||||
add r0, 128 |
||||
mov r3, -128 |
||||
pxor m7, m7 |
||||
.loop: |
||||
mova m0, [r1] |
||||
mova m2, [r1+r2] |
||||
mova m1, m0 |
||||
mova m3, m2 |
||||
punpcklbw m0, m7 |
||||
punpckhbw m1, m7 |
||||
punpcklbw m2, m7 |
||||
punpckhbw m3, m7 |
||||
mova [r0+r3+ 0], m0 |
||||
mova [r0+r3+ 8], m1 |
||||
mova [r0+r3+16], m2 |
||||
mova [r0+r3+24], m3 |
||||
lea r1, [r1+r2*2] |
||||
add r3, 32 |
||||
js .loop |
||||
REP_RET |
||||
|
||||
INIT_XMM sse2 |
||||
cglobal get_pixels, 3, 4 |
||||
movsxdifnidn r2, r2d |
||||
lea r3, [r2*3] |
||||
pxor m4, m4 |
||||
movh m0, [r1] |
||||
movh m1, [r1+r2] |
||||
movh m2, [r1+r2*2] |
||||
movh m3, [r1+r3] |
||||
lea r1, [r1+r2*4] |
||||
punpcklbw m0, m4 |
||||
punpcklbw m1, m4 |
||||
punpcklbw m2, m4 |
||||
punpcklbw m3, m4 |
||||
mova [r0], m0 |
||||
mova [r0+0x10], m1 |
||||
mova [r0+0x20], m2 |
||||
mova [r0+0x30], m3 |
||||
movh m0, [r1] |
||||
movh m1, [r1+r2*1] |
||||
movh m2, [r1+r2*2] |
||||
movh m3, [r1+r3] |
||||
punpcklbw m0, m4 |
||||
punpcklbw m1, m4 |
||||
punpcklbw m2, m4 |
||||
punpcklbw m3, m4 |
||||
mova [r0+0x40], m0 |
||||
mova [r0+0x50], m1 |
||||
mova [r0+0x60], m2 |
||||
mova [r0+0x70], m3 |
||||
RET |
||||
|
||||
INIT_MMX mmx |
||||
; void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, |
||||
; int stride); |
||||
cglobal diff_pixels, 4,5 |
||||
movsxdifnidn r3, r3d |
||||
pxor m7, m7 |
||||
add r0, 128 |
||||
mov r4, -128 |
||||
.loop: |
||||
mova m0, [r1] |
||||
mova m2, [r2] |
||||
mova m1, m0 |
||||
mova m3, m2 |
||||
punpcklbw m0, m7 |
||||
punpckhbw m1, m7 |
||||
punpcklbw m2, m7 |
||||
punpckhbw m3, m7 |
||||
psubw m0, m2 |
||||
psubw m1, m3 |
||||
mova [r0+r4+0], m0 |
||||
mova [r0+r4+8], m1 |
||||
add r1, r3 |
||||
add r2, r3 |
||||
add r4, 16 |
||||
jne .loop |
||||
REP_RET |
@ -0,0 +1,47 @@ |
||||
/*
|
||||
* SIMD-optimized pixel operations |
||||
* |
||||
* This file is part of Libav. |
||||
* |
||||
* Libav is free software; you can redistribute it and/or |
||||
* 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. |
||||
* |
||||
* Libav is distributed in the hope that it will be useful, |
||||
* 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 |
||||
* License along with Libav; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "libavutil/attributes.h" |
||||
#include "libavutil/cpu.h" |
||||
#include "libavutil/x86/cpu.h" |
||||
#include "libavcodec/pixblockdsp.h" |
||||
|
||||
void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size); |
||||
void ff_get_pixels_sse2(int16_t *block, const uint8_t *pixels, int line_size); |
||||
void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, |
||||
int stride); |
||||
|
||||
av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c, |
||||
AVCodecContext *avctx, |
||||
unsigned high_bit_depth) |
||||
{ |
||||
int cpu_flags = av_get_cpu_flags(); |
||||
|
||||
if (EXTERNAL_MMX(cpu_flags)) { |
||||
if (!high_bit_depth) |
||||
c->get_pixels = ff_get_pixels_mmx; |
||||
c->diff_pixels = ff_diff_pixels_mmx; |
||||
} |
||||
|
||||
if (EXTERNAL_SSE2(cpu_flags)) { |
||||
if (!high_bit_depth) |
||||
c->get_pixels = ff_get_pixels_sse2; |
||||
} |
||||
} |
Loading…
Reference in new issue