Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From debb3a32b06adfb52b1a57ed3a3947622fd812f0 Mon Sep 17 00:00:00 2001
- From: Daniel Kang <daniel.d.kang@gmail.com>
- Date: Mon, 16 May 2011 19:12:01 -0400
- Subject: [PATCH 1/2] Add h264_idct_10.asm
- Adds h264_idct_add_10_(sse2|avx) and changes the way H.264 iDCT fucntion headers are declared.
- Code ported from x264.
- ---
- libavcodec/x86/Makefile | 1 +
- libavcodec/x86/h264_idct.asm | 4 +-
- libavcodec/x86/h264_idct_10bit.asm | 145 ++++++++++++++++++++++++++++++++++++
- libavcodec/x86/h264dsp_mmx.c | 38 +++++++++-
- 4 files changed, 182 insertions(+), 6 deletions(-)
- create mode 100755 libavcodec/x86/h264_idct_10bit.asm
- diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
- index 1cde951..4a8474a 100644
- --- a/libavcodec/x86/Makefile
- +++ b/libavcodec/x86/Makefile
- @@ -12,6 +12,7 @@ YASM-OBJS-$(CONFIG_H264DSP) += x86/h264_deblock.o \
- x86/h264_deblock_10bit.o \
- x86/h264_weight.o \
- x86/h264_idct.o \
- + x86/h264_idct_10bit.o \
- YASM-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred.o
- MMX-OBJS-$(CONFIG_H264PRED) += x86/h264_intrapred_init.o
- diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm
- index ae70a30..b5d7c1e 100644
- --- a/libavcodec/x86/h264_idct.asm
- +++ b/libavcodec/x86/h264_idct.asm
- @@ -73,7 +73,7 @@ SECTION .text
- INIT_MMX
- ; ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride)
- -cglobal h264_idct_add_mmx, 3, 3, 0
- +cglobal h264_idct_add_8_mmx, 3, 3, 0
- IDCT4_ADD r0, r1, r2
- RET
- @@ -297,7 +297,7 @@ cglobal h264_idct8_dc_add_mmx2, 3, 3, 0
- ; ff_h264_idct_add16_mmx(uint8_t *dst, const int *block_offset,
- ; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
- -cglobal h264_idct_add16_mmx, 5, 7, 0
- +cglobal h264_idct_add16_8_mmx, 5, 7, 0
- xor r5, r5
- %ifdef PIC
- lea r11, [scan8_mem]
- diff --git a/libavcodec/x86/h264_idct_10bit.asm b/libavcodec/x86/h264_idct_10bit.asm
- new file mode 100755
- index 0000000..fbd4bf7
- --- /dev/null
- +++ b/libavcodec/x86/h264_idct_10bit.asm
- @@ -0,0 +1,145 @@
- +;*****************************************************************************
- +;* MMX/SSE2/AVX-optimized 10-bit H.264 iDCT code
- +;*****************************************************************************
- +;* Copyright (C) 2005-2011 x264 project
- +;*
- +;* Authors: Daniel Kang <daniel.d.kang@gmail.com>
- +;* Oskar Arvidsson <oskar@irock.se>
- +;*
- +;* 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 "x86inc.asm"
- +%include "x86util.asm"
- +
- +SECTION_RODATA
- +
- +pw_pixel_max: times 8 dw ((1 << 10)-1)
- +pd_32: times 4 dd 32
- +scan8_mem: db 4+1*8, 5+1*8, 4+2*8, 5+2*8
- + db 6+1*8, 7+1*8, 6+2*8, 7+2*8
- + db 4+3*8, 5+3*8, 4+4*8, 5+4*8
- + db 6+3*8, 7+3*8, 6+4*8, 7+4*8
- + db 1+1*8, 2+1*8
- + db 1+2*8, 2+2*8
- + db 1+4*8, 2+4*8
- + db 1+5*8, 2+5*8
- +
- +%ifdef PIC
- +%define scan8 r11
- +%else
- +%define scan8 scan8_mem
- +%endif
- +
- +SECTION .text
- +
- +;-----------------------------------------------------------------------------
- +; void h264_idct_add(pixel *dst, dctcoef *block, int stride)
- +;-----------------------------------------------------------------------------
- +%macro STORE_DIFFx2 6
- + psrad %1, 6
- + psrad %2, 6
- + packssdw %1, %2
- + movq %3, %5
- + movhps %3, %6
- + paddsw %1, %3
- + CLIPW %1, %4, [pw_pixel_max]
- + movq %5, %1
- + movhps %6, %1
- +%endmacro
- +
- +;dst, in, stride
- +%macro IDCT4_ADD_10 3
- + mova m1, [%2+16]
- + mova m3, [%2+48]
- + mova m2, [%2+32]
- + mova m0, [%2+ 0]
- + IDCT4_1D d,0,1,2,3,4,5
- + TRANSPOSE4x4D 0,1,2,3,4
- + paddd m0, [pd_32]
- + IDCT4_1D d,0,1,2,3,4,5
- + pxor m5, m5
- + STORE_DIFFx2 m0, m1, m4, m5, [%1], [%1+%3]
- + lea %1, [%1+%3*2]
- + STORE_DIFFx2 m2, m3, m4, m5, [%1], [%1+%3]
- +%endmacro
- +
- +%macro IDCT_ADD_10 1
- +cglobal h264_idct_add_10_%1, 3,3
- + IDCT4_ADD_10 r0, r1, r2
- + RET
- +%endmacro
- +
- +INIT_XMM
- +IDCT_ADD_10 sse2
- +%ifdef HAVE_AVX
- +INIT_AVX
- +IDCT_ADD_10 avx
- +%endif
- +
- +;-----------------------------------------------------------------------------
- +; h264_idct_add16(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
- +;-----------------------------------------------------------------------------
- +%macro IDCT_ADD16_10 1
- +cglobal h264_idct_add16_10_%1, 5,7
- + xor r5, r5
- +%ifdef PIC
- + lea r11, [scan8_mem]
- +%endif
- +.nextblock
- + movzx r6, byte [scan8+r5]
- + movzx r6, byte [r4+r6]
- + test r6, r6
- + jz .skipblock
- + mov r6d, dword [r1+r5*4]
- + lea r6, [r0+r6]
- + IDCT4_ADD_10 r6, r2, r3
- +.skipblock
- + inc r5
- + add r2, 64
- + cmp r5, 16
- + jl .nextblock
- + REP_RET
- +%endmacro
- +
- +INIT_XMM
- +IDCT_ADD16_10 sse2
- +%ifdef HAVE_AVX
- +INIT_AVX
- +IDCT_ADD16_10 avx
- +%endif
- +
- +cglobal h264_idct_add16intra_10_sse2, 5,7
- + xor r5, r5
- +%ifdef PIC
- + lea r11, [scan8_mem]
- +%endif
- +.nextblock
- + movzx r6, byte [scan8+r5]
- + movzx r6, byte [r4+r6]
- + or r6w, word [r2]
- + test r6, r6
- + jz .skipblock
- + mov r6d, dword [r1+r5*4]
- + lea r6, [r0+r6]
- + IDCT4_ADD_10 r6, r2, r3
- +.skipblock
- + inc r5
- + add r2, 64
- + cmp r5, 16
- + jl .nextblock
- + REP_RET
- diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c
- index 1c07d14..d77299d 100644
- --- a/libavcodec/x86/h264dsp_mmx.c
- +++ b/libavcodec/x86/h264dsp_mmx.c
- @@ -27,15 +27,31 @@ DECLARE_ALIGNED(8, static const uint64_t, ff_pb_3_1 ) = 0x0103010301030103ULL;
- /***********************************/
- /* IDCT */
- +#define IDCT_ADD_FUNC(NUM, DEPTH, OPT) \
- +void ff_h264_idct ## NUM ## _add_ ## DEPTH ## _ ## OPT (uint8_t *dst, int16_t *block, int stride);
- -void ff_h264_idct_add_mmx (uint8_t *dst, int16_t *block, int stride);
- +IDCT_ADD_FUNC(, 8, mmx)
- +IDCT_ADD_FUNC(, 10, sse2)
- +#if HAVE_AVX
- +IDCT_ADD_FUNC(, 10, avx)
- +#endif
- void ff_h264_idct8_add_mmx (uint8_t *dst, int16_t *block, int stride);
- void ff_h264_idct8_add_sse2 (uint8_t *dst, int16_t *block, int stride);
- void ff_h264_idct_dc_add_mmx2 (uint8_t *dst, int16_t *block, int stride);
- void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride);
- -void ff_h264_idct_add16_mmx (uint8_t *dst, const int *block_offset,
- +
- +#define IDCT_ADD_REP_FUNC(NUM, REP, DEPTH, OPT) \
- +void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
- + (uint8_t *dst, const int *block_offset, \
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- +
- +
- +IDCT_ADD_REP_FUNC(, 16, 8, mmx)
- +IDCT_ADD_REP_FUNC(, 16, 10, sse2)
- +#if HAVE_AVX
- +IDCT_ADD_REP_FUNC(, 16, 10, avx)
- +#endif
- void ff_h264_idct8_add4_mmx (uint8_t *dst, const int *block_offset,
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- void ff_h264_idct_add16_mmx2 (uint8_t *dst, const int *block_offset,
- @@ -44,6 +60,8 @@ void ff_h264_idct_add16intra_mmx (uint8_t *dst, const int *block_offset,
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- +void ff_h264_idct_add16intra_10_sse2(uint8_t *dst, const int *block_offset,
- + DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- void ff_h264_idct8_add4_mmx2 (uint8_t *dst, const int *block_offset,
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- void ff_h264_idct8_add4_sse2 (uint8_t *dst, const int *block_offset,
- @@ -314,11 +332,11 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
- #if HAVE_YASM
- if (mm_flags & AV_CPU_FLAG_MMX) {
- c->h264_idct_dc_add=
- - c->h264_idct_add= ff_h264_idct_add_mmx;
- + c->h264_idct_add= ff_h264_idct_add_8_mmx;
- c->h264_idct8_dc_add=
- c->h264_idct8_add= ff_h264_idct8_add_mmx;
- - c->h264_idct_add16 = ff_h264_idct_add16_mmx;
- + c->h264_idct_add16 = ff_h264_idct_add16_8_mmx;
- c->h264_idct8_add4 = ff_h264_idct8_add4_mmx;
- c->h264_idct_add8 = ff_h264_idct_add8_mmx;
- c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx;
- @@ -419,6 +437,12 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_mmxext;
- #endif
- if (mm_flags&AV_CPU_FLAG_SSE2) {
- + c->h264_idct_dc_add=
- + c->h264_idct_add= ff_h264_idct_add_10_sse2;
- +
- + c->h264_idct_add16 = ff_h264_idct_add16_10_sse2;
- + c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2;
- +
- c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_sse2;
- c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_sse2;
- #if HAVE_ALIGNED_STACK
- @@ -428,7 +452,12 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_sse2;
- #endif
- }
- +#if HAVE_AVX
- if (mm_flags&AV_CPU_FLAG_AVX) {
- + c->h264_idct_dc_add=
- + c->h264_idct_add= ff_h264_idct_add_10_avx;
- + c->h264_idct_add16 = ff_h264_idct_add16_10_avx;
- +
- c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_avx;
- c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_avx;
- #if HAVE_ALIGNED_STACK
- @@ -438,6 +467,7 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_avx;
- #endif
- }
- +#endif
- }
- }
- #endif
- --
- 1.7.4
- From 49e3c15a378b1691d0c85e10ab115007c261f0a9 Mon Sep 17 00:00:00 2001
- From: Daniel Kang <daniel.d.kang@gmail.com>
- Date: Tue, 17 May 2011 21:26:30 -0400
- Subject: [PATCH 2/2] WIP patch
- ---
- libavcodec/x86/h264_idct.asm | 14 ++--
- libavcodec/x86/h264_idct_10bit.asm | 132 +++++++++++++++++++++++++++++++----
- libavcodec/x86/h264dsp_mmx.c | 58 +++++++++-------
- 3 files changed, 158 insertions(+), 46 deletions(-)
- diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm
- index b5d7c1e..1dc7963 100644
- --- a/libavcodec/x86/h264_idct.asm
- +++ b/libavcodec/x86/h264_idct.asm
- @@ -261,7 +261,7 @@ cglobal h264_idct8_add_sse2, 3, 4, 10
- packuswb m1, m1
- %endmacro
- -%macro DC_ADD_MMX2_OP 3-4
- +%macro DC_ADD_MMX2_OP 4
- %1 m2, [%2 ]
- %1 m3, [%2+%3 ]
- %1 m4, [%2+%3*2]
- @@ -282,7 +282,7 @@ cglobal h264_idct8_add_sse2, 3, 4, 10
- INIT_MMX
- ; ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
- -cglobal h264_idct_dc_add_mmx2, 3, 3, 0
- +cglobal h264_idct_dc_add_8_mmx2, 3, 3, 0
- DC_ADD_MMX2_INIT r1, r2
- DC_ADD_MMX2_OP movh, r0, r2, r1
- RET
- @@ -398,7 +398,7 @@ cglobal h264_idct_add16_mmx2, 5, 7, 0
- ; ff_h264_idct_add16intra_mmx(uint8_t *dst, const int *block_offset,
- ; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
- -cglobal h264_idct_add16intra_mmx, 5, 7, 0
- +cglobal h264_idct_add16intra_8_mmx, 5, 7, 0
- xor r5, r5
- %ifdef PIC
- lea r11, [scan8_mem]
- @@ -421,7 +421,7 @@ cglobal h264_idct_add16intra_mmx, 5, 7, 0
- ; ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
- ; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
- -cglobal h264_idct_add16intra_mmx2, 5, 7, 0
- +cglobal h264_idct_add16intra_8_mmx2, 5, 7, 0
- xor r5, r5
- %ifdef PIC
- lea r11, [scan8_mem]
- @@ -607,7 +607,7 @@ h264_idct_add8_mmx_plane:
- ; ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset,
- ; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
- -cglobal h264_idct_add8_mmx, 5, 7, 0
- +cglobal h264_idct_add8_8_mmx, 5, 7, 0
- mov r5, 16
- add r2, 512
- %ifdef PIC
- @@ -668,7 +668,7 @@ h264_idct_add8_mmx2_plane
- ; ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset,
- ; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
- -cglobal h264_idct_add8_mmx2, 5, 7, 0
- +cglobal h264_idct_add8_8_mmx2, 5, 7, 0
- mov r5, 16
- add r2, 512
- %ifdef ARCH_X86_64
- @@ -791,7 +791,7 @@ cglobal h264_idct_add16_sse2, 5, 5, 8
- ; ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset,
- ; DCTELEM *block, int stride, const uint8_t nnzc[6*8])
- -cglobal h264_idct_add16intra_sse2, 5, 7, 8
- +cglobal h264_idct_add16intra_8_sse2, 5, 7, 8
- %ifdef ARCH_X86_64
- mov r10, r0
- %endif
- diff --git a/libavcodec/x86/h264_idct_10bit.asm b/libavcodec/x86/h264_idct_10bit.asm
- index fbd4bf7..d4cfa6b 100755
- --- a/libavcodec/x86/h264_idct_10bit.asm
- +++ b/libavcodec/x86/h264_idct_10bit.asm
- @@ -51,33 +51,34 @@ SECTION .text
- ; void h264_idct_add(pixel *dst, dctcoef *block, int stride)
- ;-----------------------------------------------------------------------------
- %macro STORE_DIFFx2 6
- - psrad %1, 6
- - psrad %2, 6
- - packssdw %1, %2
- - movq %3, %5
- - movhps %3, %6
- - paddsw %1, %3
- - CLIPW %1, %4, [pw_pixel_max]
- - movq %5, %1
- - movhps %6, %1
- + psrad %1, 6
- + psrad %2, 6
- + packssdw %1, %2
- + movq %3, [%5]
- + movhps %3, [%5+%6]
- + paddsw %1, %3
- + CLIPW %1, %4, [pw_pixel_max]
- + movq [%5], %1
- + movhps [%5+%6], %1
- %endmacro
- ;dst, in, stride
- %macro IDCT4_ADD_10 3
- + mova m0, [%2+ 0]
- mova m1, [%2+16]
- - mova m3, [%2+48]
- mova m2, [%2+32]
- - mova m0, [%2+ 0]
- + mova m3, [%2+48]
- IDCT4_1D d,0,1,2,3,4,5
- TRANSPOSE4x4D 0,1,2,3,4
- paddd m0, [pd_32]
- IDCT4_1D d,0,1,2,3,4,5
- pxor m5, m5
- - STORE_DIFFx2 m0, m1, m4, m5, [%1], [%1+%3]
- + STORE_DIFFx2 m0, m1, m4, m5, %1, %3
- lea %1, [%1+%3*2]
- - STORE_DIFFx2 m2, m3, m4, m5, [%1], [%1+%3]
- + STORE_DIFFx2 m2, m3, m4, m5, %1, %3
- %endmacro
- +;;;;;;;;;; ACTUALLY WORKING
- %macro IDCT_ADD_10 1
- cglobal h264_idct_add_10_%1, 3,3
- IDCT4_ADD_10 r0, r1, r2
- @@ -94,6 +95,8 @@ IDCT_ADD_10 avx
- ;-----------------------------------------------------------------------------
- ; h264_idct_add16(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
- ;-----------------------------------------------------------------------------
- +
- +;;;;;;; NO FATE SAMPLES TRIGGER THIS UNTESTED
- %macro IDCT_ADD16_10 1
- cglobal h264_idct_add16_10_%1, 5,7
- xor r5, r5
- @@ -123,7 +126,10 @@ INIT_AVX
- IDCT_ADD16_10 avx
- %endif
- -cglobal h264_idct_add16intra_10_sse2, 5,7
- +
- +;;;;; CURRENTLY DOES NOT WORK DO NOT KNOW WHY
- +%macro IDCT_ADD16INTRA_10 1
- +cglobal h264_idct_add16intra_10_%1,5,7
- xor r5, r5
- %ifdef PIC
- lea r11, [scan8_mem]
- @@ -131,7 +137,7 @@ cglobal h264_idct_add16intra_10_sse2, 5,7
- .nextblock
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- - or r6w, word [r2]
- + or r6d, dword [r2]
- test r6, r6
- jz .skipblock
- mov r6d, dword [r1+r5*4]
- @@ -143,3 +149,99 @@ cglobal h264_idct_add16intra_10_sse2, 5,7
- cmp r5, 16
- jl .nextblock
- REP_RET
- +%endmacro
- +
- +INIT_XMM
- +IDCT_ADD16INTRA_10 sse2
- +%ifdef HAVE_AVX
- +INIT_AVX
- +IDCT_ADD16INTRA_10 avx
- +%endif
- +
- +
- +;-----------------------------------------------------------------------------
- +; h264_idct_add8(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
- +;-----------------------------------------------------------------------------
- +
- +;;;;;;; WORKING
- +%macro IDCT_ADD8 1
- +h264_idct_add8_10_%1_plane:
- +.nextblock
- + movzx r6, byte [scan8+r5]
- + movzx r6, byte [r4+r6]
- + or r6d, dword [r2]
- + test r6, r6
- + jz .skipblock
- +%ifdef ARCH_X86_64
- + mov r0d, dword [r1+r5*4]
- + add r0, [r10]
- +%else
- + mov r0, r1m ; XXX r1m here is actually r0m of the calling func
- + mov r0, [r0]
- + add r0, dword [r1+r5*4]
- +%endif
- + IDCT4_ADD_10 r0, r2, r3
- +.skipblock
- + inc r5
- + add r2, 64
- + test r5, 3
- + jnz .nextblock
- + rep ret
- +
- +cglobal h264_idct_add8_10_%1,5,7,0
- + mov r5, 16
- + add r2, 512*2
- +%ifdef PIC
- + lea r11, [scan8_mem]
- +%endif
- +%ifdef ARCH_X86_64
- + mov r10, r0
- +%endif
- + call h264_idct_add8_10_sse2_plane
- +%ifdef ARCH_X86_64
- + add r10, gprsize
- +%else
- + add r0mp, gprsize
- +%endif
- + call h264_idct_add8_10_sse2_plane
- + RET
- +%endmacro ; IDCT_ADD8
- +
- +INIT_XMM
- +IDCT_ADD8 sse2
- +%ifdef HAVE_AVX
- +INIT_AVX
- +IDCT_ADD8 avx
- +%endif
- +
- +;-----------------------------------------------------------------------------
- +; void h264_idct_dc_add(pixel *dst, dctcoef *block, int stride)
- +;-----------------------------------------------------------------------------
- +INIT_MMX
- +
- +%macro ADD_CLIPW 3
- + paddw %2, %1
- + CLIPW %2, %3, [pw_pixel_max]
- +%endmacro
- +;;;;;;;;;; THIS ALSO WORKS BUT I DON'T KNOW WHICH ONE IS FASTER (THIS OR SSE2)
- +cglobal h264_idct_dc_add_10_mmx2,3,3
- + mov r1, dword [r1]
- + add r1, 32
- + sar r1, 6
- + movd m0, r1d
- + lea r1, [r0+r2*2]
- + pshufw m0, m0, 0
- + movq m1, [r0+ 0]
- + movq m2, [r0+r2]
- + movq m3, [r1+ 0]
- + movq m4, [r1+r2]
- + pxor m5, m5
- + ADD_CLIPW m0, m1, m5
- + ADD_CLIPW m0, m2, m5
- + ADD_CLIPW m0, m3, m5
- + ADD_CLIPW m0, m4, m5
- + movq [r0+ 0], m1
- + movq [r0+r2], m2
- + movq [r1+ 0], m3
- + movq [r1+r2], m4
- + RET
- \ No newline at end of file
- diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c
- index d77299d..b15ca7a 100644
- --- a/libavcodec/x86/h264dsp_mmx.c
- +++ b/libavcodec/x86/h264dsp_mmx.c
- @@ -32,49 +32,54 @@ void ff_h264_idct ## NUM ## _add_ ## DEPTH ## _ ## OPT (uint8_t *dst, int16_t *b
- IDCT_ADD_FUNC(, 8, mmx)
- IDCT_ADD_FUNC(, 10, sse2)
- +IDCT_ADD_FUNC(_dc, 8, mmx2)
- +IDCT_ADD_FUNC(_dc, 10, mmx2)
- #if HAVE_AVX
- IDCT_ADD_FUNC(, 10, avx)
- #endif
- void ff_h264_idct8_add_mmx (uint8_t *dst, int16_t *block, int stride);
- void ff_h264_idct8_add_sse2 (uint8_t *dst, int16_t *block, int stride);
- -void ff_h264_idct_dc_add_mmx2 (uint8_t *dst, int16_t *block, int stride);
- void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride);
- #define IDCT_ADD_REP_FUNC(NUM, REP, DEPTH, OPT) \
- void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
- - (uint8_t *dst, const int *block_offset, \
- - DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- -
- + (uint8_t *dst, const int *block_offset, \
- + DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- IDCT_ADD_REP_FUNC(, 16, 8, mmx)
- IDCT_ADD_REP_FUNC(, 16, 10, sse2)
- +IDCT_ADD_REP_FUNC(, 16intra, 8, mmx)
- +IDCT_ADD_REP_FUNC(, 16intra, 8, mmx2)
- +IDCT_ADD_REP_FUNC(, 16intra, 8, sse2)
- +IDCT_ADD_REP_FUNC(, 16intra, 10, sse2)
- #if HAVE_AVX
- IDCT_ADD_REP_FUNC(, 16, 10, avx)
- +IDCT_ADD_REP_FUNC(, 16intra, 10, avx)
- #endif
- +
- void ff_h264_idct8_add4_mmx (uint8_t *dst, const int *block_offset,
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- void ff_h264_idct_add16_mmx2 (uint8_t *dst, const int *block_offset,
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- -void ff_h264_idct_add16intra_mmx (uint8_t *dst, const int *block_offset,
- - DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- -void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
- - DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- -void ff_h264_idct_add16intra_10_sse2(uint8_t *dst, const int *block_offset,
- - DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- void ff_h264_idct8_add4_mmx2 (uint8_t *dst, const int *block_offset,
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- void ff_h264_idct8_add4_sse2 (uint8_t *dst, const int *block_offset,
- DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- -void ff_h264_idct_add8_mmx (uint8_t **dest, const int *block_offset,
- - DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- -void ff_h264_idct_add8_mmx2 (uint8_t **dest, const int *block_offset,
- - DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- +
- +#define IDCT_ADD_REP_FUNC2(NUM, REP, DEPTH, OPT) \
- +void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
- + (uint8_t **dst, const int *block_offset, \
- + DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
- +IDCT_ADD_REP_FUNC2(, 8, 8, mmx)
- +IDCT_ADD_REP_FUNC2(, 8, 8, mmx2)
- +IDCT_ADD_REP_FUNC2(, 8, 10, sse2)
- +#if HAVE_AVX
- +IDCT_ADD_REP_FUNC2(, 8, 10, avx)
- +#endif
- void ff_h264_idct_add16_sse2 (uint8_t *dst, const int *block_offset, DCTELEM *block,
- int stride, const uint8_t nnzc[6*8]);
- -void ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block,
- - int stride, const uint8_t nnzc[6*8]);
- void ff_h264_idct_add8_sse2 (uint8_t **dest, const int *block_offset, DCTELEM *block,
- int stride, const uint8_t nnzc[6*8]);
- void ff_h264_luma_dc_dequant_idct_mmx (DCTELEM *output, DCTELEM *input, int qmul);
- @@ -338,17 +343,17 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
- c->h264_idct_add16 = ff_h264_idct_add16_8_mmx;
- c->h264_idct8_add4 = ff_h264_idct8_add4_mmx;
- - c->h264_idct_add8 = ff_h264_idct_add8_mmx;
- - c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx;
- + c->h264_idct_add8 = ff_h264_idct_add8_8_mmx;
- + c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx;
- c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_mmx;
- if (mm_flags & AV_CPU_FLAG_MMX2) {
- - c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
- + c->h264_idct_dc_add= ff_h264_idct_dc_add_8_mmx2;
- c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
- c->h264_idct_add16 = ff_h264_idct_add16_mmx2;
- c->h264_idct8_add4 = ff_h264_idct8_add4_mmx2;
- - c->h264_idct_add8 = ff_h264_idct_add8_mmx2;
- - c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx2;
- + c->h264_idct_add8 = ff_h264_idct_add8_8_mmx2;
- + c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx2;
- c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_8_mmxext;
- c->h264_h_loop_filter_chroma= ff_deblock_h_chroma_8_mmxext;
- @@ -404,7 +409,7 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
- c->h264_idct_add16 = ff_h264_idct_add16_sse2;
- c->h264_idct_add8 = ff_h264_idct_add8_sse2;
- - c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2;
- + c->h264_idct_add16intra = ff_h264_idct_add16intra_8_sse2;
- }
- if (mm_flags&AV_CPU_FLAG_SSSE3) {
- c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3;
- @@ -436,12 +441,14 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
- c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_10_mmxext;
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_mmxext;
- #endif
- + c->h264_idct_dc_add= ff_h264_idct_dc_add_10_mmx2;
- if (mm_flags&AV_CPU_FLAG_SSE2) {
- - c->h264_idct_dc_add=
- + //c->h264_idct_dc_add= //WORK BUT I DON'T KNOW IF THE MMX2 VERSION IS FASTER OR NOT
- c->h264_idct_add= ff_h264_idct_add_10_sse2;
- + c->h264_idct_add8 = ff_h264_idct_add8_10_sse2;
- c->h264_idct_add16 = ff_h264_idct_add16_10_sse2;
- - c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2;
- + //c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2;
- c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_sse2;
- c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_sse2;
- @@ -456,7 +463,10 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
- if (mm_flags&AV_CPU_FLAG_AVX) {
- c->h264_idct_dc_add=
- c->h264_idct_add= ff_h264_idct_add_10_avx;
- + c->h264_idct_add8 = ff_h264_idct_add8_10_avx;
- +
- c->h264_idct_add16 = ff_h264_idct_add16_10_avx;
- + //c->h264_idct_add16intra= ff_h264_idct_add16intra_10_avx;
- c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_avx;
- c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_avx;
- --
- 1.7.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement