2 * Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
3 * Copyright (C) 2008 David Conrad
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libavutil/attributes.h"
23 #include "libavutil/avassert.h"
24 #include "libavutil/common.h"
25 #include "dirac_dwt.h"
26 #include "libavcodec/x86/dirac_dwt.h"
29 #include "dirac_dwt_template.c"
31 #define TEMPLATE_10bit
32 #include "dirac_dwt_template.c"
34 #define TEMPLATE_12bit
35 #include "dirac_dwt_template.c"
37 int ff_spatial_idwt_init2(DWTContext *d, uint8_t *buffer, int width, int height,
38 int stride, enum dwt_type type, int decomposition_count,
39 uint8_t *temp, int bit_depth)
44 ret = ff_spatial_idwt_init2_8bit(d, buffer, width, height, stride, type, decomposition_count, temp);
45 else if (bit_depth == 10)
46 ret = ff_spatial_idwt_init2_10bit(d, buffer, width, height, stride, type, decomposition_count, temp);
47 else if (bit_depth == 12)
48 ret = ff_spatial_idwt_init2_12bit(d, buffer, width, height, stride, type, decomposition_count, temp);
50 av_log(NULL, AV_LOG_WARNING, "Unsupported bit depth = %i\n", bit_depth);
53 av_log(NULL, AV_LOG_ERROR, "Unknown wavelet type %d\n", type);
54 return AVERROR_INVALIDDATA;
57 if (bit_depth == 8 && HAVE_MMX)
58 ff_spatial_idwt_init_mmx(d, type);
62 void ff_spatial_idwt_slice2(DWTContext *d, int y)
64 int level, support = d->support;
66 for (level = d->decomposition_count-1; level >= 0; level--) {
67 int wl = d->width >> level;
68 int hl = d->height >> level;
69 int stride_l = d->stride << level;
71 while (d->cs[level].y <= FFMIN((y>>level)+support, hl))
72 d->spatial_compose(d, level, wl, hl, stride_l);