ivi_dsp.c
Go to the documentation of this file.
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 compensation, wavelet recompostions)
26  * for Indeo Video Interactive codecs.
27  */
28 
29 #include "avcodec.h"
30 #include "ivi_common.h"
31 #include "ivi_dsp.h"
32 
34  const int dst_pitch)
35 {
36  int x, y, indx;
37  int32_t p0, p1, p2, p3, tmp0, tmp1, tmp2;
38  int32_t b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
39  int32_t b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
40  int32_t pitch, back_pitch;
41  const short *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
42  const int num_bands = 4;
43 
44  /* all bands should have the same pitch */
45  pitch = plane->bands[0].pitch;
46 
47  /* pixels at the position "y-1" will be set to pixels at the "y" for the 1st iteration */
48  back_pitch = 0;
49 
50  /* get pointers to the wavelet bands */
51  b0_ptr = plane->bands[0].buf;
52  b1_ptr = plane->bands[1].buf;
53  b2_ptr = plane->bands[2].buf;
54  b3_ptr = plane->bands[3].buf;
55 
56  for (y = 0; y < plane->height; y += 2) {
57 
58  if (y+2 >= plane->height)
59  pitch= 0;
60  /* load storage variables with values */
61  if (num_bands > 0) {
62  b0_1 = b0_ptr[0];
63  b0_2 = b0_ptr[pitch];
64  }
65 
66  if (num_bands > 1) {
67  b1_1 = b1_ptr[back_pitch];
68  b1_2 = b1_ptr[0];
69  b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch];
70  }
71 
72  if (num_bands > 2) {
73  b2_2 = b2_ptr[0]; // b2[x, y ]
74  b2_3 = b2_2; // b2[x+1,y ] = b2[x,y]
75  b2_5 = b2_ptr[pitch]; // b2[x ,y+1]
76  b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1]
77  }
78 
79  if (num_bands > 3) {
80  b3_2 = b3_ptr[back_pitch]; // b3[x ,y-1]
81  b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1]
82  b3_5 = b3_ptr[0]; // b3[x ,y ]
83  b3_6 = b3_5; // b3[x+1,y ] = b3[x ,y ]
84  b3_8 = b3_2 - b3_5*6 + b3_ptr[pitch];
85  b3_9 = b3_8;
86  }
87 
88  for (x = 0, indx = 0; x < plane->width; x+=2, indx++) {
89  if (x+2 >= plane->width) {
90  b0_ptr --;
91  b1_ptr --;
92  b2_ptr --;
93  b3_ptr --;
94  }
95 
96  /* some values calculated in the previous iterations can */
97  /* be reused in the next ones, so do appropriate copying */
98  b2_1 = b2_2; // b2[x-1,y ] = b2[x, y ]
99  b2_2 = b2_3; // b2[x ,y ] = b2[x+1,y ]
100  b2_4 = b2_5; // b2[x-1,y+1] = b2[x ,y+1]
101  b2_5 = b2_6; // b2[x ,y+1] = b2[x+1,y+1]
102  b3_1 = b3_2; // b3[x-1,y-1] = b3[x ,y-1]
103  b3_2 = b3_3; // b3[x ,y-1] = b3[x+1,y-1]
104  b3_4 = b3_5; // b3[x-1,y ] = b3[x ,y ]
105  b3_5 = b3_6; // b3[x ,y ] = b3[x+1,y ]
106  b3_7 = b3_8; // vert_HPF(x-1)
107  b3_8 = b3_9; // vert_HPF(x )
108 
109  p0 = p1 = p2 = p3 = 0;
110 
111  /* process the LL-band by applying LPF both vertically and horizontally */
112  if (num_bands > 0) {
113  tmp0 = b0_1;
114  tmp2 = b0_2;
115  b0_1 = b0_ptr[indx+1];
116  b0_2 = b0_ptr[pitch+indx+1];
117  tmp1 = tmp0 + b0_1;
118 
119  p0 = tmp0 << 4;
120  p1 = tmp1 << 3;
121  p2 = (tmp0 + tmp2) << 3;
122  p3 = (tmp1 + tmp2 + b0_2) << 2;
123  }
124 
125  /* process the HL-band by applying HPF vertically and LPF horizontally */
126  if (num_bands > 1) {
127  tmp0 = b1_2;
128  tmp1 = b1_1;
129  b1_2 = b1_ptr[indx+1];
130  b1_1 = b1_ptr[back_pitch+indx+1];
131 
132  tmp2 = tmp1 - tmp0*6 + b1_3;
133  b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch+indx+1];
134 
135  p0 += (tmp0 + tmp1) << 3;
136  p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;
137  p2 += tmp2 << 2;
138  p3 += (tmp2 + b1_3) << 1;
139  }
140 
141  /* process the LH-band by applying LPF vertically and HPF horizontally */
142  if (num_bands > 2) {
143  b2_3 = b2_ptr[indx+1];
144  b2_6 = b2_ptr[pitch+indx+1];
145 
146  tmp0 = b2_1 + b2_2;
147  tmp1 = b2_1 - b2_2*6 + b2_3;
148 
149  p0 += tmp0 << 3;
150  p1 += tmp1 << 2;
151  p2 += (tmp0 + b2_4 + b2_5) << 2;
152  p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1;
153  }
154 
155  /* process the HH-band by applying HPF both vertically and horizontally */
156  if (num_bands > 3) {
157  b3_6 = b3_ptr[indx+1]; // b3[x+1,y ]
158  b3_3 = b3_ptr[back_pitch+indx+1]; // b3[x+1,y-1]
159 
160  tmp0 = b3_1 + b3_4;
161  tmp1 = b3_2 + b3_5;
162  tmp2 = b3_3 + b3_6;
163 
164  b3_9 = b3_3 - b3_6*6 + b3_ptr[pitch+indx+1];
165 
166  p0 += (tmp0 + tmp1) << 2;
167  p1 += (tmp0 - tmp1*6 + tmp2) << 1;
168  p2 += (b3_7 + b3_8) << 1;
169  p3 += b3_7 - b3_8*6 + b3_9;
170  }
171 
172  /* output four pixels */
173  dst[x] = av_clip_uint8((p0 >> 6) + 128);
174  dst[x+1] = av_clip_uint8((p1 >> 6) + 128);
175  dst[dst_pitch+x] = av_clip_uint8((p2 >> 6) + 128);
176  dst[dst_pitch+x+1] = av_clip_uint8((p3 >> 6) + 128);
177  }// for x
178 
179  dst += dst_pitch << 1;
180 
181  back_pitch = -pitch;
182 
183  b0_ptr += pitch + 1;
184  b1_ptr += pitch + 1;
185  b2_ptr += pitch + 1;
186  b3_ptr += pitch + 1;
187  }
188 }
189 
191  const int dst_pitch)
192 {
193  int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
194  const short *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
195  int32_t pitch;
196 
197  /* all bands should have the same pitch */
198  pitch = plane->bands[0].pitch;
199 
200  /* get pointers to the wavelet bands */
201  b0_ptr = plane->bands[0].buf;
202  b1_ptr = plane->bands[1].buf;
203  b2_ptr = plane->bands[2].buf;
204  b3_ptr = plane->bands[3].buf;
205 
206  for (y = 0; y < plane->height; y += 2) {
207  for (x = 0, indx = 0; x < plane->width; x += 2, indx++) {
208  /* load coefficients */
209  b0 = b0_ptr[indx]; //should be: b0 = (num_bands > 0) ? b0_ptr[indx] : 0;
210  b1 = b1_ptr[indx]; //should be: b1 = (num_bands > 1) ? b1_ptr[indx] : 0;
211  b2 = b2_ptr[indx]; //should be: b2 = (num_bands > 2) ? b2_ptr[indx] : 0;
212  b3 = b3_ptr[indx]; //should be: b3 = (num_bands > 3) ? b3_ptr[indx] : 0;
213 
214  /* haar wavelet recomposition */
215  p0 = (b0 + b1 + b2 + b3 + 2) >> 2;
216  p1 = (b0 + b1 - b2 - b3 + 2) >> 2;
217  p2 = (b0 - b1 + b2 - b3 + 2) >> 2;
218  p3 = (b0 - b1 - b2 + b3 + 2) >> 2;
219 
220  /* bias, convert and output four pixels */
221  dst[x] = av_clip_uint8(p0 + 128);
222  dst[x + 1] = av_clip_uint8(p1 + 128);
223  dst[dst_pitch + x] = av_clip_uint8(p2 + 128);
224  dst[dst_pitch + x + 1] = av_clip_uint8(p3 + 128);
225  }// for x
226 
227  dst += dst_pitch << 1;
228 
229  b0_ptr += pitch;
230  b1_ptr += pitch;
231  b2_ptr += pitch;
232  b3_ptr += pitch;
233  }// for y
234 }
235 
236 /** butterfly operation for the inverse Haar transform */
237 #define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \
238  t = (s1 - s2) >> 1;\
239  o1 = (s1 + s2) >> 1;\
240  o2 = t;\
241 
242 /** inverse 8-point Haar transform */
243 #define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\
244  d1, d2, d3, d4, d5, d6, d7, d8,\
245  t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
246  t1 = s1 << 1; t5 = s5 << 1;\
247  IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
248  IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
249  IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
250  IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\
251  d1 = COMPENSATE(t1);\
252  d2 = COMPENSATE(t2);\
253  d3 = COMPENSATE(t3);\
254  d4 = COMPENSATE(t4);\
255  d5 = COMPENSATE(t5);\
256  d6 = COMPENSATE(t6);\
257  d7 = COMPENSATE(t7);\
258  d8 = COMPENSATE(t8); }
259 
260 /** inverse 4-point Haar transform */
261 #define INV_HAAR4(s1, s3, s5, s7) {\
262  HAAR_BFLY(s1, s5); HAAR_BFLY(s1, s3); HAAR_BFLY(s5, s7);\
263  s1 = COMPENSATE(s1);\
264  s3 = COMPENSATE(s3);\
265  s5 = COMPENSATE(s5);\
266  s7 = COMPENSATE(s7); }
267 
268 void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
269  const uint8_t *flags)
270 {
271  int i, shift, sp1, sp2, sp3, sp4;
272  const int32_t *src;
273  int32_t *dst;
274  int tmp[64];
275  int t0, t1, t2, t3, t4, t5, t6, t7, t8;
276 
277  /* apply the InvHaar8 to all columns */
278 #define COMPENSATE(x) (x)
279  src = in;
280  dst = tmp;
281  for (i = 0; i < 8; i++) {
282  if (flags[i]) {
283  /* pre-scaling */
284  shift = !(i & 4);
285  sp1 = src[ 0] << shift;
286  sp2 = src[ 8] << shift;
287  sp3 = src[16] << shift;
288  sp4 = src[24] << shift;
289  INV_HAAR8( sp1, sp2, sp3, sp4,
290  src[32], src[40], src[48], src[56],
291  dst[ 0], dst[ 8], dst[16], dst[24],
292  dst[32], dst[40], dst[48], dst[56],
293  t0, t1, t2, t3, t4, t5, t6, t7, t8);
294  } else
295  dst[ 0] = dst[ 8] = dst[16] = dst[24] =
296  dst[32] = dst[40] = dst[48] = dst[56] = 0;
297 
298  src++;
299  dst++;
300  }
301 #undef COMPENSATE
302 
303  /* apply the InvHaar8 to all rows */
304 #define COMPENSATE(x) (x)
305  src = tmp;
306  for (i = 0; i < 8; i++) {
307  if ( !src[0] && !src[1] && !src[2] && !src[3]
308  && !src[4] && !src[5] && !src[6] && !src[7]) {
309  memset(out, 0, 8 * sizeof(out[0]));
310  } else {
311  INV_HAAR8(src[0], src[1], src[2], src[3],
312  src[4], src[5], src[6], src[7],
313  out[0], out[1], out[2], out[3],
314  out[4], out[5], out[6], out[7],
315  t0, t1, t2, t3, t4, t5, t6, t7, t8);
316  }
317  src += 8;
318  out += pitch;
319  }
320 #undef COMPENSATE
321 }
322 
323 void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
324  int blk_size)
325 {
326  int x, y;
327  int16_t dc_coeff;
328 
329  dc_coeff = (*in + 0) >> 3;
330 
331  for (y = 0; y < blk_size; out += pitch, y++) {
332  for (x = 0; x < blk_size; x++)
333  out[x] = dc_coeff;
334  }
335 }
336 
337 /** butterfly operation for the inverse slant transform */
338 #define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \
339  t = s1 - s2;\
340  o1 = s1 + s2;\
341  o2 = t;\
342 
343 /** This is a reflection a,b = 1/2, 5/4 for the inverse slant transform */
344 #define IVI_IREFLECT(s1, s2, o1, o2, t) \
345  t = ((s1 + s2*2 + 2) >> 2) + s1;\
346  o2 = ((s1*2 - s2 + 2) >> 2) - s2;\
347  o1 = t;\
348 
349 /** This is a reflection a,b = 1/2, 7/8 for the inverse slant transform */
350 #define IVI_SLANT_PART4(s1, s2, o1, o2, t) \
351  t = s2 + ((s1*4 - s2 + 4) >> 3);\
352  o2 = s1 + ((-s1 - s2*4 + 4) >> 3);\
353  o1 = t;\
354 
355 /** inverse slant8 transform */
356 #define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\
357  d1, d2, d3, d4, d5, d6, d7, d8,\
358  t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
359  IVI_SLANT_PART4(s4, s5, t4, t5, t0);\
360 \
361  IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\
362  IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\
363 \
364  IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\
365  IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\
366  IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
367  IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\
368  d1 = COMPENSATE(t1);\
369  d2 = COMPENSATE(t2);\
370  d3 = COMPENSATE(t3);\
371  d4 = COMPENSATE(t4);\
372  d5 = COMPENSATE(t5);\
373  d6 = COMPENSATE(t6);\
374  d7 = COMPENSATE(t7);\
375  d8 = COMPENSATE(t8);}
376 
377 /** inverse slant4 transform */
378 #define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\
379  IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\
380 \
381  IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
382  d1 = COMPENSATE(t1);\
383  d2 = COMPENSATE(t2);\
384  d3 = COMPENSATE(t3);\
385  d4 = COMPENSATE(t4);}
386 
387 void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
388 {
389  int i;
390  const int32_t *src;
391  int32_t *dst;
392  int tmp[64];
393  int t0, t1, t2, t3, t4, t5, t6, t7, t8;
394 
395 #define COMPENSATE(x) (x)
396  src = in;
397  dst = tmp;
398  for (i = 0; i < 8; i++) {
399  if (flags[i]) {
400  IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56],
401  dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56],
402  t0, t1, t2, t3, t4, t5, t6, t7, t8);
403  } else
404  dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0;
405 
406  src++;
407  dst++;
408  }
409 #undef COMPENSATE
410 
411 #define COMPENSATE(x) ((x + 1)>>1)
412  src = tmp;
413  for (i = 0; i < 8; i++) {
414  if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) {
415  memset(out, 0, 8*sizeof(out[0]));
416  } else {
417  IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7],
418  out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
419  t0, t1, t2, t3, t4, t5, t6, t7, t8);
420  }
421  src += 8;
422  out += pitch;
423  }
424 #undef COMPENSATE
425 }
426 
427 void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
428 {
429  int i;
430  const int32_t *src;
431  int32_t *dst;
432  int tmp[16];
433  int t0, t1, t2, t3, t4;
434 
435 #define COMPENSATE(x) (x)
436  src = in;
437  dst = tmp;
438  for (i = 0; i < 4; i++) {
439  if (flags[i]) {
440  IVI_INV_SLANT4(src[0], src[4], src[8], src[12],
441  dst[0], dst[4], dst[8], dst[12],
442  t0, t1, t2, t3, t4);
443  } else
444  dst[0] = dst[4] = dst[8] = dst[12] = 0;
445 
446  src++;
447  dst++;
448  }
449 #undef COMPENSATE
450 
451 #define COMPENSATE(x) ((x + 1)>>1)
452  src = tmp;
453  for (i = 0; i < 4; i++) {
454  if (!src[0] && !src[1] && !src[2] && !src[3]) {
455  out[0] = out[1] = out[2] = out[3] = 0;
456  } else {
457  IVI_INV_SLANT4(src[0], src[1], src[2], src[3],
458  out[0], out[1], out[2], out[3],
459  t0, t1, t2, t3, t4);
460  }
461  src += 4;
462  out += pitch;
463  }
464 #undef COMPENSATE
465 }
466 
467 void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
468 {
469  int x, y;
470  int16_t dc_coeff;
471 
472  dc_coeff = (*in + 1) >> 1;
473 
474  for (y = 0; y < blk_size; out += pitch, y++) {
475  for (x = 0; x < blk_size; x++)
476  out[x] = dc_coeff;
477  }
478 }
479 
480 void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
481 {
482  int i;
483  int t0, t1, t2, t3, t4, t5, t6, t7, t8;
484 
485 #define COMPENSATE(x) ((x + 1)>>1)
486  for (i = 0; i < 8; i++) {
487  if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) {
488  memset(out, 0, 8*sizeof(out[0]));
489  } else {
490  IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7],
491  out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
492  t0, t1, t2, t3, t4, t5, t6, t7, t8);
493  }
494  in += 8;
495  out += pitch;
496  }
497 #undef COMPENSATE
498 }
499 
500 void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
501 {
502  int x, y;
503  int16_t dc_coeff;
504 
505  dc_coeff = (*in + 1) >> 1;
506 
507  for (x = 0; x < blk_size; x++)
508  out[x] = dc_coeff;
509 
510  out += pitch;
511 
512  for (y = 1; y < blk_size; out += pitch, y++) {
513  for (x = 0; x < blk_size; x++)
514  out[x] = 0;
515  }
516 }
517 
518 void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
519 {
520  int i, row2, row4, row8;
521  int t0, t1, t2, t3, t4, t5, t6, t7, t8;
522 
523  row2 = pitch << 1;
524  row4 = pitch << 2;
525  row8 = pitch << 3;
526 
527 #define COMPENSATE(x) ((x + 1)>>1)
528  for (i = 0; i < 8; i++) {
529  if (flags[i]) {
530  IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56],
531  out[0], out[pitch], out[row2], out[row2 + pitch], out[row4],
532  out[row4 + pitch], out[row4 + row2], out[row8 - pitch],
533  t0, t1, t2, t3, t4, t5, t6, t7, t8);
534  } else {
535  out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] =
536  out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0;
537  }
538 
539  in++;
540  out++;
541  }
542 #undef COMPENSATE
543 }
544 
545 void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
546 {
547  int x, y;
548  int16_t dc_coeff;
549 
550  dc_coeff = (*in + 1) >> 1;
551 
552  for (y = 0; y < blk_size; out += pitch, y++) {
553  out[0] = dc_coeff;
554  for (x = 1; x < blk_size; x++)
555  out[x] = 0;
556  }
557 }
558 
559 void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
560  const uint8_t *flags)
561 {
562  int x, y;
563 
564  for (y = 0; y < 8; out += pitch, in += 8, y++)
565  for (x = 0; x < 8; x++)
566  out[x] = in[x];
567 }
568 
569 void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
570  int blk_size)
571 {
572  int y;
573 
574  out[0] = in[0];
575  memset(out + 1, 0, 7*sizeof(out[0]));
576  out += pitch;
577 
578  for (y = 1; y < 8; out += pitch, y++)
579  memset(out, 0, 8*sizeof(out[0]));
580 }
581 
582 #define IVI_MC_TEMPLATE(size, suffix, OP) \
583 void ff_ivi_mc_ ## size ##x## size ## suffix (int16_t *buf, const int16_t *ref_buf, \
584  uint32_t pitch, int mc_type) \
585 { \
586  int i, j; \
587  const int16_t *wptr; \
588 \
589  switch (mc_type) { \
590  case 0: /* fullpel (no interpolation) */ \
591  for (i = 0; i < size; i++, buf += pitch, ref_buf += pitch) { \
592  for (j = 0; j < size; j++) {\
593  OP(buf[j], ref_buf[j]); \
594  } \
595  } \
596  break; \
597  case 1: /* horizontal halfpel interpolation */ \
598  for (i = 0; i < size; i++, buf += pitch, ref_buf += pitch) \
599  for (j = 0; j < size; j++) \
600  OP(buf[j], (ref_buf[j] + ref_buf[j+1]) >> 1); \
601  break; \
602  case 2: /* vertical halfpel interpolation */ \
603  wptr = ref_buf + pitch; \
604  for (i = 0; i < size; i++, buf += pitch, wptr += pitch, ref_buf += pitch) \
605  for (j = 0; j < size; j++) \
606  OP(buf[j], (ref_buf[j] + wptr[j]) >> 1); \
607  break; \
608  case 3: /* vertical and horizontal halfpel interpolation */ \
609  wptr = ref_buf + pitch; \
610  for (i = 0; i < size; i++, buf += pitch, wptr += pitch, ref_buf += pitch) \
611  for (j = 0; j < size; j++) \
612  OP(buf[j], (ref_buf[j] + ref_buf[j+1] + wptr[j] + wptr[j+1]) >> 2); \
613  break; \
614  } \
615 } \
616 
617 #define OP_PUT(a, b) (a) = (b)
618 #define OP_ADD(a, b) (a) += (b)
619 
620 IVI_MC_TEMPLATE(8, _no_delta, OP_PUT)
621 IVI_MC_TEMPLATE(8, _delta, OP_ADD)
622 IVI_MC_TEMPLATE(4, _no_delta, OP_PUT)
623 IVI_MC_TEMPLATE(4, _delta, OP_ADD)
static int shift(int a, int b)
Definition: sonic.c:86
void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
DC-only two-dimensional inverse Haar transform for Indeo 4.
Definition: ivi_dsp.c:323
void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
Copy the DC coefficient into the first pixel of the block and zero all others.
Definition: ivi_dsp.c:569
int16_t * buf
pointer to the output buffer for this band
Definition: ivi_common.h:138
DSP functions (inverse transforms, motion compensations, wavelet recompostion) for Indeo Video Intera...
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip in
Definition: git-howto.txt:5
#define t8
Definition: regdef.h:53
uint16_t height
Definition: ivi_common.h:181
#define t7
Definition: regdef.h:35
void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
Copy the pixels into the frame buffer.
Definition: ivi_dsp.c:559
uint8_t
#define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4)
inverse slant4 transform
Definition: ivi_dsp.c:378
#define t0
Definition: regdef.h:28
int pitch
pitch associated with the buffers above
Definition: ivi_common.h:141
void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
inverse 1D row slant transform
Definition: ivi_dsp.c:480
void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
DC-only inverse row slant transform.
Definition: ivi_dsp.c:500
Discrete Time axis x
void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
two-dimensional inverse Haar 8x8 transform for Indeo 4
Definition: ivi_dsp.c:268
This file contains structures and macros shared by both Indeo4 and Indeo5 decoders.
#define t1
Definition: regdef.h:29
void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
DC-only inverse column slant transform.
Definition: ivi_dsp.c:545
#define t3
Definition: regdef.h:31
external API header
uint16_t width
Definition: ivi_common.h:180
#define IVI_MC_TEMPLATE(size, suffix, OP)
Definition: ivi_dsp.c:582
#define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7, d1, d2, d3, d4, d5, d6, d7, d8, t0, t1, t2, t3, t4, t5, t6, t7, t8)
inverse slant8 transform
Definition: ivi_dsp.c:356
int32_t
void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
two-dimensional inverse slant 8x8 transform
Definition: ivi_dsp.c:387
void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst, const int dst_pitch)
Haar wavelet recomposition filter for Indeo 4.
Definition: ivi_dsp.c:190
AVS_Value src
Definition: avisynth_c.h:523
#define OP_ADD(a, b)
Definition: ivi_dsp.c:618
synthesis window for stochastic i
IVIBandDesc * bands
array of band descriptors
Definition: ivi_common.h:183
#define t5
Definition: regdef.h:33
static int flags
Definition: cpu.c:23
#define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8, d1, d2, d3, d4, d5, d6, d7, d8, t0, t1, t2, t3, t4, t5, t6, t7, t8)
inverse 8-point Haar transform
Definition: ivi_dsp.c:243
void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
two-dimensional inverse slant 4x4 transform
Definition: ivi_dsp.c:427
#define t6
Definition: regdef.h:34
function y
Definition: D.m:1
#define t4
Definition: regdef.h:32
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
DC-only two-dimensional inverse slant transform.
Definition: ivi_dsp.c:467
#define OP_PUT(a, b)
Definition: ivi_dsp.c:617
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> out
color plane (luma or chroma) information
Definition: ivi_common.h:179
BYTE int dst_pitch
Definition: avisynth_c.h:713
void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst, const int dst_pitch)
5/3 wavelet recomposition filter for Indeo5
Definition: ivi_dsp.c:33
#define t2
Definition: regdef.h:30
void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
inverse 1D column slant transform
Definition: ivi_dsp.c:518