2013-01-15 00:30:30 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004-2010 Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
* Copyright (C) 2008 David Conrad
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg 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.
|
|
|
|
*
|
|
|
|
* FFmpeg 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 FFmpeg; 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"
|
2021-07-23 14:06:58 +02:00
|
|
|
#include "libavutil/log.h"
|
2013-01-15 00:30:30 +03:00
|
|
|
#include "dirac_dwt.h"
|
|
|
|
|
2015-12-09 10:24:36 +02:00
|
|
|
#define TEMPLATE_8bit
|
|
|
|
#include "dirac_dwt_template.c"
|
2013-01-15 00:30:30 +03:00
|
|
|
|
2015-12-09 10:24:36 +02:00
|
|
|
#define TEMPLATE_10bit
|
|
|
|
#include "dirac_dwt_template.c"
|
2013-01-15 00:30:30 +03:00
|
|
|
|
2015-12-09 10:24:36 +02:00
|
|
|
#define TEMPLATE_12bit
|
|
|
|
#include "dirac_dwt_template.c"
|
2013-01-15 00:30:30 +03:00
|
|
|
|
2016-02-03 03:30:55 +02:00
|
|
|
int ff_spatial_idwt_init(DWTContext *d, DWTPlane *p, enum dwt_type type,
|
|
|
|
int decomposition_count, int bit_depth)
|
2013-01-15 00:30:30 +03:00
|
|
|
{
|
2015-12-09 10:24:36 +02:00
|
|
|
int ret = 0;
|
2013-01-15 00:30:30 +03:00
|
|
|
|
2016-02-03 03:30:55 +02:00
|
|
|
d->buffer = p->buf;
|
|
|
|
d->width = p->width;
|
|
|
|
d->height = p->height;
|
|
|
|
d->stride = p->stride;
|
|
|
|
d->temp = p->tmp;
|
2016-02-03 02:53:28 +02:00
|
|
|
d->decomposition_count = decomposition_count;
|
|
|
|
|
2015-12-09 10:24:36 +02:00
|
|
|
if (bit_depth == 8)
|
2022-09-25 19:56:35 +02:00
|
|
|
ret = spatial_idwt_init_8bit(d, type);
|
2015-12-09 10:24:36 +02:00
|
|
|
else if (bit_depth == 10)
|
2022-09-25 19:56:35 +02:00
|
|
|
ret = spatial_idwt_init_10bit(d, type);
|
2015-12-09 10:24:36 +02:00
|
|
|
else if (bit_depth == 12)
|
2022-09-25 19:56:35 +02:00
|
|
|
ret = spatial_idwt_init_12bit(d, type);
|
2015-12-09 10:24:36 +02:00
|
|
|
else
|
|
|
|
av_log(NULL, AV_LOG_WARNING, "Unsupported bit depth = %i\n", bit_depth);
|
2013-01-15 00:30:30 +03:00
|
|
|
|
2015-12-09 10:24:36 +02:00
|
|
|
if (ret) {
|
2013-01-15 00:30:30 +03:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "Unknown wavelet type %d\n", type);
|
2015-05-06 16:54:40 +02:00
|
|
|
return AVERROR_INVALIDDATA;
|
2013-01-15 00:30:30 +03:00
|
|
|
}
|
|
|
|
|
2022-06-12 05:51:12 +02:00
|
|
|
#if ARCH_X86
|
|
|
|
if (bit_depth == 8)
|
2016-02-03 02:21:46 +02:00
|
|
|
ff_spatial_idwt_init_x86(d, type);
|
2022-06-12 05:51:12 +02:00
|
|
|
#endif
|
2013-01-15 00:30:30 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ff_spatial_idwt_slice2(DWTContext *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);
|
|
|
|
}
|
|
|
|
}
|