Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 36.28 KB | None | 0 0
  1. From bd257da42b8d31ea38141833aadda030daa9cb72 Mon Sep 17 00:00:00 2001
  2. From: Daniel Kang <daniel.d.kang@gmail.com>
  3. Date: Tue, 24 May 2011 15:14:38 -0400
  4. Subject: [PATCH 1/2] Add IDCT functions for 10-bit H.264.
  5.  
  6. Ports the majority of IDCT functions for 10-bit H.264.
  7.  
  8. Parts are inspired from 8-bit IDCT code in Libav; other parts ported from x264 with relicensing permission from author.
  9. ---
  10. libavcodec/x86/Makefile            |    3 +-
  11.  libavcodec/x86/h264_idct_10bit.asm |  570 ++++++++++++++++++++++++++++++++++++
  12.  libavcodec/x86/h264dsp_mmx.c       |   59 ++++
  13.  3 files changed, 631 insertions(+), 1 deletions(-)
  14.  create mode 100644 libavcodec/x86/h264_idct_10bit.asm
  15.  
  16. diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
  17. index ba664ab..38b736e 100644
  18. --- a/libavcodec/x86/Makefile
  19. +++ b/libavcodec/x86/Makefile
  20. @@ -12,8 +12,9 @@ YASM-OBJS-$(CONFIG_FFT)                += x86/fft_mmx.o                 \
  21.  MMX-OBJS-$(CONFIG_H264DSP)             += x86/h264dsp_mmx.o
  22.  YASM-OBJS-$(CONFIG_H264DSP)            += x86/h264_deblock.o            \
  23.                                            x86/h264_deblock_10bit.o      \
  24. -                                          x86/h264_weight.o             \
  25.                                            x86/h264_idct.o               \
  26. +                                          x86/h264_idct_10bit.o         \
  27. +                                          x86/h264_weight.o             \
  28.  
  29.  YASM-OBJS-$(CONFIG_H264PRED)           += x86/h264_intrapred.o
  30.  MMX-OBJS-$(CONFIG_H264PRED)            += x86/h264_intrapred_init.o
  31. diff --git a/libavcodec/x86/h264_idct_10bit.asm b/libavcodec/x86/h264_idct_10bit.asm
  32. new file mode 100644
  33. index 0000000..3d0004e
  34. --- /dev/null
  35. +++ b/libavcodec/x86/h264_idct_10bit.asm
  36. @@ -0,0 +1,570 @@
  37. +;*****************************************************************************
  38. +;* MMX/SSE2/AVX-optimized 10-bit H.264 iDCT code
  39. +;*****************************************************************************
  40. +;* Copyright (C) 2005-2011 x264 project
  41. +;*
  42. +;* Authors: Daniel Kang <daniel.d.kang@gmail.com>
  43. +;*
  44. +;* This file is part of Libav.
  45. +;*
  46. +;* Libav is free software; you can redistribute it and/or
  47. +;* modify it under the terms of the GNU Lesser General Public
  48. +;* License as published by the Free Software Foundation; either
  49. +;* version 2.1 of the License, or (at your option) any later version.
  50. +;*
  51. +;* Libav is distributed in the hope that it will be useful,
  52. +;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  53. +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  54. +;* Lesser General Public License for more details.
  55. +;*
  56. +;* You should have received a copy of the GNU Lesser General Public
  57. +;* License along with Libav; if not, write to the Free Software
  58. +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  59. +;******************************************************************************
  60. +
  61. +%include "x86inc.asm"
  62. +%include "x86util.asm"
  63. +
  64. +SECTION_RODATA
  65. +
  66. +pw_pixel_max: times 8 dw ((1 << 10)-1)
  67. +pd_32:        times 4 dd 32
  68. +scan8_mem: db 4+1*8, 5+1*8, 4+2*8, 5+2*8
  69. +           db 6+1*8, 7+1*8, 6+2*8, 7+2*8
  70. +           db 4+3*8, 5+3*8, 4+4*8, 5+4*8
  71. +           db 6+3*8, 7+3*8, 6+4*8, 7+4*8
  72. +           db 1+1*8, 2+1*8
  73. +           db 1+2*8, 2+2*8
  74. +           db 1+4*8, 2+4*8
  75. +           db 1+5*8, 2+5*8
  76. +
  77. +%ifdef PIC
  78. +%define scan8 r11
  79. +%else
  80. +%define scan8 scan8_mem
  81. +%endif
  82. +
  83. +SECTION .text
  84. +
  85. +;-----------------------------------------------------------------------------
  86. +; void h264_idct_add(pixel *dst, dctcoef *block, int stride)
  87. +;-----------------------------------------------------------------------------
  88. +%macro STORE_DIFFx2 6
  89. +    psrad       %1, 6
  90. +    psrad       %2, 6
  91. +    packssdw    %1, %2
  92. +    movq        %3, [%5]
  93. +    movhps      %3, [%5+%6]
  94. +    paddsw      %1, %3
  95. +    CLIPW       %1, %4, [pw_pixel_max]
  96. +    movq      [%5], %1
  97. +    movhps [%5+%6], %1
  98. +%endmacro
  99. +
  100. +%macro STORE_DIFF16 5
  101. +    psrad       %1, 6
  102. +    psrad       %2, 6
  103. +    packssdw    %1, %2
  104. +    paddsw      %1, [%5]
  105. +    CLIPW       %1, %3, %4
  106. +    mova      [%5], %1
  107. +%endmacro
  108. +
  109. +;dst, in, stride
  110. +%macro IDCT4_ADD_10 3
  111. +    mova  m0, [%2+ 0]
  112. +    mova  m1, [%2+16]
  113. +    mova  m2, [%2+32]
  114. +    mova  m3, [%2+48]
  115. +    IDCT4_1D d,0,1,2,3,4,5
  116. +    TRANSPOSE4x4D 0,1,2,3,4
  117. +    paddd m0, [pd_32]
  118. +    IDCT4_1D d,0,1,2,3,4,5
  119. +    pxor  m5, m5
  120. +    STORE_DIFFx2 m0, m1, m4, m5, %1, %3
  121. +    lea   %1, [%1+%3*2]
  122. +    STORE_DIFFx2 m2, m3, m4, m5, %1, %3
  123. +%endmacro
  124. +
  125. +%macro IDCT_ADD_10 1
  126. +cglobal h264_idct_add_10_%1, 3,3
  127. +    IDCT4_ADD_10 r0, r1, r2
  128. +    RET
  129. +%endmacro
  130. +
  131. +INIT_XMM
  132. +IDCT_ADD_10 sse2
  133. +%ifdef HAVE_AVX
  134. +INIT_AVX
  135. +IDCT_ADD_10 avx
  136. +%endif
  137. +
  138. +;-----------------------------------------------------------------------------
  139. +; h264_idct_add16(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
  140. +;-----------------------------------------------------------------------------
  141. +;;;;;;; NO FATE SAMPLES TRIGGER THIS
  142. +%macro ADD4x4IDCT 1
  143. +add4x4_idct_%1:
  144. +    add   r5, r0
  145. +    mova  m0, [r2+ 0]
  146. +    mova  m1, [r2+16]
  147. +    mova  m2, [r2+32]
  148. +    mova  m3, [r2+48]
  149. +    IDCT4_1D d,0,1,2,3,4,5
  150. +    TRANSPOSE4x4D 0,1,2,3,4
  151. +    paddd m0, [pd_32]
  152. +    IDCT4_1D d,0,1,2,3,4,5
  153. +    pxor  m5, m5
  154. +    STORE_DIFFx2 m0, m1, m4, m5, r5, r3
  155. +    lea   r5, [r5+r3*2]
  156. +    STORE_DIFFx2 m2, m3, m4, m5, r5, r3
  157. +    ret
  158. +%endmacro
  159. +
  160. +INIT_XMM
  161. +ALIGN 16
  162. +ADD4x4IDCT sse2
  163. +%ifdef HAVE_AVX
  164. +INIT_AVX
  165. +ALIGN 16
  166. +ADD4x4IDCT avx
  167. +%endif
  168. +
  169. +%macro ADD16_OP 3
  170. +    cmp          byte [r4+%3], 0
  171. +    jz .skipblock%2
  172. +    mov         r5d, dword [r1+%2*4]
  173. +    call add4x4_idct_%1
  174. +.skipblock%2:
  175. +%if %2<15
  176. +    add          r2, 64
  177. +%endif
  178. +%endmacro
  179. +
  180. +%macro IDCT_ADD16_10 1
  181. +cglobal h264_idct_add16_10_%1, 5,6
  182. +    ADD16_OP %1, 0, 4+1*8
  183. +    ADD16_OP %1, 1, 5+1*8
  184. +    ADD16_OP %1, 2, 4+2*8
  185. +    ADD16_OP %1, 3, 5+2*8
  186. +    ADD16_OP %1, 4, 6+1*8
  187. +    ADD16_OP %1, 5, 7+1*8
  188. +    ADD16_OP %1, 6, 6+2*8
  189. +    ADD16_OP %1, 7, 7+2*8
  190. +    ADD16_OP %1, 8, 4+3*8
  191. +    ADD16_OP %1, 9, 5+3*8
  192. +    ADD16_OP %1, 10, 4+4*8
  193. +    ADD16_OP %1, 11, 5+4*8
  194. +    ADD16_OP %1, 12, 6+3*8
  195. +    ADD16_OP %1, 13, 7+3*8
  196. +    ADD16_OP %1, 14, 6+4*8
  197. +    ADD16_OP %1, 15, 7+4*8
  198. +    RET
  199. +%endmacro
  200. +
  201. +INIT_XMM
  202. +IDCT_ADD16_10 sse2
  203. +%ifdef HAVE_AVX
  204. +INIT_AVX
  205. +IDCT_ADD16_10 avx
  206. +%endif
  207. +
  208. +;-----------------------------------------------------------------------------
  209. +; void h264_idct_dc_add(pixel *dst, dctcoef *block, int stride)
  210. +;-----------------------------------------------------------------------------
  211. +%macro IDCT_DC_ADD_OP_10 3
  212. +    pxor      m5, m5
  213. +%if avx_enabled
  214. +    paddw     m1, m0, [%1+0   ]
  215. +    paddw     m2, m0, [%1+%2  ]
  216. +    paddw     m3, m0, [%1+%2*2]
  217. +    paddw     m4, m0, [%1+%3  ]
  218. +%else
  219. +    mova      m1, [%1+0   ]
  220. +    mova      m2, [%1+%2  ]
  221. +    mova      m3, [%1+%2*2]
  222. +    mova      m4, [%1+%3  ]
  223. +    paddw     m1, m0
  224. +    paddw     m2, m0
  225. +    paddw     m3, m0
  226. +    paddw     m4, m0
  227. +%endif
  228. +    CLIPW     m1, m5, m6
  229. +    CLIPW     m2, m5, m6
  230. +    CLIPW     m3, m5, m6
  231. +    CLIPW     m4, m5, m6
  232. +    mova [%1+0   ], m1
  233. +    mova [%1+%2  ], m2
  234. +    mova [%1+%2*2], m3
  235. +    mova [%1+%3  ], m4
  236. +%endmacro
  237. +
  238. +INIT_MMX
  239. +cglobal h264_idct_dc_add_10_mmx2,3,3
  240. +    movd      m0, dword [r1]
  241. +    paddd     m0, [pd_32]
  242. +    psrad     m0, 6
  243. +    lea       r1, [r2*3]
  244. +    pshufw    m0, m0, 0
  245. +    mova      m6, [pw_pixel_max]
  246. +    IDCT_DC_ADD_OP_10 r0, r2, r1
  247. +    RET
  248. +
  249. +;-----------------------------------------------------------------------------
  250. +; void h264_idct8_dc_add(pixel *dst, dctcoef *block, int stride)
  251. +;-----------------------------------------------------------------------------
  252. +%macro IDCT8_DC_ADD 1
  253. +cglobal h264_idct8_dc_add_10_%1,3,3,7
  254. +    mov      r1d, dword [r1]
  255. +    add       r1, 32
  256. +    sar       r1, 6
  257. +    movd      m0, r1d
  258. +    lea       r1, [r2*3]
  259. +    SPLATW    m0, m0, 0
  260. +    mova      m6, [pw_pixel_max]
  261. +    IDCT_DC_ADD_OP_10 r0, r2, r1
  262. +    lea       r0, [r0+r2*4]
  263. +    IDCT_DC_ADD_OP_10 r0, r2, r1
  264. +    RET
  265. +%endmacro
  266. +
  267. +INIT_XMM
  268. +IDCT8_DC_ADD sse2
  269. +%ifdef HAVE_AVX
  270. +INIT_AVX
  271. +IDCT8_DC_ADD avx
  272. +%endif
  273. +
  274. +;-----------------------------------------------------------------------------
  275. +; h264_idct_add16intra(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
  276. +;-----------------------------------------------------------------------------
  277. +%macro AC 2
  278. +.ac%2
  279. +    mov  r5d, dword [r1+(%2+0)*4]
  280. +    call add4x4_idct_%1
  281. +    mov  r5d, dword [r1+(%2+1)*4]
  282. +    add  r2, 64
  283. +    call add4x4_idct_%1
  284. +    add  r2, 64
  285. +    jmp .skipadd%2
  286. +%endmacro
  287. +
  288. +%macro ADD16_OP_INTRA 3
  289. +    cmp         word [r4+%3], 0
  290. +    jnz .ac%2
  291. +    mov         r6d, dword [r2+ 0]
  292. +    or          r6d, dword [r2+64]
  293. +    jz .skipblock%2
  294. +    mov  r5d, dword [r1+(%2+0)*4]
  295. +    call idct_dc_add_%1
  296. +.skipblock%2:
  297. +%if %2<15
  298. +    add          r2, 128
  299. +%endif
  300. +.skipadd%2:
  301. +%endmacro
  302. +
  303. +%macro IDCT_ADD16INTRA_10 1
  304. +idct_dc_add_%1:
  305. +    add       r5, r0
  306. +    movq      m0, [r2+ 0]
  307. +    movhps    m0, [r2+64]
  308. +    paddd     m0, [pd_32]
  309. +    psrad     m0, 6
  310. +    pshufhw   m0, m0, 0
  311. +    pshuflw   m0, m0, 0
  312. +    lea       r6, [r3*3]
  313. +    mova      m6, [pw_pixel_max]
  314. +    IDCT_DC_ADD_OP_10 r5, r3, r6
  315. +    ret
  316. +
  317. +cglobal h264_idct_add16intra_10_%1,5,7,8
  318. +    ADD16_OP_INTRA %1, 0, 4+1*8
  319. +    ADD16_OP_INTRA %1, 2, 4+2*8
  320. +    ADD16_OP_INTRA %1, 4, 6+1*8
  321. +    ADD16_OP_INTRA %1, 6, 6+2*8
  322. +    ADD16_OP_INTRA %1, 8, 4+3*8
  323. +    ADD16_OP_INTRA %1, 10, 4+4*8
  324. +    ADD16_OP_INTRA %1, 12, 6+3*8
  325. +    ADD16_OP_INTRA %1, 14, 6+4*8
  326. +    RET
  327. +%assign i 14
  328. +%rep 8
  329. +    AC %1, i
  330. +%assign i i-2
  331. +%endrep
  332. +%endmacro
  333. +
  334. +INIT_XMM
  335. +IDCT_ADD16INTRA_10 sse2
  336. +%ifdef HAVE_AVX
  337. +INIT_AVX
  338. +IDCT_ADD16INTRA_10 avx
  339. +%endif
  340. +
  341. +;-----------------------------------------------------------------------------
  342. +; h264_idct_add8(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
  343. +;-----------------------------------------------------------------------------
  344. +%macro IDCT_ADD8 1
  345. +cglobal h264_idct_add8_10_%1,5,7
  346. +    mov          r5, 16
  347. +    add          r2, 1024
  348. +%ifdef PIC
  349. +    lea         r11, [scan8_mem]
  350. +%endif
  351. +%ifdef ARCH_X86_64
  352. +    mov         r10, r0
  353. +%endif
  354. +.nextblock:
  355. +    movzx        r6, byte [scan8+r5]
  356. +    movzx        r6, byte [r4+r6]
  357. +    or          r6d, dword [r2]
  358. +    test         r6, r6
  359. +    jz .skipblock
  360. +%ifdef ARCH_X86_64
  361. +    mov         r0d, dword [r1+r5*4]
  362. +    add          r0, [r10]
  363. +%else
  364. +    mov          r0, r0m
  365. +    mov          r0, [r0]
  366. +    add          r0, dword [r1+r5*4]
  367. +%endif
  368. +    IDCT4_ADD_10 r0, r2, r3
  369. +.skipblock:
  370. +    inc          r5
  371. +    add          r2, 64
  372. +    test         r5, 3
  373. +    jnz .nextblock
  374. +%ifdef ARCH_X86_64
  375. +    add         r10, gprsize
  376. +%else
  377. +    add        r0mp, gprsize
  378. +%endif
  379. +    test         r5, 4
  380. +    jnz .nextblock
  381. +    REP_RET
  382. +%endmacro ; IDCT_ADD8
  383. +
  384. +INIT_XMM
  385. +IDCT_ADD8 sse2
  386. +%ifdef HAVE_AVX
  387. +INIT_AVX
  388. +IDCT_ADD8 avx
  389. +%endif
  390. +
  391. +;-----------------------------------------------------------------------------
  392. +; void h264_idct8_add(pixel *dst, dctcoef *block, int stride)
  393. +;-----------------------------------------------------------------------------
  394. +%macro IDCT8_1D 2
  395. +    SWAP         0, 1
  396. +    psrad        m4, m5, 1
  397. +    psrad        m1, m0, 1
  398. +    paddd        m4, m5
  399. +    paddd        m1, m0
  400. +    paddd        m4, m7
  401. +    paddd        m1, m5
  402. +    psubd        m4, m0
  403. +    paddd        m1, m3
  404. +
  405. +    psubd        m0, m3
  406. +    psubd        m5, m3
  407. +    paddd        m0, m7
  408. +    psubd        m5, m7
  409. +    psrad        m3, 1
  410. +    psrad        m7, 1
  411. +    psubd        m0, m3
  412. +    psubd        m5, m7
  413. +
  414. +    SWAP         1, 7
  415. +    psrad        m1, m7, 2
  416. +    psrad        m3, m4, 2
  417. +    paddd        m3, m0
  418. +    psrad        m0, 2
  419. +    paddd        m1, m5
  420. +    psrad        m5, 2
  421. +    psubd        m0, m4
  422. +    psubd        m7, m5
  423. +
  424. +    SWAP         5, 6
  425. +    psrad        m4, m2, 1
  426. +    psrad        m6, m5, 1
  427. +    psubd        m4, m5
  428. +    paddd        m6, m2
  429. +
  430. +    mova         m2, %1
  431. +    mova         m5, %2
  432. +    SUMSUB_BA    d, 5, 2
  433. +    SUMSUB_BA    d, 6, 5
  434. +    SUMSUB_BA    d, 4, 2
  435. +    SUMSUB_BA    d, 7, 6
  436. +    SUMSUB_BA    d, 0, 4
  437. +    SUMSUB_BA    d, 3, 2
  438. +    SUMSUB_BA    d, 1, 5
  439. +    SWAP         7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567
  440. +%endmacro
  441. +
  442. +%macro IDCT8_1D_FULL 1
  443. +    mova         m7, [%1+112*2]
  444. +    mova         m6, [%1+ 96*2]
  445. +    mova         m5, [%1+ 80*2]
  446. +    mova         m3, [%1+ 48*2]
  447. +    mova         m2, [%1+ 32*2]
  448. +    mova         m1, [%1+ 16*2]
  449. +    IDCT8_1D   [%1], [%1+ 64*2]
  450. +%endmacro
  451. +
  452. +; %1=int16_t *block, %2=int16_t *dstblock
  453. +%macro IDCT8_ADD_SSE_START 2
  454. +    IDCT8_1D_FULL %1
  455. +%ifdef ARCH_X86_64
  456. +    TRANSPOSE4x4D  0,1,2,3,8
  457. +    mova    [%2    ], m0
  458. +    TRANSPOSE4x4D  4,5,6,7,8
  459. +    mova    [%2+8*2], m4
  460. +%else
  461. +    mova         [%1], m7
  462. +    TRANSPOSE4x4D   0,1,2,3,7
  463. +    mova           m7, [%1]
  464. +    mova    [%2     ], m0
  465. +    mova    [%2+16*2], m1
  466. +    mova    [%2+32*2], m2
  467. +    mova    [%2+48*2], m3
  468. +    TRANSPOSE4x4D   4,5,6,7,3
  469. +    mova    [%2+ 8*2], m4
  470. +    mova    [%2+24*2], m5
  471. +    mova    [%2+40*2], m6
  472. +    mova    [%2+56*2], m7
  473. +%endif
  474. +%endmacro
  475. +
  476. +; %1=uint8_t *dst, %2=int16_t *block, %3=int stride
  477. +%macro IDCT8_ADD_SSE_END 3
  478. +    IDCT8_1D_FULL %2
  479. +    mova  [%2     ], m6
  480. +    mova  [%2+16*2], m7
  481. +
  482. +    pxor         m7, m7
  483. +    STORE_DIFFx2 m0, m1, m6, m7, %1, %3
  484. +    lea          %1, [%1+%3*2]
  485. +    STORE_DIFFx2 m2, m3, m6, m7, %1, %3
  486. +    mova         m0, [%2     ]
  487. +    mova         m1, [%2+16*2]
  488. +    lea          %1, [%1+%3*2]
  489. +    STORE_DIFFx2 m4, m5, m6, m7, %1, %3
  490. +    lea          %1, [%1+%3*2]
  491. +    STORE_DIFFx2 m0, m1, m6, m7, %1, %3
  492. +%endmacro
  493. +
  494. +%macro IDCT8_ADD 1
  495. +cglobal h264_idct8_add_10_%1, 3,4,16
  496. +%ifndef UNIX64
  497. +    %assign pad 16-gprsize-(stack_offset&15)
  498. +    sub  rsp, pad
  499. +    call h264_idct8_add1_10_%1
  500. +    add  rsp, pad
  501. +    RET
  502. +%endif
  503. +
  504. +ALIGN 16
  505. +; TODO: does not need to use stack
  506. +h264_idct8_add1_10_%1:
  507. +%assign pad 256+16-gprsize
  508. +    sub          rsp, pad
  509. +    add   dword [r1], 32
  510. +
  511. +%ifdef ARCH_X86_64
  512. +    IDCT8_ADD_SSE_START r1, rsp
  513. +    SWAP 1,  9
  514. +    SWAP 2, 10
  515. +    SWAP 3, 11
  516. +    SWAP 5, 13
  517. +    SWAP 6, 14
  518. +    SWAP 7, 15
  519. +    IDCT8_ADD_SSE_START r1+16, rsp+128
  520. +    PERMUTE 1,9, 2,10, 3,11, 5,1, 6,2, 7,3, 9,13, 10,14, 11,15, 13,5, 14,6, 15,7
  521. +    IDCT8_1D [rsp], [rsp+128]
  522. +    SWAP 0,  8
  523. +    SWAP 1,  9
  524. +    SWAP 2, 10
  525. +    SWAP 3, 11
  526. +    SWAP 4, 12
  527. +    SWAP 5, 13
  528. +    SWAP 6, 14
  529. +    SWAP 7, 15
  530. +    IDCT8_1D [rsp+16], [rsp+144]
  531. +    psrad         m8, 6
  532. +    psrad         m0, 6
  533. +    packssdw      m8, m0
  534. +    paddsw        m8, [r0]
  535. +    pxor          m0, m0
  536. +    CLIPW         m8, m0, [pw_pixel_max]
  537. +    mova        [r0], m8
  538. +    mova          m8, [pw_pixel_max]
  539. +    STORE_DIFF16  m9, m1, m0, m8, r0+r2
  540. +    lea           r0, [r0+r2*2]
  541. +    STORE_DIFF16 m10, m2, m0, m8, r0
  542. +    STORE_DIFF16 m11, m3, m0, m8, r0+r2
  543. +    lea           r0, [r0+r2*2]
  544. +    STORE_DIFF16 m12, m4, m0, m8, r0
  545. +    STORE_DIFF16 m13, m5, m0, m8, r0+r2
  546. +    lea           r0, [r0+r2*2]
  547. +    STORE_DIFF16 m14, m6, m0, m8, r0
  548. +    STORE_DIFF16 m15, m7, m0, m8, r0+r2
  549. +%else
  550. +    IDCT8_ADD_SSE_START r1,    rsp
  551. +    IDCT8_ADD_SSE_START r1+16, rsp+128
  552. +    lea           r3, [r0+8]
  553. +    IDCT8_ADD_SSE_END r0, rsp,    r2
  554. +    IDCT8_ADD_SSE_END r3, rsp+16, r2
  555. +%endif ; ARCH_X86_64
  556. +
  557. +    add          rsp, pad
  558. +    ret
  559. +%endmacro
  560. +
  561. +INIT_XMM
  562. +IDCT8_ADD sse2
  563. +%ifdef HAVE_AVX
  564. +INIT_AVX
  565. +IDCT8_ADD avx
  566. +%endif
  567. +
  568. +;-----------------------------------------------------------------------------
  569. +; h264_idct8_add4(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
  570. +;-----------------------------------------------------------------------------
  571. +;;;;;;; NO FATE SAMPLES TRIGGER THIS
  572. +%macro IDCT8_ADD4_OP 3
  573. +    cmp       byte [r4+%3], 0
  574. +    jz .skipblock%2
  575. +    mov      r0d, dword [r6+%2*4]
  576. +    add       r0, r5
  577. +    call h264_idct8_add1_10_%1
  578. +.skipblock%2:
  579. +%if %2<12
  580. +    add       r1, 256
  581. +%endif
  582. +%endmacro
  583. +
  584. +%macro IDCT8_ADD4 1
  585. +cglobal h264_idct8_add4_10_%1, 0,7,16
  586. +    %assign pad 16-gprsize-(stack_offset&15)
  587. +    SUB      rsp, pad
  588. +    mov       r5, r0mp
  589. +    mov       r6, r1mp
  590. +    mov       r1, r2mp
  591. +    mov      r2d, r3m
  592. +    movifnidn r4, r4mp
  593. +    IDCT8_ADD4_OP %1,  0, 4+1*8
  594. +    IDCT8_ADD4_OP %1,  4, 6+1*8
  595. +    IDCT8_ADD4_OP %1,  8, 4+3*8
  596. +    IDCT8_ADD4_OP %1, 12, 6+3*8
  597. +    ADD       rsp, pad
  598. +    RET
  599. +%endmacro ; IDCT8_ADD4
  600. +
  601. +INIT_XMM
  602. +IDCT8_ADD4 sse2
  603. +%ifdef HAVE_AVX
  604. +INIT_AVX
  605. +IDCT8_ADD4 avx
  606. +%endif
  607. diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c
  608. index 1c07d14..d60fbd5 100644
  609. --- a/libavcodec/x86/h264dsp_mmx.c
  610. +++ b/libavcodec/x86/h264dsp_mmx.c
  611. @@ -27,6 +27,43 @@ DECLARE_ALIGNED(8, static const uint64_t, ff_pb_3_1  ) = 0x0103010301030103ULL;
  612.  
  613.  /***********************************/
  614.  /* IDCT */
  615. +#define IDCT_ADD_FUNC(NUM, DEPTH, OPT) \
  616. +void ff_h264_idct ## NUM ## _add_ ## DEPTH ## _ ## OPT (uint8_t *dst, int16_t *block, int stride);
  617. +
  618. +IDCT_ADD_FUNC(, 10, sse2)
  619. +IDCT_ADD_FUNC(_dc, 10, mmx2)
  620. +IDCT_ADD_FUNC(8_dc, 10, sse2)
  621. +IDCT_ADD_FUNC(8, 10, sse2)
  622. +#if HAVE_AVX
  623. +IDCT_ADD_FUNC(, 10, avx)
  624. +IDCT_ADD_FUNC(8_dc, 10, avx)
  625. +IDCT_ADD_FUNC(8, 10, avx)
  626. +#endif
  627. +
  628. +
  629. +#define IDCT_ADD_REP_FUNC(NUM, REP, DEPTH, OPT) \
  630. +void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
  631. +                              (uint8_t *dst, const int *block_offset, \
  632. +                              DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  633. +
  634. +IDCT_ADD_REP_FUNC(8, 4, 10, sse2)
  635. +IDCT_ADD_REP_FUNC(8, 4, 10, avx)
  636. +IDCT_ADD_REP_FUNC(, 16, 10, sse2)
  637. +IDCT_ADD_REP_FUNC(, 16intra, 10, sse2)
  638. +#if HAVE_AVX
  639. +IDCT_ADD_REP_FUNC(, 16, 10, avx)
  640. +IDCT_ADD_REP_FUNC(, 16intra, 10, avx)
  641. +#endif
  642. +
  643. +
  644. +#define IDCT_ADD_REP_FUNC2(NUM, REP, DEPTH, OPT) \
  645. +void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
  646. +                              (uint8_t **dst, const int *block_offset, \
  647. +                              DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  648. +IDCT_ADD_REP_FUNC2(, 8, 10, sse2)
  649. +#if HAVE_AVX
  650. +IDCT_ADD_REP_FUNC2(, 8, 10, avx)
  651. +#endif
  652.  
  653.  void ff_h264_idct_add_mmx     (uint8_t *dst, int16_t *block, int stride);
  654.  void ff_h264_idct8_add_mmx    (uint8_t *dst, int16_t *block, int stride);
  655. @@ -418,7 +455,17 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  656.              c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_10_mmxext;
  657.              c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_mmxext;
  658.  #endif
  659. +            c->h264_idct_dc_add= ff_h264_idct_dc_add_10_mmx2;
  660.              if (mm_flags&AV_CPU_FLAG_SSE2) {
  661. +                c->h264_idct_add       = ff_h264_idct_add_10_sse2;
  662. +                c->h264_idct8_dc_add   = ff_h264_idct8_dc_add_10_sse2;
  663. +                c->h264_idct8_add      = ff_h264_idct8_add_10_sse2;
  664. +
  665. +                c->h264_idct_add16     = ff_h264_idct_add16_10_sse2;
  666. +                c->h264_idct8_add4     = ff_h264_idct8_add4_10_sse2;
  667. +                c->h264_idct_add8      = ff_h264_idct_add8_10_sse2;
  668. +                c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2;
  669. +
  670.                  c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_sse2;
  671.                  c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_sse2;
  672.  #if HAVE_ALIGNED_STACK
  673. @@ -428,7 +475,18 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  674.                  c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_sse2;
  675.  #endif
  676.              }
  677. +#if HAVE_AVX
  678.              if (mm_flags&AV_CPU_FLAG_AVX) {
  679. +                c->h264_idct_dc_add    =
  680. +                c->h264_idct_add       = ff_h264_idct_add_10_avx;
  681. +                c->h264_idct8_add      = ff_h264_idct8_add_10_avx;
  682. +                c->h264_idct8_dc_add   = ff_h264_idct8_dc_add_10_avx;
  683. +
  684. +                c->h264_idct_add16     = ff_h264_idct_add16_10_avx;
  685. +                c->h264_idct8_add4     = ff_h264_idct8_add4_10_avx;
  686. +                c->h264_idct_add8      = ff_h264_idct_add8_10_avx;
  687. +                c->h264_idct_add16intra= ff_h264_idct_add16intra_10_avx;
  688. +
  689.                  c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_avx;
  690.                  c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_avx;
  691.  #if HAVE_ALIGNED_STACK
  692. @@ -438,6 +496,7 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  693.                  c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_avx;
  694.  #endif
  695.              }
  696. +#endif /* HAVE_AVX */
  697.          }
  698.      }
  699.  #endif
  700. --
  701. 1.7.5.1
  702.  
  703.  
  704. From 7c1c19152cad7aa57a798390da4e3a56c1608a82 Mon Sep 17 00:00:00 2001
  705. From: Daniel Kang <daniel.d.kang@gmail.com>
  706. Date: Tue, 24 May 2011 15:15:08 -0400
  707. Subject: [PATCH 2/2] Update 8-bit H.264 IDCT function names to reflect
  708.  bit-depth.
  709.  
  710. ---
  711. libavcodec/h264dsp.h         |    1 -
  712.  libavcodec/x86/h264_idct.asm |   38 +++++++++---------
  713.  libavcodec/x86/h264dsp_mmx.c |   90 ++++++++++++++++++------------------------
  714.  3 files changed, 57 insertions(+), 72 deletions(-)
  715.  
  716. diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h
  717. index 87a1dd9..864c118 100644
  718. --- a/libavcodec/h264dsp.h
  719. +++ b/libavcodec/h264dsp.h
  720. @@ -66,7 +66,6 @@ typedef struct H264DSPContext{
  721.      void (*h264_idct_dc_add)(uint8_t *dst/*align 4*/, DCTELEM *block/*align 16*/, int stride);
  722.      void (*h264_idct8_dc_add)(uint8_t *dst/*align 8*/, DCTELEM *block/*align 16*/, int stride);
  723.  
  724. -    void (*h264_dct)(DCTELEM block[4][4]);
  725.      void (*h264_idct_add16)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
  726.      void (*h264_idct8_add4)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
  727.      void (*h264_idct_add8)(uint8_t **dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[6*8]);
  728. diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm
  729. index ae70a30..f90f41c 100644
  730. --- a/libavcodec/x86/h264_idct.asm
  731. +++ b/libavcodec/x86/h264_idct.asm
  732. @@ -73,7 +73,7 @@ SECTION .text
  733.  
  734.  INIT_MMX
  735.  ; ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride)
  736. -cglobal h264_idct_add_mmx, 3, 3, 0
  737. +cglobal h264_idct_add_8_mmx, 3, 3, 0
  738.      IDCT4_ADD    r0, r1, r2
  739.      RET
  740.  
  741. @@ -125,7 +125,7 @@ cglobal h264_idct_add_mmx, 3, 3, 0
  742.      SUMSUB_BA    w, 0, 4
  743.      SUMSUB_BA    w, 3, 2
  744.      SUMSUB_BA    w, 1, 5
  745. -    SWAP          7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567
  746. +    SWAP         7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567
  747.  %endmacro
  748.  
  749.  %macro IDCT8_1D_FULL 1
  750. @@ -177,7 +177,7 @@ cglobal h264_idct_add_mmx, 3, 3, 0
  751.  
  752.  INIT_MMX
  753.  ; ff_h264_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
  754. -cglobal h264_idct8_add_mmx, 3, 4, 0
  755. +cglobal h264_idct8_add_8_mmx, 3, 4, 0
  756.      %assign pad 128+4-(stack_offset&7)
  757.      SUB         rsp, pad
  758.  
  759. @@ -237,7 +237,7 @@ cglobal h264_idct8_add_mmx, 3, 4, 0
  760.  
  761.  INIT_XMM
  762.  ; ff_h264_idct8_add_sse2(uint8_t *dst, int16_t *block, int stride)
  763. -cglobal h264_idct8_add_sse2, 3, 4, 10
  764. +cglobal h264_idct8_add_8_sse2, 3, 4, 10
  765.      IDCT8_ADD_SSE r0, r1, r2, r3
  766.      RET
  767.  
  768. @@ -261,7 +261,7 @@ cglobal h264_idct8_add_sse2, 3, 4, 10
  769.      packuswb     m1, m1
  770.  %endmacro
  771.  
  772. -%macro DC_ADD_MMX2_OP 3-4
  773. +%macro DC_ADD_MMX2_OP 4
  774.      %1           m2, [%2     ]
  775.      %1           m3, [%2+%3  ]
  776.      %1           m4, [%2+%3*2]
  777. @@ -282,13 +282,13 @@ cglobal h264_idct8_add_sse2, 3, 4, 10
  778.  
  779.  INIT_MMX
  780.  ; ff_h264_idct_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
  781. -cglobal h264_idct_dc_add_mmx2, 3, 3, 0
  782. +cglobal h264_idct_dc_add_8_mmx2, 3, 3, 0
  783.      DC_ADD_MMX2_INIT r1, r2
  784.      DC_ADD_MMX2_OP movh, r0, r2, r1
  785.      RET
  786.  
  787.  ; ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride)
  788. -cglobal h264_idct8_dc_add_mmx2, 3, 3, 0
  789. +cglobal h264_idct8_dc_add_8_mmx2, 3, 3, 0
  790.      DC_ADD_MMX2_INIT r1, r2
  791.      DC_ADD_MMX2_OP mova, r0, r2, r1
  792.      lea          r0, [r0+r2*4]
  793. @@ -297,7 +297,7 @@ cglobal h264_idct8_dc_add_mmx2, 3, 3, 0
  794.  
  795.  ; ff_h264_idct_add16_mmx(uint8_t *dst, const int *block_offset,
  796.  ;             DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  797. -cglobal h264_idct_add16_mmx, 5, 7, 0
  798. +cglobal h264_idct_add16_8_mmx, 5, 7, 0
  799.      xor          r5, r5
  800.  %ifdef PIC
  801.      lea         r11, [scan8_mem]
  802. @@ -319,7 +319,7 @@ cglobal h264_idct_add16_mmx, 5, 7, 0
  803.  
  804.  ; ff_h264_idct8_add4_mmx(uint8_t *dst, const int *block_offset,
  805.  ;                        DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  806. -cglobal h264_idct8_add4_mmx, 5, 7, 0
  807. +cglobal h264_idct8_add4_8_mmx, 5, 7, 0
  808.      %assign pad 128+4-(stack_offset&7)
  809.      SUB         rsp, pad
  810.  
  811. @@ -351,7 +351,7 @@ cglobal h264_idct8_add4_mmx, 5, 7, 0
  812.  
  813.  ; ff_h264_idct_add16_mmx2(uint8_t *dst, const int *block_offset,
  814.  ;                         DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  815. -cglobal h264_idct_add16_mmx2, 5, 7, 0
  816. +cglobal h264_idct_add16_8_mmx2, 5, 7, 0
  817.      xor          r5, r5
  818.  %ifdef PIC
  819.      lea         r11, [scan8_mem]
  820. @@ -398,7 +398,7 @@ cglobal h264_idct_add16_mmx2, 5, 7, 0
  821.  
  822.  ; ff_h264_idct_add16intra_mmx(uint8_t *dst, const int *block_offset,
  823.  ;                             DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  824. -cglobal h264_idct_add16intra_mmx, 5, 7, 0
  825. +cglobal h264_idct_add16intra_8_mmx, 5, 7, 0
  826.      xor          r5, r5
  827.  %ifdef PIC
  828.      lea         r11, [scan8_mem]
  829. @@ -421,7 +421,7 @@ cglobal h264_idct_add16intra_mmx, 5, 7, 0
  830.  
  831.  ; ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
  832.  ;                              DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  833. -cglobal h264_idct_add16intra_mmx2, 5, 7, 0
  834. +cglobal h264_idct_add16intra_8_mmx2, 5, 7, 0
  835.      xor          r5, r5
  836.  %ifdef PIC
  837.      lea         r11, [scan8_mem]
  838. @@ -466,7 +466,7 @@ cglobal h264_idct_add16intra_mmx2, 5, 7, 0
  839.  
  840.  ; ff_h264_idct8_add4_mmx2(uint8_t *dst, const int *block_offset,
  841.  ;                         DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  842. -cglobal h264_idct8_add4_mmx2, 5, 7, 0
  843. +cglobal h264_idct8_add4_8_mmx2, 5, 7, 0
  844.      %assign pad 128+4-(stack_offset&7)
  845.      SUB         rsp, pad
  846.  
  847. @@ -529,7 +529,7 @@ cglobal h264_idct8_add4_mmx2, 5, 7, 0
  848.  INIT_XMM
  849.  ; ff_h264_idct8_add4_sse2(uint8_t *dst, const int *block_offset,
  850.  ;                         DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  851. -cglobal h264_idct8_add4_sse2, 5, 7, 10
  852. +cglobal h264_idct8_add4_8_sse2, 5, 7, 10
  853.      xor          r5, r5
  854.  %ifdef PIC
  855.      lea         r11, [scan8_mem]
  856. @@ -607,7 +607,7 @@ h264_idct_add8_mmx_plane:
  857.  
  858.  ; ff_h264_idct_add8_mmx(uint8_t **dest, const int *block_offset,
  859.  ;                       DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  860. -cglobal h264_idct_add8_mmx, 5, 7, 0
  861. +cglobal h264_idct_add8_8_mmx, 5, 7, 0
  862.      mov          r5, 16
  863.      add          r2, 512
  864.  %ifdef PIC
  865. @@ -668,7 +668,7 @@ h264_idct_add8_mmx2_plane
  866.  
  867.  ; ff_h264_idct_add8_mmx2(uint8_t **dest, const int *block_offset,
  868.  ;                        DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  869. -cglobal h264_idct_add8_mmx2, 5, 7, 0
  870. +cglobal h264_idct_add8_8_mmx2, 5, 7, 0
  871.      mov          r5, 16
  872.      add          r2, 512
  873.  %ifdef ARCH_X86_64
  874. @@ -744,7 +744,7 @@ x264_add8x4_idct_sse2:
  875.  
  876.  ; ff_h264_idct_add16_sse2(uint8_t *dst, const int *block_offset,
  877.  ;                         DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  878. -cglobal h264_idct_add16_sse2, 5, 5, 8
  879. +cglobal h264_idct_add16_8_sse2, 5, 5, 8
  880.  %ifdef ARCH_X86_64
  881.      mov        r10, r0
  882.  %endif
  883. @@ -791,7 +791,7 @@ cglobal h264_idct_add16_sse2, 5, 5, 8
  884.  
  885.  ; ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset,
  886.  ;                              DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  887. -cglobal h264_idct_add16intra_sse2, 5, 7, 8
  888. +cglobal h264_idct_add16intra_8_sse2, 5, 7, 8
  889.  %ifdef ARCH_X86_64
  890.      mov        r10, r0
  891.  %endif
  892. @@ -840,7 +840,7 @@ cglobal h264_idct_add16intra_sse2, 5, 7, 8
  893.  
  894.  ; ff_h264_idct_add8_sse2(uint8_t **dest, const int *block_offset,
  895.  ;                        DCTELEM *block, int stride, const uint8_t nnzc[6*8])
  896. -cglobal h264_idct_add8_sse2, 5, 7, 8
  897. +cglobal h264_idct_add8_8_sse2, 5, 7, 8
  898.      add          r2, 512
  899.  %ifdef ARCH_X86_64
  900.      mov         r10, r0
  901. diff --git a/libavcodec/x86/h264dsp_mmx.c b/libavcodec/x86/h264dsp_mmx.c
  902. index d60fbd5..1a31e41 100644
  903. --- a/libavcodec/x86/h264dsp_mmx.c
  904. +++ b/libavcodec/x86/h264dsp_mmx.c
  905. @@ -30,9 +30,14 @@ DECLARE_ALIGNED(8, static const uint64_t, ff_pb_3_1  ) = 0x0103010301030103ULL;
  906.  #define IDCT_ADD_FUNC(NUM, DEPTH, OPT) \
  907.  void ff_h264_idct ## NUM ## _add_ ## DEPTH ## _ ## OPT (uint8_t *dst, int16_t *block, int stride);
  908.  
  909. +IDCT_ADD_FUNC(, 8, mmx)
  910.  IDCT_ADD_FUNC(, 10, sse2)
  911. +IDCT_ADD_FUNC(_dc, 8, mmx2)
  912.  IDCT_ADD_FUNC(_dc, 10, mmx2)
  913. +IDCT_ADD_FUNC(8_dc, 8, mmx2)
  914.  IDCT_ADD_FUNC(8_dc, 10, sse2)
  915. +IDCT_ADD_FUNC(8, 8, mmx)
  916. +IDCT_ADD_FUNC(8, 8, sse2)
  917.  IDCT_ADD_FUNC(8, 10, sse2)
  918.  #if HAVE_AVX
  919.  IDCT_ADD_FUNC(, 10, avx)
  920. @@ -46,9 +51,18 @@ void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
  921.                                (uint8_t *dst, const int *block_offset, \
  922.                                DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  923.  
  924. +IDCT_ADD_REP_FUNC(8, 4, 8, mmx)
  925. +IDCT_ADD_REP_FUNC(8, 4, 8, mmx2)
  926. +IDCT_ADD_REP_FUNC(8, 4, 8, sse2)
  927.  IDCT_ADD_REP_FUNC(8, 4, 10, sse2)
  928.  IDCT_ADD_REP_FUNC(8, 4, 10, avx)
  929. +IDCT_ADD_REP_FUNC(, 16, 8, mmx)
  930. +IDCT_ADD_REP_FUNC(, 16, 8, mmx2)
  931. +IDCT_ADD_REP_FUNC(, 16, 8, sse2)
  932.  IDCT_ADD_REP_FUNC(, 16, 10, sse2)
  933. +IDCT_ADD_REP_FUNC(, 16intra, 8, mmx)
  934. +IDCT_ADD_REP_FUNC(, 16intra, 8, mmx2)
  935. +IDCT_ADD_REP_FUNC(, 16intra, 8, sse2)
  936.  IDCT_ADD_REP_FUNC(, 16intra, 10, sse2)
  937.  #if HAVE_AVX
  938.  IDCT_ADD_REP_FUNC(, 16, 10, avx)
  939. @@ -60,42 +74,14 @@ IDCT_ADD_REP_FUNC(, 16intra, 10, avx)
  940.  void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
  941.                                (uint8_t **dst, const int *block_offset, \
  942.                                DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  943. +IDCT_ADD_REP_FUNC2(, 8, 8, mmx)
  944. +IDCT_ADD_REP_FUNC2(, 8, 8, mmx2)
  945. +IDCT_ADD_REP_FUNC2(, 8, 8, sse2)
  946.  IDCT_ADD_REP_FUNC2(, 8, 10, sse2)
  947.  #if HAVE_AVX
  948.  IDCT_ADD_REP_FUNC2(, 8, 10, avx)
  949.  #endif
  950.  
  951. -void ff_h264_idct_add_mmx     (uint8_t *dst, int16_t *block, int stride);
  952. -void ff_h264_idct8_add_mmx    (uint8_t *dst, int16_t *block, int stride);
  953. -void ff_h264_idct8_add_sse2   (uint8_t *dst, int16_t *block, int stride);
  954. -void ff_h264_idct_dc_add_mmx2 (uint8_t *dst, int16_t *block, int stride);
  955. -void ff_h264_idct8_dc_add_mmx2(uint8_t *dst, int16_t *block, int stride);
  956. -
  957. -void ff_h264_idct_add16_mmx      (uint8_t *dst, const int *block_offset,
  958. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  959. -void ff_h264_idct8_add4_mmx      (uint8_t *dst, const int *block_offset,
  960. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  961. -void ff_h264_idct_add16_mmx2     (uint8_t *dst, const int *block_offset,
  962. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  963. -void ff_h264_idct_add16intra_mmx (uint8_t *dst, const int *block_offset,
  964. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  965. -void ff_h264_idct_add16intra_mmx2(uint8_t *dst, const int *block_offset,
  966. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  967. -void ff_h264_idct8_add4_mmx2     (uint8_t *dst, const int *block_offset,
  968. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  969. -void ff_h264_idct8_add4_sse2     (uint8_t *dst, const int *block_offset,
  970. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  971. -void ff_h264_idct_add8_mmx       (uint8_t **dest, const int *block_offset,
  972. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  973. -void ff_h264_idct_add8_mmx2      (uint8_t **dest, const int *block_offset,
  974. -                                  DCTELEM *block, int stride, const uint8_t nnzc[6*8]);
  975. -
  976. -void ff_h264_idct_add16_sse2     (uint8_t *dst, const int *block_offset, DCTELEM *block,
  977. -                                  int stride, const uint8_t nnzc[6*8]);
  978. -void ff_h264_idct_add16intra_sse2(uint8_t *dst, const int *block_offset, DCTELEM *block,
  979. -                                  int stride, const uint8_t nnzc[6*8]);
  980. -void ff_h264_idct_add8_sse2      (uint8_t **dest, const int *block_offset, DCTELEM *block,
  981. -                                  int stride, const uint8_t nnzc[6*8]);
  982.  void ff_h264_luma_dc_dequant_idct_mmx (DCTELEM *output, DCTELEM *input, int qmul);
  983.  void ff_h264_luma_dc_dequant_idct_sse2(DCTELEM *output, DCTELEM *input, int qmul);
  984.  
  985. @@ -350,24 +336,24 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  986.      }
  987.  #if HAVE_YASM
  988.      if (mm_flags & AV_CPU_FLAG_MMX) {
  989. -        c->h264_idct_dc_add=
  990. -        c->h264_idct_add= ff_h264_idct_add_mmx;
  991. -        c->h264_idct8_dc_add=
  992. -        c->h264_idct8_add= ff_h264_idct8_add_mmx;
  993. -
  994. -        c->h264_idct_add16     = ff_h264_idct_add16_mmx;
  995. -        c->h264_idct8_add4     = ff_h264_idct8_add4_mmx;
  996. -        c->h264_idct_add8      = ff_h264_idct_add8_mmx;
  997. -        c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx;
  998. +        c->h264_idct_dc_add         =
  999. +        c->h264_idct_add            = ff_h264_idct_add_8_mmx;
  1000. +        c->h264_idct8_dc_add        =
  1001. +        c->h264_idct8_add           = ff_h264_idct8_add_8_mmx;
  1002. +
  1003. +        c->h264_idct_add16          = ff_h264_idct_add16_8_mmx;
  1004. +        c->h264_idct8_add4          = ff_h264_idct8_add4_8_mmx;
  1005. +        c->h264_idct_add8           = ff_h264_idct_add8_8_mmx;
  1006. +        c->h264_idct_add16intra     = ff_h264_idct_add16intra_8_mmx;
  1007.          c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_mmx;
  1008.  
  1009.          if (mm_flags & AV_CPU_FLAG_MMX2) {
  1010. -            c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
  1011. -            c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
  1012. -            c->h264_idct_add16     = ff_h264_idct_add16_mmx2;
  1013. -            c->h264_idct8_add4     = ff_h264_idct8_add4_mmx2;
  1014. -            c->h264_idct_add8      = ff_h264_idct_add8_mmx2;
  1015. -            c->h264_idct_add16intra= ff_h264_idct_add16intra_mmx2;
  1016. +            c->h264_idct_dc_add    = ff_h264_idct_dc_add_8_mmx2;
  1017. +            c->h264_idct8_dc_add   = ff_h264_idct8_dc_add_8_mmx2;
  1018. +            c->h264_idct_add16     = ff_h264_idct_add16_8_mmx2;
  1019. +            c->h264_idct8_add4     = ff_h264_idct8_add4_8_mmx2;
  1020. +            c->h264_idct_add8      = ff_h264_idct_add8_8_mmx2;
  1021. +            c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx2;
  1022.  
  1023.              c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_8_mmxext;
  1024.              c->h264_h_loop_filter_chroma= ff_deblock_h_chroma_8_mmxext;
  1025. @@ -398,8 +384,12 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  1026.              c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
  1027.  
  1028.              if (mm_flags&AV_CPU_FLAG_SSE2) {
  1029. -                c->h264_idct8_add = ff_h264_idct8_add_sse2;
  1030. -                c->h264_idct8_add4= ff_h264_idct8_add4_sse2;
  1031. +                c->h264_idct8_add           = ff_h264_idct8_add_8_sse2;
  1032. +
  1033. +                c->h264_idct_add16          = ff_h264_idct_add16_8_sse2;
  1034. +                c->h264_idct8_add4          = ff_h264_idct8_add4_8_sse2;
  1035. +                c->h264_idct_add8           = ff_h264_idct_add8_8_sse2;
  1036. +                c->h264_idct_add16intra     = ff_h264_idct_add16intra_8_sse2;
  1037.                  c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_sse2;
  1038.  
  1039.                  c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_sse2;
  1040. @@ -420,10 +410,6 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth)
  1041.                  c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_sse2;
  1042.                  c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_sse2;
  1043.  #endif
  1044. -
  1045. -                c->h264_idct_add16 = ff_h264_idct_add16_sse2;
  1046. -                c->h264_idct_add8  = ff_h264_idct_add8_sse2;
  1047. -                c->h264_idct_add16intra = ff_h264_idct_add16intra_sse2;
  1048.              }
  1049.              if (mm_flags&AV_CPU_FLAG_SSSE3) {
  1050.                  c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3;
  1051. --
  1052. 1.7.5.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement