1 /* 2 * HEVC video decoder 3 * 4 * Copyright (C) 2012 - 2013 Guillaume Martres 5 * Copyright (C) 2013 - 2014 Pierre-Edouard Lepere 6 * 7 * 8 * This file is part of FFmpeg. 9 * 10 * FFmpeg is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * FFmpeg is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with FFmpeg; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef AVCODEC_X86_HEVCDSP_H 26 #define AVCODEC_X86_HEVCDSP_H 27 28 #include <stddef.h> 29 #include <stdint.h> 30 31 32 #define PEL_LINK(dst, idx1, idx2, idx3, name, D, opt) \ 33 dst[idx1][idx2][idx3] = ff_hevc_put_hevc_ ## name ## _ ## D ## _##opt; \ 34 dst ## _bi[idx1][idx2][idx3] = ff_hevc_put_hevc_bi_ ## name ## _ ## D ## _##opt; \ 35 dst ## _uni[idx1][idx2][idx3] = ff_hevc_put_hevc_uni_ ## name ## _ ## D ## _##opt; \ 36 dst ## _uni_w[idx1][idx2][idx3] = ff_hevc_put_hevc_uni_w_ ## name ## _ ## D ## _##opt; \ 37 dst ## _bi_w[idx1][idx2][idx3] = ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt 38 39 40 #define PEL_PROTOTYPE(name, D, opt) \ 41 void ff_hevc_put_hevc_ ## name ## _ ## D ## _##opt(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); \ 42 void ff_hevc_put_hevc_bi_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); \ 43 void ff_hevc_put_hevc_uni_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width); \ 44 void ff_hevc_put_hevc_uni_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width); \ 45 void ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width) 46 47 48 /////////////////////////////////////////////////////////////////////////////// 49 // MC functions 50 /////////////////////////////////////////////////////////////////////////////// 51 52 #define EPEL_PROTOTYPES(fname, bitd, opt) \ 53 PEL_PROTOTYPE(fname##4, bitd, opt); \ 54 PEL_PROTOTYPE(fname##6, bitd, opt); \ 55 PEL_PROTOTYPE(fname##8, bitd, opt); \ 56 PEL_PROTOTYPE(fname##12, bitd, opt); \ 57 PEL_PROTOTYPE(fname##16, bitd, opt); \ 58 PEL_PROTOTYPE(fname##24, bitd, opt); \ 59 PEL_PROTOTYPE(fname##32, bitd, opt); \ 60 PEL_PROTOTYPE(fname##48, bitd, opt); \ 61 PEL_PROTOTYPE(fname##64, bitd, opt) 62 63 #define QPEL_PROTOTYPES(fname, bitd, opt) \ 64 PEL_PROTOTYPE(fname##4, bitd, opt); \ 65 PEL_PROTOTYPE(fname##8, bitd, opt); \ 66 PEL_PROTOTYPE(fname##12, bitd, opt); \ 67 PEL_PROTOTYPE(fname##16, bitd, opt); \ 68 PEL_PROTOTYPE(fname##24, bitd, opt); \ 69 PEL_PROTOTYPE(fname##32, bitd, opt); \ 70 PEL_PROTOTYPE(fname##48, bitd, opt); \ 71 PEL_PROTOTYPE(fname##64, bitd, opt) 72 73 #define WEIGHTING_PROTOTYPE(width, bitd, opt) \ 74 void ff_hevc_put_hevc_uni_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, int16_t *_src, int height, int denom, int _wx, int _ox); \ 75 void ff_hevc_put_hevc_bi_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, int16_t *_src, int16_t *_src2, int height, int denom, int _wx0, int _wx1, int _ox0, int _ox1) 76 77 #define WEIGHTING_PROTOTYPES(bitd, opt) \ 78 WEIGHTING_PROTOTYPE(2, bitd, opt); \ 79 WEIGHTING_PROTOTYPE(4, bitd, opt); \ 80 WEIGHTING_PROTOTYPE(6, bitd, opt); \ 81 WEIGHTING_PROTOTYPE(8, bitd, opt); \ 82 WEIGHTING_PROTOTYPE(12, bitd, opt); \ 83 WEIGHTING_PROTOTYPE(16, bitd, opt); \ 84 WEIGHTING_PROTOTYPE(24, bitd, opt); \ 85 WEIGHTING_PROTOTYPE(32, bitd, opt); \ 86 WEIGHTING_PROTOTYPE(48, bitd, opt); \ 87 WEIGHTING_PROTOTYPE(64, bitd, opt) 88 89 90 /////////////////////////////////////////////////////////////////////////////// 91 // QPEL_PIXELS EPEL_PIXELS 92 /////////////////////////////////////////////////////////////////////////////// 93 EPEL_PROTOTYPES(pel_pixels , 8, sse4); 94 EPEL_PROTOTYPES(pel_pixels , 10, sse4); 95 EPEL_PROTOTYPES(pel_pixels , 12, sse4); 96 97 void ff_hevc_put_hevc_pel_pixels16_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 98 void ff_hevc_put_hevc_pel_pixels24_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 99 void ff_hevc_put_hevc_pel_pixels32_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 100 void ff_hevc_put_hevc_pel_pixels48_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 101 void ff_hevc_put_hevc_pel_pixels64_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 102 103 void ff_hevc_put_hevc_pel_pixels16_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 104 void ff_hevc_put_hevc_pel_pixels24_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 105 void ff_hevc_put_hevc_pel_pixels32_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 106 void ff_hevc_put_hevc_pel_pixels48_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 107 void ff_hevc_put_hevc_pel_pixels64_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 108 109 110 111 void ff_hevc_put_hevc_uni_pel_pixels32_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 112 void ff_hevc_put_hevc_uni_pel_pixels48_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 113 void ff_hevc_put_hevc_uni_pel_pixels64_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); 114 void ff_hevc_put_hevc_uni_pel_pixels96_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); //used for 10bit 115 void ff_hevc_put_hevc_uni_pel_pixels128_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);//used for 10bit 116 117 118 void ff_hevc_put_hevc_bi_pel_pixels16_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 119 void ff_hevc_put_hevc_bi_pel_pixels24_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 120 void ff_hevc_put_hevc_bi_pel_pixels32_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 121 void ff_hevc_put_hevc_bi_pel_pixels48_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 122 void ff_hevc_put_hevc_bi_pel_pixels64_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 123 124 void ff_hevc_put_hevc_bi_pel_pixels16_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 125 void ff_hevc_put_hevc_bi_pel_pixels24_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 126 void ff_hevc_put_hevc_bi_pel_pixels32_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 127 void ff_hevc_put_hevc_bi_pel_pixels48_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 128 void ff_hevc_put_hevc_bi_pel_pixels64_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); 129 130 /////////////////////////////////////////////////////////////////////////////// 131 // EPEL 132 /////////////////////////////////////////////////////////////////////////////// 133 EPEL_PROTOTYPES(epel_h , 8, sse4); 134 EPEL_PROTOTYPES(epel_h , 10, sse4); 135 EPEL_PROTOTYPES(epel_h , 12, sse4); 136 137 EPEL_PROTOTYPES(epel_v , 8, sse4); 138 EPEL_PROTOTYPES(epel_v , 10, sse4); 139 EPEL_PROTOTYPES(epel_v , 12, sse4); 140 141 EPEL_PROTOTYPES(epel_hv , 8, sse4); 142 EPEL_PROTOTYPES(epel_hv , 10, sse4); 143 EPEL_PROTOTYPES(epel_hv , 12, sse4); 144 145 PEL_PROTOTYPE(epel_h16, 8, avx2); 146 PEL_PROTOTYPE(epel_h24, 8, avx2); 147 PEL_PROTOTYPE(epel_h32, 8, avx2); 148 PEL_PROTOTYPE(epel_h48, 8, avx2); 149 PEL_PROTOTYPE(epel_h64, 8, avx2); 150 151 PEL_PROTOTYPE(epel_h16,10, avx2); 152 PEL_PROTOTYPE(epel_h24,10, avx2); 153 PEL_PROTOTYPE(epel_h32,10, avx2); 154 PEL_PROTOTYPE(epel_h48,10, avx2); 155 PEL_PROTOTYPE(epel_h64,10, avx2); 156 157 PEL_PROTOTYPE(epel_v16, 8, avx2); 158 PEL_PROTOTYPE(epel_v24, 8, avx2); 159 PEL_PROTOTYPE(epel_v32, 8, avx2); 160 PEL_PROTOTYPE(epel_v48, 8, avx2); 161 PEL_PROTOTYPE(epel_v64, 8, avx2); 162 163 PEL_PROTOTYPE(epel_v16,10, avx2); 164 PEL_PROTOTYPE(epel_v24,10, avx2); 165 PEL_PROTOTYPE(epel_v32,10, avx2); 166 PEL_PROTOTYPE(epel_v48,10, avx2); 167 PEL_PROTOTYPE(epel_v64,10, avx2); 168 169 PEL_PROTOTYPE(epel_hv16, 8, avx2); 170 PEL_PROTOTYPE(epel_hv24, 8, avx2); 171 PEL_PROTOTYPE(epel_hv32, 8, avx2); 172 PEL_PROTOTYPE(epel_hv48, 8, avx2); 173 PEL_PROTOTYPE(epel_hv64, 8, avx2); 174 175 PEL_PROTOTYPE(epel_hv16,10, avx2); 176 PEL_PROTOTYPE(epel_hv24,10, avx2); 177 PEL_PROTOTYPE(epel_hv32,10, avx2); 178 PEL_PROTOTYPE(epel_hv48,10, avx2); 179 PEL_PROTOTYPE(epel_hv64,10, avx2); 180 181 /////////////////////////////////////////////////////////////////////////////// 182 // QPEL 183 /////////////////////////////////////////////////////////////////////////////// 184 QPEL_PROTOTYPES(qpel_h , 8, sse4); 185 QPEL_PROTOTYPES(qpel_h , 10, sse4); 186 QPEL_PROTOTYPES(qpel_h , 12, sse4); 187 188 QPEL_PROTOTYPES(qpel_v, 8, sse4); 189 QPEL_PROTOTYPES(qpel_v, 10, sse4); 190 QPEL_PROTOTYPES(qpel_v, 12, sse4); 191 192 QPEL_PROTOTYPES(qpel_hv, 8, sse4); 193 QPEL_PROTOTYPES(qpel_hv, 10, sse4); 194 QPEL_PROTOTYPES(qpel_hv, 12, sse4); 195 196 PEL_PROTOTYPE(qpel_h16, 8, avx2); 197 PEL_PROTOTYPE(qpel_h24, 8, avx2); 198 PEL_PROTOTYPE(qpel_h32, 8, avx2); 199 PEL_PROTOTYPE(qpel_h48, 8, avx2); 200 PEL_PROTOTYPE(qpel_h64, 8, avx2); 201 202 PEL_PROTOTYPE(qpel_h16,10, avx2); 203 PEL_PROTOTYPE(qpel_h24,10, avx2); 204 PEL_PROTOTYPE(qpel_h32,10, avx2); 205 PEL_PROTOTYPE(qpel_h48,10, avx2); 206 PEL_PROTOTYPE(qpel_h64,10, avx2); 207 208 PEL_PROTOTYPE(qpel_v16, 8, avx2); 209 PEL_PROTOTYPE(qpel_v24, 8, avx2); 210 PEL_PROTOTYPE(qpel_v32, 8, avx2); 211 PEL_PROTOTYPE(qpel_v48, 8, avx2); 212 PEL_PROTOTYPE(qpel_v64, 8, avx2); 213 214 PEL_PROTOTYPE(qpel_v16,10, avx2); 215 PEL_PROTOTYPE(qpel_v24,10, avx2); 216 PEL_PROTOTYPE(qpel_v32,10, avx2); 217 PEL_PROTOTYPE(qpel_v48,10, avx2); 218 PEL_PROTOTYPE(qpel_v64,10, avx2); 219 220 PEL_PROTOTYPE(qpel_hv16, 8, avx2); 221 PEL_PROTOTYPE(qpel_hv24, 8, avx2); 222 PEL_PROTOTYPE(qpel_hv32, 8, avx2); 223 PEL_PROTOTYPE(qpel_hv48, 8, avx2); 224 PEL_PROTOTYPE(qpel_hv64, 8, avx2); 225 226 PEL_PROTOTYPE(qpel_hv16,10, avx2); 227 PEL_PROTOTYPE(qpel_hv24,10, avx2); 228 PEL_PROTOTYPE(qpel_hv32,10, avx2); 229 PEL_PROTOTYPE(qpel_hv48,10, avx2); 230 PEL_PROTOTYPE(qpel_hv64,10, avx2); 231 232 WEIGHTING_PROTOTYPES(8, sse4); 233 WEIGHTING_PROTOTYPES(10, sse4); 234 WEIGHTING_PROTOTYPES(12, sse4); 235 236 /////////////////////////////////////////////////////////////////////////////// 237 // TRANSFORM_ADD 238 /////////////////////////////////////////////////////////////////////////////// 239 240 void ff_hevc_add_residual_4_8_mmxext(uint8_t *dst, int16_t *res, ptrdiff_t stride); 241 void ff_hevc_add_residual_8_8_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 242 void ff_hevc_add_residual_16_8_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 243 void ff_hevc_add_residual_32_8_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 244 245 void ff_hevc_add_residual_8_8_avx(uint8_t *dst, int16_t *res, ptrdiff_t stride); 246 void ff_hevc_add_residual_16_8_avx(uint8_t *dst, int16_t *res, ptrdiff_t stride); 247 void ff_hevc_add_residual_32_8_avx(uint8_t *dst, int16_t *res, ptrdiff_t stride); 248 249 void ff_hevc_add_residual_32_8_avx2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 250 251 void ff_hevc_add_residual_4_10_mmxext(uint8_t *dst, int16_t *res, ptrdiff_t stride); 252 void ff_hevc_add_residual_8_10_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 253 void ff_hevc_add_residual_16_10_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 254 void ff_hevc_add_residual_32_10_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 255 256 void ff_hevc_add_residual_16_10_avx2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 257 void ff_hevc_add_residual_32_10_avx2(uint8_t *dst, int16_t *res, ptrdiff_t stride); 258 259 #endif // AVCODEC_X86_HEVCDSP_H 260