181
void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst,
182
const int dst_pitch, const int num_bands)
184
int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
185
const IDWTELEM *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
188
/* all bands should have the same pitch */
189
pitch = plane->bands[0].pitch;
191
/* get pointers to the wavelet bands */
192
b0_ptr = plane->bands[0].buf;
193
b1_ptr = plane->bands[1].buf;
194
b2_ptr = plane->bands[2].buf;
195
b3_ptr = plane->bands[3].buf;
197
for (y = 0; y < plane->height; y += 2) {
198
for (x = 0, indx = 0; x < plane->width; x += 2, indx++) {
199
/* load coefficients */
200
b0 = b0_ptr[indx]; //should be: b0 = (num_bands > 0) ? b0_ptr[indx] : 0;
201
b1 = b1_ptr[indx]; //should be: b1 = (num_bands > 1) ? b1_ptr[indx] : 0;
202
b2 = b2_ptr[indx]; //should be: b2 = (num_bands > 2) ? b2_ptr[indx] : 0;
203
b3 = b3_ptr[indx]; //should be: b3 = (num_bands > 3) ? b3_ptr[indx] : 0;
205
/* haar wavelet recomposition */
206
p0 = (b0 + b1 + b2 + b3 + 2) >> 2;
207
p1 = (b0 + b1 - b2 - b3 + 2) >> 2;
208
p2 = (b0 - b1 + b2 - b3 + 2) >> 2;
209
p3 = (b0 - b1 - b2 + b3 + 2) >> 2;
211
/* bias, convert and output four pixels */
212
dst[x] = av_clip_uint8(p0 + 128);
213
dst[x + 1] = av_clip_uint8(p1 + 128);
214
dst[dst_pitch + x] = av_clip_uint8(p2 + 128);
215
dst[dst_pitch + x + 1] = av_clip_uint8(p3 + 128);
218
dst += dst_pitch << 1;
227
/** butterfly operation for the inverse Haar transform */
228
#define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \
230
o1 = (s1 + s2) >> 1;\
233
/** inverse 8-point Haar transform */
234
#define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\
235
d1, d2, d3, d4, d5, d6, d7, d8,\
236
t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
237
t1 = s1 << 1; t5 = s5 << 1;\
238
IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
239
IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
240
IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
241
IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\
242
d1 = COMPENSATE(t1);\
243
d2 = COMPENSATE(t2);\
244
d3 = COMPENSATE(t3);\
245
d4 = COMPENSATE(t4);\
246
d5 = COMPENSATE(t5);\
247
d6 = COMPENSATE(t6);\
248
d7 = COMPENSATE(t7);\
249
d8 = COMPENSATE(t8); }
251
/** inverse 4-point Haar transform */
252
#define INV_HAAR4(s1, s3, s5, s7) {\
253
HAAR_BFLY(s1, s5); HAAR_BFLY(s1, s3); HAAR_BFLY(s5, s7);\
254
s1 = COMPENSATE(s1);\
255
s3 = COMPENSATE(s3);\
256
s5 = COMPENSATE(s5);\
257
s7 = COMPENSATE(s7); }
259
void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
260
const uint8_t *flags)
262
int i, shift, sp1, sp2, sp3, sp4;
266
int t0, t1, t2, t3, t4, t5, t6, t7, t8;
268
/* apply the InvHaar8 to all columns */
269
#define COMPENSATE(x) (x)
272
for (i = 0; i < 8; i++) {
276
sp1 = src[ 0] << shift;
277
sp2 = src[ 8] << shift;
278
sp3 = src[16] << shift;
279
sp4 = src[24] << shift;
280
INV_HAAR8( sp1, sp2, sp3, sp4,
281
src[32], src[40], src[48], src[56],
282
dst[ 0], dst[ 8], dst[16], dst[24],
283
dst[32], dst[40], dst[48], dst[56],
284
t0, t1, t2, t3, t4, t5, t6, t7, t8);
286
dst[ 0] = dst[ 8] = dst[16] = dst[24] =
287
dst[32] = dst[40] = dst[48] = dst[56] = 0;
294
/* apply the InvHaar8 to all rows */
295
#define COMPENSATE(x) (x)
297
for (i = 0; i < 8; i++) {
298
if ( !src[0] && !src[1] && !src[2] && !src[3]
299
&& !src[4] && !src[5] && !src[6] && !src[7]) {
300
memset(out, 0, 8 * sizeof(out[0]));
302
INV_HAAR8(src[0], src[1], src[2], src[3],
303
src[4], src[5], src[6], src[7],
304
out[0], out[1], out[2], out[3],
305
out[4], out[5], out[6], out[7],
306
t0, t1, t2, t3, t4, t5, t6, t7, t8);
314
void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
320
dc_coeff = (*in + 0) >> 3;
322
for (y = 0; y < blk_size; out += pitch, y++) {
323
for (x = 0; x < blk_size; x++)
181
328
/** butterfly operation for the inverse slant transform */
182
329
#define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \