]> git.sesse.net Git - ffmpeg/blob - libavcodec/ivi_dsp.h
Hap decoder and encoder
[ffmpeg] / libavcodec / ivi_dsp.h
1 /*
2  * DSP functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
3  *
4  * Copyright (c) 2009-2011 Maxim Poliakovski
5  *
6  * This file is part of Libav.
7  *
8  * Libav is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * Libav 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 GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22
23 /**
24  * @file
25  * DSP functions (inverse transforms, motion compensations, wavelet recompostion)
26  * for Indeo Video Interactive codecs.
27  */
28
29 #ifndef AVCODEC_IVI_DSP_H
30 #define AVCODEC_IVI_DSP_H
31
32 #include <stdint.h>
33
34 #include "ivi.h"
35
36 /**
37  *  5/3 wavelet recomposition filter for Indeo5
38  *
39  *  @param[in]   plane        pointer to the descriptor of the plane being processed
40  *  @param[out]  dst          pointer to the destination buffer
41  *  @param[in]   dst_pitch    pitch of the destination buffer
42  */
43 void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
44                         const int dst_pitch);
45
46 /**
47  *  Haar wavelet recomposition filter for Indeo 4
48  *
49  *  @param[in]  plane        pointer to the descriptor of the plane being processed
50  *  @param[out] dst          pointer to the destination buffer
51  *  @param[in]  dst_pitch    pitch of the destination buffer
52  */
53 void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst,
54                            const int dst_pitch);
55
56 /**
57  *  two-dimensional inverse Haar 8x8 transform for Indeo 4
58  *
59  *  @param[in]  in        pointer to the vector of transform coefficients
60  *  @param[out] out       pointer to the output buffer (frame)
61  *  @param[in]  pitch     pitch to move to the next y line
62  *  @param[in]  flags     pointer to the array of column flags:
63  *                        != 0 - non_empty column, 0 - empty one
64  *                        (this array must be filled by caller)
65  */
66 void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
67                              const uint8_t *flags);
68
69 /**
70  *  one-dimensional inverse 8-point Haar transform on rows for Indeo 4
71  *
72  *  @param[in]  in        pointer to the vector of transform coefficients
73  *  @param[out] out       pointer to the output buffer (frame)
74  *  @param[in]  pitch     pitch to move to the next y line
75  *  @param[in]  flags     pointer to the array of column flags:
76  *                        != 0 - non_empty column, 0 - empty one
77  *                        (this array must be filled by caller)
78  */
79 void ff_ivi_row_haar8(const int32_t *in, int16_t *out, uint32_t pitch,
80                       const uint8_t *flags);
81
82 /**
83  *  one-dimensional inverse 8-point Haar transform on columns for Indeo 4
84  *
85  *  @param[in]  in        pointer to the vector of transform coefficients
86  *  @param[out] out       pointer to the output buffer (frame)
87  *  @param[in]  pitch     pitch to move to the next y line
88  *  @param[in]  flags     pointer to the array of column flags:
89  *                        != 0 - non_empty column, 0 - empty one
90  *                        (this array must be filled by caller)
91  */
92 void ff_ivi_col_haar8(const int32_t *in, int16_t *out, uint32_t pitch,
93                       const uint8_t *flags);
94
95 /**
96  *  two-dimensional inverse Haar 4x4 transform for Indeo 4
97  *
98  *  @param[in]  in        pointer to the vector of transform coefficients
99  *  @param[out] out       pointer to the output buffer (frame)
100  *  @param[in]  pitch     pitch to move to the next y line
101  *  @param[in]  flags     pointer to the array of column flags:
102  *                        != 0 - non_empty column, 0 - empty one
103  *                        (this array must be filled by caller)
104  */
105 void ff_ivi_inverse_haar_4x4(const int32_t *in, int16_t *out, uint32_t pitch,
106                              const uint8_t *flags);
107
108 /**
109  *  one-dimensional inverse 4-point Haar transform on rows for Indeo 4
110  *
111  *  @param[in]  in        pointer to the vector of transform coefficients
112  *  @param[out] out       pointer to the output buffer (frame)
113  *  @param[in]  pitch     pitch to move to the next y line
114  *  @param[in]  flags     pointer to the array of column flags:
115  *                        != 0 - non_empty column, 0 - empty one
116  *                        (this array must be filled by caller)
117  */
118 void ff_ivi_row_haar4(const int32_t *in, int16_t *out, uint32_t pitch,
119                       const uint8_t *flags);
120
121 /**
122  *  one-dimensional inverse 4-point Haar transform on columns for Indeo 4
123  *
124  *  @param[in]  in        pointer to the vector of transform coefficients
125  *  @param[out] out       pointer to the output buffer (frame)
126  *  @param[in]  pitch     pitch to move to the next y line
127  *  @param[in]  flags     pointer to the array of column flags:
128  *                        != 0 - non_empty column, 0 - empty one
129  *                        (this array must be filled by caller)
130  */
131 void ff_ivi_col_haar4(const int32_t *in, int16_t *out, uint32_t pitch,
132                       const uint8_t *flags);
133
134 /**
135  *  DC-only two-dimensional inverse Haar transform for Indeo 4.
136  *  Performing the inverse transform in this case is equivalent to
137  *  spreading DC_coeff >> 3 over the whole block.
138  *
139  *  @param[in]  in          pointer to the dc coefficient
140  *  @param[out] out         pointer to the output buffer (frame)
141  *  @param[in]  pitch       pitch to move to the next y line
142  *  @param[in]  blk_size    transform block size
143  */
144 void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
145                        int blk_size);
146
147 /**
148  *  two-dimensional inverse slant 8x8 transform
149  *
150  *  @param[in]    in      pointer to the vector of transform coefficients
151  *  @param[out]   out     pointer to the output buffer (frame)
152  *  @param[in]    pitch   pitch to move to the next y line
153  *  @param[in]    flags   pointer to the array of column flags:
154  *                        != 0 - non_empty column, 0 - empty one
155  *                        (this array must be filled by caller)
156  */
157 void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
158                               const uint8_t *flags);
159
160 /**
161  *  two-dimensional inverse slant 4x4 transform
162  *
163  *  @param[in]    in      pointer to the vector of transform coefficients
164  *  @param[out]   out     pointer to the output buffer (frame)
165  *  @param[in]    pitch   pitch to move to the next y line
166  *  @param[in]    flags   pointer to the array of column flags:
167  *                        != 0 - non_empty column, 0 - empty one
168  *                        (this array must be filled by caller)
169  */
170 void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch,
171                               const uint8_t *flags);
172
173 /**
174  *  DC-only two-dimensional inverse slant transform.
175  *  Performing the inverse slant transform in this case is equivalent to
176  *  spreading (DC_coeff + 1)/2 over the whole block.
177  *  It works much faster than performing the slant transform on a vector of zeroes.
178  *
179  *  @param[in]    in          pointer to the dc coefficient
180  *  @param[out]   out         pointer to the output buffer (frame)
181  *  @param[in]    pitch       pitch to move to the next y line
182  *  @param[in]    blk_size    transform block size
183  */
184 void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
185
186 /**
187  *  inverse 1D row slant transform
188  *
189  *  @param[in]    in      pointer to the vector of transform coefficients
190  *  @param[out]   out     pointer to the output buffer (frame)
191  *  @param[in]    pitch   pitch to move to the next y line
192  *  @param[in]    flags   pointer to the array of column flags (unused here)
193  */
194 void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch,
195                        const uint8_t *flags);
196
197 /**
198  *  inverse 1D column slant transform
199  *
200  *  @param[in]    in      pointer to the vector of transform coefficients
201  *  @param[out]   out     pointer to the output buffer (frame)
202  *  @param[in]    pitch   pitch to move to the next y line
203  *  @param[in]    flags   pointer to the array of column flags:
204  *                        != 0 - non_empty column, 0 - empty one
205  *                        (this array must be filled by caller)
206  */
207 void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch,
208                        const uint8_t *flags);
209
210 /**
211  *  inverse 1D row slant transform
212  *
213  *  @param[in]    in      pointer to the vector of transform coefficients
214  *  @param[out]   out     pointer to the output buffer (frame)
215  *  @param[in]    pitch   pitch to move to the next y line
216  *  @param[in]    flags   pointer to the array of column flags (unused here)
217  */
218 void ff_ivi_row_slant4(const int32_t *in, int16_t *out, uint32_t pitch,
219                        const uint8_t *flags);
220
221 /**
222  *  inverse 1D column slant transform
223  *
224  *  @param[in]    in      pointer to the vector of transform coefficients
225  *  @param[out]   out     pointer to the output buffer (frame)
226  *  @param[in]    pitch   pitch to move to the next y line
227  *  @param[in]    flags   pointer to the array of column flags:
228  *                        != 0 - non_empty column, 0 - empty one
229  *                        (this array must be filled by caller)
230  */
231 void ff_ivi_col_slant4(const int32_t *in, int16_t *out, uint32_t pitch,
232                        const uint8_t *flags);
233
234 /**
235  *  DC-only inverse row slant transform
236  */
237 void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
238
239 /**
240  *  DC-only inverse column slant transform
241  */
242 void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
243
244 /**
245  *  Copy the pixels into the frame buffer.
246  */
247 void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags);
248
249 /**
250  *  Copy the DC coefficient into the first pixel of the block and
251  *  zero all others.
252  */
253 void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
254
255 /**
256  *  8x8 block motion compensation with adding delta
257  *
258  *  @param[in,out]   buf      pointer to the block in the current frame buffer containing delta
259  *  @param[in]       ref_buf  pointer to the corresponding block in the reference frame
260  *  @param[in]       pitch    pitch for moving to the next y line
261  *  @param[in]       mc_type  interpolation type
262  */
263 void ff_ivi_mc_8x8_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
264
265 /**
266  *  4x4 block motion compensation with adding delta
267  *
268  *  @param[in,out]   buf      pointer to the block in the current frame buffer containing delta
269  *  @param[in]       ref_buf  pointer to the corresponding block in the reference frame
270  *  @param[in]       pitch    pitch for moving to the next y line
271  *  @param[in]       mc_type  interpolation type
272  */
273 void ff_ivi_mc_4x4_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
274
275 /**
276  *  motion compensation without adding delta
277  *
278  *  @param[in,out]  buf      pointer to the block in the current frame receiving the result
279  *  @param[in]      ref_buf  pointer to the corresponding block in the reference frame
280  *  @param[in]      pitch    pitch for moving to the next y line
281  *  @param[in]      mc_type  interpolation type
282  */
283 void ff_ivi_mc_8x8_no_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
284
285 /**
286  *  4x4 block motion compensation without adding delta
287  *
288  *  @param[in,out]  buf      pointer to the block in the current frame receiving the result
289  *  @param[in]      ref_buf  pointer to the corresponding block in the reference frame
290  *  @param[in]      pitch    pitch for moving to the next y line
291  *  @param[in]      mc_type  interpolation type
292  */
293 void ff_ivi_mc_4x4_no_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
294
295 /**
296  *  8x8 block motion compensation with adding delta
297  *
298  *  @param[in,out]  buf      pointer to the block in the current frame buffer containing delta
299  *  @param[in]      ref_buf  pointer to the corresponding block in the backward reference frame
300  *  @param[in]      ref_buf2 pointer to the corresponding block in the forward reference frame
301  *  @param[in]      pitch    pitch for moving to the next y line
302  *  @param[in]      mc_type  interpolation type for backward reference
303  *  @param[in]      mc_type2 interpolation type for forward reference
304  */
305 void ff_ivi_mc_avg_8x8_delta(int16_t *buf, const int16_t *ref_buf, const int16_t *ref_buf2, uint32_t pitch, int mc_type, int mc_type2);
306
307 /**
308  *  4x4 block motion compensation with adding delta
309  *
310  *  @param[in,out]  buf      pointer to the block in the current frame buffer containing delta
311  *  @param[in]      ref_buf  pointer to the corresponding block in the backward reference frame
312  *  @param[in]      ref_buf2 pointer to the corresponding block in the forward reference frame
313  *  @param[in]      pitch    pitch for moving to the next y line
314  *  @param[in]      mc_type  interpolation type for backward reference
315  *  @param[in]      mc_type2 interpolation type for forward reference
316  */
317 void ff_ivi_mc_avg_4x4_delta(int16_t *buf, const int16_t *ref_buf, const int16_t *ref_buf2, uint32_t pitch, int mc_type, int mc_type2);
318
319 /**
320  *  motion compensation without adding delta for B-frames
321  *
322  *  @param[in,out]  buf      pointer to the block in the current frame receiving the result
323  *  @param[in]      ref_buf  pointer to the corresponding block in the backward reference frame
324  *  @param[in]      ref_buf2 pointer to the corresponding block in the forward reference frame
325  *  @param[in]      pitch    pitch for moving to the next y line
326  *  @param[in]      mc_type  interpolation type for backward reference
327  *  @param[in]      mc_type2 interpolation type for forward reference
328  */
329 void ff_ivi_mc_avg_8x8_no_delta(int16_t *buf, const int16_t *ref_buf, const int16_t *ref_buf2, uint32_t pitch, int mc_type, int mc_type2);
330
331 /**
332  *  4x4 block motion compensation without adding delta for B-frames
333  *
334  *  @param[in,out]  buf      pointer to the block in the current frame receiving the result
335  *  @param[in]      ref_buf  pointer to the corresponding block in the backward reference frame
336  *  @param[in]      ref_buf2 pointer to the corresponding block in the forward reference frame
337  *  @param[in]      pitch    pitch for moving to the next y line
338  *  @param[in]      mc_type  interpolation type for backward reference
339  *  @param[in]      mc_type2 interpolation type for forward reference
340  */
341 void ff_ivi_mc_avg_4x4_no_delta(int16_t *buf, const int16_t *ref_buf, const int16_t *ref_buf2, uint32_t pitch, int mc_type, int mc_type2);
342
343 #endif /* AVCODEC_IVI_DSP_H */