1 /*****************************************************************************
2  * dct.h: transform and zigzag
3  *****************************************************************************
4  * Copyright (C) 2004-2021 x264 project
5  *
6  * Authors: Loren Merritt <lorenm@u.washington.edu>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
21  *
22  * This program is also available under a commercial proprietary license.
23  * For more information, contact us at licensing@x264.com.
24  *****************************************************************************/
25 
26 #ifndef X264_DCT_H
27 #define X264_DCT_H
28 
29 typedef struct
30 {
31     // pix1  stride = FENC_STRIDE
32     // pix2  stride = FDEC_STRIDE
33     // p_dst stride = FDEC_STRIDE
34     void (*sub4x4_dct) ( dctcoef dct[16], pixel *pix1, pixel *pix2 );
35     void (*add4x4_idct)( pixel *p_dst, dctcoef dct[16] );
36 
37     void (*sub8x8_dct)    ( dctcoef dct[4][16], pixel *pix1, pixel *pix2 );
38     void (*sub8x8_dct_dc) ( dctcoef dct[4], pixel *pix1, pixel *pix2 );
39     void (*add8x8_idct)   ( pixel *p_dst, dctcoef dct[4][16] );
40     void (*add8x8_idct_dc)( pixel *p_dst, dctcoef dct[4] );
41 
42     void (*sub8x16_dct_dc)( dctcoef dct[8], pixel *pix1, pixel *pix2 );
43 
44     void (*sub16x16_dct)    ( dctcoef dct[16][16], pixel *pix1, pixel *pix2 );
45     void (*add16x16_idct)   ( pixel *p_dst, dctcoef dct[16][16] );
46     void (*add16x16_idct_dc)( pixel *p_dst, dctcoef dct[16] );
47 
48     void (*sub8x8_dct8) ( dctcoef dct[64], pixel *pix1, pixel *pix2 );
49     void (*add8x8_idct8)( pixel *p_dst, dctcoef dct[64] );
50 
51     void (*sub16x16_dct8) ( dctcoef dct[4][64], pixel *pix1, pixel *pix2 );
52     void (*add16x16_idct8)( pixel *p_dst, dctcoef dct[4][64] );
53 
54     void (*dct4x4dc) ( dctcoef d[16] );
55     void (*idct4x4dc)( dctcoef d[16] );
56 
57     void (*dct2x4dc)( dctcoef dct[8], dctcoef dct4x4[8][16] );
58 
59 } x264_dct_function_t;
60 
61 typedef struct
62 {
63     void (*scan_8x8)( dctcoef level[64], dctcoef dct[64] );
64     void (*scan_4x4)( dctcoef level[16], dctcoef dct[16] );
65     int  (*sub_8x8)  ( dctcoef level[64], const pixel *p_src, pixel *p_dst );
66     int  (*sub_4x4)  ( dctcoef level[16], const pixel *p_src, pixel *p_dst );
67     int  (*sub_4x4ac)( dctcoef level[16], const pixel *p_src, pixel *p_dst, dctcoef *dc );
68     void (*interleave_8x8_cavlc)( dctcoef *dst, dctcoef *src, uint8_t *nnz );
69 
70 } x264_zigzag_function_t;
71 
72 #define x264_dct_init x264_template(dct_init)
73 void x264_dct_init( uint32_t cpu, x264_dct_function_t *dctf );
74 #define x264_zigzag_init x264_template(zigzag_init)
75 void x264_zigzag_init( uint32_t cpu, x264_zigzag_function_t *pf_progressive, x264_zigzag_function_t *pf_interlaced );
76 
77 #endif
78