]> git.sesse.net Git - x264/blob - common/pixel.h
remove private stuff from public headers. no more need for -D__X264__
[x264] / common / pixel.h
1 /*****************************************************************************
2  * pixel.h: h264 encoder library
3  *****************************************************************************
4  * Copyright (C) 2003 Laurent Aimar
5  * $Id: pixel.h,v 1.1 2004/06/03 19:27:07 fenrir Exp $
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #ifndef _PIXEL_H
25 #define _PIXEL_H 1
26
27 typedef int  (*x264_pixel_cmp_t) ( uint8_t *, int, uint8_t *, int );
28 typedef int  (*x264_pixel_cmp_pde_t) ( uint8_t *, int, uint8_t *, int, int );
29 typedef void (*x264_pixel_cmp_x3_t) ( uint8_t *, uint8_t *, uint8_t *, uint8_t *, int, int[3] );
30 typedef void (*x264_pixel_cmp_x4_t) ( uint8_t *, uint8_t *, uint8_t *, uint8_t *, uint8_t *, int, int[4] );
31
32 enum
33 {
34     PIXEL_16x16 = 0,
35     PIXEL_16x8  = 1,
36     PIXEL_8x16  = 2,
37     PIXEL_8x8   = 3,
38     PIXEL_8x4   = 4,
39     PIXEL_4x8   = 5,
40     PIXEL_4x4   = 6,
41     PIXEL_4x2   = 7,
42     PIXEL_2x4   = 8,
43     PIXEL_2x2   = 9,
44 };
45
46 static const struct {
47     int w;
48     int h;
49 } x264_pixel_size[7] = {
50     { 16, 16 },
51     { 16,  8 }, {  8, 16 },
52     {  8,  8 },
53     {  8,  4 }, {  4,  8 },
54     {  4,  4 }
55 };
56
57 static const int x264_size2pixel[5][5] = {
58     { 0, },
59     { 0, PIXEL_4x4, PIXEL_8x4, 0, 0 },
60     { 0, PIXEL_4x8, PIXEL_8x8, 0, PIXEL_16x8 },
61     { 0, },
62     { 0, 0,        PIXEL_8x16, 0, PIXEL_16x16 }
63 };
64
65 typedef struct
66 {
67     x264_pixel_cmp_t  sad[7];
68     x264_pixel_cmp_t  ssd[7];
69     x264_pixel_cmp_t satd[7];
70     x264_pixel_cmp_t ssim[7];
71     x264_pixel_cmp_t sa8d[4];
72     x264_pixel_cmp_t mbcmp[7]; /* either satd or sad for subpel refine and mode decision */
73     x264_pixel_cmp_t rdcmp[7]; /* either ssd or ssim for rate-distortion */
74
75     void (*ssim_4x4x2_core)( const uint8_t *pix1, int stride1,
76                              const uint8_t *pix2, int stride2, int sums[2][4] );
77     float (*ssim_end4)( int sum0[5][4], int sum1[5][4], int width );
78
79     /* partial distortion elimination:
80      * terminate early if partial score is worse than a threshold.
81      * may be NULL, in which case just use sad instead. */
82     x264_pixel_cmp_pde_t sad_pde[7];
83
84     /* multiple parallel calls to sad. */
85     x264_pixel_cmp_x3_t sad_x3[7];
86     x264_pixel_cmp_x4_t sad_x4[7];
87
88     /* abs-diff-sum for successive elimination.
89      * may round width up to a multiple of 8. */
90     void (*ads[7])( int enc_dc[4], uint16_t *sums, int delta,
91                     uint16_t *res, int width );
92
93     /* calculate satd of V, H, and DC modes.
94      * may be NULL, in which case just use pred+satd instead. */
95     void (*intra_satd_x3_16x16)( uint8_t *fenc, uint8_t *fdec, int res[3] );
96     void (*intra_satd_x3_8x8c)( uint8_t *fenc, uint8_t *fdec, int res[3] );
97     void (*intra_satd_x3_4x4)( uint8_t *fenc, uint8_t *fdec, int res[3] );
98     void (*intra_sa8d_x3_8x8)( uint8_t *fenc, uint8_t edge[33], int res[3] );
99 } x264_pixel_function_t;
100
101 void x264_pixel_init( int cpu, x264_pixel_function_t *pixf );
102 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 );
103 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 );
104
105 #endif