mirror of https://github.com/FFmpeg/FFmpeg.git
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>pull/101/head
parent
33c827f632
commit
9a738c27dc
8 changed files with 389 additions and 55 deletions
@ -0,0 +1,35 @@ |
||||
/*
|
||||
* 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 AVCOENC_V210ENC_H |
||||
#define AVCOENC_V210ENC_H |
||||
|
||||
#include "libavutil/log.h" |
||||
#include "libavutil/opt.h" |
||||
#include "libavutil/pixfmt.h" |
||||
|
||||
typedef struct { |
||||
void (*pack_line_8)(const uint8_t *y, const uint8_t *u, |
||||
const uint8_t *v, uint8_t *dst, ptrdiff_t width); |
||||
void (*pack_line_10)(const uint16_t *y, const uint16_t *u, |
||||
const uint16_t *v, uint8_t *dst, ptrdiff_t width); |
||||
} V210EncContext; |
||||
|
||||
void ff_v210enc_init_x86(V210EncContext *s); |
||||
|
||||
#endif /* AVCOENC_V210ENC_H */ |
@ -0,0 +1,145 @@ |
||||
;****************************************************************************** |
||||
;* V210 SIMD pack |
||||
;* Copyright (c) 2014 Kieran Kunhya <kierank@obe.tv> |
||||
;* |
||||
;* 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_RODATA |
||||
|
||||
v210_enc_min_10: times 8 dw 0x4 |
||||
v210_enc_max_10: times 8 dw 0x3fb |
||||
|
||||
v210_enc_luma_mult_10: dw 4,1,16,4,1,16,0,0 |
||||
v210_enc_luma_shuf_10: db -1,0,1,-1,2,3,4,5,-1,6,7,-1,8,9,10,11 |
||||
|
||||
v210_enc_chroma_mult_10: dw 1,4,16,0,16,1,4,0 |
||||
v210_enc_chroma_shuf_10: db 0,1,8,9,-1,2,3,-1,10,11,4,5,-1,12,13,-1 |
||||
|
||||
v210_enc_min_8: times 16 db 0x1 |
||||
v210_enc_max_8: times 16 db 0xfe |
||||
|
||||
v210_enc_luma_shuf_8: db 6,-1,7,-1,8,-1,9,-1,10,-1,11,-1,-1,-1,-1,-1 |
||||
v210_enc_luma_mult_8: dw 16,4,64,16,4,64,0,0 |
||||
|
||||
v210_enc_chroma_shuf1_8: db 0,-1,1,-1,2,-1,3,-1,8,-1,9,-1,10,-1,11,-1 |
||||
v210_enc_chroma_shuf2_8: db 3,-1,4,-1,5,-1,7,-1,11,-1,12,-1,13,-1,15,-1 |
||||
|
||||
v210_enc_chroma_mult_8: dw 4,16,64,0,64,4,16,0 |
||||
|
||||
SECTION .text |
||||
|
||||
%macro v210_planar_pack_10 0 |
||||
|
||||
; v210_planar_pack_10(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width) |
||||
cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width |
||||
lea r0, [yq+2*widthq] |
||||
add uq, widthq |
||||
add vq, widthq |
||||
neg widthq |
||||
|
||||
mova m2, [v210_enc_min_10] |
||||
mova m3, [v210_enc_max_10] |
||||
|
||||
.loop |
||||
movu m0, [yq+2*widthq] |
||||
CLIPW m0, m2, m3 |
||||
|
||||
movq m1, [uq+widthq] |
||||
movhps m1, [vq+widthq] |
||||
CLIPW m1, m2, m3 |
||||
|
||||
pmullw m0, [v210_enc_luma_mult_10] |
||||
pshufb m0, [v210_enc_luma_shuf_10] |
||||
|
||||
pmullw m1, [v210_enc_chroma_mult_10] |
||||
pshufb m1, [v210_enc_chroma_shuf_10] |
||||
|
||||
por m0, m1 |
||||
|
||||
movu [dstq], m0 |
||||
|
||||
add dstq, mmsize |
||||
add widthq, 6 |
||||
jl .loop |
||||
|
||||
RET |
||||
%endmacro |
||||
|
||||
INIT_XMM ssse3 |
||||
v210_planar_pack_10 |
||||
|
||||
%macro v210_planar_pack_8 0 |
||||
|
||||
; v210_planar_pack_8(const uint8_t *y, const uint8_t *u, const uint8_t *v, uint8_t *dst, ptrdiff_t width) |
||||
cglobal v210_planar_pack_8, 5, 5, 7, y, u, v, dst, width |
||||
add yq, widthq |
||||
shr widthq, 1 |
||||
add uq, widthq |
||||
add vq, widthq |
||||
neg widthq |
||||
|
||||
mova m4, [v210_enc_min_8] |
||||
mova m5, [v210_enc_max_8] |
||||
pxor m6, m6 |
||||
|
||||
.loop |
||||
movu m1, [yq+2*widthq] |
||||
CLIPUB m1, m4, m5 |
||||
|
||||
punpcklbw m0, m1, m6 |
||||
; can't unpack high bytes in the same way because we process |
||||
; only six bytes at a time |
||||
pshufb m1, [v210_enc_luma_shuf_8] |
||||
|
||||
pmullw m0, [v210_enc_luma_mult_8] |
||||
pmullw m1, [v210_enc_luma_mult_8] |
||||
pshufb m0, [v210_enc_luma_shuf_10] |
||||
pshufb m1, [v210_enc_luma_shuf_10] |
||||
|
||||
movq m3, [uq+widthq] |
||||
movhps m3, [vq+widthq] |
||||
CLIPUB m3, m4, m5 |
||||
|
||||
; shuffle and multiply to get the same packing as in 10-bit |
||||
pshufb m2, m3, [v210_enc_chroma_shuf1_8] |
||||
pshufb m3, [v210_enc_chroma_shuf2_8] |
||||
|
||||
pmullw m2, [v210_enc_chroma_mult_8] |
||||
pmullw m3, [v210_enc_chroma_mult_8] |
||||
pshufb m2, [v210_enc_chroma_shuf_10] |
||||
pshufb m3, [v210_enc_chroma_shuf_10] |
||||
|
||||
por m0, m2 |
||||
por m1, m3 |
||||
|
||||
movu [dstq], m0 |
||||
movu [dstq+mmsize], m1 |
||||
|
||||
add dstq, 2*mmsize |
||||
add widthq, 6 |
||||
jl .loop |
||||
|
||||
RET |
||||
%endmacro |
||||
|
||||
INIT_XMM ssse3 |
||||
v210_planar_pack_8 |
||||
INIT_XMM avx |
||||
v210_planar_pack_8 |
@ -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 "libavutil/x86/cpu.h" |
||||
#include "libavcodec/v210enc.h" |
||||
|
||||
void ff_v210_planar_pack_8_ssse3(const uint8_t *y, const uint8_t *u, |
||||
const uint8_t *v, uint8_t *dst, |
||||
ptrdiff_t width); |
||||
void ff_v210_planar_pack_8_avx(const uint8_t *y, const uint8_t *u, |
||||
const uint8_t *v, uint8_t *dst, ptrdiff_t width); |
||||
void ff_v210_planar_pack_10_ssse3(const uint16_t *y, const uint16_t *u, |
||||
const uint16_t *v, uint8_t *dst, |
||||
ptrdiff_t width); |
||||
|
||||
av_cold void ff_v210enc_init_x86(V210EncContext *s) |
||||
{ |
||||
int cpu_flags = av_get_cpu_flags(); |
||||
|
||||
if (EXTERNAL_SSSE3(cpu_flags)) { |
||||
s->pack_line_8 = ff_v210_planar_pack_8_ssse3; |
||||
s->pack_line_10 = ff_v210_planar_pack_10_ssse3; |
||||
} |
||||
|
||||
if (EXTERNAL_AVX(cpu_flags)) |
||||
s->pack_line_8 = ff_v210_planar_pack_8_avx; |
||||
} |
@ -1,4 +1,4 @@ |
||||
054d7e903fb4d9e68700c56b93d45916 *tests/data/fate/vsynth1-v210.avi |
||||
a38de84bfef53ed69204480c979dd6c4 *tests/data/fate/vsynth1-v210.avi |
||||
14752448 tests/data/fate/vsynth1-v210.avi |
||||
50973792d3f1abe04a51ee0121f077f2 *tests/data/fate/vsynth1-v210.out.rawvideo |
||||
stddev: 1.85 PSNR: 42.78 MAXDIFF: 29 bytes: 7603200/ 7603200 |
||||
2ba7f4ca302f3c4147860b9dfb12b6e4 *tests/data/fate/vsynth1-v210.out.rawvideo |
||||
stddev: 1.84 PSNR: 42.81 MAXDIFF: 29 bytes: 7603200/ 7603200 |
||||
|
@ -1,4 +1,4 @@ |
||||
87bb634932b3f5cacd4d08142798db17 *tests/data/fate/vsynth2-v210.avi |
||||
3aae4d5b25a4d91e4812a297c6a9ef8a *tests/data/fate/vsynth2-v210.avi |
||||
14752448 tests/data/fate/vsynth2-v210.avi |
||||
8bb1c449e1a2a94fd0d98841c04246bb *tests/data/fate/vsynth2-v210.out.rawvideo |
||||
stddev: 0.39 PSNR: 56.17 MAXDIFF: 9 bytes: 7603200/ 7603200 |
||||
99e367a50da75c2c187230889bee8e2e *tests/data/fate/vsynth2-v210.out.rawvideo |
||||
stddev: 0.40 PSNR: 56.06 MAXDIFF: 9 bytes: 7603200/ 7603200 |
||||
|
Loading…
Reference in new issue