]> git.sesse.net Git - ffmpeg/blob - libavcodec/ivi_dsp.h
avcodec/motion_est_template: Fix map cache use in qpel_motion_search()
[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 FFmpeg.
7  *
8  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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 void ff_ivi_inverse_haar_8x1(const int32_t *in, int16_t *out, uint32_t pitch,
69                              const uint8_t *flags);
70 void ff_ivi_inverse_haar_1x8(const int32_t *in, int16_t *out, uint32_t pitch,
71                              const uint8_t *flags);
72
73 /**
74  *  one-dimensional inverse 8-point Haar transform on rows for Indeo 4
75  *
76  *  @param[in]  in        pointer to the vector of transform coefficients
77  *  @param[out] out       pointer to the output buffer (frame)
78  *  @param[in]  pitch     pitch to move to the next y line
79  *  @param[in]  flags     pointer to the array of column flags:
80  *                        != 0 - non_empty column, 0 - empty one
81  *                        (this array must be filled by caller)
82  */
83 void ff_ivi_row_haar8(const int32_t *in, int16_t *out, uint32_t pitch,
84                       const uint8_t *flags);
85
86 /**
87  *  one-dimensional inverse 8-point Haar transform on columns for Indeo 4
88  *
89  *  @param[in]  in        pointer to the vector of transform coefficients
90  *  @param[out] out       pointer to the output buffer (frame)
91  *  @param[in]  pitch     pitch to move to the next y line
92  *  @param[in]  flags     pointer to the array of column flags:
93  *                        != 0 - non_empty column, 0 - empty one
94  *                        (this array must be filled by caller)
95  */
96 void ff_ivi_col_haar8(const int32_t *in, int16_t *out, uint32_t pitch,
97                       const uint8_t *flags);
98
99 /**
100  *  two-dimensional inverse Haar 4x4 transform for Indeo 4
101  *
102  *  @param[in]  in        pointer to the vector of transform coefficients
103  *  @param[out] out       pointer to the output buffer (frame)
104  *  @param[in]  pitch     pitch to move to the next y line
105  *  @param[in]  flags     pointer to the array of column flags:
106  *                        != 0 - non_empty column, 0 - empty one
107  *                        (this array must be filled by caller)
108  */
109 void ff_ivi_inverse_haar_4x4(const int32_t *in, int16_t *out, uint32_t pitch,
110                              const uint8_t *flags);
111
112 /**
113  *  one-dimensional inverse 4-point Haar transform on rows for Indeo 4
114  *
115  *  @param[in]  in        pointer to the vector of transform coefficients
116  *  @param[out] out       pointer to the output buffer (frame)
117  *  @param[in]  pitch     pitch to move to the next y line
118  *  @param[in]  flags     pointer to the array of column flags:
119  *                        != 0 - non_empty column, 0 - empty one
120  *                        (this array must be filled by caller)
121  */
122 void ff_ivi_row_haar4(const int32_t *in, int16_t *out, uint32_t pitch,
123                       const uint8_t *flags);
124
125 /**
126  *  one-dimensional inverse 4-point Haar transform on columns for Indeo 4
127  *
128  *  @param[in]  in        pointer to the vector of transform coefficients
129  *  @param[out] out       pointer to the output buffer (frame)
130  *  @param[in]  pitch     pitch to move to the next y line
131  *  @param[in]  flags     pointer to the array of column flags:
132  *                        != 0 - non_empty column, 0 - empty one
133  *                        (this array must be filled by caller)
134  */
135 void ff_ivi_col_haar4(const int32_t *in, int16_t *out, uint32_t pitch,
136                       const uint8_t *flags);
137
138 /**
139  *  DC-only two-dimensional inverse Haar transform for Indeo 4.
140  *  Performing the inverse transform in this case is equivalent to
141  *  spreading DC_coeff >> 3 over the whole block.
142  *
143  *  @param[in]  in          pointer to the dc coefficient
144  *  @param[out] out         pointer to the output buffer (frame)
145  *  @param[in]  pitch       pitch to move to the next y line
146  *  @param[in]  blk_size    transform block size
147  */
148 void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
149                        int blk_size);
150
151 /**
152  *  two-dimensional inverse slant 8x8 transform
153  *
154  *  @param[in]    in      pointer to the vector of transform coefficients
155  *  @param[out]   out     pointer to the output buffer (frame)
156  *  @param[in]    pitch   pitch to move to the next y line
157  *  @param[in]    flags   pointer to the array of column flags:
158  *                        != 0 - non_empty column, 0 - empty one
159  *                        (this array must be filled by caller)
160  */
161 void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
162                               const uint8_t *flags);
163
164 /**
165  *  two-dimensional inverse slant 4x4 transform
166  *
167  *  @param[in]    in      pointer to the vector of transform coefficients
168  *  @param[out]   out     pointer to the output buffer (frame)
169  *  @param[in]    pitch   pitch to move to the next y line
170  *  @param[in]    flags   pointer to the array of column flags:
171  *                        != 0 - non_empty column, 0 - empty one
172  *                        (this array must be filled by caller)
173  */
174 void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch,
175                               const uint8_t *flags);
176
177 /**
178  *  DC-only two-dimensional inverse slant transform.
179  *  Performing the inverse slant transform in this case is equivalent to
180  *  spreading (DC_coeff + 1)/2 over the whole block.
181  *  It works much faster than performing the slant transform on a vector of zeroes.
182  *
183  *  @param[in]    in          pointer to the dc coefficient
184  *  @param[out]   out         pointer to the output buffer (frame)
185  *  @param[in]    pitch       pitch to move to the next y line
186  *  @param[in]    blk_size    transform block size
187  */
188 void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
189
190 /**
191  *  inverse 1D row slant transform
192  *
193  *  @param[in]    in      pointer to the vector of transform coefficients
194  *  @param[out]   out     pointer to the output buffer (frame)
195  *  @param[in]    pitch   pitch to move to the next y line
196  *  @param[in]    flags   pointer to the array of column flags (unused here)
197  */
198 void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch,
199                        const uint8_t *flags);
200
201 /**
202  *  inverse 1D column slant transform
203  *
204  *  @param[in]    in      pointer to the vector of transform coefficients
205  *  @param[out]   out     pointer to the output buffer (frame)
206  *  @param[in]    pitch   pitch to move to the next y line
207  *  @param[in]    flags   pointer to the array of column flags:
208  *                        != 0 - non_empty column, 0 - empty one
209  *                        (this array must be filled by caller)
210  */
211 void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch,
212                        const uint8_t *flags);
213
214 /**
215  *  inverse 1D row slant transform
216  *
217  *  @param[in]    in      pointer to the vector of transform coefficients
218  *  @param[out]   out     pointer to the output buffer (frame)
219  *  @param[in]    pitch   pitch to move to the next y line
220  *  @param[in]    flags   pointer to the array of column flags (unused here)
221  */
222 void ff_ivi_row_slant4(const int32_t *in, int16_t *out, uint32_t pitch,
223                        const uint8_t *flags);
224
225 /**
226  *  inverse 1D column slant transform
227  *
228  *  @param[in]    in      pointer to the vector of transform coefficients
229  *  @param[out]   out     pointer to the output buffer (frame)
230  *  @param[in]    pitch   pitch to move to the next y line
231  *  @param[in]    flags   pointer to the array of column flags:
232  *                        != 0 - non_empty column, 0 - empty one
233  *                        (this array must be filled by caller)
234  */
235 void ff_ivi_col_slant4(const int32_t *in, int16_t *out, uint32_t pitch,
236                        const uint8_t *flags);
237
238 /**
239  *  DC-only inverse row slant transform
240  */
241 void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
242
243 /**
244  *  DC-only inverse column slant transform
245  */
246 void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
247
248 /**
249  *  Copy the pixels into the frame buffer.
250  */
251 void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags);
252
253 /**
254  *  Copy the DC coefficient into the first pixel of the block and
255  *  zero all others.
256  */
257 void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
258
259 /**
260  *  8x8 block motion compensation with adding delta
261  *
262  *  @param[in,out]   buf      pointer to the block in the current frame buffer containing delta
263  *  @param[in]       ref_buf  pointer to the corresponding block in the reference frame
264  *  @param[in]       pitch    pitch for moving to the next y line
265  *  @param[in]       mc_type  interpolation type
266  */
267 void ff_ivi_mc_8x8_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
268
269 /**
270  *  4x4 block motion compensation with adding delta
271  *
272  *  @param[in,out]   buf      pointer to the block in the current frame buffer containing delta
273  *  @param[in]       ref_buf  pointer to the corresponding block in the reference frame
274  *  @param[in]       pitch    pitch for moving to the next y line
275  *  @param[in]       mc_type  interpolation type
276  */
277 void ff_ivi_mc_4x4_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
278
279 /**
280  *  motion compensation without adding delta
281  *
282  *  @param[in,out]  buf      pointer to the block in the current frame receiving the result
283  *  @param[in]      ref_buf  pointer to the corresponding block in the reference frame
284  *  @param[in]      pitch    pitch for moving to the next y line
285  *  @param[in]      mc_type  interpolation type
286  */
287 void ff_ivi_mc_8x8_no_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
288
289 /**
290  *  4x4 block motion compensation without adding delta
291  *
292  *  @param[in,out]  buf      pointer to the block in the current frame receiving the result
293  *  @param[in]      ref_buf  pointer to the corresponding block in the reference frame
294  *  @param[in]      pitch    pitch for moving to the next y line
295  *  @param[in]      mc_type  interpolation type
296  */
297 void ff_ivi_mc_4x4_no_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
298
299 /**
300  *  8x8 block motion compensation with adding delta
301  *
302  *  @param[in,out]  buf      pointer to the block in the current frame buffer containing delta
303  *  @param[in]      ref_buf  pointer to the corresponding block in the backward reference frame
304  *  @param[in]      ref_buf2 pointer to the corresponding block in the forward reference frame
305  *  @param[in]      pitch    pitch for moving to the next y line
306  *  @param[in]      mc_type  interpolation type for backward reference
307  *  @param[in]      mc_type2 interpolation type for forward reference
308  */
309 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);
310
311 /**
312  *  4x4 block motion compensation with adding delta
313  *
314  *  @param[in,out]  buf      pointer to the block in the current frame buffer containing delta
315  *  @param[in]      ref_buf  pointer to the corresponding block in the backward reference frame
316  *  @param[in]      ref_buf2 pointer to the corresponding block in the forward reference frame
317  *  @param[in]      pitch    pitch for moving to the next y line
318  *  @param[in]      mc_type  interpolation type for backward reference
319  *  @param[in]      mc_type2 interpolation type for forward reference
320  */
321 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);
322
323 /**
324  *  motion compensation without adding delta for B-frames
325  *
326  *  @param[in,out]  buf      pointer to the block in the current frame receiving the result
327  *  @param[in]      ref_buf  pointer to the corresponding block in the backward reference frame
328  *  @param[in]      ref_buf2 pointer to the corresponding block in the forward reference frame
329  *  @param[in]      pitch    pitch for moving to the next y line
330  *  @param[in]      mc_type  interpolation type for backward reference
331  *  @param[in]      mc_type2 interpolation type for forward reference
332  */
333 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);
334
335 /**
336  *  4x4 block motion compensation without adding delta for B-frames
337  *
338  *  @param[in,out]  buf      pointer to the block in the current frame receiving the result
339  *  @param[in]      ref_buf  pointer to the corresponding block in the backward reference frame
340  *  @param[in]      ref_buf2 pointer to the corresponding block in the forward reference frame
341  *  @param[in]      pitch    pitch for moving to the next y line
342  *  @param[in]      mc_type  interpolation type for backward reference
343  *  @param[in]      mc_type2 interpolation type for forward reference
344  */
345 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);
346
347 #endif /* AVCODEC_IVI_DSP_H */