---
 libavcodec/dirac_dwt.c | 608 +++++++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/dirac_dwt.h | 132 +++++++++++
 libavcodec/diracdsp.c  | 311 +++++++++++++++++++++++++
 libavcodec/diracdsp.h  |  96 ++++++++
 4 files changed, 1147 insertions(+)
 create mode 100644 libavcodec/dirac_dwt.c
 create mode 100644 libavcodec/dirac_dwt.h
 create mode 100644 libavcodec/diracdsp.c
 create mode 100644 libavcodec/diracdsp.h

diff --git a/libavcodec/dirac_dwt.c b/libavcodec/dirac_dwt.c
new file mode 100644
index 0000000..1ff5460
--- /dev/null
+++ b/libavcodec/dirac_dwt.c
@@ -0,0 +1,608 @@
+/*
+ * Copyright (C) 2009 David Conrad
+ * Copyright (C) 2012 Jordi Ortiz
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/attributes.h"
+#include "libavutil/common.h"
+#include "avcodec.h"
+#include "dirac_dwt.h"
+
+static inline int mirror(int v, int m)
+{
+    while ((unsigned)v > (unsigned)m) {
+        v = -v;
+        if (v < 0)
+            v += 2 * m;
+    }
+    return v;
+}
+
+static av_always_inline void interleave(IDWTELEM *dst, IDWTELEM *src0,
+                                        IDWTELEM *src1, int w2, int add,
+                                        int shift)
+{
+    int i;
+    for (i = 0; i < w2; i++) {
+        dst[2 * i]     = src0[i] + add >> shift;
+        dst[2 * i + 1] = src1[i] + add >> shift;
+    }
+}
+
+static void vertical_compose53iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                  int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        b1[i] -= (b0[i] + b2[i] + 2) >> 2;
+}
+
+static void horizontal_compose_dirac53i(IDWTELEM *b, IDWTELEM *temp, int w)
+{
+    const int w2 = w >> 1;
+    int x;
+
+    temp[0] = COMPOSE_53iL0(b[w2], b[0], b[w2]);
+    for (x = 1; x < w2; x++) {
+        temp[x]          = COMPOSE_53iL0(b[x + w2 - 1], b[x], b[x + w2]);
+        temp[x + w2 - 1] = COMPOSE_DIRAC53iH0(temp[x - 1], b[x + w2 - 1],
+                                              temp[x]);
+    }
+    temp[w - 1] = COMPOSE_DIRAC53iH0(temp[w2 - 1], b[w - 1], temp[w2 - 1]);
+
+    interleave(b, temp, temp + w2, w2, 1, 1);
+}
+
+static void horizontal_compose_dd97i(IDWTELEM *b, IDWTELEM *tmp, int w)
+{
+    const int w2 = w >> 1;
+    int x;
+
+    tmp[0] = COMPOSE_53iL0(b[w2], b[0], b[w2]);
+    for (x = 1; x < w2; x++)
+        tmp[x] = COMPOSE_53iL0(b[x + w2 - 1], b[x], b[x + w2]);
+
+    // extend the edges
+    tmp[-1]     = tmp[0];
+    tmp[w2 + 1] = tmp[w2] = tmp[w2 - 1];
+
+    for (x = 0; x < w2; x++) {
+        b[2 * x]     = tmp[x] + 1 >> 1;
+        b[2 * x + 1] = COMPOSE_DD97iH0(tmp[x - 1], tmp[x], b[x + w2],
+                                       tmp[x + 1], tmp[x + 2]) + 1 >> 1;
+    }
+}
+
+static void horizontal_compose_dd137i(IDWTELEM *b, IDWTELEM *tmp, int w)
+{
+    const int w2 = w >> 1;
+    int x;
+
+    tmp[0] = COMPOSE_DD137iL0(b[w2], b[w2], b[0], b[w2], b[w2 + 1]);
+    tmp[1] = COMPOSE_DD137iL0(b[w2], b[w2], b[1], b[w2 + 1], b[w2 + 2]);
+    for (x = 2; x < w2 - 1; x++)
+        tmp[x] = COMPOSE_DD137iL0(b[x + w2 - 2], b[x + w2 - 1], b[x], b[x + 
w2],
+                                  b[x + w2 + 1]);
+    tmp[w2 - 1] = COMPOSE_DD137iL0(b[w - 3], b[w - 2], b[w2 - 1], b[w - 1],
+                                   b[w - 1]);
+
+    // extend the edges
+    tmp[-1]     = tmp[0];
+    tmp[w2 + 1] = tmp[w2] = tmp[w2 - 1];
+
+    for (x = 0; x < w2; x++) {
+        b[2 * x]     = tmp[x] + 1 >> 1;
+        b[2 * x + 1] = COMPOSE_DD97iH0(tmp[x - 1], tmp[x], b[x + w2],
+                                       tmp[x + 1], tmp[x + 2]) + 1 >> 1;
+    }
+}
+
+static av_always_inline void horizontal_compose_haari(IDWTELEM *b,
+                                                      IDWTELEM *temp, int w,
+                                                      int shift)
+{
+    const int w2 = w >> 1;
+    int x;
+
+    for (x = 0; x < w2; x++) {
+        temp[x]      = COMPOSE_HAARiL0(b[x], b[x + w2]);
+        temp[x + w2] = COMPOSE_HAARiH0(b[x + w2], temp[x]);
+    }
+
+    interleave(b, temp, temp + w2, w2, shift, shift);
+}
+
+static void horizontal_compose_haar0i(IDWTELEM *b, IDWTELEM *temp, int w)
+{
+    horizontal_compose_haari(b, temp, w, 0);
+}
+
+static void horizontal_compose_haar1i(IDWTELEM *b, IDWTELEM *temp, int w)
+{
+    horizontal_compose_haari(b, temp, w, 1);
+}
+
+static void horizontal_compose_fidelityi(IDWTELEM *b, IDWTELEM *tmp, int w)
+{
+    const int w2 = w >> 1;
+    int i, x;
+    IDWTELEM v[8];
+
+    for (x = 0; x < w2; x++) {
+        for (i = 0; i < 8; i++)
+            v[i] = b[av_clip(x - 3 + i, 0, w2 - 1)];
+        tmp[x] = COMPOSE_FIDELITYiH0(v[0], v[1], v[2], v[3], b[x + w2], v[4],
+                                     v[5], v[6], v[7]);
+    }
+
+    for (x = 0; x < w2; x++) {
+        for (i = 0; i < 8; i++)
+            v[i] = tmp[av_clip(x - 4 + i, 0, w2 - 1)];
+        tmp[x + w2] = COMPOSE_FIDELITYiL0(v[0], v[1], v[2], v[3], b[x], v[4],
+                                          v[5], v[6], v[7]);
+    }
+
+    interleave(b, tmp + w2, tmp, w2, 0, 0);
+}
+
+static void horizontal_compose_daub97i(IDWTELEM *b, IDWTELEM *temp, int w)
+{
+    const int w2 = w >> 1;
+    int x, b0, b1, b2;
+
+    temp[0] = COMPOSE_DAUB97iL1(b[w2], b[0], b[w2]);
+    for (x = 1; x < w2; x++) {
+        temp[x]          = COMPOSE_DAUB97iL1(b[x + w2 - 1], b[x], b[x + w2]);
+        temp[x + w2 - 1] = COMPOSE_DAUB97iH1(temp[x - 1], b[x + w2 - 1],
+                                             temp[x]);
+    }
+    temp[w - 1] = COMPOSE_DAUB97iH1(temp[w2 - 1], b[w - 1], temp[w2 - 1]);
+
+    // second stage combined with interleave and shift
+    b0   = b2 = COMPOSE_DAUB97iL0(temp[w2], temp[0], temp[w2]);
+    b[0] = b0 + 1 >> 1;
+    for (x = 1; x < w2; x++) {
+        b2           = COMPOSE_DAUB97iL0(temp[x + w2 - 1], temp[x], temp[x + 
w2]);
+        b1           = COMPOSE_DAUB97iH0(b0, temp[x + w2 - 1], b2);
+        b[2 * x - 1] = b1 + 1 >> 1;
+        b[2 * x]     = b2 + 1 >> 1;
+        b0           = b2;
+    }
+    b[w - 1] = COMPOSE_DAUB97iH0(b2, temp[w - 1], b2) + 1 >> 1;
+}
+
+static void vertical_compose_dirac53iH0(IDWTELEM *b0, IDWTELEM *b1,
+                                        IDWTELEM *b2, int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        b1[i] = COMPOSE_DIRAC53iH0(b0[i], b1[i], b2[i]);
+}
+
+static void vertical_compose_dd97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                     IDWTELEM *b3, IDWTELEM *b4, int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        b2[i] = COMPOSE_DD97iH0(b0[i], b1[i], b2[i], b3[i], b4[i]);
+}
+
+static void vertical_compose_dd137iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                      IDWTELEM *b3, IDWTELEM *b4, int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        b2[i] = COMPOSE_DD137iL0(b0[i], b1[i], b2[i], b3[i], b4[i]);
+}
+
+static void vertical_compose_haar(IDWTELEM *b0, IDWTELEM *b1, int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++) {
+        b0[i] = COMPOSE_HAARiL0(b0[i], b1[i]);
+        b1[i] = COMPOSE_HAARiH0(b1[i], b0[i]);
+    }
+}
+
+static void vertical_compose_fidelityiH0(IDWTELEM *dst, IDWTELEM *b[8],
+                                         int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        dst[i] = COMPOSE_FIDELITYiH0(b[0][i], b[1][i], b[2][i], b[3][i], 
dst[i],
+                                     b[4][i], b[5][i], b[6][i], b[7][i]);
+}
+
+static void vertical_compose_fidelityiL0(IDWTELEM *dst, IDWTELEM *b[8],
+                                         int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        dst[i] = COMPOSE_FIDELITYiL0(b[0][i], b[1][i], b[2][i], b[3][i], 
dst[i],
+                                     b[4][i], b[5][i], b[6][i], b[7][i]);
+}
+
+static void vertical_compose_daub97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM 
*b2,
+                                       int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        b1[i] = COMPOSE_DAUB97iH0(b0[i], b1[i], b2[i]);
+}
+
+static void vertical_compose_daub97iH1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM 
*b2,
+                                       int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        b1[i] = COMPOSE_DAUB97iH1(b0[i], b1[i], b2[i]);
+}
+
+static void vertical_compose_daub97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM 
*b2,
+                                       int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        b1[i] = COMPOSE_DAUB97iL0(b0[i], b1[i], b2[i]);
+}
+
+static void vertical_compose_daub97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM 
*b2,
+                                       int width)
+{
+    int i;
+
+    for (i = 0; i < width; i++)
+        b1[i] = COMPOSE_DAUB97iL1(b0[i], b1[i], b2[i]);
+}
+
+static void spatial_compose_dd97i_dy(DiracDWTContext *d, int level, unsigned 
width,
+                                     unsigned height, int stride)
+{
+    DiracDWTCompose *cs = d->cs + level;
+    int i, y            = cs->y;
+    IDWTELEM *b[8];
+
+    for (i = 0; i < 6; i++)
+        b[i] = cs->b[i];
+    b[6] = d->buffer + av_clip(y + 5, 0, height - 2) * stride;
+    b[7] = d->buffer + av_clip(y + 6, 1, height - 1) * stride;
+
+    if (y + 5 < height)
+        d->vertical_compose_l0_3tap(b[5], b[6], b[7], width);
+    if (y + 1 < height)
+        d->vertical_compose_h0_5tap(b[0], b[2], b[3], b[4], b[6], width);
+    if (y - 1 < height)
+        d->horizontal_compose(b[0], d->temp, width);
+    if (y + 0 < height)
+        d->horizontal_compose(b[1], d->temp, width);
+
+    for (i = 0; i < 6; i++)
+        cs->b[i] = b[i + 2];
+    cs->y += 2;
+}
+
+static void spatial_compose_dirac53i_dy(DiracDWTContext *d, int level,
+                                        unsigned width, unsigned height,
+                                        int stride)
+{
+    DiracDWTCompose *cs  = d->cs + level;
+    int y                = cs->y;
+    IDWTELEM *b[4]       = { cs->b[0], cs->b[1] };
+
+    b[2] = d->buffer + mirror(y + 1, height - 1) * stride;
+    b[3] = d->buffer + mirror(y + 2, height - 1) * stride;
+
+    if (y + 1 < height)
+        d->vertical_compose_l0_3tap(b[1], b[2], b[3], width);
+    if (y + 0 < height)
+        d->vertical_compose_h0_3tap(b[0], b[1], b[2], width);
+    if (y - 1 < height)
+        d->horizontal_compose(b[0], d->temp, width);
+    if (y + 0 < height)
+        d->horizontal_compose(b[1], d->temp, width);
+
+    cs->b[0] = b[2];
+    cs->b[1] = b[3];
+    cs->y   += 2;
+}
+
+static void spatial_compose_dd137i_dy(DiracDWTContext *d, int level,
+                                      unsigned width, unsigned height,
+                                      int stride)
+{
+    DiracDWTCompose *cs = d->cs + level;
+    int i, y            = cs->y;
+    IDWTELEM *b[10];
+
+    for (i = 0; i < 8; i++)
+        b[i] = cs->b[i];
+    b[8] = d->buffer + av_clip(y + 7, 0, height - 2) * stride;
+    b[9] = d->buffer + av_clip(y + 8, 1, height - 1) * stride;
+
+    if (y + 5 < height)
+        d->vertical_compose_l0_5tap(b[3], b[5], b[6], b[7], b[9], width);
+    if (y + 1 < height)
+        d->vertical_compose_h0_5tap(b[0], b[2], b[3], b[4], b[6], width);
+    if (y - 1 < height)
+        d->horizontal_compose(b[0], d->temp, width);
+    if (y + 0 < height)
+        d->horizontal_compose(b[1], d->temp, width);
+
+    for (i = 0; i < 8; i++)
+        cs->b[i] = b[i + 2];
+    cs->y += 2;
+}
+
+/* Haar makes the assumption that height is even (always true for Dirac). */
+static void spatial_compose_haari_dy(DiracDWTContext *d, int level,
+                                     unsigned width, unsigned height,
+                                     int stride)
+{
+    int y        = d->cs[level].y;
+    IDWTELEM *b0 = d->buffer + (y - 1) * stride;
+    IDWTELEM *b1 = d->buffer + y       * stride;
+
+    d->vertical_compose(b0, b1, width);
+    d->horizontal_compose(b0, d->temp, width);
+    d->horizontal_compose(b1, d->temp, width);
+
+    d->cs[level].y += 2;
+}
+
+/* Do not do sliced IDWT for fidelity; the 9 tap filter makes it a bit
+ * annoying. Fortunately, this filter is not used in practice. */
+static void spatial_compose_fidelity(DiracDWTContext *d, int level,
+                                     unsigned width,unsigned height,
+                                     int stride)
+{
+    int i, y;
+    IDWTELEM *b[8];
+
+    for (y = 1; y < height; y += 2) {
+        for (i = 0; i < 8; i++)
+            b[i] = d->buffer + av_clip((y - 7 + 2 * i), 0, height - 2) * 
stride;
+        d->vertical_compose_h0_9tap(d->buffer + y * stride, b, width);
+    }
+
+    for (y = 0; y < height; y += 2) {
+        for (i = 0; i < 8; i++)
+            b[i] = d->buffer + av_clip((y - 7 + 2 * i), 1, height - 1) * 
stride;
+        d->vertical_compose_l0_9tap(d->buffer + y * stride, b, width);
+    }
+
+    for (y = 0; y < height; y++)
+        d->horizontal_compose(d->buffer + y * stride, d->temp, width);
+
+    d->cs[level].y = height + 1;
+}
+
+static void spatial_compose_daub97i_dy(DiracDWTContext *d, int level,
+                                       unsigned width, unsigned height,
+                                       int stride)
+{
+    DiracDWTCompose *cs = d->cs + level;
+    int i, y            = cs->y;
+    IDWTELEM *b[6];
+
+    for (i = 0; i < 4; i++)
+        b[i] = cs->b[i];
+    b[4] = d->buffer + mirror(y + 3, height - 1) * stride;
+    b[5] = d->buffer + mirror(y + 4, height - 1) * stride;
+
+    if (y + 3 < (unsigned)height)
+        d->vertical_compose_l1(b[3], b[4], b[5], width);
+    if (y + 2 < (unsigned)height)
+        d->vertical_compose_h1(b[2], b[3], b[4], width);
+    if (y + 1 < (unsigned)height)
+        d->vertical_compose_l0_3tap(b[1], b[2], b[3], width);
+    if (y + 0 < (unsigned)height)
+        d->vertical_compose_h0_3tap(b[0], b[1], b[2], width);
+
+    if (y - 1 < (unsigned)height)
+        d->horizontal_compose(b[0], d->temp, width);
+    if (y + 0 < (unsigned)height)
+        d->horizontal_compose(b[1], d->temp, width);
+
+    for (i = 0; i < 4; i++)
+        cs->b[i] = b[i + 2];
+    cs->y += 2;
+}
+
+static void spatial_compose97i_init(DiracDWTCompose *cs, IDWTELEM *buffer,
+                                    int height, int stride)
+{
+    cs->b[0] = buffer + mirror(-3 - 1, height - 1) * stride;
+    cs->b[1] = buffer + mirror(-3,     height - 1) * stride;
+    cs->b[2] = buffer + mirror(-3 + 1, height - 1) * stride;
+    cs->b[3] = buffer + mirror(-3 + 2, height - 1) * stride;
+    cs->y    = -3;
+}
+
+static void spatial_compose53i_init(DiracDWTCompose *cs, IDWTELEM *buffer,
+                                    int height, int stride)
+{
+    cs->b[0] = buffer + mirror(-1 - 1, height - 1) * stride;
+    cs->b[1] = buffer + mirror(-1,     height - 1) * stride;
+    cs->y    = -1;
+}
+
+static void spatial_compose_dd97i_init(DiracDWTCompose *cs, IDWTELEM *buffer,
+                                       int height, int stride)
+{
+    cs->b[0] = buffer + av_clip(-5 - 1, 0, height - 2) * stride;
+    cs->b[1] = buffer + av_clip(-5,     1, height - 1) * stride;
+    cs->b[2] = buffer + av_clip(-5 + 1, 0, height - 2) * stride;
+    cs->b[3] = buffer + av_clip(-5 + 2, 1, height - 1) * stride;
+    cs->b[4] = buffer + av_clip(-5 + 3, 0, height - 2) * stride;
+    cs->b[5] = buffer + av_clip(-5 + 4, 1, height - 1) * stride;
+    cs->y    = -5;
+}
+
+static void spatial_compose_dd137i_init(DiracDWTCompose *cs, IDWTELEM *buffer,
+                                        int height, int stride)
+{
+    cs->b[0] = buffer + av_clip(-5 - 1, 0, height - 2) * stride;
+    cs->b[1] = buffer + av_clip(-5,     1, height - 1) * stride;
+    cs->b[2] = buffer + av_clip(-5 + 1, 0, height - 2) * stride;
+    cs->b[3] = buffer + av_clip(-5 + 2, 1, height - 1) * stride;
+    cs->b[4] = buffer + av_clip(-5 + 3, 0, height - 2) * stride;
+    cs->b[5] = buffer + av_clip(-5 + 4, 1, height - 1) * stride;
+    cs->b[6] = buffer + av_clip(-5 + 5, 0, height - 2) * stride;
+    cs->b[7] = buffer + av_clip(-5 + 6, 1, height - 1) * stride;
+    cs->y    = -5;
+}
+
+int ff_spatial_idwt_init(DiracDWTContext *d, IDWTELEM *buffer, int width,
+                         int height, int stride, enum dwt_type type,
+                         int decomposition_count, IDWTELEM *temp)
+{
+    int level;
+
+    d->buffer              = buffer;
+    d->width               = width;
+    d->height              = height;
+    d->stride              = stride;
+    d->decomposition_count = decomposition_count;
+    d->temp                = temp + 8;
+
+    for (level = decomposition_count - 1; level >= 0; level--) {
+        int hl       = height >> level;
+        int stride_l = stride << level;
+
+        switch (type) {
+        case DWT_DIRAC_DD9_7:
+            spatial_compose_dd97i_init(d->cs + level, buffer, hl, stride_l);
+            break;
+        case DWT_DIRAC_LEGALL5_3:
+            spatial_compose53i_init(d->cs + level, buffer, hl, stride_l);
+            break;
+        case DWT_DIRAC_DD13_7:
+            spatial_compose_dd137i_init(d->cs + level, buffer, hl, stride_l);
+            break;
+        case DWT_DIRAC_HAAR0:
+        case DWT_DIRAC_HAAR1:
+            d->cs[level].y = 1;
+            break;
+        case DWT_DIRAC_DAUB9_7:
+            spatial_compose97i_init(d->cs + level, buffer, hl, stride_l);
+            break;
+        default:
+            d->cs[level].y = 0;
+            break;
+        }
+    }
+
+    switch (type) {
+    case DWT_DIRAC_DD9_7:
+        d->spatial_compose          = spatial_compose_dd97i_dy;
+        d->vertical_compose_l0_3tap = vertical_compose53iL0;
+        d->vertical_compose_h0_5tap = vertical_compose_dd97iH0;
+        d->horizontal_compose       = horizontal_compose_dd97i;
+        d->support                  = 7;
+        break;
+    case DWT_DIRAC_LEGALL5_3:
+        d->spatial_compose          = spatial_compose_dirac53i_dy;
+        d->vertical_compose_l0_3tap = vertical_compose53iL0;
+        d->vertical_compose_h0_3tap = vertical_compose_dirac53iH0;
+        d->horizontal_compose       = horizontal_compose_dirac53i;
+        d->support                  = 3;
+        break;
+    case DWT_DIRAC_DD13_7:
+        d->spatial_compose          = spatial_compose_dd137i_dy;
+        d->vertical_compose_l0_5tap = vertical_compose_dd137iL0;
+        d->vertical_compose_h0_5tap = vertical_compose_dd97iH0;
+        d->horizontal_compose       = horizontal_compose_dd137i;
+        d->support                  = 7;
+        break;
+    case DWT_DIRAC_HAAR0:
+        d->spatial_compose    = spatial_compose_haari_dy;
+        d->vertical_compose   = vertical_compose_haar;
+        d->horizontal_compose = horizontal_compose_haar0i;
+        d->support = 1;
+        break;
+    case DWT_DIRAC_HAAR1:
+        d->spatial_compose    = spatial_compose_haari_dy;
+        d->vertical_compose   = vertical_compose_haar;
+        d->horizontal_compose = horizontal_compose_haar1i;
+        d->support = 1;
+        break;
+    case DWT_DIRAC_FIDELITY:
+        d->spatial_compose          = spatial_compose_fidelity;
+        d->vertical_compose_l0_9tap = vertical_compose_fidelityiL0;
+        d->vertical_compose_h0_9tap = vertical_compose_fidelityiH0;
+        d->horizontal_compose       = horizontal_compose_fidelityi;
+        break;
+    case DWT_DIRAC_DAUB9_7:
+        d->spatial_compose          = spatial_compose_daub97i_dy;
+        d->vertical_compose_l0_3tap = vertical_compose_daub97iL0;
+        d->vertical_compose_h0_3tap = vertical_compose_daub97iH0;
+        d->vertical_compose_l1      = vertical_compose_daub97iL1;
+        d->vertical_compose_h1      = vertical_compose_daub97iH1;
+        d->horizontal_compose       = horizontal_compose_daub97i;
+        d->support                  = 5;
+        break;
+    default:
+        av_log(NULL, AV_LOG_ERROR, "Unknown wavelet type %d\n", type);
+        return AVERROR_OPTION_NOT_FOUND;
+    }
+
+    return 0;
+}
+
+void ff_spatial_idwt_slice(DiracDWTContext *d, int y)
+{
+    int level, support = d->support;
+
+    for (level = d->decomposition_count - 1; level >= 0; level--) {
+        int wl       = d->width  >> level;
+        int hl       = d->height >> level;
+        int stride_l = d->stride << level;
+
+        while (d->cs[level].y <= FFMIN((y >> level) + support, hl))
+            d->spatial_compose(d, level, wl, hl, stride_l);
+    }
+}
+
+int ff_spatial_idwt(IDWTELEM *buffer, int width, int height, int stride,
+                    enum dwt_type type, int decomposition_count,
+                    IDWTELEM *temp)
+{
+    DiracDWTContext d;
+    int y;
+    int ret;
+
+    if (ret = ff_spatial_idwt_init(&d, buffer, width, height, stride, type,
+                                    decomposition_count, temp))
+        return ret;
+
+    for (y = 0; y < d.height; y += 4)
+        ff_spatial_idwt_slice(&d, y);
+
+    return 0;
+}
diff --git a/libavcodec/dirac_dwt.h b/libavcodec/dirac_dwt.h
new file mode 100644
index 0000000..ce48aed
--- /dev/null
+++ b/libavcodec/dirac_dwt.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2009 David Conrad
+ * Copyright (C) 2012 Jordi Ortiz
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_DIRAC_DWT_H
+#define AVCODEC_DIRAC_DWT_H
+
+#include <stdint.h>
+
+typedef int   DWTELEM;
+typedef short IDWTELEM;
+
+#define MAX_DWT_SUPPORT    8
+#define MAX_DECOMPOSITIONS 8
+
+typedef struct DiracDWTCompose {
+    IDWTELEM *b[MAX_DWT_SUPPORT];
+    int y;
+} DiracDWTCompose;
+
+enum dwt_type {
+    DWT_SNOW_DAUB9_7,
+    DWT_SNOW_LEGALL5_3,
+    DWT_DIRAC_DD9_7,
+    DWT_DIRAC_LEGALL5_3,
+    DWT_DIRAC_DD13_7,
+    DWT_DIRAC_HAAR0,
+    DWT_DIRAC_HAAR1,
+    DWT_DIRAC_FIDELITY,
+    DWT_DIRAC_DAUB9_7,
+    DWT_NUM_TYPES
+};
+
+typedef struct DiracDWTContext {
+    IDWTELEM *buffer;
+    IDWTELEM *temp;
+    int width;
+    int height;
+    int stride;
+    int decomposition_count;
+    int support;
+
+    void (*spatial_compose)(struct DiracDWTContext *cs, int level,
+                            unsigned width, unsigned height, int stride);
+    void (*vertical_compose_l0_3tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                     int width);
+    void (*vertical_compose_l0_5tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                     IDWTELEM *b3, IDWTELEM *b4, int width);
+    void (*vertical_compose_l0_9tap)(IDWTELEM *dst, IDWTELEM *b[8],
+                                     int width);
+    void (*vertical_compose_h0_3tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                     int width);
+    void (*vertical_compose_h0_5tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                     IDWTELEM *b3, IDWTELEM *b4, int width);
+    void (*vertical_compose_h0_9tap)(IDWTELEM *dst, IDWTELEM *b[8],
+                                     int width);
+    void (*vertical_compose_l1)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                     int width);
+    void (*vertical_compose_h1)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
+                                     int width);
+    void (*vertical_compose)(IDWTELEM *b0, IDWTELEM *b1, int width);
+    void (*horizontal_compose)(IDWTELEM *b, IDWTELEM *tmp, int width);
+    DiracDWTCompose cs[MAX_DECOMPOSITIONS];
+} DiracDWTContext;
+
+int ff_spatial_idwt_init(DiracDWTContext *d, IDWTELEM *buffer, int width,
+                         int height, int stride, enum dwt_type type,
+                         int decomposition_count, IDWTELEM *temp);
+
+int ff_spatial_idwt(IDWTELEM *buffer, int width, int height, int stride,
+                    enum dwt_type type, int decomposition_count,
+                    IDWTELEM *temp);
+
+void ff_spatial_idwt_slice(DiracDWTContext *d, int y);
+
+// shared stuff for SIMD optimizations
+#define COMPOSE_53iL0(b0, b1, b2)                                       \
+    (b1 - ((b0 + b2 + 2) >> 2))
+
+#define COMPOSE_DIRAC53iH0(b0, b1, b2)                                  \
+    (b1 + ((b0 + b2 + 1) >> 1))
+
+#define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)                             \
+    (b2 + ((-b0 + 9 * b1 + 9 * b3 - b4 + 8) >> 4))
+
+#define COMPOSE_DD137iL0(b0, b1, b2, b3, b4)                            \
+    (b2 - ((-b0 + 9 * b1 + 9 * b3 - b4 + 16) >> 5))
+
+#define COMPOSE_HAARiL0(b0, b1)                                         \
+    (b0 - ((b1 + 1) >> 1))
+
+#define COMPOSE_HAARiH0(b0, b1)                                         \
+    (b0 + b1)
+
+#define COMPOSE_FIDELITYiL0(b0, b1, b2, b3, b4, b5, b6, b7, b8)         \
+    (b4 - ((-8 * (b0 + b8) + 21 * (b1 + b7) - 46 * (b2 + b6) +          \
+            161 * (b3 + b5) + 128) >> 8))
+
+#define COMPOSE_FIDELITYiH0(b0, b1, b2, b3, b4, b5, b6, b7, b8)         \
+    (b4 + ((-2 * (b0 + b8) + 10 * (b1 + b7) - 25 * (b2 + b6) +          \
+            81 * (b3 + b5) + 128) >> 8))
+
+#define COMPOSE_DAUB97iL1(b0, b1, b2)                                   \
+    (b1 - ((1817 * (b0 + b2) + 2048) >> 12))
+
+#define COMPOSE_DAUB97iH1(b0, b1, b2)                                   \
+    (b1 - ((113 * (b0 + b2) + 64) >> 7))
+
+#define COMPOSE_DAUB97iL0(b0, b1, b2)                                   \
+    (b1 + ((217 * (b0 + b2) + 2048) >> 12))
+
+#define COMPOSE_DAUB97iH0(b0, b1, b2)                                   \
+    (b1 + ((6497 * (b0 + b2) + 2048) >> 12))
+
+#endif /* AVCODEC_DIRAC_DWT_H */
diff --git a/libavcodec/diracdsp.c b/libavcodec/diracdsp.c
new file mode 100644
index 0000000..6dd3c39
--- /dev/null
+++ b/libavcodec/diracdsp.c
@@ -0,0 +1,311 @@
+/*
+ * Copyright (C) 2009 David Conrad
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "diracdsp.h"
+#include "dsputil.h"
+
+#define FILTER(src, stride)                                      \
+    ((21 * ((src)[0  * stride] + (src)[1 * stride]) -            \
+       7 * ((src)[-1 * stride] + (src)[2 * stride]) +            \
+       3 * ((src)[-2 * stride] + (src)[3 * stride]) -            \
+       1 * ((src)[-3 * stride] + (src)[4 * stride]) + 16) >> 5)
+
+#define DIRAC_MC(OPNAME)                                                \
+void ff_ ## OPNAME ## _dirac_pixels8_c(DiracDSPContext *dc,             \
+                                       uint8_t *dst,                    \
+                                       const uint8_t *src[5],           \
+                                       int stride, int h)               \
+{                                                                       \
+    dc->dsp.OPNAME ## _tpel_pixels_tab[0](dst, src[0], stride, 8, h);   \
+}                                                                       \
+void ff_ ## OPNAME ## _dirac_pixels16_c(DiracDSPContext *dc,            \
+                                        uint8_t *dst,                   \
+                                        const uint8_t *src[5],          \
+                                        int stride, int h)              \
+{                                                                       \
+    dc->dsp.OPNAME ## _tpel_pixels_tab[0](dst, src[0], stride, 16, h);  \
+}                                                                       \
+void ff_ ## OPNAME ## _dirac_pixels32_c(DiracDSPContext *dc,            \
+                                        uint8_t *dst,                   \
+                                        const uint8_t *src[5],          \
+                                        int stride, int h)              \
+{                                                                       \
+    dc->dsp.OPNAME ## _tpel_pixels_tab[0](dst, src[0], stride, 16, h);  \
+        dc->dsp.OPNAME ## _tpel_pixels_tab[0](dst + 16, src[0] + 16,    \
+                                              stride, 16, h);           \
+}                                                                       \
+void ff_ ## OPNAME ## _dirac_pixels8_l2_c(DiracDSPContext *dc,          \
+                                          uint8_t *dst,                 \
+                                          const uint8_t *src[5],        \
+                                          int stride, int h)            \
+{                                                                       \
+    dc->dsp.OPNAME ## _pixels_l2[1](dst,  src[0], src[1], stride,       \
+                                    stride, stride, h);                 \
+}                                                                       \
+void ff_ ## OPNAME ## _dirac_pixels16_l2_c(DiracDSPContext *dc,         \
+                                           uint8_t *dst,                \
+                                           const uint8_t *src[5],       \
+                                           int stride, int h)           \
+{                                                                       \
+    dc->dsp.OPNAME ## _pixels_l2[0](dst,  src[0], src[1], stride,       \
+                                    stride, stride, h);                 \
+}                                                                       \
+void ff_ ## OPNAME ## _dirac_pixels32_l2_c(DiracDSPContext *dc,         \
+                                           uint8_t *dst,                \
+                                           const uint8_t *src[5],       \
+                                           int stride, int h)           \
+{                                                                       \
+    dc->dsp.OPNAME ## _pixels_l2[0](dst,  src[0], src[1], stride,       \
+                                    stride, stride, h);                 \
+    dc->dsp.OPNAME ## _pixels_l2[0](dst + 16,  src[0] + 16,             \
+                                    src[1] + 16, stride, stride,        \
+                                    stride, h);                         \
+}                                                                       \
+void ff_ ## OPNAME ## _dirac_pixels8_l4_c(DiracDSPContext *dc,          \
+                                          uint8_t *dst,                 \
+                                          const uint8_t *src[5],        \
+                                          int stride, int h)            \
+{                                                                       \
+    dc->dsp.OPNAME ## _pixels_l4[1](dst, src[0], src[1], src[2],        \
+                                    src[3], stride, stride, stride,     \
+                                    stride, stride, h);                 \
+}                                                                       \
+void ff_ ## OPNAME ## _dirac_pixels16_l4_c(DiracDSPContext *dc,         \
+                                           uint8_t *dst,                \
+                                           const uint8_t *src[5],       \
+                                           int stride, int h)           \
+{                                                                       \
+    dc->dsp.OPNAME ## _pixels_l4[0](dst, src[0], src[1], src[2],        \
+                                    src[3], stride, stride, stride,     \
+                                    stride, stride, h);                 \
+}                                                                       \
+void ff_ ## OPNAME ## _dirac_pixels32_l4_c(DiracDSPContext *dc,         \
+                                           uint8_t *dst,                \
+                                           const uint8_t *src[5],       \
+                                           int stride, int h)           \
+{                                                                       \
+    dc->dsp.OPNAME ## _pixels_l4[0](dst, src[0], src[1], src[2],        \
+                                    src[3], stride, stride, stride,     \
+                                    stride, stride, h);                 \
+    dc->dsp.OPNAME ## _pixels_l4[0](dst + 16, src[0] + 16, src[1] + 16, \
+                                    src[2] + 16, src[3] + 16, stride,   \
+                                    stride, stride, stride, stride, h); \
+}
+
+DIRAC_MC(put)
+DIRAC_MC(avg)
+
+static void dirac_hpel_filter(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc,
+                              const uint8_t *src, int stride, int width,
+                              int height)
+{
+    int x, y;
+
+    for (y = 0; y < height; y++) {
+        for (x = -3; x < width + 5; x++)
+            dstv[x] = av_clip_uint8(FILTER(src + x, stride));
+
+        for (x = 0; x < width; x++)
+            dstc[x] = av_clip_uint8(FILTER(dstv + x, 1));
+
+        for (x = 0; x < width; x++)
+            dsth[x] = av_clip_uint8(FILTER(src + x, 1));
+
+        src  += stride;
+        dsth += stride;
+        dstv += stride;
+        dstc += stride;
+    }
+}
+
+#define PIXOP_BILINEAR(PFX, OP, WIDTH)                                  \
+static void ff_ ## PFX ## _dirac_pixels ## WIDTH ## _bilinear_c(        \
+    DiracDSPContext *dc, uint8_t *dst, const uint8_t *src[5],           \
+    int stride, int h)                                                  \
+{                                                                       \
+    int x;                                                              \
+    const uint8_t *s0 = src[0];                                         \
+    const uint8_t *s1 = src[1];                                         \
+    const uint8_t *s2 = src[2];                                         \
+    const uint8_t *s3 = src[3];                                         \
+    const uint8_t *w  = src[4];                                         \
+                                                                        \
+    while (h--) {                                                       \
+        for (x = 0; x < WIDTH; x++) {                                   \
+            OP(dst[x],                                                  \
+               (s0[x] *                                                 \
+                w[0] + s1[x] *                                          \
+                w[1] + s2[x] *                                          \
+                w[2] + s3[x] *                                          \
+                w[3] + 8) >> 4);                                        \
+        }                                                               \
+                                                                        \
+        dst += stride;                                                  \
+        s0  += stride;                                                  \
+        s1  += stride;                                                  \
+        s2  += stride;                                                  \
+        s3  += stride;                                                  \
+    }                                                                   \
+}
+
+#define OP_PUT(dst, val) (dst) = (val)
+#define OP_AVG(dst, val) (dst) = (((dst) + (val) + 1) >> 1)
+
+PIXOP_BILINEAR(put, OP_PUT,  8)
+PIXOP_BILINEAR(put, OP_PUT, 16)
+PIXOP_BILINEAR(put, OP_PUT, 32)
+PIXOP_BILINEAR(avg, OP_AVG,  8)
+PIXOP_BILINEAR(avg, OP_AVG, 16)
+PIXOP_BILINEAR(avg, OP_AVG, 32)
+
+#define op_scale1(x)                                                    \
+    block[x] = av_clip_uint8((block[x] * weight +                       \
+                              (1 << (log2_denom - 1))) >> log2_denom)
+#define op_scale2(x)                                                    \
+    dst[x] = av_clip_uint8((src[x] * weights + dst[x] * weightd +       \
+                            (1 << (log2_denom - 1))) >> log2_denom)
+
+#define DIRAC_WEIGHT(W)                                                 \
+static void weight_dirac_pixels ## W ## _c(uint8_t *block,              \
+                                           int stride, int log2_denom,  \
+                                           int weight, int h)           \
+{                                                                       \
+    int x;                                                              \
+    while (h--) {                                                       \
+        for (x = 0; x < W; x++) {                                       \
+            op_scale1(x);                                               \
+            op_scale1(x + 1);                                           \
+        }                                                               \
+        block += stride;                                                \
+    }                                                                   \
+}                                                                       \
+static void biweight_dirac_pixels ## W ## _c(uint8_t *dst,              \
+                                             const uint8_t *src,        \
+                                             int stride,                \
+                                             int log2_denom,            \
+                                             int weightd,               \
+                                             int weights,               \
+                                             int h)                     \
+{                                                                       \
+    int x;                                                              \
+    while (h--) {                                                       \
+        for (x = 0; x < W; x++) {                                       \
+            op_scale2(x);                                               \
+            op_scale2(x + 1);                                           \
+        }                                                               \
+        dst += stride;                                                  \
+        src += stride;                                                  \
+    }                                                                   \
+}
+
+DIRAC_WEIGHT(8)
+DIRAC_WEIGHT(16)
+DIRAC_WEIGHT(32)
+
+#define ADD_OBMC(xblen)                                                 \
+static void add_obmc ## xblen ## _c(uint16_t *dst,                      \
+                                    const uint8_t *src, int stride,     \
+                                    const uint8_t *obmc_weight,         \
+                                    int yblen)                          \
+{                                                                       \
+    int x;                                                              \
+    while (yblen--) {                                                   \
+        for (x = 0; x < xblen; x += 2) {                                \
+            dst[x]     += src[x]     * obmc_weight[x];                  \
+            dst[x + 1] += src[x + 1] * obmc_weight[x + 1];              \
+        }                                                               \
+        dst         += stride;                                          \
+        src         += stride;                                          \
+        obmc_weight += 32;                                              \
+    }                                                                   \
+}
+
+ADD_OBMC(8)
+ADD_OBMC(16)
+ADD_OBMC(32)
+
+static void put_signed_rect_clamped_c(uint8_t *dst, int dst_stride,
+                                      const int16_t *src, int src_stride,
+                                      int width, int height)
+{
+    int x, y;
+    for (y = 0; y < height; y++) {
+        for (x = 0; x < width; x += 4) {
+            dst[x]     = av_clip_uint8(src[x] + 128);
+            dst[x + 1] = av_clip_uint8(src[x + 1] + 128);
+            dst[x + 2] = av_clip_uint8(src[x + 2] + 128);
+            dst[x + 3] = av_clip_uint8(src[x + 3] + 128);
+        }
+        dst += dst_stride;
+        src += src_stride;
+    }
+}
+
+static void add_rect_clamped_c(uint8_t *dst, const uint16_t *src, int stride,
+                               const int16_t *idwt, int idwt_stride,
+                               int width, int height)
+{
+    int x, y;
+
+    for (y = 0; y < height; y++) {
+        for (x = 0; x < width; x += 2) {
+            dst[x]     = av_clip_uint8((src[x]     + 32 >> 6) + idwt[x]);
+            dst[x + 1] = av_clip_uint8((src[x + 1] + 32 >> 6) + idwt[x + 1]);
+        }
+        dst  += stride;
+        src  += stride;
+        idwt += idwt_stride;
+    }
+}
+
+#define PIXFUNC(PFX, WIDTH)                                                    
                 \
+    c->PFX ## _dirac_pixels_tab[WIDTH >> 4][0] = ff_ ## PFX ## _dirac_pixels 
## WIDTH ## _c;    \
+    c->PFX ## _dirac_pixels_tab[WIDTH >> 4][1] = ff_ ## PFX ## _dirac_pixels 
## WIDTH ## _l2_c; \
+    c->PFX ## _dirac_pixels_tab[WIDTH >> 4][2] = ff_ ## PFX ## _dirac_pixels 
## WIDTH ## _l4_c; \
+    c->PFX ## _dirac_pixels_tab[WIDTH >> 4][3] = ff_ ## PFX ## _dirac_pixels 
## WIDTH ## _bilinear_c
+
+void ff_diracdsp_init(DiracDSPContext *c, AVCodecContext *avctx)
+{
+    ff_dsputil_init(&c->dsp, avctx);
+
+    c->dirac_hpel_filter       = dirac_hpel_filter;
+    c->add_rect_clamped        = add_rect_clamped_c;
+    c->put_signed_rect_clamped = put_signed_rect_clamped_c;
+
+    c->add_dirac_obmc[0] = add_obmc8_c;
+    c->add_dirac_obmc[1] = add_obmc16_c;
+    c->add_dirac_obmc[2] = add_obmc32_c;
+
+    c->weight_dirac_pixels_tab[0] = weight_dirac_pixels8_c;
+    c->weight_dirac_pixels_tab[1] = weight_dirac_pixels16_c;
+    c->weight_dirac_pixels_tab[2] = weight_dirac_pixels32_c;
+
+    c->biweight_dirac_pixels_tab[0] = biweight_dirac_pixels8_c;
+    c->biweight_dirac_pixels_tab[1] = biweight_dirac_pixels16_c;
+    c->biweight_dirac_pixels_tab[2] = biweight_dirac_pixels32_c;
+
+    PIXFUNC(put, 8);
+    PIXFUNC(put, 16);
+    PIXFUNC(put, 32);
+    PIXFUNC(avg, 8);
+    PIXFUNC(avg, 16);
+    PIXFUNC(avg, 32);
+}
diff --git a/libavcodec/diracdsp.h b/libavcodec/diracdsp.h
new file mode 100644
index 0000000..2560d9c
--- /dev/null
+++ b/libavcodec/diracdsp.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2010 David Conrad
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_DIRACDSP_H
+#define AVCODEC_DIRACDSP_H
+
+#include <stdint.h>
+
+#include "dsputil.h"
+
+typedef void (*dirac_weight_func)(uint8_t *block, int stride, int log2_denom,
+                                  int weight, int h);
+typedef void (*dirac_biweight_func)(uint8_t *dst, const uint8_t *src,
+                                    int stride, int log2_denom, int weightd,
+                                    int weights, int h);
+typedef struct DiracDSPContext {
+    void (*dirac_hpel_filter)(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc,
+                              const uint8_t *src, int stride, int width,
+                              int height);
+    /**
+     * dirac_pixels_tab[width][subpel]
+     * width is 2 for 32, 1 for 16, 0 for 8
+     * subpel is 0 for fpel and hpel (only need to copy from the first plane 
in src)
+     *           1 if an average of the first 2 planes is needed (TODO: worth 
it?)
+     *           2 for general qpel (avg of 4)
+     *           3 for general epel (biweight of 4 using the weights in src[4])
+     * src[0-3] is each of the hpel planes
+     * src[4] is the 1/8 pel weights if needed
+     */
+    void (*put_dirac_pixels_tab[3][4])(struct DiracDSPContext *dc,
+                                       uint8_t *dst, const uint8_t *src[5],
+                                       int stride, int h);
+    void (*avg_dirac_pixels_tab[3][4])(struct DiracDSPContext *dc,
+                                       uint8_t *dst, const uint8_t *src[5],
+                                       int stride, int h);
+
+    void (*put_signed_rect_clamped)(uint8_t *dst /*align 16*/, int dst_stride,
+                                    const int16_t *src /*align 16*/,
+                                    int src_stride, int width,
+                                    int height /*mod 2*/);
+    void (*put_rect_clamped)(uint8_t *dst /*align 16*/, int dst_stride,
+                             const int16_t *src /*align 16*/, int src_stride,
+                             int width, int height /*mod 2*/);
+    void (*add_rect_clamped)(uint8_t *dst /*align 16*/,
+                             const uint16_t *src /*align 16*/, int stride,
+                             const int16_t *idwt /*align 16*/, int idwt_stride,
+                             int width, int height /*mod 2*/);
+    void (*add_dirac_obmc[3]) (uint16_t *dst, const uint8_t *src, int stride,
+                               const uint8_t *obmc_weight, int yblen);
+
+    dirac_weight_func weight_dirac_pixels_tab[3];
+    dirac_biweight_func biweight_dirac_pixels_tab[3];
+    DSPContext dsp;
+} DiracDSPContext;
+
+#define DECL_DIRAC_PIXOP(PFX, EXT)                                     \
+    void ff_ ## PFX ## _dirac_pixels8_ ## EXT(DiracDSPContext *dc,     \
+                                              uint8_t *dst,            \
+                                              const uint8_t *src[5],   \
+                                              int stride, int h);      \
+    void ff_ ## PFX ## _dirac_pixels16_ ## EXT(DiracDSPContext *dc,    \
+                                               uint8_t *dst,           \
+                                               const uint8_t *src[5],  \
+                                               int stride, int h);     \
+    void ff_ ## PFX ## _dirac_pixels32_ ## EXT(DiracDSPContext *dc,    \
+                                               uint8_t *dst,           \
+                                               const uint8_t *src[5],  \
+                                               int stride, int h)
+
+DECL_DIRAC_PIXOP(put, c);
+DECL_DIRAC_PIXOP(avg, c);
+DECL_DIRAC_PIXOP(put, l2_c);
+DECL_DIRAC_PIXOP(avg, l2_c);
+DECL_DIRAC_PIXOP(put, l4_c);
+DECL_DIRAC_PIXOP(avg, l4_c);
+
+void ff_diracdsp_init(DiracDSPContext *c, AVCodecContext *avctx);
+
+#endif /* AVCODEC_DIRACDSP_H */
-- 
1.8.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to