predict.c 24.2 KB
Newer Older
Laurent Aimar's avatar
Laurent Aimar committed
1 2 3
/*****************************************************************************
 * predict.c: h264 encoder
 *****************************************************************************
4
 * Copyright (C) 2003-2008 x264 project
Laurent Aimar's avatar
Laurent Aimar committed
5 6
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7
 *          Loren Merritt <lorenm@u.washington.edu>
8
 *          Fiona Glaser <fiona@x264.com>
Laurent Aimar's avatar
Laurent Aimar committed
9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
Laurent Aimar's avatar
Laurent Aimar committed
23 24
 *****************************************************************************/

Loren Merritt's avatar
Loren Merritt committed
25
/* predict4x4 are inspired from ffmpeg h264 decoder */
Laurent Aimar's avatar
Laurent Aimar committed
26 27


28
#include "common.h"
Laurent Aimar's avatar
Laurent Aimar committed
29

30
#ifdef HAVE_MMX
31
#   include "x86/predict.h"
Laurent Aimar's avatar
Laurent Aimar committed
32
#endif
33 34 35
#ifdef ARCH_PPC
#   include "ppc/predict.h"
#endif
36 37 38
#ifdef ARCH_ARM
#   include "arm/predict.h"
#endif
Laurent Aimar's avatar
Laurent Aimar committed
39 40

/****************************************************************************
41
 * 16x16 prediction for intra luma block
Laurent Aimar's avatar
Laurent Aimar committed
42
 ****************************************************************************/
43 44 45 46

#define PREDICT_16x16_DC(v) \
    for( i = 0; i < 16; i++ )\
    {\
Fiona Glaser's avatar
Fiona Glaser committed
47 48 49 50
        M32( src+ 0 ) = v;\
        M32( src+ 4 ) = v;\
        M32( src+ 8 ) = v;\
        M32( src+12 ) = v;\
51
        src += FDEC_STRIDE;\
52 53
    }

