+static av_always_inline void dwt_haar(VC2TransformContext *t, dwtcoef *data,
+ ptrdiff_t stride, int width, int height,
+ const int s)
+{
+ int x, y;
+ dwtcoef *synth = t->buffer, *synthl = synth, *datal = data;
+ const ptrdiff_t synth_width = width << 1;
+ const ptrdiff_t synth_height = height << 1;
+
+ /* Horizontal synthesis. */
+ for (y = 0; y < synth_height; y++) {
+ for (x = 0; x < synth_width; x += 2) {
+ synthl[y*synth_width + x + 1] = (datal[y*stride + x + 1] << s) -
+ (datal[y*stride + x] << s);
+ synthl[y*synth_width + x] = (datal[y*stride + x + 0] << s) +
+ ((synthl[y*synth_width + x + 1] + 1) >> 1);
+ }
+ }
+
+ /* Vertical synthesis. */
+ for (x = 0; x < synth_width; x++) {
+ for (y = 0; y < synth_height; y += 2) {
+ synthl[(y + 1)*synth_width + x] = synthl[(y + 1)*synth_width + x] -
+ synthl[y*synth_width + x];
+ synthl[y*synth_width + x] = synthl[y*synth_width + x] +
+ ((synthl[(y + 1)*synth_width + x] + 1) >> 1);
+ }
+ }
+
+ deinterleave(data, stride, width, height, synth);
+}
+
+static void vc2_subband_dwt_haar(VC2TransformContext *t, dwtcoef *data,
+ ptrdiff_t stride, int width, int height)
+{
+ dwt_haar(t, data, stride, width, height, 0);
+}
+
+static void vc2_subband_dwt_haar_shift(VC2TransformContext *t, dwtcoef *data,
+ ptrdiff_t stride, int width, int height)
+{
+ dwt_haar(t, data, stride, width, height, 1);
+}
+