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