54
static void predict_16x16_dc( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
55
{
56 57
    uint32_t dc = 0;
    int i;
Laurent Aimar's avatar
Laurent Aimar committed
58 59 60

    for( i = 0; i < 16; i++ )
    {
61 62
        dc += src[-1 + i * FDEC_STRIDE];
        dc += src[i - FDEC_STRIDE];
Laurent Aimar's avatar
Laurent Aimar committed
63
    }
64
    dc = (( dc + 16 ) >> 5) * 0x01010101;
Laurent Aimar's avatar
Laurent Aimar committed
65

66
    PREDICT_16x16_DC(dc);
Laurent Aimar's avatar
Laurent Aimar committed
67
}
68
static void predict_16x16_dc_left( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
69
{
70 71
    uint32_t dc = 0;
    int i;
Laurent Aimar's avatar
Laurent Aimar committed
72 73 74

    for( i = 0; i < 16; i++ )
    {
75
        dc += src[-1 + i * FDEC_STRIDE];
Laurent Aimar's avatar
Laurent Aimar committed
76
    }
77
    dc = (( dc + 8 ) >> 4) * 0x01010101;
Laurent Aimar's avatar
Laurent Aimar committed
78

79
    PREDICT_16x16_DC(dc);
Laurent Aimar's avatar
Laurent Aimar committed
80
}
81
static void predict_16x16_dc_top( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
82
{
83 84
    uint32_t dc = 0;
    int i;
Laurent Aimar's avatar
Laurent Aimar committed
85 86 87

    for( i = 0; i < 16; i++ )
    {
88
        dc += src[i - FDEC_STRIDE];
Laurent Aimar's avatar
Laurent Aimar committed
89
    }
90
    dc = (( dc + 8 ) >> 4) * 0x01010101;
Laurent Aimar's avatar
Laurent Aimar committed
91

92
    PREDICT_16x16_DC(dc);
Laurent Aimar's avatar
Laurent Aimar committed
93
}
94
static void predict_16x16_dc_128( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
95
{
96 97
    int i;
    PREDICT_16x16_DC(0x80808080);
Laurent Aimar's avatar
Laurent Aimar committed
98
}
99
static void predict_16x16_h( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
100
{
101
    int i;
Laurent Aimar's avatar
Laurent Aimar committed
102 103 104

    for( i = 0; i < 16; i++ )
    {
105
        const uint32_t v = 0x01010101 * src[-1];
Fiona Glaser's avatar
Fiona Glaser committed
106 107 108 109
        M32( src+ 0 ) = v;
        M32( src+ 4 ) = v;
        M32( src+ 8 ) = v;
        M32( src+12 ) = v;
110
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
111 112 113

    }
}
114
static void predict_16x16_v( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
115
{
Fiona Glaser's avatar
Fiona Glaser committed
116 117 118 119
    uint32_t v0 = M32( &src[ 0-FDEC_STRIDE] );
    uint32_t v1 = M32( &src[ 4-FDEC_STRIDE] );
    uint32_t v2 = M32( &src[ 8-FDEC_STRIDE] );
    uint32_t v3 = M32( &src[12-FDEC_STRIDE] );
120
    int i;
Laurent Aimar's avatar
Laurent Aimar committed
121 122 123

    for( i = 0; i < 16; i++ )
    {
Fiona Glaser's avatar
Fiona Glaser committed
124 125 126 127
        M32( src+ 0 ) = v0;
        M32( src+ 4 ) = v1;
        M32( src+ 8 ) = v2;
        M32( src+12 ) = v3;
128
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
129 130
    }
}
131
static void predict_16x16_p( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
132 133 134 135 136 137 138
{
    int x, y, i;
    int a, b, c;
    int H = 0;
    int V = 0;
    int i00;

Loren Merritt's avatar
Loren Merritt committed
139
    /* calculate H and V */
Laurent Aimar's avatar
Laurent Aimar committed
140 141
    for( i = 0; i <= 7; i++ )
    {
142 143
        H += ( i + 1 ) * ( src[ 8 + i - FDEC_STRIDE ] - src[6 -i -FDEC_STRIDE] );
        V += ( i + 1 ) * ( src[-1 + (8+i)*FDEC_STRIDE] - src[-1 + (6-i)*FDEC_STRIDE] );
Laurent Aimar's avatar
Laurent Aimar committed
144 145
    }

146
    a = 16 * ( src[-1 + 15*FDEC_STRIDE] + src[15 - FDEC_STRIDE] );
Laurent Aimar's avatar
Laurent Aimar committed
147 148 149 150 151 152 153
    b = ( 5 * H + 32 ) >> 6;
    c = ( 5 * V + 32 ) >> 6;

    i00 = a - b * 7 - c * 7 + 16;

    for( y = 0; y < 16; y++ )
    {
154
        int pix = i00;
Laurent Aimar's avatar
Laurent Aimar committed
155 156
        for( x = 0; x < 16; x++ )
        {
157 158
            src[x] = x264_clip_uint8( pix>>5 );
            pix += b;
Laurent Aimar's avatar
Laurent Aimar committed
159
        }
160
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
161 162 163 164 165 166
        i00 += c;
    }
}


/****************************************************************************
167
 * 8x8 prediction for intra chroma block
Laurent Aimar's avatar
Laurent Aimar committed
168
 ****************************************************************************/
169

170
static void predict_8x8c_dc_128( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
171
{
172
    int y;
Laurent Aimar's avatar
Laurent Aimar committed
173 174 175

    for( y = 0; y < 8; y++ )
    {
Fiona Glaser's avatar
Fiona Glaser committed
176 177
        M32( src+0 ) = 0x80808080;
        M32( src+4 ) = 0x80808080;
178
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
179 180
    }
}
181
static void predict_8x8c_dc_left( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
182
{
183 184
    int y;
    uint32_t dc0 = 0, dc1 = 0;
Laurent Aimar's avatar
Laurent Aimar committed
185 186 187

    for( y = 0; y < 4; y++ )
    {
188 189
        dc0 += src[y * FDEC_STRIDE     - 1];
        dc1 += src[(y+4) * FDEC_STRIDE - 1];
Laurent Aimar's avatar
Laurent Aimar committed
190
    }
191 192
    dc0 = (( dc0 + 2 ) >> 2)*0x01010101;
    dc1 = (( dc1 + 2 ) >> 2)*0x01010101;
Laurent Aimar's avatar
Laurent Aimar committed
193 194 195

    for( y = 0; y < 4; y++ )
    {
Fiona Glaser's avatar
Fiona Glaser committed
196 197
        M32( src+0 ) = dc0;
        M32( src+4 ) = dc0;
198
        src += FDEC_STRIDE;
199 200 201
    }
    for( y = 0; y < 4; y++ )
    {
Fiona Glaser's avatar
Fiona Glaser committed
202 203
        M32( src+0 ) = dc1;
        M32( src+4 ) = dc1;
204
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
205
    }
206

Laurent Aimar's avatar
Laurent Aimar committed
207
}
208
static void predict_8x8c_dc_top( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
209
{
210 211
    int y, x;
    uint32_t dc0 = 0, dc1 = 0;
Laurent Aimar's avatar
Laurent Aimar committed
212 213 214

    for( x = 0; x < 4; x++ )
    {
215 216
        dc0 += src[x     - FDEC_STRIDE];
        dc1 += src[x + 4 - FDEC_STRIDE];
Laurent Aimar's avatar
Laurent Aimar committed
217
    }
218 219
    dc0 = (( dc0 + 2 ) >> 2)*0x01010101;
    dc1 = (( dc1 + 2 ) >> 2)*0x01010101;
Laurent Aimar's avatar
Laurent Aimar committed
220 221 222

    for( y = 0; y < 8; y++ )
    {
Fiona Glaser's avatar
Fiona Glaser committed
223 224
        M32( src+0 ) = dc0;
        M32( src+4 ) = dc1;
225
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
226 227
    }
}
228
static void predict_8x8c_dc( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
229
{
230
    int y;
Laurent Aimar's avatar
Laurent Aimar committed
231
    int s0 = 0, s1 = 0, s2 = 0, s3 = 0;
232
    uint32_t dc0, dc1, dc2, dc3;
Laurent Aimar's avatar
Laurent Aimar committed
233 234
    int i;

235
    /*
Laurent Aimar's avatar
Laurent Aimar committed
236 237 238 239 240 241
          s0 s1
       s2
       s3
    */
    for( i = 0; i < 4; i++ )
    {
242 243 244 245
        s0 += src[i - FDEC_STRIDE];
        s1 += src[i + 4 - FDEC_STRIDE];
        s2 += src[-1 + i * FDEC_STRIDE];
        s3 += src[-1 + (i+4)*FDEC_STRIDE];
Laurent Aimar's avatar
Laurent Aimar committed
246
    }
247
    /*
Laurent Aimar's avatar
Laurent Aimar committed
248 249 250
       dc0 dc1
       dc2 dc3
     */
251 252 253 254
    dc0 = (( s0 + s2 + 4 ) >> 3)*0x01010101;
    dc1 = (( s1 + 2 ) >> 2)*0x01010101;
    dc2 = (( s3 + 2 ) >> 2)*0x01010101;
    dc3 = (( s1 + s3 + 4 ) >> 3)*0x01010101;
Laurent Aimar's avatar
Laurent Aimar committed
255 256 257

    for( y = 0; y < 4; y++ )
    {
Fiona Glaser's avatar
Fiona Glaser committed
258 259
        M32( src+0 ) = dc0;
        M32( src+4 ) = dc1;
260
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
261 262
    }

263 264
    for( y = 0; y < 4; y++ )
    {
Fiona Glaser's avatar
Fiona Glaser committed
265 266
        M32( src+0 ) = dc2;
        M32( src+4 ) = dc3;
267
        src += FDEC_STRIDE;
268 269
    }
}
270
static void predict_8x8c_h( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
271
{
272
    int i;
Laurent Aimar's avatar
Laurent Aimar committed
273 274 275

    for( i = 0; i < 8; i++ )
    {
276
        uint32_t v = 0x01010101 * src[-1];
Fiona Glaser's avatar
Fiona Glaser committed
277 278
        M32( src+0 ) = v;
        M32( src+4 ) = v;
279
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
280 281
    }
}
282
static void predict_8x8c_v( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
283
{
Fiona Glaser's avatar
Fiona Glaser committed
284 285
    uint32_t v0 = M32( src+0-FDEC_STRIDE );
    uint32_t v1 = M32( src+4-FDEC_STRIDE );
286
    int i;
Laurent Aimar's avatar
Laurent Aimar committed
287 288 289

    for( i = 0; i < 8; i++ )
    {
Fiona Glaser's avatar
Fiona Glaser committed
290 291
        M32( src+0 ) = v0;
        M32( src+4 ) = v1;
292
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
293 294
    }
}
295
static void predict_8x8c_p( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
296 297 298 299 300 301 302 303 304 305
{
    int i;
    int x,y;
    int a, b, c;
    int H = 0;
    int V = 0;
    int i00;

    for( i = 0; i < 4; i++ )
    {
306 307
        H += ( i + 1 ) * ( src[4+i - FDEC_STRIDE] - src[2 - i -FDEC_STRIDE] );
        V += ( i + 1 ) * ( src[-1 +(i+4)*FDEC_STRIDE] - src[-1+(2-i)*FDEC_STRIDE] );
Laurent Aimar's avatar
Laurent Aimar committed
308 309
    }

310
    a = 16 * ( src[-1+7*FDEC_STRIDE] + src[7 - FDEC_STRIDE] );
Laurent Aimar's avatar
Laurent Aimar committed
311 312 313 314 315 316
    b = ( 17 * H + 16 ) >> 5;
    c = ( 17 * V + 16 ) >> 5;
    i00 = a -3*b -3*c + 16;

    for( y = 0; y < 8; y++ )
    {
317
        int pix = i00;
Laurent Aimar's avatar
Laurent Aimar committed
318 319
        for( x = 0; x < 8; x++ )
        {
320 321
            src[x] = x264_clip_uint8( pix>>5 );
            pix += b;
Laurent Aimar's avatar
Laurent Aimar committed
322
        }
323
        src += FDEC_STRIDE;
Laurent Aimar's avatar
Laurent Aimar committed
324 325 326 327 328
        i00 += c;
    }
}

/****************************************************************************
329
 * 4x4 prediction for intra luma block
Laurent Aimar's avatar
Laurent Aimar committed
330
 ****************************************************************************/
331

Loren Merritt's avatar
Loren Merritt committed
332
#define SRC(x,y) src[(x)+(y)*FDEC_STRIDE]
Fiona Glaser's avatar
Fiona Glaser committed
333
#define SRC32(x,y) M32( &SRC(x,y) )
Loren Merritt's avatar
Loren Merritt committed
334 335 336

#define PREDICT_4x4_DC(v)\
    SRC32(0,0) = SRC32(0,1) = SRC32(0,2) = SRC32(0,3) = v;
337

338
static void predict_4x4_dc_128( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
339
{
340
    PREDICT_4x4_DC(0x80808080);
Laurent Aimar's avatar
Laurent Aimar committed
341
}
342
static void predict_4x4_dc_left( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
343
{
Loren Merritt's avatar
Loren Merritt committed
344
    uint32_t dc = ((SRC(-1,0) + SRC(-1,1) + SRC(-1,2) + SRC(-1,3) + 2) >> 2) * 0x01010101;
345
    PREDICT_4x4_DC(dc);
Laurent Aimar's avatar
Laurent Aimar committed
346
}
347
static void predict_4x4_dc_top( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
348
{
Loren Merritt's avatar
Loren Merritt committed
349
    uint32_t dc = ((SRC(0,-1) + SRC(1,-1) + SRC(2,-1) + SRC(3,-1) + 2) >> 2) * 0x01010101;
350
    PREDICT_4x4_DC(dc);
Laurent Aimar's avatar
Laurent Aimar committed
351
}
352
static void predict_4x4_dc( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
353
{
Loren Merritt's avatar
Loren Merritt committed
354 355
    uint32_t dc = ((SRC(-1,0) + SRC(-1,1) + SRC(-1,2) + SRC(-1,3) +
                    SRC(0,-1) + SRC(1,-1) + SRC(2,-1) + SRC(3,-1) + 4) >> 3) * 0x01010101;
356
    PREDICT_4x4_DC(dc);
Laurent Aimar's avatar
Laurent Aimar committed
357
}
358
static void predict_4x4_h( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
359
{
Loren Merritt's avatar
Loren Merritt committed
360 361 362 363
    SRC32(0,0) = SRC(-1,0) * 0x01010101;
    SRC32(0,1) = SRC(-1,1) * 0x01010101;
    SRC32(0,2) = SRC(-1,2) * 0x01010101;
    SRC32(0,3) = SRC(-1,3) * 0x01010101;
Laurent Aimar's avatar
Laurent Aimar committed
364
}
365
static void predict_4x4_v( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
366
{
Loren Merritt's avatar
Loren Merritt committed
367
    PREDICT_4x4_DC(SRC32(0,-1));
Laurent Aimar's avatar
Laurent Aimar committed
368 369
}

Loren Merritt's avatar
Loren Merritt committed
370 371 372 373 374 375 376 377 378 379 380
#define PREDICT_4x4_LOAD_LEFT\
    const int l0 = SRC(-1,0);\
    const int l1 = SRC(-1,1);\
    const int l2 = SRC(-1,2);\
    UNUSED const int l3 = SRC(-1,3);

#define PREDICT_4x4_LOAD_TOP\
    const int t0 = SRC(0,-1);\
    const int t1 = SRC(1,-1);\
    const int t2 = SRC(2,-1);\
    UNUSED const int t3 = SRC(3,-1);
Laurent Aimar's avatar
Laurent Aimar committed
381

Loren Merritt's avatar
Loren Merritt committed
382 383 384 385 386
#define PREDICT_4x4_LOAD_TOP_RIGHT\
    const int t4 = SRC(4,-1);\
    const int t5 = SRC(5,-1);\
    const int t6 = SRC(6,-1);\
    UNUSED const int t7 = SRC(7,-1);
Laurent Aimar's avatar
Laurent Aimar committed
387

Loren Merritt's avatar
Loren Merritt committed
388 389
#define F1(a,b)   (((a)+(b)+1)>>1)
#define F2(a,b,c) (((a)+2*(b)+(c)+2)>>2)
Laurent Aimar's avatar
Laurent Aimar committed
390

391
static void predict_4x4_ddl( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
392 393 394
{
    PREDICT_4x4_LOAD_TOP
    PREDICT_4x4_LOAD_TOP_RIGHT
Loren Merritt's avatar
Loren Merritt committed
395 396 397 398 399 400 401
    SRC(0,0)= F2(t0,t1,t2);
    SRC(1,0)=SRC(0,1)= F2(t1,t2,t3);
    SRC(2,0)=SRC(1,1)=SRC(0,2)= F2(t2,t3,t4);
    SRC(3,0)=SRC(2,1)=SRC(1,2)=SRC(0,3)= F2(t3,t4,t5);
    SRC(3,1)=SRC(2,2)=SRC(1,3)= F2(t4,t5,t6);
    SRC(3,2)=SRC(2,3)= F2(t5,t6,t7);
    SRC(3,3)= F2(t6,t7,t7);
Laurent Aimar's avatar
Laurent Aimar committed
402
}
403
static void predict_4x4_ddr( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
404
{
Loren Merritt's avatar
Loren Merritt committed
405
    const int lt = SRC(-1,-1);
Laurent Aimar's avatar
Laurent Aimar committed
406 407
    PREDICT_4x4_LOAD_LEFT
    PREDICT_4x4_LOAD_TOP
Loren Merritt's avatar
Loren Merritt committed
408 409 410 411 412 413 414
    SRC(3,0)= F2(t3,t2,t1);
    SRC(2,0)=SRC(3,1)= F2(t2,t1,t0);
    SRC(1,0)=SRC(2,1)=SRC(3,2)= F2(t1,t0,lt);
    SRC(0,0)=SRC(1,1)=SRC(2,2)=SRC(3,3)= F2(t0,lt,l0);
    SRC(0,1)=SRC(1,2)=SRC(2,3)= F2(lt,l0,l1);
    SRC(0,2)=SRC(1,3)= F2(l0,l1,l2);
    SRC(0,3)= F2(l1,l2,l3);
Laurent Aimar's avatar
Laurent Aimar committed
415 416
}

417
static void predict_4x4_vr( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
418
{
Loren Merritt's avatar
Loren Merritt committed
419
    const int lt = SRC(-1,-1);
Laurent Aimar's avatar
Laurent Aimar committed
420 421
    PREDICT_4x4_LOAD_LEFT
    PREDICT_4x4_LOAD_TOP
Loren Merritt's avatar
Loren Merritt committed
422 423 424 425 426 427 428 429 430 431
    SRC(0,3)= F2(l2,l1,l0);
    SRC(0,2)= F2(l1,l0,lt);
    SRC(0,1)=SRC(1,3)= F2(l0,lt,t0);
    SRC(0,0)=SRC(1,2)= F1(lt,t0);
    SRC(1,1)=SRC(2,3)= F2(lt,t0,t1);
    SRC(1,0)=SRC(2,2)= F1(t0,t1);
    SRC(2,1)=SRC(3,3)= F2(t0,t1,t2);
    SRC(2,0)=SRC(3,2)= F1(t1,t2);
    SRC(3,1)= F2(t1,t2,t3);
    SRC(3,0)= F1(t2,t3);
Laurent Aimar's avatar
Laurent Aimar committed
432 433
}

434
static void predict_4x4_hd( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
435
{
Loren Merritt's avatar
Loren Merritt committed
436
    const int lt= SRC(-1,-1);
Laurent Aimar's avatar
Laurent Aimar committed
437 438
    PREDICT_4x4_LOAD_LEFT
    PREDICT_4x4_LOAD_TOP
Loren Merritt's avatar
Loren Merritt committed
439 440 441 442 443 444 445 446 447 448
    SRC(0,3)= F1(l2,l3);
    SRC(1,3)= F2(l1,l2,l3);
    SRC(0,2)=SRC(2,3)= F1(l1,l2);
    SRC(1,2)=SRC(3,3)= F2(l0,l1,l2);
    SRC(0,1)=SRC(2,2)= F1(l0,l1);
    SRC(1,1)=SRC(3,2)= F2(lt,l0,l1);
    SRC(0,0)=SRC(2,1)= F1(lt,l0);
    SRC(1,0)=SRC(3,1)= F2(t0,lt,l0);
    SRC(2,0)= F2(t1,t0,lt);
    SRC(3,0)= F2(t2,t1,t0);
Laurent Aimar's avatar
Laurent Aimar committed
449 450
}

451
static void predict_4x4_vl( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
452 453 454
{
    PREDICT_4x4_LOAD_TOP
    PREDICT_4x4_LOAD_TOP_RIGHT
Loren Merritt's avatar
Loren Merritt committed
455 456 457 458 459 460 461 462 463 464
    SRC(0,0)= F1(t0,t1);
    SRC(0,1)= F2(t0,t1,t2);
    SRC(1,0)=SRC(0,2)= F1(t1,t2);
    SRC(1,1)=SRC(0,3)= F2(t1,t2,t3);
    SRC(2,0)=SRC(1,2)= F1(t2,t3);
    SRC(2,1)=SRC(1,3)= F2(t2,t3,t4);
    SRC(3,0)=SRC(2,2)= F1(t3,t4);
    SRC(3,1)=SRC(2,3)= F2(t3,t4,t5);
    SRC(3,2)= F1(t4,t5);
    SRC(3,3)= F2(t4,t5,t6);
Laurent Aimar's avatar
Laurent Aimar committed
465 466
}

467
static void predict_4x4_hu( uint8_t *src )
Laurent Aimar's avatar
Laurent Aimar committed
468 469
{
    PREDICT_4x4_LOAD_LEFT
Loren Merritt's avatar
Loren Merritt committed
470 471 472 473 474 475 476 477
    SRC(0,0)= F1(l0,l1);
    SRC(1,0)= F2(l0,l1,l2);
    SRC(2,0)=SRC(0,1)= F1(l1,l2);
    SRC(3,0)=SRC(1,1)= F2(l1,l2,l3);
    SRC(2,1)=SRC(0,2)= F1(l2,l3);
    SRC(3,1)=SRC(1,2)= F2(l2,l3,l3);
    SRC(3,2)=SRC(1,3)=SRC(0,3)=
    SRC(2,2)=SRC(2,3)=SRC(3,3)= l3;
Laurent Aimar's avatar
Laurent Aimar committed
478 479
}

480 481 482 483 484
/****************************************************************************
 * 8x8 prediction for intra luma block
 ****************************************************************************/

#define PL(y) \
Loren Merritt's avatar
Loren Merritt committed
485
    edge[14-y] = F2(SRC(-1,y-1), SRC(-1,y), SRC(-1,y+1));
486
#define PT(x) \
Loren Merritt's avatar
Loren Merritt committed
487
    edge[16+x] = F2(SRC(x-1,-1), SRC(x,-1), SRC(x+1,-1));
488

Fiona Glaser's avatar
Fiona Glaser committed
489
static void predict_8x8_filter( uint8_t *src, uint8_t edge[33], int i_neighbor, int i_filters )
490 491 492 493 494 495 496 497 498
{
    /* edge[7..14] = l7..l0
     * edge[15] = lt
     * edge[16..31] = t0 .. t15
     * edge[32] = t15 */

    int have_lt = i_neighbor & MB_TOPLEFT;
    if( i_filters & MB_LEFT )
    {
499
        edge[15] = (SRC(0,-1) + 2*SRC(-1,-1) + SRC(-1,0) + 2) >> 2;
500 501 502 503 504 505 506 507 508 509 510 511
        edge[14] = ((have_lt ? SRC(-1,-1) : SRC(-1,0))
                    + 2*SRC(-1,0) + SRC(-1,1) + 2) >> 2;
        PL(1) PL(2) PL(3) PL(4) PL(5) PL(6)
        edge[7] = (SRC(-1,6) + 3*SRC(-1,7) + 2) >> 2;
    }

    if( i_filters & MB_TOP )
    {
        int have_tr = i_neighbor & MB_TOPRIGHT;
        edge[16] = ((have_lt ? SRC(-1,-1) : SRC(0,-1))
                    + 2*SRC(0,-1) + SRC(1,-1) + 2) >> 2;
        PT(1) PT(2) PT(3) PT(4) PT(5) PT(6)
512 513
        edge[23] = (SRC(6,-1) + 2*SRC(7,-1)
                    + (have_tr ? SRC(8,-1) : SRC(7,-1)) + 2) >> 2;
514 515 516 517 518 519 520 521 522 523 524

        if( i_filters & MB_TOPRIGHT )
        {
            if( have_tr )
            {
                PT(8) PT(9) PT(10) PT(11) PT(12) PT(13) PT(14)
                edge[31] =
                edge[32] = (SRC(14,-1) + 3*SRC(15,-1) + 2) >> 2;
            }
            else
            {
Fiona Glaser's avatar
Fiona Glaser committed
525
                M64( edge+24 ) = SRC(7,-1) * 0x0101010101010101ULL;
526 527 528 529 530
                edge[32] = SRC(7,-1);
            }
        }
    }
}
531

532 533 534 535 536 537 538
#undef PL
#undef PT

#define PL(y) \
    UNUSED const int l##y = edge[14-y];
#define PT(x) \
    UNUSED const int t##x = edge[16+x];
539
#define PREDICT_8x8_LOAD_TOPLEFT \
540 541 542 543 544 545 546
    const int lt = edge[15];
#define PREDICT_8x8_LOAD_LEFT \
    PL(0) PL(1) PL(2) PL(3) PL(4) PL(5) PL(6) PL(7)
#define PREDICT_8x8_LOAD_TOP \
    PT(0) PT(1) PT(2) PT(3) PT(4) PT(5) PT(6) PT(7)
#define PREDICT_8x8_LOAD_TOPRIGHT \
    PT(8) PT(9) PT(10) PT(11) PT(12) PT(13) PT(14) PT(15)
547 548 549 550

#define PREDICT_8x8_DC(v) \
    int y; \
    for( y = 0; y < 8; y++ ) { \
Fiona Glaser's avatar
Fiona Glaser committed
551 552
        M32( src+0 ) = v; \
        M32( src+4 ) = v; \
553
        src += FDEC_STRIDE; \
554 555
    }

556
static void predict_8x8_dc_128( uint8_t *src, uint8_t edge[33] )
557 558 559
{
    PREDICT_8x8_DC(0x80808080);
}
560
static void predict_8x8_dc_left( uint8_t *src, uint8_t edge[33] )
561
{
562
    PREDICT_8x8_LOAD_LEFT
563 564 565
    const uint32_t dc = ((l0+l1+l2+l3+l4+l5+l6+l7+4) >> 3) * 0x01010101;
    PREDICT_8x8_DC(dc);
}
566
static void predict_8x8_dc_top( uint8_t *src, uint8_t edge[33] )
567
{
568
    PREDICT_8x8_LOAD_TOP
569 570 571
    const uint32_t dc = ((t0+t1+t2+t3+t4+t5+t6+t7+4) >> 3) * 0x01010101;
    PREDICT_8x8_DC(dc);
}
572
static void predict_8x8_dc( uint8_t *src, uint8_t edge[33] )
573
{
574 575
    PREDICT_8x8_LOAD_LEFT
    PREDICT_8x8_LOAD_TOP
576 577 578 579
    const uint32_t dc = ((l0+l1+l2+l3+l4+l5+l6+l7
                         +t0+t1+t2+t3+t4+t5+t6+t7+8) >> 4) * 0x01010101;
    PREDICT_8x8_DC(dc);
}
580
static void predict_8x8_h( uint8_t *src, uint8_t edge[33] )
581
{
582
    PREDICT_8x8_LOAD_LEFT
Fiona Glaser's avatar
Fiona Glaser committed
583 584
#define ROW(y) M32( src+y*FDEC_STRIDE+0 ) =\
               M32( src+y*FDEC_STRIDE+4 ) = 0x01010101U * l##y;
585 586 587
    ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
#undef ROW
}
588
static void predict_8x8_v( uint8_t *src, uint8_t edge[33] )
589
{
Fiona Glaser's avatar
Fiona Glaser committed
590
    const uint64_t top = M64( edge+16 );
591
    int y;
592
    for( y = 0; y < 8; y++ )
Fiona Glaser's avatar
Fiona Glaser committed
593
        M64( src+y*FDEC_STRIDE ) = top;
594 595 596 597
}
static void predict_8x8_ddl( uint8_t *src, uint8_t edge[33] )
{
    PREDICT_8x8_LOAD_TOP
598
    PREDICT_8x8_LOAD_TOPRIGHT
Loren Merritt's avatar
Loren Merritt committed
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
    SRC(0,0)= F2(t0,t1,t2);
    SRC(0,1)=SRC(1,0)= F2(t1,t2,t3);
    SRC(0,2)=SRC(1,1)=SRC(2,0)= F2(t2,t3,t4);
    SRC(0,3)=SRC(1,2)=SRC(2,1)=SRC(3,0)= F2(t3,t4,t5);
    SRC(0,4)=SRC(1,3)=SRC(2,2)=SRC(3,1)=SRC(4,0)= F2(t4,t5,t6);
    SRC(0,5)=SRC(1,4)=SRC(2,3)=SRC(3,2)=SRC(4,1)=SRC(5,0)= F2(t5,t6,t7);
    SRC(0,6)=SRC(1,5)=SRC(2,4)=SRC(3,3)=SRC(4,2)=SRC(5,1)=SRC(6,0)= F2(t6,t7,t8);
    SRC(0,7)=SRC(1,6)=SRC(2,5)=SRC(3,4)=SRC(4,3)=SRC(5,2)=SRC(6,1)=SRC(7,0)= F2(t7,t8,t9);
    SRC(1,7)=SRC(2,6)=SRC(3,5)=SRC(4,4)=SRC(5,3)=SRC(6,2)=SRC(7,1)= F2(t8,t9,t10);
    SRC(2,7)=SRC(3,6)=SRC(4,5)=SRC(5,4)=SRC(6,3)=SRC(7,2)= F2(t9,t10,t11);
    SRC(3,7)=SRC(4,6)=SRC(5,5)=SRC(6,4)=SRC(7,3)= F2(t10,t11,t12);
    SRC(4,7)=SRC(5,6)=SRC(6,5)=SRC(7,4)= F2(t11,t12,t13);
    SRC(5,7)=SRC(6,6)=SRC(7,5)= F2(t12,t13,t14);
    SRC(6,7)=SRC(7,6)= F2(t13,t14,t15);
    SRC(7,7)= F2(t14,t15,t15);
614
}
615
static void predict_8x8_ddr( uint8_t *src, uint8_t edge[33] )
616
{
617 618
    PREDICT_8x8_LOAD_TOP
    PREDICT_8x8_LOAD_LEFT
619
    PREDICT_8x8_LOAD_TOPLEFT
Loren Merritt's avatar
Loren Merritt committed
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
    SRC(0,7)= F2(l7,l6,l5);
    SRC(0,6)=SRC(1,7)= F2(l6,l5,l4);
    SRC(0,5)=SRC(1,6)=SRC(2,7)= F2(l5,l4,l3);
    SRC(0,4)=SRC(1,5)=SRC(2,6)=SRC(3,7)= F2(l4,l3,l2);
    SRC(0,3)=SRC(1,4)=SRC(2,5)=SRC(3,6)=SRC(4,7)= F2(l3,l2,l1);
    SRC(0,2)=SRC(1,3)=SRC(2,4)=SRC(3,5)=SRC(4,6)=SRC(5,7)= F2(l2,l1,l0);
    SRC(0,1)=SRC(1,2)=SRC(2,3)=SRC(3,4)=SRC(4,5)=SRC(5,6)=SRC(6,7)= F2(l1,l0,lt);
    SRC(0,0)=SRC(1,1)=SRC(2,2)=SRC(3,3)=SRC(4,4)=SRC(5,5)=SRC(6,6)=SRC(7,7)= F2(l0,lt,t0);
    SRC(1,0)=SRC(2,1)=SRC(3,2)=SRC(4,3)=SRC(5,4)=SRC(6,5)=SRC(7,6)= F2(lt,t0,t1);
    SRC(2,0)=SRC(3,1)=SRC(4,2)=SRC(5,3)=SRC(6,4)=SRC(7,5)= F2(t0,t1,t2);
    SRC(3,0)=SRC(4,1)=SRC(5,2)=SRC(6,3)=SRC(7,4)= F2(t1,t2,t3);
    SRC(4,0)=SRC(5,1)=SRC(6,2)=SRC(7,3)= F2(t2,t3,t4);
    SRC(5,0)=SRC(6,1)=SRC(7,2)= F2(t3,t4,t5);
    SRC(6,0)=SRC(7,1)= F2(t4,t5,t6);
    SRC(7,0)= F2(t5,t6,t7);
Loren Merritt's avatar
Loren Merritt committed
635

636
}
637
static void predict_8x8_vr( uint8_t *src, uint8_t edge[33] )
638
{
639 640
    PREDICT_8x8_LOAD_TOP
    PREDICT_8x8_LOAD_LEFT
641
    PREDICT_8x8_LOAD_TOPLEFT
Loren Merritt's avatar
Loren Merritt committed
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
    SRC(0,6)= F2(l5,l4,l3);
    SRC(0,7)= F2(l6,l5,l4);
    SRC(0,4)=SRC(1,6)= F2(l3,l2,l1);
    SRC(0,5)=SRC(1,7)= F2(l4,l3,l2);
    SRC(0,2)=SRC(1,4)=SRC(2,6)= F2(l1,l0,lt);
    SRC(0,3)=SRC(1,5)=SRC(2,7)= F2(l2,l1,l0);
    SRC(0,1)=SRC(1,3)=SRC(2,5)=SRC(3,7)= F2(l0,lt,t0);
    SRC(0,0)=SRC(1,2)=SRC(2,4)=SRC(3,6)= F1(lt,t0);
    SRC(1,1)=SRC(2,3)=SRC(3,5)=SRC(4,7)= F2(lt,t0,t1);
    SRC(1,0)=SRC(2,2)=SRC(3,4)=SRC(4,6)= F1(t0,t1);
    SRC(2,1)=SRC(3,3)=SRC(4,5)=SRC(5,7)= F2(t0,t1,t2);
    SRC(2,0)=SRC(3,2)=SRC(4,4)=SRC(5,6)= F1(t1,t2);
    SRC(3,1)=SRC(4,3)=SRC(5,5)=SRC(6,7)= F2(t1,t2,t3);
    SRC(3,0)=SRC(4,2)=SRC(5,4)=SRC(6,6)= F1(t2,t3);
    SRC(4,1)=SRC(5,3)=SRC(6,5)=SRC(7,7)= F2(t2,t3,t4);
    SRC(4,0)=SRC(5,2)=SRC(6,4)=SRC(7,6)= F1(t3,t4);
    SRC(5,1)=SRC(6,3)=SRC(7,5)= F2(t3,t4,t5);
    SRC(5,0)=SRC(6,2)=SRC(7,4)= F1(t4,t5);
    SRC(6,1)=SRC(7,3)= F2(t4,t5,t6);
    SRC(6,0)=SRC(7,2)= F1(t5,t6);
    SRC(7,1)= F2(t5,t6,t7);
    SRC(7,0)= F1(t6,t7);
664
}
665
static void predict_8x8_hd( uint8_t *src, uint8_t edge[33] )
666
{
667 668
    PREDICT_8x8_LOAD_TOP
    PREDICT_8x8_LOAD_LEFT
669
    PREDICT_8x8_LOAD_TOPLEFT
Loren Merritt's avatar
Loren Merritt committed
670 671 672 673 674 675 676 677
    int p1 = pack8to16(F1(l6,l7), F2(l5,l6,l7));
    int p2 = pack8to16(F1(l5,l6), F2(l4,l5,l6));
    int p3 = pack8to16(F1(l4,l5), F2(l3,l4,l5));
    int p4 = pack8to16(F1(l3,l4), F2(l2,l3,l4));
    int p5 = pack8to16(F1(l2,l3), F2(l1,l2,l3));
    int p6 = pack8to16(F1(l1,l2), F2(l0,l1,l2));
    int p7 = pack8to16(F1(l0,l1), F2(lt,l0,l1));
    int p8 = pack8to16(F1(lt,l0), F2(l0,lt,t0));
Loren Merritt's avatar
Loren Merritt committed
678 679 680
    int p9 = pack8to16(F2(t1,t0,lt), F2(t2,t1,t0));
    int p10 = pack8to16(F2(t3,t2,t1), F2(t4,t3,t2));
    int p11 = pack8to16(F2(t5,t4,t3), F2(t6,t5,t4));
Fiona Glaser's avatar
Fiona Glaser committed
681 682 683 684 685 686 687 688 689 690
    SRC32(0,7)= pack16to32(p1,p2);
    SRC32(0,6)= pack16to32(p2,p3);
    SRC32(4,7)=SRC32(0,5)= pack16to32(p3,p4);
    SRC32(4,6)=SRC32(0,4)= pack16to32(p4,p5);
    SRC32(4,5)=SRC32(0,3)= pack16to32(p5,p6);
    SRC32(4,4)=SRC32(0,2)= pack16to32(p6,p7);
    SRC32(4,3)=SRC32(0,1)= pack16to32(p7,p8);
    SRC32(4,2)=SRC32(0,0)= pack16to32(p8,p9);
    SRC32(4,1)= pack16to32(p9,p10);
    SRC32(4,0)= pack16to32(p10,p11);
691
}
692
static void predict_8x8_vl( uint8_t *src, uint8_t edge[33] )
693
{
694
    PREDICT_8x8_LOAD_TOP
695
    PREDICT_8x8_LOAD_TOPRIGHT
Loren Merritt's avatar
Loren Merritt committed
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
    SRC(0,0)= F1(t0,t1);
    SRC(0,1)= F2(t0,t1,t2);
    SRC(0,2)=SRC(1,0)= F1(t1,t2);
    SRC(0,3)=SRC(1,1)= F2(t1,t2,t3);
    SRC(0,4)=SRC(1,2)=SRC(2,0)= F1(t2,t3);
    SRC(0,5)=SRC(1,3)=SRC(2,1)= F2(t2,t3,t4);
    SRC(0,6)=SRC(1,4)=SRC(2,2)=SRC(3,0)= F1(t3,t4);
    SRC(0,7)=SRC(1,5)=SRC(2,3)=SRC(3,1)= F2(t3,t4,t5);
    SRC(1,6)=SRC(2,4)=SRC(3,2)=SRC(4,0)= F1(t4,t5);
    SRC(1,7)=SRC(2,5)=SRC(3,3)=SRC(4,1)= F2(t4,t5,t6);
    SRC(2,6)=SRC(3,4)=SRC(4,2)=SRC(5,0)= F1(t5,t6);
    SRC(2,7)=SRC(3,5)=SRC(4,3)=SRC(5,1)= F2(t5,t6,t7);
    SRC(3,6)=SRC(4,4)=SRC(5,2)=SRC(6,0)= F1(t6,t7);
    SRC(3,7)=SRC(4,5)=SRC(5,3)=SRC(6,1)= F2(t6,t7,t8);
    SRC(4,6)=SRC(5,4)=SRC(6,2)=SRC(7,0)= F1(t7,t8);
    SRC(4,7)=SRC(5,5)=SRC(6,3)=SRC(7,1)= F2(t7,t8,t9);
    SRC(5,6)=SRC(6,4)=SRC(7,2)= F1(t8,t9);
    SRC(5,7)=SRC(6,5)=SRC(7,3)= F2(t8,t9,t10);
    SRC(6,6)=SRC(7,4)= F1(t9,t10);
    SRC(6,7)=SRC(7,5)= F2(t9,t10,t11);
    SRC(7,6)= F1(t10,t11);
    SRC(7,7)= F2(t10,t11,t12);
718
}
719
static void predict_8x8_hu( uint8_t *src, uint8_t edge[33] )
720
{
721
    PREDICT_8x8_LOAD_LEFT
Loren Merritt's avatar
Loren Merritt committed
722 723 724 725 726 727 728
    int p1 = pack8to16(F1(l0,l1), F2(l0,l1,l2));
    int p2 = pack8to16(F1(l1,l2), F2(l1,l2,l3));
    int p3 = pack8to16(F1(l2,l3), F2(l2,l3,l4));
    int p4 = pack8to16(F1(l3,l4), F2(l3,l4,l5));
    int p5 = pack8to16(F1(l4,l5), F2(l4,l5,l6));
    int p6 = pack8to16(F1(l5,l6), F2(l5,l6,l7));
    int p7 = pack8to16(F1(l6,l7), F2(l6,l7,l7));
Fiona Glaser's avatar
Fiona Glaser committed
729 730 731 732 733 734 735 736 737
    int p8 = pack8to16(l7,l7);
    SRC32(0,0)= pack16to32(p1,p2);
    SRC32(0,1)= pack16to32(p2,p3);
    SRC32(4,0)=SRC32(0,2)= pack16to32(p3,p4);
    SRC32(4,1)=SRC32(0,3)= pack16to32(p4,p5);
    SRC32(4,2)=SRC32(0,4)= pack16to32(p5,p6);
    SRC32(4,3)=SRC32(0,5)= pack16to32(p6,p7);
    SRC32(4,4)=SRC32(0,6)= pack16to32(p7,p8);
    SRC32(4,5)=SRC32(4,6)= SRC32(0,7) = SRC32(4,7) = pack16to32(p8,p8);
738 739
}

Laurent Aimar's avatar
Laurent Aimar committed
740 741 742 743 744 745 746 747 748 749 750 751 752
/****************************************************************************
 * Exported functions:
 ****************************************************************************/
void x264_predict_16x16_init( int cpu, x264_predict_t pf[7] )
{
    pf[I_PRED_16x16_V ]     = predict_16x16_v;
    pf[I_PRED_16x16_H ]     = predict_16x16_h;
    pf[I_PRED_16x16_DC]     = predict_16x16_dc;
    pf[I_PRED_16x16_P ]     = predict_16x16_p;
    pf[I_PRED_16x16_DC_LEFT]= predict_16x16_dc_left;
    pf[I_PRED_16x16_DC_TOP ]= predict_16x16_dc_top;
    pf[I_PRED_16x16_DC_128 ]= predict_16x16_dc_128;

753
#ifdef HAVE_MMX
Loren Merritt's avatar
Loren Merritt committed
754
    x264_predict_16x16_init_mmx( cpu, pf );
Laurent Aimar's avatar
Laurent Aimar committed
755
#endif
756

757
#ifdef HAVE_ALTIVEC
758 759 760 761 762
    if( cpu&X264_CPU_ALTIVEC )
    {
        x264_predict_16x16_init_altivec( pf );
    }
#endif
763 764 765 766

#ifdef HAVE_ARMV6
    x264_predict_16x16_init_arm( cpu, pf );
#endif
Laurent Aimar's avatar
Laurent Aimar committed
767 768
}

769
void x264_predict_8x8c_init( int cpu, x264_predict_t pf[7] )
Laurent Aimar's avatar
Laurent Aimar committed
770
{
771 772 773 774 775 776 777
    pf[I_PRED_CHROMA_V ]     = predict_8x8c_v;
    pf[I_PRED_CHROMA_H ]     = predict_8x8c_h;
    pf[I_PRED_CHROMA_DC]     = predict_8x8c_dc;
    pf[I_PRED_CHROMA_P ]     = predict_8x8c_p;
    pf[I_PRED_CHROMA_DC_LEFT]= predict_8x8c_dc_left;
    pf[I_PRED_CHROMA_DC_TOP ]= predict_8x8c_dc_top;
    pf[I_PRED_CHROMA_DC_128 ]= predict_8x8c_dc_128;
Laurent Aimar's avatar
Laurent Aimar committed
778

779
#ifdef HAVE_MMX
Loren Merritt's avatar
Loren Merritt committed
780
    x264_predict_8x8c_init_mmx( cpu, pf );
Laurent Aimar's avatar
Laurent Aimar committed
781
#endif
782

783
#ifdef HAVE_ALTIVEC
784 785 786 787 788
    if( cpu&X264_CPU_ALTIVEC )
    {
        x264_predict_8x8c_init_altivec( pf );
    }
#endif
789 790 791 792

#ifdef HAVE_ARMV6
    x264_predict_8x8c_init_arm( cpu, pf );
#endif
Laurent Aimar's avatar
Laurent Aimar committed
793 794
}

Fiona Glaser's avatar
Fiona Glaser committed
795
void x264_predict_8x8_init( int cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_filter )
796 797 798 799 800 801 802 803 804 805 806 807 808
{
    pf[I_PRED_8x8_V]      = predict_8x8_v;
    pf[I_PRED_8x8_H]      = predict_8x8_h;
    pf[I_PRED_8x8_DC]     = predict_8x8_dc;
    pf[I_PRED_8x8_DDL]    = predict_8x8_ddl;
    pf[I_PRED_8x8_DDR]    = predict_8x8_ddr;
    pf[I_PRED_8x8_VR]     = predict_8x8_vr;
    pf[I_PRED_8x8_HD]     = predict_8x8_hd;
    pf[I_PRED_8x8_VL]     = predict_8x8_vl;
    pf[I_PRED_8x8_HU]     = predict_8x8_hu;
    pf[I_PRED_8x8_DC_LEFT]= predict_8x8_dc_left;
    pf[I_PRED_8x8_DC_TOP] = predict_8x8_dc_top;
    pf[I_PRED_8x8_DC_128] = predict_8x8_dc_128;
Fiona Glaser's avatar
Fiona Glaser committed
809
    *predict_filter       = predict_8x8_filter;
810

811
#ifdef HAVE_MMX
Fiona Glaser's avatar
Fiona Glaser committed
812
    x264_predict_8x8_init_mmx( cpu, pf, predict_filter );
813
#endif
814 815 816 817

#ifdef HAVE_ARMV6
    x264_predict_8x8_init_arm( cpu, pf, predict_filter );
#endif
818 819
}

Laurent Aimar's avatar
Laurent Aimar committed
820 821 822 823 824 825 826 827 828 829 830 831 832 833
void x264_predict_4x4_init( int cpu, x264_predict_t pf[12] )
{
    pf[I_PRED_4x4_V]      = predict_4x4_v;
    pf[I_PRED_4x4_H]      = predict_4x4_h;
    pf[I_PRED_4x4_DC]     = predict_4x4_dc;
    pf[I_PRED_4x4_DDL]    = predict_4x4_ddl;
    pf[I_PRED_4x4_DDR]    = predict_4x4_ddr;
    pf[I_PRED_4x4_VR]     = predict_4x4_vr;
    pf[I_PRED_4x4_HD]     = predict_4x4_hd;
    pf[I_PRED_4x4_VL]     = predict_4x4_vl;
    pf[I_PRED_4x4_HU]     = predict_4x4_hu;
    pf[I_PRED_4x4_DC_LEFT]= predict_4x4_dc_left;
    pf[I_PRED_4x4_DC_TOP] = predict_4x4_dc_top;
    pf[I_PRED_4x4_DC_128] = predict_4x4_dc_128;
834

835
#ifdef HAVE_MMX
Loren Merritt's avatar
Loren Merritt committed
836
    x264_predict_4x4_init_mmx( cpu, pf );
837
#endif
838 839 840 841

#ifdef HAVE_ARMV6
    x264_predict_4x4_init_arm( cpu, pf );
#endif
Laurent Aimar's avatar
Laurent Aimar committed
842 843
}