| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder | ||
| 3 | * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> | ||
| 4 | * | ||
| 5 | * This file is part of FFmpeg. | ||
| 6 | * | ||
| 7 | * FFmpeg is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with FFmpeg; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * @file | ||
| 24 | * H.264 / AVC / MPEG-4 part10 prediction functions. | ||
| 25 | * @author Michael Niedermayer <michaelni@gmx.at> | ||
| 26 | */ | ||
| 27 | |||
| 28 | #include "config.h" | ||
| 29 | #include "libavutil/attributes.h" | ||
| 30 | #include "libavutil/avassert.h" | ||
| 31 | #include "libavutil/intreadwrite.h" | ||
| 32 | #include "codec_id.h" | ||
| 33 | #include "h264pred.h" | ||
| 34 | #include "mathops.h" | ||
| 35 | |||
| 36 | #define BIT_DEPTH 8 | ||
| 37 | #include "h264pred_template.c" | ||
| 38 | #undef BIT_DEPTH | ||
| 39 | |||
| 40 | #define BIT_DEPTH 9 | ||
| 41 | #include "h264pred_template.c" | ||
| 42 | #undef BIT_DEPTH | ||
| 43 | |||
| 44 | #define BIT_DEPTH 10 | ||
| 45 | #include "h264pred_template.c" | ||
| 46 | #undef BIT_DEPTH | ||
| 47 | |||
| 48 | #define BIT_DEPTH 12 | ||
| 49 | #include "h264pred_template.c" | ||
| 50 | #undef BIT_DEPTH | ||
| 51 | |||
| 52 | #define BIT_DEPTH 14 | ||
| 53 | #include "h264pred_template.c" | ||
| 54 | #undef BIT_DEPTH | ||
| 55 | |||
| 56 | 26 | static void pred4x4_127_dc_c(uint8_t *src, const uint8_t *topright, | |
| 57 | ptrdiff_t _stride) | ||
| 58 | { | ||
| 59 | 26 | int stride = _stride; | |
| 60 | 26 | const uint32_t a = 0x7F7F7F7FU; | |
| 61 | |||
| 62 | 26 | AV_WN32A(src + 0 * stride, a); | |
| 63 | 26 | AV_WN32A(src + 1 * stride, a); | |
| 64 | 26 | AV_WN32A(src + 2 * stride, a); | |
| 65 | 26 | AV_WN32A(src + 3 * stride, a); | |
| 66 | 26 | } | |
| 67 | |||
| 68 | 47 | static void pred4x4_129_dc_c(uint8_t *src, const uint8_t *topright, | |
| 69 | ptrdiff_t _stride) | ||
| 70 | { | ||
| 71 | 47 | int stride = _stride; | |
| 72 | 47 | const uint32_t a = 0x81818181U; | |
| 73 | |||
| 74 | 47 | AV_WN32A(src + 0 * stride, a); | |
| 75 | 47 | AV_WN32A(src + 1 * stride, a); | |
| 76 | 47 | AV_WN32A(src + 2 * stride, a); | |
| 77 | 47 | AV_WN32A(src + 3 * stride, a); | |
| 78 | 47 | } | |
| 79 | |||
| 80 | 13003 | static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, | |
| 81 | ptrdiff_t stride) | ||
| 82 | { | ||
| 83 | 13003 | const unsigned lt = src[-1-1*stride]; | |
| 84 | 13003 | LOAD_TOP_EDGE | |
| 85 | 13003 | LOAD_TOP_RIGHT_EDGE | |
| 86 | 13003 | uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2, | |
| 87 | (t0 + 2*t1 + t2 + 2) >> 2, | ||
| 88 | (t1 + 2*t2 + t3 + 2) >> 2, | ||
| 89 | (t2 + 2*t3 + t4 + 2) >> 2); | ||
| 90 | |||
| 91 | 13003 | AV_WN32A(src+0*stride, v); | |
| 92 | 13003 | AV_WN32A(src+1*stride, v); | |
| 93 | 13003 | AV_WN32A(src+2*stride, v); | |
| 94 | 13003 | AV_WN32A(src+3*stride, v); | |
| 95 | 13003 | } | |
| 96 | |||
| 97 | 19451 | static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright, | |
| 98 | ptrdiff_t stride) | ||
| 99 | { | ||
| 100 | 19451 | const unsigned lt = src[-1-1*stride]; | |
| 101 | 19451 | LOAD_LEFT_EDGE | |
| 102 | |||
| 103 | 19451 | AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101); | |
| 104 | 19451 | AV_WN32A(src+1*stride, ((l0 + 2*l1 + l2 + 2) >> 2)*0x01010101); | |
| 105 | 19451 | AV_WN32A(src+2*stride, ((l1 + 2*l2 + l3 + 2) >> 2)*0x01010101); | |
| 106 | 19451 | AV_WN32A(src+3*stride, ((l2 + 2*l3 + l3 + 2) >> 2)*0x01010101); | |
| 107 | 19451 | } | |
| 108 | |||
| 109 | 52993 | static void pred4x4_down_left_svq3_c(uint8_t *src, const uint8_t *topright, | |
| 110 | ptrdiff_t stride) | ||
| 111 | { | ||
| 112 | 52993 | LOAD_TOP_EDGE | |
| 113 | 52993 | LOAD_LEFT_EDGE | |
| 114 | |||
| 115 | 52993 | src[0+0*stride]=(l1 + t1)>>1; | |
| 116 | 52993 | src[1+0*stride]= | |
| 117 | 52993 | src[0+1*stride]=(l2 + t2)>>1; | |
| 118 | 52993 | src[2+0*stride]= | |
| 119 | 52993 | src[1+1*stride]= | |
| 120 | 52993 | src[0+2*stride]= | |
| 121 | 52993 | src[3+0*stride]= | |
| 122 | 52993 | src[2+1*stride]= | |
| 123 | 52993 | src[1+2*stride]= | |
| 124 | 52993 | src[0+3*stride]= | |
| 125 | 52993 | src[3+1*stride]= | |
| 126 | 52993 | src[2+2*stride]= | |
| 127 | 52993 | src[1+3*stride]= | |
| 128 | 52993 | src[3+2*stride]= | |
| 129 | 52993 | src[2+3*stride]= | |
| 130 | 52993 | src[3+3*stride]=(l3 + t3)>>1; | |
| 131 | 52993 | } | |
| 132 | |||
| 133 | 4445 | static void pred4x4_down_left_rv40_c(uint8_t *src, const uint8_t *topright, | |
| 134 | ptrdiff_t stride) | ||
| 135 | { | ||
| 136 | 4445 | LOAD_TOP_EDGE | |
| 137 | 4445 | LOAD_TOP_RIGHT_EDGE | |
| 138 | 4445 | LOAD_LEFT_EDGE | |
| 139 | 4445 | LOAD_DOWN_LEFT_EDGE | |
| 140 | |||
| 141 | 4445 | src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3; | |
| 142 | 4445 | src[1+0*stride]= | |
| 143 | 4445 | src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3; | |
| 144 | 4445 | src[2+0*stride]= | |
| 145 | 4445 | src[1+1*stride]= | |
| 146 | 4445 | src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + l4 + 2*l3 + 2)>>3; | |
| 147 | 4445 | src[3+0*stride]= | |
| 148 | 4445 | src[2+1*stride]= | |
| 149 | 4445 | src[1+2*stride]= | |
| 150 | 4445 | src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3 + l5 + 2*l4 + 2)>>3; | |
| 151 | 4445 | src[3+1*stride]= | |
| 152 | 4445 | src[2+2*stride]= | |
| 153 | 4445 | src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l4 + l6 + 2*l5 + 2)>>3; | |
| 154 | 4445 | src[3+2*stride]= | |
| 155 | 4445 | src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l5 + l7 + 2*l6 + 2)>>3; | |
| 156 | 4445 | src[3+3*stride]=(t6 + t7 + 1 + l6 + l7 + 1)>>2; | |
| 157 | 4445 | } | |
| 158 | |||
| 159 | 16272 | static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, | |
| 160 | const uint8_t *topright, | ||
| 161 | ptrdiff_t stride) | ||
| 162 | { | ||
| 163 | 16272 | LOAD_TOP_EDGE | |
| 164 | 16272 | LOAD_TOP_RIGHT_EDGE | |
| 165 | 16272 | LOAD_LEFT_EDGE | |
| 166 | |||
| 167 | 16272 | src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3; | |
| 168 | 16272 | src[1+0*stride]= | |
| 169 | 16272 | src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3; | |
| 170 | 16272 | src[2+0*stride]= | |
| 171 | 16272 | src[1+1*stride]= | |
| 172 | 16272 | src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + 3*l3 + 2)>>3; | |
| 173 | 16272 | src[3+0*stride]= | |
| 174 | 16272 | src[2+1*stride]= | |
| 175 | 16272 | src[1+2*stride]= | |
| 176 | 16272 | src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3*4 + 2)>>3; | |
| 177 | 16272 | src[3+1*stride]= | |
| 178 | 16272 | src[2+2*stride]= | |
| 179 | 16272 | src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l3*4 + 2)>>3; | |
| 180 | 16272 | src[3+2*stride]= | |
| 181 | 16272 | src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l3*4 + 2)>>3; | |
| 182 | 16272 | src[3+3*stride]=(t6 + t7 + 1 + 2*l3 + 1)>>2; | |
| 183 | 16272 | } | |
| 184 | |||
| 185 | 27536 | static void pred4x4_vertical_left_rv40(uint8_t *src, const uint8_t *topright, | |
| 186 | ptrdiff_t stride, | ||
| 187 | const int l0, const int l1, const int l2, | ||
| 188 | const int l3, const int l4) | ||
| 189 | { | ||
| 190 | 27536 | LOAD_TOP_EDGE | |
| 191 | 27536 | LOAD_TOP_RIGHT_EDGE | |
| 192 | |||
| 193 | 27536 | src[0+0*stride]=(2*t0 + 2*t1 + l1 + 2*l2 + l3 + 4)>>3; | |
| 194 | 27536 | src[1+0*stride]= | |
| 195 | 27536 | src[0+2*stride]=(t1 + t2 + 1)>>1; | |
| 196 | 27536 | src[2+0*stride]= | |
| 197 | 27536 | src[1+2*stride]=(t2 + t3 + 1)>>1; | |
| 198 | 27536 | src[3+0*stride]= | |
| 199 | 27536 | src[2+2*stride]=(t3 + t4+ 1)>>1; | |
| 200 | 27536 | src[3+2*stride]=(t4 + t5+ 1)>>1; | |
| 201 | 27536 | src[0+1*stride]=(t0 + 2*t1 + t2 + l2 + 2*l3 + l4 + 4)>>3; | |
| 202 | 27536 | src[1+1*stride]= | |
| 203 | 27536 | src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2; | |
| 204 | 27536 | src[2+1*stride]= | |
| 205 | 27536 | src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2; | |
| 206 | 27536 | src[3+1*stride]= | |
| 207 | 27536 | src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2; | |
| 208 | 27536 | src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2; | |
| 209 | 27536 | } | |
| 210 | |||
| 211 | 4338 | static void pred4x4_vertical_left_rv40_c(uint8_t *src, const uint8_t *topright, | |
| 212 | ptrdiff_t stride) | ||
| 213 | { | ||
| 214 | 4338 | LOAD_LEFT_EDGE | |
| 215 | 4338 | LOAD_DOWN_LEFT_EDGE | |
| 216 | |||
| 217 | 4338 | pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l4); | |
| 218 | 4338 | } | |
| 219 | |||
| 220 | 23198 | static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src, | |
| 221 | const uint8_t *topright, | ||
| 222 | ptrdiff_t stride) | ||
| 223 | { | ||
| 224 | 23198 | LOAD_LEFT_EDGE | |
| 225 | |||
| 226 | 23198 | pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l3); | |
| 227 | 23198 | } | |
| 228 | |||
| 229 | 9994 | static void pred4x4_vertical_left_vp8_c(uint8_t *src, const uint8_t *topright, | |
| 230 | ptrdiff_t stride) | ||
| 231 | { | ||
| 232 | 9994 | LOAD_TOP_EDGE | |
| 233 | 9994 | LOAD_TOP_RIGHT_EDGE | |
| 234 | |||
| 235 | 9994 | src[0+0*stride]=(t0 + t1 + 1)>>1; | |
| 236 | 9994 | src[1+0*stride]= | |
| 237 | 9994 | src[0+2*stride]=(t1 + t2 + 1)>>1; | |
| 238 | 9994 | src[2+0*stride]= | |
| 239 | 9994 | src[1+2*stride]=(t2 + t3 + 1)>>1; | |
| 240 | 9994 | src[3+0*stride]= | |
| 241 | 9994 | src[2+2*stride]=(t3 + t4 + 1)>>1; | |
| 242 | 9994 | src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2; | |
| 243 | 9994 | src[1+1*stride]= | |
| 244 | 9994 | src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2; | |
| 245 | 9994 | src[2+1*stride]= | |
| 246 | 9994 | src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2; | |
| 247 | 9994 | src[3+1*stride]= | |
| 248 | 9994 | src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2; | |
| 249 | 9994 | src[3+2*stride]=(t4 + 2*t5 + t6 + 2)>>2; | |
| 250 | 9994 | src[3+3*stride]=(t5 + 2*t6 + t7 + 2)>>2; | |
| 251 | 9994 | } | |
| 252 | |||
| 253 | 2358 | static void pred4x4_horizontal_up_rv40_c(uint8_t *src, const uint8_t *topright, | |
| 254 | ptrdiff_t stride) | ||
| 255 | { | ||
| 256 | 2358 | LOAD_LEFT_EDGE | |
| 257 | 2358 | LOAD_DOWN_LEFT_EDGE | |
| 258 | 2358 | LOAD_TOP_EDGE | |
| 259 | 2358 | LOAD_TOP_RIGHT_EDGE | |
| 260 | |||
| 261 | 2358 | src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3; | |
| 262 | 2358 | src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3; | |
| 263 | 2358 | src[2+0*stride]= | |
| 264 | 2358 | src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3; | |
| 265 | 2358 | src[3+0*stride]= | |
| 266 | 2358 | src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3; | |
| 267 | 2358 | src[2+1*stride]= | |
| 268 | 2358 | src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3; | |
| 269 | 2358 | src[3+1*stride]= | |
| 270 | 2358 | src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3; | |
| 271 | 2358 | src[3+2*stride]= | |
| 272 | 2358 | src[1+3*stride]=(l3 + 2*l4 + l5 + 2)>>2; | |
| 273 | 2358 | src[0+3*stride]= | |
| 274 | 2358 | src[2+2*stride]=(t6 + t7 + l3 + l4 + 2)>>2; | |
| 275 | 2358 | src[2+3*stride]=(l4 + l5 + 1)>>1; | |
| 276 | 2358 | src[3+3*stride]=(l4 + 2*l5 + l6 + 2)>>2; | |
| 277 | 2358 | } | |
| 278 | |||
| 279 | 9071 | static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, | |
| 280 | const uint8_t *topright, | ||
| 281 | ptrdiff_t stride) | ||
| 282 | { | ||
| 283 | 9071 | LOAD_LEFT_EDGE | |
| 284 | 9071 | LOAD_TOP_EDGE | |
| 285 | 9071 | LOAD_TOP_RIGHT_EDGE | |
| 286 | |||
| 287 | 9071 | src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3; | |
| 288 | 9071 | src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3; | |
| 289 | 9071 | src[2+0*stride]= | |
| 290 | 9071 | src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3; | |
| 291 | 9071 | src[3+0*stride]= | |
| 292 | 9071 | src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3; | |
| 293 | 9071 | src[2+1*stride]= | |
| 294 | 9071 | src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3; | |
| 295 | 9071 | src[3+1*stride]= | |
| 296 | 9071 | src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3; | |
| 297 | 9071 | src[3+2*stride]= | |
| 298 | 9071 | src[1+3*stride]=l3; | |
| 299 | 9071 | src[0+3*stride]= | |
| 300 | 9071 | src[2+2*stride]=(t6 + t7 + 2*l3 + 2)>>2; | |
| 301 | 9071 | src[2+3*stride]= | |
| 302 | 9071 | src[3+3*stride]=l3; | |
| 303 | 9071 | } | |
| 304 | |||
| 305 | 45199 | static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright, | |
| 306 | ptrdiff_t stride) | ||
| 307 | { | ||
| 308 | 45199 | const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride]; | |
| 309 | 45199 | uint8_t *top = src-stride; | |
| 310 | int y; | ||
| 311 | |||
| 312 |
2/2✓ Branch 0 taken 180796 times.
✓ Branch 1 taken 45199 times.
|
225995 | for (y = 0; y < 4; y++) { |
| 313 | 180796 | const uint8_t *cm_in = cm + src[-1]; | |
| 314 | 180796 | src[0] = cm_in[top[0]]; | |
| 315 | 180796 | src[1] = cm_in[top[1]]; | |
| 316 | 180796 | src[2] = cm_in[top[2]]; | |
| 317 | 180796 | src[3] = cm_in[top[3]]; | |
| 318 | 180796 | src += stride; | |
| 319 | } | ||
| 320 | 45199 | } | |
| 321 | |||
| 322 | 56 | static void pred16x16_plane_svq3_c(uint8_t *src, ptrdiff_t stride) | |
| 323 | { | ||
| 324 | 56 | pred16x16_plane_compat_8_c(src, stride, 1, 0); | |
| 325 | 56 | } | |
| 326 | |||
| 327 | 1217 | static void pred16x16_plane_rv40_c(uint8_t *src, ptrdiff_t stride) | |
| 328 | { | ||
| 329 | 1217 | pred16x16_plane_compat_8_c(src, stride, 0, 1); | |
| 330 | 1217 | } | |
| 331 | |||
| 332 | 371 | static void pred16x16_tm_vp8_c(uint8_t *src, ptrdiff_t stride) | |
| 333 | { | ||
| 334 | 371 | const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride]; | |
| 335 | 371 | uint8_t *top = src-stride; | |
| 336 | int y; | ||
| 337 | |||
| 338 |
2/2✓ Branch 0 taken 5936 times.
✓ Branch 1 taken 371 times.
|
6307 | for (y = 0; y < 16; y++) { |
| 339 | 5936 | const uint8_t *cm_in = cm + src[-1]; | |
| 340 | 5936 | src[0] = cm_in[top[0]]; | |
| 341 | 5936 | src[1] = cm_in[top[1]]; | |
| 342 | 5936 | src[2] = cm_in[top[2]]; | |
| 343 | 5936 | src[3] = cm_in[top[3]]; | |
| 344 | 5936 | src[4] = cm_in[top[4]]; | |
| 345 | 5936 | src[5] = cm_in[top[5]]; | |
| 346 | 5936 | src[6] = cm_in[top[6]]; | |
| 347 | 5936 | src[7] = cm_in[top[7]]; | |
| 348 | 5936 | src[8] = cm_in[top[8]]; | |
| 349 | 5936 | src[9] = cm_in[top[9]]; | |
| 350 | 5936 | src[10] = cm_in[top[10]]; | |
| 351 | 5936 | src[11] = cm_in[top[11]]; | |
| 352 | 5936 | src[12] = cm_in[top[12]]; | |
| 353 | 5936 | src[13] = cm_in[top[13]]; | |
| 354 | 5936 | src[14] = cm_in[top[14]]; | |
| 355 | 5936 | src[15] = cm_in[top[15]]; | |
| 356 | 5936 | src += stride; | |
| 357 | } | ||
| 358 | 371 | } | |
| 359 | |||
| 360 | 9178 | static void pred8x8_left_dc_rv40_c(uint8_t *src, ptrdiff_t stride) | |
| 361 | { | ||
| 362 | int i; | ||
| 363 | unsigned dc0; | ||
| 364 | |||
| 365 | 9178 | dc0=0; | |
| 366 |
2/2✓ Branch 0 taken 73424 times.
✓ Branch 1 taken 9178 times.
|
82602 | for(i=0;i<8; i++) |
| 367 | 73424 | dc0+= src[-1+i*stride]; | |
| 368 | 9178 | dc0= 0x01010101*((dc0 + 4)>>3); | |
| 369 | |||
| 370 |
2/2✓ Branch 0 taken 73424 times.
✓ Branch 1 taken 9178 times.
|
82602 | for(i=0; i<8; i++){ |
| 371 | 73424 | ((uint32_t*)(src+i*stride))[0]= | |
| 372 | 73424 | ((uint32_t*)(src+i*stride))[1]= dc0; | |
| 373 | } | ||
| 374 | 9178 | } | |
| 375 | |||
| 376 | 3848 | static void pred8x8_top_dc_rv40_c(uint8_t *src, ptrdiff_t stride) | |
| 377 | { | ||
| 378 | int i; | ||
| 379 | unsigned dc0; | ||
| 380 | |||
| 381 | 3848 | dc0=0; | |
| 382 |
2/2✓ Branch 0 taken 30784 times.
✓ Branch 1 taken 3848 times.
|
34632 | for(i=0;i<8; i++) |
| 383 | 30784 | dc0+= src[i-stride]; | |
| 384 | 3848 | dc0= 0x01010101*((dc0 + 4)>>3); | |
| 385 | |||
| 386 |
2/2✓ Branch 0 taken 30784 times.
✓ Branch 1 taken 3848 times.
|
34632 | for(i=0; i<8; i++){ |
| 387 | 30784 | ((uint32_t*)(src+i*stride))[0]= | |
| 388 | 30784 | ((uint32_t*)(src+i*stride))[1]= dc0; | |
| 389 | } | ||
| 390 | 3848 | } | |
| 391 | |||
| 392 | 88902 | static void pred8x8_dc_rv40_c(uint8_t *src, ptrdiff_t stride) | |
| 393 | { | ||
| 394 | int i; | ||
| 395 | 88902 | unsigned dc0 = 0; | |
| 396 | |||
| 397 |
2/2✓ Branch 0 taken 355608 times.
✓ Branch 1 taken 88902 times.
|
444510 | for(i=0;i<4; i++){ |
| 398 | 355608 | dc0+= src[-1+i*stride] + src[i-stride]; | |
| 399 | 355608 | dc0+= src[4+i-stride]; | |
| 400 | 355608 | dc0+= src[-1+(i+4)*stride]; | |
| 401 | } | ||
| 402 | 88902 | dc0= 0x01010101*((dc0 + 8)>>4); | |
| 403 | |||
| 404 |
2/2✓ Branch 0 taken 355608 times.
✓ Branch 1 taken 88902 times.
|
444510 | for(i=0; i<4; i++){ |
| 405 | 355608 | ((uint32_t*)(src+i*stride))[0]= dc0; | |
| 406 | 355608 | ((uint32_t*)(src+i*stride))[1]= dc0; | |
| 407 | } | ||
| 408 |
2/2✓ Branch 0 taken 355608 times.
✓ Branch 1 taken 88902 times.
|
444510 | for(i=4; i<8; i++){ |
| 409 | 355608 | ((uint32_t*)(src+i*stride))[0]= dc0; | |
| 410 | 355608 | ((uint32_t*)(src+i*stride))[1]= dc0; | |
| 411 | } | ||
| 412 | 88902 | } | |
| 413 | |||
| 414 | 2853 | static void pred8x8_tm_vp8_c(uint8_t *src, ptrdiff_t stride) | |
| 415 | { | ||
| 416 | 2853 | const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride]; | |
| 417 | 2853 | uint8_t *top = src-stride; | |
| 418 | int y; | ||
| 419 | |||
| 420 |
2/2✓ Branch 0 taken 22824 times.
✓ Branch 1 taken 2853 times.
|
25677 | for (y = 0; y < 8; y++) { |
| 421 | 22824 | const uint8_t *cm_in = cm + src[-1]; | |
| 422 | 22824 | src[0] = cm_in[top[0]]; | |
| 423 | 22824 | src[1] = cm_in[top[1]]; | |
| 424 | 22824 | src[2] = cm_in[top[2]]; | |
| 425 | 22824 | src[3] = cm_in[top[3]]; | |
| 426 | 22824 | src[4] = cm_in[top[4]]; | |
| 427 | 22824 | src[5] = cm_in[top[5]]; | |
| 428 | 22824 | src[6] = cm_in[top[6]]; | |
| 429 | 22824 | src[7] = cm_in[top[7]]; | |
| 430 | 22824 | src += stride; | |
| 431 | } | ||
| 432 | 2853 | } | |
| 433 | |||
| 434 | /** | ||
| 435 | * Set the intra prediction function pointers. | ||
| 436 | */ | ||
| 437 | 1201 | av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, | |
| 438 | const int bit_depth, | ||
| 439 | int chroma_format_idc) | ||
| 440 | { | ||
| 441 | #undef FUNC | ||
| 442 | #undef FUNCC | ||
| 443 | #define FUNC(a, depth) a ## _ ## depth | ||
| 444 | #define FUNCC(a, depth) a ## _ ## depth ## _c | ||
| 445 | #define FUNCD(a) a ## _c | ||
| 446 | |||
| 447 | #define H264_PRED(depth) \ | ||
| 448 | h->pred4x4[VERT_PRED ] = FUNCC(pred4x4_vertical, depth);\ | ||
| 449 | h->pred4x4[HOR_PRED ] = FUNCC(pred4x4_horizontal, depth);\ | ||
| 450 | h->pred4x4[DC_PRED ] = FUNCC(pred4x4_dc, depth);\ | ||
| 451 | h->pred4x4[DIAG_DOWN_LEFT_PRED ] = FUNCC(pred4x4_down_left, depth);\ | ||
| 452 | h->pred4x4[DIAG_DOWN_RIGHT_PRED] = FUNCC(pred4x4_down_right, depth);\ | ||
| 453 | h->pred4x4[VERT_RIGHT_PRED ] = FUNCC(pred4x4_vertical_right, depth);\ | ||
| 454 | h->pred4x4[HOR_DOWN_PRED ] = FUNCC(pred4x4_horizontal_down, depth);\ | ||
| 455 | h->pred4x4[VERT_LEFT_PRED ] = FUNCC(pred4x4_vertical_left, depth);\ | ||
| 456 | h->pred4x4[HOR_UP_PRED ] = FUNCC(pred4x4_horizontal_up, depth);\ | ||
| 457 | h->pred4x4[LEFT_DC_PRED ] = FUNCC(pred4x4_left_dc, depth);\ | ||
| 458 | h->pred4x4[TOP_DC_PRED ] = FUNCC(pred4x4_top_dc, depth);\ | ||
| 459 | if (depth > 8 || codec_id != AV_CODEC_ID_VP8)\ | ||
| 460 | h->pred4x4[DC_128_PRED ] = FUNCC(pred4x4_128_dc, depth);\ | ||
| 461 | \ | ||
| 462 | h->pred8x8l[VERT_PRED ]= FUNCC(pred8x8l_vertical , depth);\ | ||
| 463 | h->pred8x8l[HOR_PRED ]= FUNCC(pred8x8l_horizontal , depth);\ | ||
| 464 | h->pred8x8l[DC_PRED ]= FUNCC(pred8x8l_dc , depth);\ | ||
| 465 | h->pred8x8l[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred8x8l_down_left , depth);\ | ||
| 466 | h->pred8x8l[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred8x8l_down_right , depth);\ | ||
| 467 | h->pred8x8l[VERT_RIGHT_PRED ]= FUNCC(pred8x8l_vertical_right , depth);\ | ||
| 468 | h->pred8x8l[HOR_DOWN_PRED ]= FUNCC(pred8x8l_horizontal_down , depth);\ | ||
| 469 | h->pred8x8l[VERT_LEFT_PRED ]= FUNCC(pred8x8l_vertical_left , depth);\ | ||
| 470 | h->pred8x8l[HOR_UP_PRED ]= FUNCC(pred8x8l_horizontal_up , depth);\ | ||
| 471 | h->pred8x8l[LEFT_DC_PRED ]= FUNCC(pred8x8l_left_dc , depth);\ | ||
| 472 | h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\ | ||
| 473 | h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\ | ||
| 474 | \ | ||
| 475 | if (chroma_format_idc <= 1) {\ | ||
| 476 | h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\ | ||
| 477 | h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\ | ||
| 478 | h->pred8x8[PLANE_PRED8x8] = FUNCC(pred8x8_plane, depth);\ | ||
| 479 | } else {\ | ||
| 480 | h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x16_vertical , depth);\ | ||
| 481 | h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\ | ||
| 482 | h->pred8x8[PLANE_PRED8x8] = FUNCC(pred8x16_plane, depth);\ | ||
| 483 | }\ | ||
| 484 | if (depth > 8 || (codec_id != AV_CODEC_ID_RV40 && \ | ||
| 485 | codec_id != AV_CODEC_ID_VP7 && \ | ||
| 486 | codec_id != AV_CODEC_ID_VP8)) { \ | ||
| 487 | if (chroma_format_idc <= 1) {\ | ||
| 488 | h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\ | ||
| 489 | h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\ | ||
| 490 | h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\ | ||
| 491 | h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\ | ||
| 492 | h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\ | ||
| 493 | h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\ | ||
| 494 | h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\ | ||
| 495 | } else {\ | ||
| 496 | h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x16_dc , depth);\ | ||
| 497 | h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x16_left_dc , depth);\ | ||
| 498 | h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x16_top_dc , depth);\ | ||
| 499 | h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l0t, depth);\ | ||
| 500 | h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0lt, depth);\ | ||
| 501 | h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l00, depth);\ | ||
| 502 | h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0l0, depth);\ | ||
| 503 | }\ | ||
| 504 | }else{\ | ||
| 505 | h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\ | ||
| 506 | h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\ | ||
| 507 | h->pred8x8[TOP_DC_PRED8x8 ]= FUNCD(pred8x8_top_dc_rv40);\ | ||
| 508 | }\ | ||
| 509 | if (chroma_format_idc <= 1) {\ | ||
| 510 | h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\ | ||
| 511 | } else {\ | ||
| 512 | h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc , depth);\ | ||
| 513 | }\ | ||
| 514 | \ | ||
| 515 | h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\ | ||
| 516 | h->pred16x16[VERT_PRED8x8 ]= FUNCC(pred16x16_vertical , depth);\ | ||
| 517 | h->pred16x16[HOR_PRED8x8 ]= FUNCC(pred16x16_horizontal , depth);\ | ||
| 518 | h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane , depth);\ | ||
| 519 | h->pred16x16[LEFT_DC_PRED8x8]= FUNCC(pred16x16_left_dc , depth);\ | ||
| 520 | h->pred16x16[TOP_DC_PRED8x8 ]= FUNCC(pred16x16_top_dc , depth);\ | ||
| 521 | h->pred16x16[DC_128_PRED8x8 ]= FUNCC(pred16x16_128_dc , depth);\ | ||
| 522 | \ | ||
| 523 | /* special lossless h/v prediction for H.264 */ \ | ||
| 524 | h->pred4x4_add [VERT_PRED ]= FUNCC(pred4x4_vertical_add , depth);\ | ||
| 525 | h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\ | ||
| 526 | h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\ | ||
| 527 | h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\ | ||
| 528 | h->pred8x8l_filter_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_filter_add , depth);\ | ||
| 529 | h->pred8x8l_filter_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_filter_add , depth);\ | ||
| 530 | if (chroma_format_idc <= 1) {\ | ||
| 531 | h->pred8x8_add[VERT_PRED8x8] = FUNCC(pred8x8_vertical_add, depth);\ | ||
| 532 | h->pred8x8_add[ HOR_PRED8x8] = FUNCC(pred8x8_horizontal_add, depth);\ | ||
| 533 | } else {\ | ||
| 534 | h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x16_vertical_add , depth);\ | ||
| 535 | h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x16_horizontal_add , depth);\ | ||
| 536 | }\ | ||
| 537 | h->pred16x16_add[VERT_PRED8x8]= FUNCC(pred16x16_vertical_add , depth);\ | ||
| 538 | h->pred16x16_add[ HOR_PRED8x8]= FUNCC(pred16x16_horizontal_add , depth);\ | ||
| 539 | |||
| 540 |
3/5✓ Branch 0 taken 117 times.
✓ Branch 1 taken 163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 921 times.
|
1201 | switch (bit_depth) { |
| 541 | 117 | case 9: | |
| 542 |
8/8✓ Branch 0 taken 59 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 58 times.
✓ Branch 6 taken 59 times.
✓ Branch 7 taken 58 times.
|
117 | H264_PRED(9) |
| 543 | 117 | break; | |
| 544 | 163 | case 10: | |
| 545 |
8/8✓ Branch 0 taken 86 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 77 times.
✓ Branch 4 taken 86 times.
✓ Branch 5 taken 77 times.
✓ Branch 6 taken 86 times.
✓ Branch 7 taken 77 times.
|
163 | H264_PRED(10) |
| 546 | 163 | break; | |
| 547 | ✗ | case 12: | |
| 548 | ✗ | H264_PRED(12) | |
| 549 | ✗ | break; | |
| 550 | ✗ | case 14: | |
| 551 | ✗ | H264_PRED(14) | |
| 552 | ✗ | break; | |
| 553 | 921 | default: | |
| 554 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 921 times.
|
921 | av_assert0(bit_depth<=8); |
| 555 |
16/16✓ Branch 0 taken 805 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 839 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 856 times.
✓ Branch 5 taken 65 times.
✓ Branch 6 taken 853 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 737 times.
✓ Branch 9 taken 116 times.
✓ Branch 10 taken 655 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 839 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 839 times.
✓ Branch 15 taken 82 times.
|
921 | H264_PRED(8) |
| 556 |
4/4✓ Branch 0 taken 64 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 673 times.
|
921 | switch (codec_id) { |
| 557 | 64 | case AV_CODEC_ID_SVQ3: | |
| 558 | 64 | h->pred4x4[DIAG_DOWN_LEFT_PRED] = FUNCD(pred4x4_down_left_svq3); | |
| 559 | 64 | h->pred16x16[PLANE_PRED8x8 ] = FUNCD(pred16x16_plane_svq3); | |
| 560 | 64 | break; | |
| 561 | 65 | case AV_CODEC_ID_RV40: | |
| 562 | 65 | h->pred4x4[DIAG_DOWN_LEFT_PRED] = FUNCD(pred4x4_down_left_rv40); | |
| 563 | 65 | h->pred4x4[VERT_LEFT_PRED ] = FUNCD(pred4x4_vertical_left_rv40); | |
| 564 | 65 | h->pred4x4[HOR_UP_PRED ] = FUNCD(pred4x4_horizontal_up_rv40); | |
| 565 | 65 | h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN] = FUNCD(pred4x4_down_left_rv40_nodown); | |
| 566 | 65 | h->pred4x4[HOR_UP_PRED_RV40_NODOWN] = FUNCD(pred4x4_horizontal_up_rv40_nodown); | |
| 567 | 65 | h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN] = FUNCD(pred4x4_vertical_left_rv40_nodown); | |
| 568 | 65 | h->pred16x16[PLANE_PRED8x8 ] = FUNCD(pred16x16_plane_rv40); | |
| 569 | 65 | break; | |
| 570 | 119 | case AV_CODEC_ID_VP7: | |
| 571 | case AV_CODEC_ID_VP8: | ||
| 572 | 119 | h->pred4x4[VERT_PRED ] = FUNCD(pred4x4_vertical_vp8); | |
| 573 | 119 | h->pred4x4[HOR_PRED ] = FUNCD(pred4x4_horizontal_vp8); | |
| 574 | 119 | h->pred4x4[VERT_LEFT_PRED ] = FUNCD(pred4x4_vertical_left_vp8); | |
| 575 | 119 | h->pred4x4[TM_VP8_PRED ] = FUNCD(pred4x4_tm_vp8); | |
| 576 | 119 | h->pred4x4[VERT_VP8_PRED ] = FUNCC(pred4x4_vertical, 8); | |
| 577 | 119 | h->pred4x4[DC_127_PRED ] = FUNCD(pred4x4_127_dc); | |
| 578 | 119 | h->pred4x4[DC_129_PRED ] = FUNCD(pred4x4_129_dc); | |
| 579 | 119 | h->pred4x4[HOR_VP8_PRED ] = FUNCC(pred4x4_horizontal, 8); | |
| 580 | 119 | h->pred8x8[PLANE_PRED8x8 ] = FUNCD(pred8x8_tm_vp8); | |
| 581 | 119 | h->pred8x8[DC_127_PRED8x8 ] = FUNCC(pred8x8_127_dc, 8); | |
| 582 | 119 | h->pred8x8[DC_129_PRED8x8 ] = FUNCC(pred8x8_129_dc, 8); | |
| 583 | 119 | h->pred16x16[PLANE_PRED8x8 ] = FUNCD(pred16x16_tm_vp8); | |
| 584 | 119 | h->pred16x16[DC_127_PRED8x8] = FUNCC(pred16x16_127_dc, 8); | |
| 585 | 119 | h->pred16x16[DC_129_PRED8x8] = FUNCC(pred16x16_129_dc, 8); | |
| 586 | 119 | break; | |
| 587 | } | ||
| 588 | 921 | break; | |
| 589 | } | ||
| 590 | |||
| 591 | #if ARCH_AARCH64 | ||
| 592 | ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc); | ||
| 593 | #elif ARCH_ARM | ||
| 594 | ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc); | ||
| 595 | #elif ARCH_X86 && HAVE_X86ASM | ||
| 596 | 1201 | ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc); | |
| 597 | #elif ARCH_MIPS | ||
| 598 | ff_h264_pred_init_mips(h, codec_id, bit_depth, chroma_format_idc); | ||
| 599 | #elif ARCH_LOONGARCH | ||
| 600 | ff_h264_pred_init_loongarch(h, codec_id, bit_depth, chroma_format_idc); | ||
| 601 | #endif | ||
| 602 | 1201 | } | |
| 603 |