mirror of https://github.com/FFmpeg/FFmpeg.git
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>pull/100/head
parent
1d3a3b9f89
commit
36091742d1
9 changed files with 381 additions and 50 deletions
@ -0,0 +1,33 @@ |
||||
/*
|
||||
* 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 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 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 |
||||
|
||||
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,37 @@ |
||||
/*
|
||||
* 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/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 @@ |
||||
895d30660eb4da017568141a8d1df4e8 *tests/data/fate/vsynth1-v210.avi |
||||
b066679e08cd90c342da21c88bec2a20 *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 @@ |
||||
6fbbcfee1832fe4c62aacb70454cff62 *tests/data/fate/vsynth2-v210.avi |
||||
fa1c4b1b8d0e9454b4bc2269c7fe634b *tests/data/fate/vsynth2-v210.avi |
||||
14752448 tests/data/fate/vsynth2-v210.avi |
||||
a627fb50c8276200fd71383977d87ca3 *tests/data/fate/vsynth2-v210.out.rawvideo |
||||
stddev: 0.34 PSNR: 57.43 MAXDIFF: 6 bytes: 7603200/ 7603200 |
||||
7ba6e411e43c6b57c95c49d6848f41e6 *tests/data/fate/vsynth2-v210.out.rawvideo |
||||
stddev: 0.34 PSNR: 57.41 MAXDIFF: 6 bytes: 7603200/ 7603200 |
||||
|
@ -1,4 +1,4 @@ |
||||
d2f5e07f0c0e917d80d63f39d683919e *tests/data/fate/vsynth3-v210.avi |
||||
6618ab86d047f4fb8fdd2d633888b20b *tests/data/fate/vsynth3-v210.avi |
||||
224448 tests/data/fate/vsynth3-v210.avi |
||||
0cf7cf68724fa5146b1667e4fa08b0e1 *tests/data/fate/vsynth3-v210.out.rawvideo |
||||
stddev: 2.12 PSNR: 41.58 MAXDIFF: 26 bytes: 86700/ 86700 |
||||
198ffb24c06927d8aaac5e59d81a0934 *tests/data/fate/vsynth3-v210.out.rawvideo |
||||
stddev: 2.11 PSNR: 41.61 MAXDIFF: 27 bytes: 86700/ 86700 |
||||
|
Loading…
Reference in new issue