mirror of https://github.com/FFmpeg/FFmpeg.git
Signed-off-by: Paul B Mahol <onemda@gmail.com>pull/154/head
parent
2f4374fae1
commit
35af7add6f
7 changed files with 299 additions and 26 deletions
@ -0,0 +1,82 @@ |
||||
/*
|
||||
* TAK decoder |
||||
* Copyright (c) 2015 Paul B Mahol |
||||
* |
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "libavutil/attributes.h" |
||||
#include "takdsp.h" |
||||
#include "config.h" |
||||
|
||||
static void decorrelate_ls(int32_t *p1, int32_t *p2, int length) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < length; i++) { |
||||
int32_t a = p1[i]; |
||||
int32_t b = p2[i]; |
||||
p2[i] = a + b; |
||||
} |
||||
} |
||||
|
||||
static void decorrelate_sr(int32_t *p1, int32_t *p2, int length) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < length; i++) { |
||||
int32_t a = p1[i]; |
||||
int32_t b = p2[i]; |
||||
p1[i] = b - a; |
||||
} |
||||
} |
||||
|
||||
static void decorrelate_sm(int32_t *p1, int32_t *p2, int length) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < length; i++) { |
||||
int32_t a = p1[i]; |
||||
int32_t b = p2[i]; |
||||
a -= b >> 1; |
||||
p1[i] = a; |
||||
p2[i] = a + b; |
||||
} |
||||
} |
||||
|
||||
static void decorrelate_sf(int32_t *p1, int32_t *p2, int length, int dshift, int dfactor) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < length; i++) { |
||||
int32_t a = p1[i]; |
||||
int32_t b = p2[i]; |
||||
b = dfactor * (b >> dshift) + 128 >> 8 << dshift; |
||||
p1[i] = b - a; |
||||
} |
||||
} |
||||
|
||||
av_cold void ff_takdsp_init(TAKDSPContext *c) |
||||
{ |
||||
c->decorrelate_ls = decorrelate_ls; |
||||
c->decorrelate_sr = decorrelate_sr; |
||||
c->decorrelate_sm = decorrelate_sm; |
||||
c->decorrelate_sf = decorrelate_sf; |
||||
|
||||
if (ARCH_X86) |
||||
ff_takdsp_init_x86(c); |
||||
} |
@ -0,0 +1,34 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#ifndef AVCODEC_TAKDSP_H |
||||
#define AVCODEC_TAKDSP_H |
||||
|
||||
#include <stdint.h> |
||||
|
||||
typedef struct TAKDSPContext { |
||||
void (*decorrelate_ls)(int32_t *p1, int32_t *p2, int length); |
||||
void (*decorrelate_sr)(int32_t *p1, int32_t *p2, int length); |
||||
void (*decorrelate_sm)(int32_t *p1, int32_t *p2, int length); |
||||
void (*decorrelate_sf)(int32_t *p1, int32_t *p2, int length, int dshift, int dfactor); |
||||
} TAKDSPContext; |
||||
|
||||
void ff_takdsp_init(TAKDSPContext *c); |
||||
void ff_takdsp_init_x86(TAKDSPContext *c); |
||||
|
||||
#endif /* AVCODEC_TAKDSP_H */ |
@ -0,0 +1,116 @@ |
||||
;****************************************************************************** |
||||
;* TAK DSP SIMD optimizations |
||||
;* |
||||
;* Copyright (C) 2015 Paul B Mahol |
||||
;* |
||||
;* This file is part of FFmpeg. |
||||
;* |
||||
;* FFmpeg 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. |
||||
;* |
||||
;* FFmpeg 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 FFmpeg; 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_RODATA |
||||
|
||||
pd_128: times 4 dd 128 |
||||
|
||||
SECTION .text |
||||
|
||||
INIT_XMM sse2 |
||||
cglobal tak_decorrelate_ls, 3, 3, 2, p1, p2, length |
||||
shl lengthd, 2 |
||||
add p1q, lengthq |
||||
add p2q, lengthq |
||||
neg lengthq |
||||
.loop: |
||||
mova m0, [p1q+lengthq+mmsize*0] |
||||
mova m1, [p1q+lengthq+mmsize*1] |
||||
paddd m0, [p2q+lengthq+mmsize*0] |
||||
paddd m1, [p2q+lengthq+mmsize*1] |
||||
mova [p2q+lengthq+mmsize*0], m0 |
||||
mova [p2q+lengthq+mmsize*1], m1 |
||||
add lengthq, mmsize*2 |
||||
jl .loop |
||||
REP_RET |
||||
|
||||
cglobal tak_decorrelate_sr, 3, 3, 2, p1, p2, length |
||||
shl lengthd, 2 |
||||
add p1q, lengthq |
||||
add p2q, lengthq |
||||
neg lengthq |
||||
|
||||
.loop: |
||||
mova m0, [p2q+lengthq+mmsize*0] |
||||
mova m1, [p2q+lengthq+mmsize*1] |
||||
psubd m0, [p1q+lengthq+mmsize*0] |
||||
psubd m1, [p1q+lengthq+mmsize*1] |
||||
mova [p1q+lengthq+mmsize*0], m0 |
||||
mova [p1q+lengthq+mmsize*1], m1 |
||||
add lengthq, mmsize*2 |
||||
jl .loop |
||||
REP_RET |
||||
|
||||
cglobal tak_decorrelate_sm, 3, 3, 6, p1, p2, length |
||||
shl lengthd, 2 |
||||
add p1q, lengthq |
||||
add p2q, lengthq |
||||
neg lengthq |
||||
|
||||
.loop: |
||||
mova m0, [p1q+lengthq] |
||||
mova m1, [p2q+lengthq] |
||||
mova m3, [p1q+lengthq+mmsize] |
||||
mova m4, [p2q+lengthq+mmsize] |
||||
mova m2, m1 |
||||
mova m5, m4 |
||||
psrld m2, 1 |
||||
psrld m5, 1 |
||||
psubd m0, m2 |
||||
psubd m3, m5 |
||||
paddd m1, m0 |
||||
paddd m4, m3 |
||||
mova [p1q+lengthq], m0 |
||||
mova [p2q+lengthq], m1 |
||||
mova [p1q+lengthq+mmsize], m3 |
||||
mova [p2q+lengthq+mmsize], m4 |
||||
add lengthq, mmsize*2 |
||||
jl .loop |
||||
REP_RET |
||||
|
||||
INIT_XMM sse4 |
||||
cglobal tak_decorrelate_sf, 3, 3, 5, p1, p2, length, dshift, dfactor |
||||
shl lengthd, 2 |
||||
add p1q, lengthq |
||||
add p2q, lengthq |
||||
neg lengthq |
||||
|
||||
movd m2, dshiftm |
||||
movd m3, dfactorm |
||||
pshufd m3, m3, 0 |
||||
mova m4, [pd_128] |
||||
|
||||
.loop: |
||||
mova m0, [p1q+lengthq] |
||||
mova m1, [p2q+lengthq] |
||||
psrld m1, m2 |
||||
pmulld m1, m3 |
||||
paddd m1, m4 |
||||
psrld m1, 8 |
||||
pslld m1, m2 |
||||
psubd m1, m0 |
||||
mova [p1q+lengthq], m1 |
||||
add lengthq, mmsize |
||||
jl .loop |
||||
REP_RET |
@ -0,0 +1,45 @@ |
||||
/*
|
||||
* Copyright (c) 2015 Paul B Mahol |
||||
* |
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg 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. |
||||
* |
||||
* FFmpeg 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 FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "libavcodec/takdsp.h" |
||||
#include "libavutil/x86/cpu.h" |
||||
#include "config.h" |
||||
|
||||
void ff_tak_decorrelate_ls_sse2(int32_t *p1, int32_t *p2, int length); |
||||
void ff_tak_decorrelate_sr_sse2(int32_t *p1, int32_t *p2, int length); |
||||
void ff_tak_decorrelate_sm_sse2(int32_t *p1, int32_t *p2, int length); |
||||
void ff_tak_decorrelate_sf_sse4(int32_t *p1, int32_t *p2, int length, int dshift, int dfactor); |
||||
|
||||
av_cold void ff_takdsp_init_x86(TAKDSPContext *c) |
||||
{ |
||||
#if HAVE_YASM |
||||
int cpu_flags = av_get_cpu_flags(); |
||||
|
||||
if (EXTERNAL_SSE2(cpu_flags)) { |
||||
c->decorrelate_ls = ff_tak_decorrelate_ls_sse2; |
||||
c->decorrelate_sr = ff_tak_decorrelate_sr_sse2; |
||||
c->decorrelate_sm = ff_tak_decorrelate_sm_sse2; |
||||
} |
||||
|
||||
if (EXTERNAL_SSE4(cpu_flags)) { |
||||
c->decorrelate_sf = ff_tak_decorrelate_sf_sse4; |
||||
} |
||||
#endif |
||||
} |
Loading…
Reference in new issue