]> git.sesse.net Git - ffmpeg/blob - libavcodec/idctdsp.h
Merge commit 'a8c104a511f97e4ea617df73b31737e28a8a5126'
[ffmpeg] / libavcodec / idctdsp.h
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #ifndef AVCODEC_IDCTDSP_H
20 #define AVCODEC_IDCTDSP_H
21
22 #include <stdint.h>
23
24 #include "avcodec.h"
25
26 /**
27  * Scantable.
28  */
29 typedef struct ScanTable {
30     const uint8_t *scantable;
31     uint8_t permutated[64];
32     uint8_t raster_end[64];
33 } ScanTable;
34
35 enum idct_permutation_type {
36     FF_IDCT_PERM_NONE,
37     FF_IDCT_PERM_LIBMPEG2,
38     FF_IDCT_PERM_SIMPLE,
39     FF_IDCT_PERM_TRANSPOSE,
40     FF_IDCT_PERM_PARTTRANS,
41     FF_IDCT_PERM_SSE2,
42 };
43
44 void ff_init_scantable(uint8_t *permutation, ScanTable *st,
45                        const uint8_t *src_scantable);
46 void ff_init_scantable_permutation(uint8_t *idct_permutation,
47                                    enum idct_permutation_type perm_type);
48 int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
49                                       enum idct_permutation_type perm_type);
50
51 void ff_put_pixels_clamped(const int16_t *block, uint8_t *av_restrict pixels,
52                            int line_size);
53 void ff_add_pixels_clamped(const int16_t *block, uint8_t *av_restrict pixels,
54                            int line_size);
55
56 typedef struct IDCTDSPContext {
57     /* pixel ops : interface with DCT */
58     void (*put_pixels_clamped)(const int16_t *block /* align 16 */,
59                                uint8_t *pixels /* align 8 */,
60                                int line_size);
61     void (*put_signed_pixels_clamped)(const int16_t *block /* align 16 */,
62                                       uint8_t *pixels /* align 8 */,
63                                       int line_size);
64     void (*add_pixels_clamped)(const int16_t *block /* align 16 */,
65                                uint8_t *pixels /* align 8 */,
66                                int line_size);
67
68     void (*idct)(int16_t *block /* align 16 */);
69
70     /**
71      * block -> idct -> clip to unsigned 8 bit -> dest.
72      * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
73      * @param line_size size in bytes of a horizontal line of dest
74      */
75     void (*idct_put)(uint8_t *dest /* align 8 */,
76                      int line_size, int16_t *block /* align 16 */);
77
78     /**
79      * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
80      * @param line_size size in bytes of a horizontal line of dest
81      */
82     void (*idct_add)(uint8_t *dest /* align 8 */,
83                      int line_size, int16_t *block /* align 16 */);
84
85     /**
86      * IDCT input permutation.
87      * Several optimized IDCTs need a permutated input (relative to the
88      * normal order of the reference IDCT).
89      * This permutation must be performed before the idct_put/add.
90      * Note, normally this can be merged with the zigzag/alternate scan<br>
91      * An example to avoid confusion:
92      * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
93      * - (x -> reference DCT -> reference IDCT -> x)
94      * - (x -> reference DCT -> simple_mmx_perm = idct_permutation
95      *    -> simple_idct_mmx -> x)
96      * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
97      *    -> simple_idct_mmx -> ...)
98      */
99     uint8_t idct_permutation[64];
100     enum idct_permutation_type perm_type;
101 } IDCTDSPContext;
102
103 void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx);
104
105 void ff_idctdsp_init_alpha(IDCTDSPContext *c, AVCodecContext *avctx,
106                            unsigned high_bit_depth);
107 void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx,
108                          unsigned high_bit_depth);
109 void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx,
110                          unsigned high_bit_depth);
111 void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
112                          unsigned high_bit_depth);
113
114 #endif /* AVCODEC_IDCTDSP_H */