Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 26.47 KB | None | 0 0
  1. From debb3a32b06adfb52b1a57ed3a3947622fd812f0 Mon Sep 17 00:00:00 2001
  2. From: Daniel Kang <daniel.d.kang@gmail.com>
  3. Date: Mon, 16 May 2011 19:12:01 -0400
  4. Subject: [PATCH 1/2] Add h264_idct_10.asm
  5.  
  6. Adds h264_idct_add_10_(sse2|avx) and changes the way H.264 iDCT fucntion headers are declared.
  7.  
  8. Code ported from x264.
  9. ---
  10. libavcodec/x86/Makefile            |    1 +
  11.  libavcodec/x86/h264_idct.asm       |    4 +-
  12.  libavcodec/x86/h264_idct_10bit.asm |  145 ++++++++++++++++++++++++++++++++++++
  13.  libavcodec/x86/h264dsp_mmx.c       |   38 +++++++++-
  14.  4 files changed, 182 insertions(+), 6 deletions(-)
  15.  create mode 100755 libavcodec/x86/h264_idct_10bit.asm
  16.  
  17. diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
  18. index 1cde951..4a8474a 100644
  19. --- a/libavcodec/x86/Makefile
  20. +++ b/libavcodec/x86/Makefile
  21. @@ -12,6 +12,7 @@ YASM-OBJS-$(CONFIG_H264DSP)            += x86/h264_deblock.o            \
  22.                                            x86/h264_deblock_10bit.o      \
  23.                                            x86/h264_weight.o             \
  24.                                            x86/h264_idct.o               \
  25. +                                          x86/h264_idct_10bit.o         \
  26.  
  27.  YASM-OBJS-$(CONFIG_H264PRED)           += x86/h264_intrapred.o
  28.  MMX-OBJS-$(CONFIG_H264PRED)            += x86/h264_intrapred_init.o
  29. diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm
  30. index ae70a30..b5d7c1e 100644
  31. --- a/libavcodec/x86/h264_idct.asm
  32. +++ b/libavcodec/x86/h264_idct.asm
  33. @@ -73,7 +73,7 @@ SECTION .text
  34.  
  35.  INIT_MMX
  36.  ; ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride)
  37. -cglobal h264_idct_add_mmx, 3, 3, 0
  38. +cglobal h264_idct_add_8_mmx, 3, 3, 0
  39.      IDCT4_ADD    r0, r1, r2
  40.      RET
  41.  
  42. @@ -297,7 +297,7 @@ cglobal h264_idct8_dc_add_mmx2, 3, 3, 0
  43.  
  44.  ; ff_h264_idct_add16_mmx(uint8_t *dst, const int *block_offset,
  45.  ;             DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  46. -cglobal h264_idct_add16_mmx, 5, 7, 0
  47. +cglobal h264_idct_add16_8_mmx, 5, 7, 0
  48.      xor          r5, r5
  49.  %ifdef PIC
  50.      lea         r11, [scan8_mem]
  51. diff --git a/libavcodec/x86/h264_idct_10bit.asm b/libavcodec/x86/h264_idct_10bit.asm
  52. new file mode 100755
  53. index 0000000..fbd4bf7
  54. --- /dev/null
  55. +++ b/libavcodec/x86/h264_idct_10bit.asm
  56. @@ -0,0 +1,145 @@
  57. +;*****************************************************************************
  58. +;* MMX/SSE2/AVX-optimized 10-bit H.264 iDCT code
  59. +;*****************************************************************************
  60. +;* Copyright (C) 2005-2011 x264 project
  61. +;*
  62. +;* Authors: Daniel Kang <daniel.d.kang@gmail.com>
  63. +;*          Oskar Arvidsson <oskar@irock.se>
  64. +;*
  65. +;* This file is part of Libav.
  66. +;*
  67. +;* Libav is free software; you can redistribute it and/or
  68. +;* modify it under the terms of the GNU Lesser General Public
  69. +;* License as published by the Free Software Foundation; either
  70. +;* version 2.1 of the License, or (at your option) any later version.
  71. +;*
  72. +;* Libav is distributed in the hope that it will be useful,
  73. +;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  74. +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  75. +;* Lesser General Public License for more details.
  76. +;*
  77. +;* You should have received a copy of the GNU Lesser General Public
  78. +;* License along with Libav; if not, write to the Free Software
  79. +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  80. +;******************************************************************************
  81. +
  82. +%include "x86inc.asm"
  83. +%include "x86util.asm"
  84. +
  85. +SECTION_RODATA
  86. +
  87. +pw_pixel_max: times 8 dw ((1 << 10)-1)
  88. +pd_32:        times 4 dd 32
  89. +scan8_mem: db 4+1*8, 5+1*8, 4+2*8, 5+2*8
  90. +           db 6+1*8, 7+1*8, 6+2*8, 7+2*8
  91. +           db 4+3*8, 5+3*8, 4+4*8, 5+4*8
  92. +           db 6+3*8, 7+3*8, 6+4*8, 7+4*8
  93. +           db 1+1*8, 2+1*8
  94. +           db 1+2*8, 2+2*8
  95. +           db 1+4*8, 2+4*8
  96. +           db 1+5*8, 2+5*8
  97. +
  98. +%ifdef PIC
  99. +%define scan8 r11
  100. +%else
  101. +%define scan8 scan8_mem
  102. +%endif
  103. +
  104. +SECTION .text
  105. +
  106. +;-----------------------------------------------------------------------------
  107. +; void h264_idct_add(pixel *dst, dctcoef *block, int stride)
  108. +;-----------------------------------------------------------------------------
  109. +%macro STORE_DIFFx2 6
  110. +    psrad     %1, 6
  111. +    psrad     %2, 6
  112. +    packssdw  %1, %2
  113. +    movq      %3, %5
  114. +    movhps    %3, %6
  115. +    paddsw    %1, %3
  116. +    CLIPW     %1, %4, [pw_pixel_max]
  117. +    movq      %5, %1
  118. +    movhps    %6, %1
  119. +%endmacro
  120. +
  121. +;dst, in, stride
  122. +%macro IDCT4_ADD_10 3
  123. +    mova  m1, [%2+16]
  124. +    mova  m3, [%2+48]
  125. +    mova  m2, [%2+32]
  126. +    mova  m0, [%2+ 0]
  127. +    IDCT4_1D d,0,1,2,3,4,5
  128. +    TRANSPOSE4x4D 0,1,2,3,4
  129. +    paddd m0, [pd_32]
  130. +    IDCT4_1D d,0,1,2,3,4,5
  131. +    pxor  m5, m5
  132. +    STORE_DIFFx2 m0, m1, m4, m5, [%1], [%1+%3]
  133. +    lea   %1, [%1+%3*2]
  134. +    STORE_DIFFx2 m2, m3, m4, m5, [%1], [%1+%3]
  135. +%endmacro
  136. +
  137. +%macro IDCT_ADD_10 1
  138. +cglobal h264_idct_add_10_%1, 3,3
  139. +    IDCT4_ADD_10 r0, r1, r2
  140. +    RET
  141. +%endmacro
  142. +
  143. +INIT_XMM
  144. +IDCT_ADD_10 sse2
  145. +%ifdef HAVE_AVX
  146. +INIT_AVX
  147. +IDCT_ADD_10 avx
  148. +%endif
  149. +
  150. +;-----------------------------------------------------------------------------
  151. +; h264_idct_add16(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
  152. +;-----------------------------------------------------------------------------
  153. +%macro IDCT_ADD16_10 1
  154. +cglobal h264_idct_add16_10_%1, 5,7
  155. +    xor          r5, r5
  156. +%ifdef PIC
  157. +    lea         r11, [scan8_mem]
  158. +%endif
  159. +.nextblock
  160. +    movzx        r6, byte [scan8+r5]
  161. +    movzx        r6, byte [r4+r6]
  162. +    test         r6, r6
  163. +    jz .skipblock
  164. +    mov         r6d, dword [r1+r5*4]
  165. +    lea          r6, [r0+r6]
  166. +    IDCT4_ADD_10 r6, r2, r3
  167. +.skipblock
  168. +    inc          r5
  169. +    add          r2, 64
  170. +    cmp          r5, 16
  171. +    jl .nextblock
  172. +    REP_RET
  173. +%endmacro
  174. +
  175. +INIT_XMM
  176. +IDCT_ADD16_10 sse2
  177. +%ifdef HAVE_AVX
  178. +INIT_AVX
  179. +IDCT_ADD16_10 avx
  180. +%endif
  181. +
  182. +cglobal h264_idct_add16intra_10_sse2, 5,7
  183. +    xor          r5, r5
  184. +%ifdef PIC
  185. +    lea         r11, [scan8_mem]
  186. +%endif
  187. +.nextblock
  188. +    movzx        r6, byte [scan8+r5]
  189. +    movzx        r6, byte [r4+r6]
  190. +    or          r6w, word [r2]
  191. +    test         r6, r6
  192. +    jz .skipblock
  193. +    mov         r6d, dword [r1+r5*4]
  194. +    lea          r6, [r0+r6]
  195. +    IDCT4_ADD_10 r6, r2, r3
  196. +.skipblock
  197. +    inc          r5
  198. +    add          r2, 64
  199. +    cmp          r5, 16
  200. +    jl .nextblock
  201. +    REP_RET
  202. diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c
  203. index 1c07d14..d77299d 100644
  204. --- a/libavcodec/x86/h264dsp_mmx.c
  205. +++ b/libavcodec/x86/h264dsp_mmx.c
  206. @@ -27,15 +27,31 @@ DECLARE_ALIGNED(8, static const uint64_t, ff_pb_3_1  ) = 0x0103010301030103ULL;
  207.  
  208.  /***********************************/
  209.  /* IDCT */
  210. +#define IDCT_ADD_FUNC(NUM, DEPTH, OPT) \
  211. +void ff_h264_idct ## NUM ## _add_ ## DEPTH ## _ ## OPT (uint8_t *dst, int16_t *block, int stride);
  212.  
  213. -void ff_h264_idct_add_mmx     (uint8_t *dst, int16_t *block, int stride);
  214. +IDCT_ADD_FUNC(, 8, mmx)
  215. +IDCT_ADD_FUNC(, 10, sse2)
  216. +#if HAVE_AVX
  217. +IDCT_ADD_FUNC(, 10, avx)
  218. +#endif
  219.  void ff_h264_idct8_add_mmx    (uint8_t *dst, int16_t *block, int stride);
  220.  void ff_h264_idct8_add_sse2   (uint8_t *dst, int16_t *block, int stride);
  221.  void ff_h264_idct_dc_add_mmx2 (uint8_t *dst, int16_t *block, int stride);
  222.  void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride);
  223.  
  224. -void ff_h264_idct_add16_mmx      (uint8_t *dst, const int *block_offset,
  225. +
  226. +#define IDCT_ADD_REP_FUNC(NUM, REP, DEPTH, OPT) \
  227. +void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
  228. +                                  (uint8_t *dst, const int *block_offset, \
  229.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  230. +
  231. +
  232. +IDCT_ADD_REP_FUNC(, 16, 8, mmx)
  233. +IDCT_ADD_REP_FUNC(, 16, 10, sse2)
  234. +#if HAVE_AVX
  235. +IDCT_ADD_REP_FUNC(, 16, 10, avx)
  236. +#endif
  237.  void ff_h264_idct8_add4_mmx      (uint8_t *dst, const int *block_offset,
  238.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  239.  void ff_h264_idct_add16_mmx2     (uint8_t *dst, const int *block_offset,
  240. @@ -44,6 +60,8 @@ void ff_h264_idct_add16intra_mmx (uint8_t *dst, const int *block_offset,
  241.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  242.  void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
  243.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  244. +void ff_h264_idct_add16intra_10_sse2(uint8_t *dst, const int *block_offset,
  245. +                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  246.  void ff_h264_idct8_add4_mmx2     (uint8_t *dst, const int *block_offset,
  247.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  248.  void ff_h264_idct8_add4_sse2     (uint8_t *dst, const int *block_offset,
  249. @@ -314,11 +332,11 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  250.  #if HAVE_YASM
  251.      if (mm_flags & AV_CPU_FLAG_MMX) {
  252.          c->h264_idct_dc_add=
  253. -        c->h264_idct_add= ff_h264_idct_add_mmx;
  254. +        c->h264_idct_add= ff_h264_idct_add_8_mmx;
  255.          c->h264_idct8_dc_add=
  256.          c->h264_idct8_add= ff_h264_idct8_add_mmx;
  257.  
  258. -        c->h264_idct_add16     = ff_h264_idct_add16_mmx;
  259. +        c->h264_idct_add16     = ff_h264_idct_add16_8_mmx;
  260.          c->h264_idct8_add4     = ff_h264_idct8_add4_mmx;
  261.          c->h264_idct_add8      = ff_h264_idct_add8_mmx;
  262.          c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx;
  263. @@ -419,6 +437,12 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  264.              c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_mmxext;
  265.  #endif
  266.              if (mm_flags&AV_CPU_FLAG_SSE2) {
  267. +                c->h264_idct_dc_add=
  268. +                c->h264_idct_add= ff_h264_idct_add_10_sse2;
  269. +
  270. +                c->h264_idct_add16     = ff_h264_idct_add16_10_sse2;
  271. +                c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2;
  272. +
  273.                  c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_sse2;
  274.                  c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_sse2;
  275.  #if HAVE_ALIGNED_STACK
  276. @@ -428,7 +452,12 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  277.                  c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_sse2;
  278.  #endif
  279.              }
  280. +#if HAVE_AVX
  281.              if (mm_flags&AV_CPU_FLAG_AVX) {
  282. +                c->h264_idct_dc_add=
  283. +                c->h264_idct_add= ff_h264_idct_add_10_avx;
  284. +                c->h264_idct_add16     = ff_h264_idct_add16_10_avx;
  285. +
  286.                  c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_avx;
  287.                  c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_avx;
  288.  #if HAVE_ALIGNED_STACK
  289. @@ -438,6 +467,7 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  290.                  c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_avx;
  291.  #endif
  292.              }
  293. +#endif
  294.          }
  295.      }
  296.  #endif
  297. --
  298. 1.7.4
  299.  
  300.  
  301. From 49e3c15a378b1691d0c85e10ab115007c261f0a9 Mon Sep 17 00:00:00 2001
  302. From: Daniel Kang <daniel.d.kang@gmail.com>
  303. Date: Tue, 17 May 2011 21:26:30 -0400
  304. Subject: [PATCH 2/2] WIP patch
  305.  
  306. ---
  307. libavcodec/x86/h264_idct.asm       |   14 ++--
  308.  libavcodec/x86/h264_idct_10bit.asm |  132 +++++++++++++++++++++++++++++++----
  309.  libavcodec/x86/h264dsp_mmx.c       |   58 +++++++++-------
  310.  3 files changed, 158 insertions(+), 46 deletions(-)
  311.  
  312. diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm
  313. index b5d7c1e..1dc7963 100644
  314. --- a/libavcodec/x86/h264_idct.asm
  315. +++ b/libavcodec/x86/h264_idct.asm
  316. @@ -261,7 +261,7 @@ cglobal h264_idct8_add_sse2, 3, 4, 10
  317.      packuswb     m1, m1
  318.  %endmacro
  319.  
  320. -%macro DC_ADD_MMX2_OP 3-4
  321. +%macro DC_ADD_MMX2_OP 4
  322.      %1           m2, [%2     ]
  323.      %1           m3, [%2+%3  ]
  324.      %1           m4, [%2+%3*2]
  325. @@ -282,7 +282,7 @@ cglobal h264_idct8_add_sse2, 3, 4, 10
  326.  
  327.  INIT_MMX
  328.  ; ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
  329. -cglobal h264_idct_dc_add_mmx2, 3, 3, 0
  330. +cglobal h264_idct_dc_add_8_mmx2, 3, 3, 0
  331.      DC_ADD_MMX2_INIT r1, r2
  332.      DC_ADD_MMX2_OP movh, r0, r2, r1
  333.      RET
  334. @@ -398,7 +398,7 @@ cglobal h264_idct_add16_mmx2, 5, 7, 0
  335.  
  336.  ; ff_h264_idct_add16intra_mmx(uint8_t *dst, const int *block_offset,
  337.  ;                             DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  338. -cglobal h264_idct_add16intra_mmx, 5, 7, 0
  339. +cglobal h264_idct_add16intra_8_mmx, 5, 7, 0
  340.      xor          r5, r5
  341.  %ifdef PIC
  342.      lea         r11, [scan8_mem]
  343. @@ -421,7 +421,7 @@ cglobal h264_idct_add16intra_mmx, 5, 7, 0
  344.  
  345.  ; ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
  346.  ;                              DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  347. -cglobal h264_idct_add16intra_mmx2, 5, 7, 0
  348. +cglobal h264_idct_add16intra_8_mmx2, 5, 7, 0
  349.      xor          r5, r5
  350.  %ifdef PIC
  351.      lea         r11, [scan8_mem]
  352. @@ -607,7 +607,7 @@ h264_idct_add8_mmx_plane:
  353.  
  354.  ; ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset,
  355.  ;                       DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  356. -cglobal h264_idct_add8_mmx, 5, 7, 0
  357. +cglobal h264_idct_add8_8_mmx, 5, 7, 0
  358.      mov          r5, 16
  359.      add          r2, 512
  360.  %ifdef PIC
  361. @@ -668,7 +668,7 @@ h264_idct_add8_mmx2_plane
  362.  
  363.  ; ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset,
  364.  ;                        DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  365. -cglobal h264_idct_add8_mmx2, 5, 7, 0
  366. +cglobal h264_idct_add8_8_mmx2, 5, 7, 0
  367.      mov          r5, 16
  368.      add          r2, 512
  369.  %ifdef ARCH_X86_64
  370. @@ -791,7 +791,7 @@ cglobal h264_idct_add16_sse2, 5, 5, 8
  371.  
  372.  ; ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset,
  373.  ;                              DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  374. -cglobal h264_idct_add16intra_sse2, 5, 7, 8
  375. +cglobal h264_idct_add16intra_8_sse2, 5, 7, 8
  376.  %ifdef ARCH_X86_64
  377.      mov        r10, r0
  378.  %endif
  379. diff --git a/libavcodec/x86/h264_idct_10bit.asm b/libavcodec/x86/h264_idct_10bit.asm
  380. index fbd4bf7..d4cfa6b 100755
  381. --- a/libavcodec/x86/h264_idct_10bit.asm
  382. +++ b/libavcodec/x86/h264_idct_10bit.asm
  383. @@ -51,33 +51,34 @@ SECTION .text
  384.  ; void h264_idct_add(pixel *dst, dctcoef *block, int stride)
  385.  ;-----------------------------------------------------------------------------
  386.  %macro STORE_DIFFx2 6
  387. -    psrad     %1, 6
  388. -    psrad     %2, 6
  389. -    packssdw  %1, %2
  390. -    movq      %3, %5
  391. -    movhps    %3, %6
  392. -    paddsw    %1, %3
  393. -    CLIPW     %1, %4, [pw_pixel_max]
  394. -    movq      %5, %1
  395. -    movhps    %6, %1
  396. +    psrad       %1, 6
  397. +    psrad       %2, 6
  398. +    packssdw    %1, %2
  399. +    movq        %3, [%5]
  400. +    movhps      %3, [%5+%6]
  401. +    paddsw      %1, %3
  402. +    CLIPW       %1, %4, [pw_pixel_max]
  403. +    movq      [%5], %1
  404. +    movhps [%5+%6], %1
  405.  %endmacro
  406.  
  407.  ;dst, in, stride
  408.  %macro IDCT4_ADD_10 3
  409. +    mova  m0, [%2+ 0]
  410.      mova  m1, [%2+16]
  411. -    mova  m3, [%2+48]
  412.      mova  m2, [%2+32]
  413. -    mova  m0, [%2+ 0]
  414. +    mova  m3, [%2+48]
  415.      IDCT4_1D d,0,1,2,3,4,5
  416.      TRANSPOSE4x4D 0,1,2,3,4
  417.      paddd m0, [pd_32]
  418.      IDCT4_1D d,0,1,2,3,4,5
  419.      pxor  m5, m5
  420. -    STORE_DIFFx2 m0, m1, m4, m5, [%1], [%1+%3]
  421. +    STORE_DIFFx2 m0, m1, m4, m5, %1, %3
  422.      lea   %1, [%1+%3*2]
  423. -    STORE_DIFFx2 m2, m3, m4, m5, [%1], [%1+%3]
  424. +    STORE_DIFFx2 m2, m3, m4, m5, %1, %3
  425.  %endmacro
  426.  
  427. +;;;;;;;;;; ACTUALLY WORKING
  428.  %macro IDCT_ADD_10 1
  429.  cglobal h264_idct_add_10_%1, 3,3
  430.      IDCT4_ADD_10 r0, r1, r2
  431. @@ -94,6 +95,8 @@ IDCT_ADD_10 avx
  432.  ;-----------------------------------------------------------------------------
  433.  ; h264_idct_add16(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
  434.  ;-----------------------------------------------------------------------------
  435. +
  436. +;;;;;;; NO FATE SAMPLES TRIGGER THIS UNTESTED
  437.  %macro IDCT_ADD16_10 1
  438.  cglobal h264_idct_add16_10_%1, 5,7
  439.      xor          r5, r5
  440. @@ -123,7 +126,10 @@ INIT_AVX
  441.  IDCT_ADD16_10 avx
  442.  %endif
  443.  
  444. -cglobal h264_idct_add16intra_10_sse2, 5,7
  445. +
  446. +;;;;; CURRENTLY DOES NOT WORK DO NOT KNOW WHY
  447. +%macro IDCT_ADD16INTRA_10 1
  448. +cglobal h264_idct_add16intra_10_%1,5,7
  449.      xor          r5, r5
  450.  %ifdef PIC
  451.      lea         r11, [scan8_mem]
  452. @@ -131,7 +137,7 @@ cglobal h264_idct_add16intra_10_sse2, 5,7
  453.  .nextblock
  454.      movzx        r6, byte [scan8+r5]
  455.      movzx        r6, byte [r4+r6]
  456. -    or          r6w, word [r2]
  457. +    or          r6d, dword [r2]
  458.      test         r6, r6
  459.      jz .skipblock
  460.      mov         r6d, dword [r1+r5*4]
  461. @@ -143,3 +149,99 @@ cglobal h264_idct_add16intra_10_sse2, 5,7
  462.      cmp          r5, 16
  463.      jl .nextblock
  464.      REP_RET
  465. +%endmacro
  466. +
  467. +INIT_XMM
  468. +IDCT_ADD16INTRA_10 sse2
  469. +%ifdef HAVE_AVX
  470. +INIT_AVX
  471. +IDCT_ADD16INTRA_10 avx
  472. +%endif
  473. +
  474. +
  475. +;-----------------------------------------------------------------------------
  476. +; h264_idct_add8(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
  477. +;-----------------------------------------------------------------------------
  478. +
  479. +;;;;;;; WORKING
  480. +%macro IDCT_ADD8 1
  481. +h264_idct_add8_10_%1_plane:
  482. +.nextblock
  483. +    movzx        r6, byte [scan8+r5]
  484. +    movzx        r6, byte [r4+r6]
  485. +    or          r6d, dword [r2]
  486. +    test         r6, r6
  487. +    jz .skipblock
  488. +%ifdef ARCH_X86_64
  489. +    mov         r0d, dword [r1+r5*4]
  490. +    add          r0, [r10]
  491. +%else
  492. +    mov          r0, r1m ; XXX r1m here is actually r0m of the calling func
  493. +    mov          r0, [r0]
  494. +    add          r0, dword [r1+r5*4]
  495. +%endif
  496. +    IDCT4_ADD_10 r0, r2, r3
  497. +.skipblock
  498. +    inc          r5
  499. +    add          r2, 64
  500. +    test         r5, 3
  501. +    jnz .nextblock
  502. +    rep ret
  503. +
  504. +cglobal h264_idct_add8_10_%1,5,7,0
  505. +    mov          r5, 16
  506. +    add          r2, 512*2
  507. +%ifdef PIC
  508. +    lea         r11, [scan8_mem]
  509. +%endif
  510. +%ifdef ARCH_X86_64
  511. +    mov         r10, r0
  512. +%endif
  513. +    call         h264_idct_add8_10_sse2_plane
  514. +%ifdef ARCH_X86_64
  515. +    add         r10, gprsize
  516. +%else
  517. +    add        r0mp, gprsize
  518. +%endif
  519. +    call         h264_idct_add8_10_sse2_plane
  520. +    RET
  521. +%endmacro ; IDCT_ADD8
  522. +
  523. +INIT_XMM
  524. +IDCT_ADD8 sse2
  525. +%ifdef HAVE_AVX
  526. +INIT_AVX
  527. +IDCT_ADD8 avx
  528. +%endif
  529. +
  530. +;-----------------------------------------------------------------------------
  531. +; void h264_idct_dc_add(pixel *dst, dctcoef *block, int stride)
  532. +;-----------------------------------------------------------------------------
  533. +INIT_MMX
  534. +
  535. +%macro ADD_CLIPW 3
  536. +    paddw %2, %1
  537. +    CLIPW %2, %3, [pw_pixel_max]
  538. +%endmacro
  539. +;;;;;;;;;; THIS ALSO WORKS BUT I DON'T KNOW WHICH ONE IS FASTER (THIS OR SSE2)
  540. +cglobal h264_idct_dc_add_10_mmx2,3,3
  541. +    mov       r1, dword [r1]
  542. +    add       r1, 32
  543. +    sar       r1, 6
  544. +    movd      m0, r1d
  545. +    lea       r1, [r0+r2*2]
  546. +    pshufw    m0, m0, 0
  547. +    movq      m1, [r0+ 0]
  548. +    movq      m2, [r0+r2]
  549. +    movq      m3, [r1+ 0]
  550. +    movq      m4, [r1+r2]
  551. +    pxor      m5, m5
  552. +    ADD_CLIPW m0, m1, m5
  553. +    ADD_CLIPW m0, m2, m5
  554. +    ADD_CLIPW m0, m3, m5
  555. +    ADD_CLIPW m0, m4, m5
  556. +    movq [r0+ 0], m1
  557. +    movq [r0+r2], m2
  558. +    movq [r1+ 0], m3
  559. +    movq [r1+r2], m4
  560. +    RET
  561. \ No newline at end of file
  562. diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c
  563. index d77299d..b15ca7a 100644
  564. --- a/libavcodec/x86/h264dsp_mmx.c
  565. +++ b/libavcodec/x86/h264dsp_mmx.c
  566. @@ -32,49 +32,54 @@ void ff_h264_idct ## NUM ## _add_ ## DEPTH ## _ ## OPT (uint8_t *dst, int16_t *b
  567.  
  568.  IDCT_ADD_FUNC(, 8, mmx)
  569.  IDCT_ADD_FUNC(, 10, sse2)
  570. +IDCT_ADD_FUNC(_dc, 8, mmx2)
  571. +IDCT_ADD_FUNC(_dc, 10, mmx2)
  572.  #if HAVE_AVX
  573.  IDCT_ADD_FUNC(, 10, avx)
  574.  #endif
  575.  void ff_h264_idct8_add_mmx    (uint8_t *dst, int16_t *block, int stride);
  576.  void ff_h264_idct8_add_sse2   (uint8_t *dst, int16_t *block, int stride);
  577. -void ff_h264_idct_dc_add_mmx2 (uint8_t *dst, int16_t *block, int stride);
  578.  void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride);
  579.  
  580.  
  581.  #define IDCT_ADD_REP_FUNC(NUM, REP, DEPTH, OPT) \
  582.  void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
  583. -                                  (uint8_t *dst, const int *block_offset, \
  584. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  585. -
  586. +                              (uint8_t *dst, const int *block_offset, \
  587. +                              DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  588.  
  589.  IDCT_ADD_REP_FUNC(, 16, 8, mmx)
  590.  IDCT_ADD_REP_FUNC(, 16, 10, sse2)
  591. +IDCT_ADD_REP_FUNC(, 16intra, 8, mmx)
  592. +IDCT_ADD_REP_FUNC(, 16intra, 8, mmx2)
  593. +IDCT_ADD_REP_FUNC(, 16intra, 8, sse2)
  594. +IDCT_ADD_REP_FUNC(, 16intra, 10, sse2)
  595.  #if HAVE_AVX
  596.  IDCT_ADD_REP_FUNC(, 16, 10, avx)
  597. +IDCT_ADD_REP_FUNC(, 16intra, 10, avx)
  598.  #endif
  599. +
  600.  void ff_h264_idct8_add4_mmx      (uint8_t *dst, const int *block_offset,
  601.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  602.  void ff_h264_idct_add16_mmx2     (uint8_t *dst, const int *block_offset,
  603.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  604. -void ff_h264_idct_add16intra_mmx (uint8_t *dst, const int *block_offset,
  605. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  606. -void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
  607. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  608. -void ff_h264_idct_add16intra_10_sse2(uint8_t *dst, const int *block_offset,
  609. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  610.  void ff_h264_idct8_add4_mmx2     (uint8_t *dst, const int *block_offset,
  611.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  612.  void ff_h264_idct8_add4_sse2     (uint8_t *dst, const int *block_offset,
  613.                                    DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  614. -void ff_h264_idct_add8_mmx       (uint8_t **dest, const int *block_offset,
  615. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  616. -void ff_h264_idct_add8_mmx2      (uint8_t **dest, const int *block_offset,
  617. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  618. +
  619. +#define IDCT_ADD_REP_FUNC2(NUM, REP, DEPTH, OPT) \
  620. +void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
  621. +                              (uint8_t **dst, const int *block_offset, \
  622. +                              DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  623. +IDCT_ADD_REP_FUNC2(, 8, 8, mmx)
  624. +IDCT_ADD_REP_FUNC2(, 8, 8, mmx2)
  625. +IDCT_ADD_REP_FUNC2(, 8, 10, sse2)
  626. +#if HAVE_AVX
  627. +IDCT_ADD_REP_FUNC2(, 8, 10, avx)
  628. +#endif
  629.  
  630.  void ff_h264_idct_add16_sse2     (uint8_t *dst, const int *block_offset, DCTELEM *block,
  631.                                    int stride, const uint8_t nnzc[6*8]);
  632. -void ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block,
  633. -                                  int stride, const uint8_t nnzc[6*8]);
  634.  void ff_h264_idct_add8_sse2      (uint8_t **dest, const int *block_offset, DCTELEM *block,
  635.                                    int stride, const uint8_t nnzc[6*8]);
  636.  void ff_h264_luma_dc_dequant_idct_mmx (DCTELEM *output, DCTELEM *input, int qmul);
  637. @@ -338,17 +343,17 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  638.  
  639.          c->h264_idct_add16     = ff_h264_idct_add16_8_mmx;
  640.          c->h264_idct8_add4     = ff_h264_idct8_add4_mmx;
  641. -        c->h264_idct_add8      = ff_h264_idct_add8_mmx;
  642. -        c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx;
  643. +        c->h264_idct_add8      = ff_h264_idct_add8_8_mmx;
  644. +        c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx;
  645.          c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_mmx;
  646.  
  647.          if (mm_flags & AV_CPU_FLAG_MMX2) {
  648. -            c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
  649. +            c->h264_idct_dc_add= ff_h264_idct_dc_add_8_mmx2;
  650.              c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
  651.              c->h264_idct_add16     = ff_h264_idct_add16_mmx2;
  652.              c->h264_idct8_add4     = ff_h264_idct8_add4_mmx2;
  653. -            c->h264_idct_add8      = ff_h264_idct_add8_mmx2;
  654. -            c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx2;
  655. +            c->h264_idct_add8      = ff_h264_idct_add8_8_mmx2;
  656. +            c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx2;
  657.  
  658.              c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_8_mmxext;
  659.              c->h264_h_loop_filter_chroma= ff_deblock_h_chroma_8_mmxext;
  660. @@ -404,7 +409,7 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  661.  
  662.                  c->h264_idct_add16 = ff_h264_idct_add16_sse2;
  663.                  c->h264_idct_add8  = ff_h264_idct_add8_sse2;
  664. -                c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2;
  665. +                c->h264_idct_add16intra = ff_h264_idct_add16intra_8_sse2;
  666.              }
  667.              if (mm_flags&AV_CPU_FLAG_SSSE3) {
  668.                  c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3;
  669. @@ -436,12 +441,14 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  670.              c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_10_mmxext;
  671.              c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_mmxext;
  672.  #endif
  673. +            c->h264_idct_dc_add= ff_h264_idct_dc_add_10_mmx2;
  674.              if (mm_flags&AV_CPU_FLAG_SSE2) {
  675. -                c->h264_idct_dc_add=
  676. +                //c->h264_idct_dc_add= //WORK BUT I DON'T KNOW IF THE MMX2 VERSION IS FASTER OR NOT
  677.                  c->h264_idct_add= ff_h264_idct_add_10_sse2;
  678. +                c->h264_idct_add8      = ff_h264_idct_add8_10_sse2;
  679.  
  680.                  c->h264_idct_add16     = ff_h264_idct_add16_10_sse2;
  681. -                c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2;
  682. +                //c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2;
  683.  
  684.                  c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_sse2;
  685.                  c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_sse2;
  686. @@ -456,7 +463,10 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  687.              if (mm_flags&AV_CPU_FLAG_AVX) {
  688.                  c->h264_idct_dc_add=
  689.                  c->h264_idct_add= ff_h264_idct_add_10_avx;
  690. +                c->h264_idct_add8      = ff_h264_idct_add8_10_avx;
  691. +
  692.                  c->h264_idct_add16     = ff_h264_idct_add16_10_avx;
  693. +                //c->h264_idct_add16intra= ff_h264_idct_add16intra_10_avx;
  694.  
  695.                  c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_avx;
  696.                  c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_avx;
  697. --
  698. 1.7.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement