pixel.h 3.62 KB
Newer Older
Laurent Aimar's avatar
Laurent Aimar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*****************************************************************************
 * pixel.h: h264 encoder library
 *****************************************************************************
 * Copyright (C) 2003 Laurent Aimar
 * $Id: pixel.h,v 1.1 2004/06/03 19:27:07 fenrir Exp $
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 *
 * 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
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

#ifndef _PIXEL_H
#define _PIXEL_H 1

27
typedef int  (*x264_pixel_cmp_t) ( uint8_t *, int, uint8_t *, int );
28 29
typedef void (*x264_pixel_cmp_x3_t) ( uint8_t *, uint8_t *, uint8_t *, uint8_t *, int, int[3] );
typedef void (*x264_pixel_cmp_x4_t) ( uint8_t *, uint8_t *, uint8_t *, uint8_t *, uint8_t *, int, int[4] );
Laurent Aimar's avatar
Laurent Aimar committed
30 31 32 33 34 35 36 37 38 39

enum
{
    PIXEL_16x16 = 0,
    PIXEL_16x8  = 1,
    PIXEL_8x16  = 2,
    PIXEL_8x8   = 3,
    PIXEL_8x4   = 4,
    PIXEL_4x8   = 5,
    PIXEL_4x4   = 6,
40 41 42
    PIXEL_4x2   = 7,
    PIXEL_2x4   = 8,
    PIXEL_2x2   = 9,
Laurent Aimar's avatar
Laurent Aimar committed
43 44 45 46 47 48 49 50 51 52 53 54 55
};

static const struct {
    int w;
    int h;
} x264_pixel_size[7] = {
    { 16, 16 },
    { 16,  8 }, {  8, 16 },
    {  8,  8 },
    {  8,  4 }, {  4,  8 },
    {  4,  4 }
};

56
static const uint8_t x264_size2pixel[5][5] = {
Loren Merritt's avatar
Loren Merritt committed
57 58 59 60 61 62 63
    { 0, },
    { 0, PIXEL_4x4, PIXEL_8x4, 0, 0 },
    { 0, PIXEL_4x8, PIXEL_8x8, 0, PIXEL_16x8 },
    { 0, },
    { 0, 0,        PIXEL_8x16, 0, PIXEL_16x16 }
};

Laurent Aimar's avatar
Laurent Aimar committed
64 65
typedef struct
{
66 67 68
    x264_pixel_cmp_t  sad[7];
    x264_pixel_cmp_t  ssd[7];
    x264_pixel_cmp_t satd[7];
69
    x264_pixel_cmp_t ssim[7];
70
    x264_pixel_cmp_t sa8d[4];
71
    x264_pixel_cmp_t mbcmp[7]; /* either satd or sad for subpel refine and mode decision */
72 73 74 75 76
    x264_pixel_cmp_t rdcmp[7]; /* either ssd or ssim for rate-distortion */

    void (*ssim_4x4x2_core)( const uint8_t *pix1, int stride1,
                             const uint8_t *pix2, int stride2, int sums[2][4] );
    float (*ssim_end4)( int sum0[5][4], int sum1[5][4], int width );
77

78 79 80
    /* multiple parallel calls to sad. */
    x264_pixel_cmp_x3_t sad_x3[7];
    x264_pixel_cmp_x4_t sad_x4[7];
81

Loren Merritt's avatar
Loren Merritt committed
82 83 84 85 86
    /* abs-diff-sum for successive elimination.
     * may round width up to a multiple of 8. */
    void (*ads[7])( int enc_dc[4], uint16_t *sums, int delta,
                    uint16_t *res, int width );

87 88 89 90 91
    /* calculate satd of V, H, and DC modes.
     * may be NULL, in which case just use pred+satd instead. */
    void (*intra_satd_x3_16x16)( uint8_t *fenc, uint8_t *fdec, int res[3] );
    void (*intra_satd_x3_8x8c)( uint8_t *fenc, uint8_t *fdec, int res[3] );
    void (*intra_satd_x3_4x4)( uint8_t *fenc, uint8_t *fdec, int res[3] );
92
    void (*intra_sa8d_x3_8x8)( uint8_t *fenc, uint8_t edge[33], int res[3] );
Laurent Aimar's avatar
Laurent Aimar committed
93 94 95
} x264_pixel_function_t;

void x264_pixel_init( int cpu, x264_pixel_function_t *pixf );
Loren Merritt's avatar
Loren Merritt committed
96
int64_t x264_pixel_ssd_wxh( x264_pixel_function_t *pf, uint8_t *pix1, int i_pix1, uint8_t *pix2, int i_pix2, int i_width, int i_height );
97
float x264_pixel_ssim_wxh( x264_pixel_function_t *pf, uint8_t *pix1, int i_pix1, uint8_t *pix2, int i_pix2, int i_width, int i_height );
Laurent Aimar's avatar
Laurent Aimar committed
98 99

#endif