2 * JPEG 2000 DSP functions
3 * Copyright (c) 2007 Kamil Nowosad
4 * Copyright (c) 2013 Nicolas Bertrand <nicoinattendu@gmail.com>
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "libavutil/attributes.h"
25 #include "jpeg2000dsp.h"
27 /* Inverse ICT parameters in float and integer.
28 * int value = (float value) * (1<<16) */
29 static const float f_ict_params
[4] = {
36 static const int i_ict_params
[4] = {
43 static void ict_float(void *_src0
, void *_src1
, void *_src2
, int csize
)
45 float *src0
= _src0
, *src1
= _src1
, *src2
= _src2
;
49 for (i
= 0; i
< csize
; i
++) {
50 i0f
= *src0
+ (f_ict_params
[0] * *src2
);
51 i1f
= *src0
- (f_ict_params
[1] * *src1
)
52 - (f_ict_params
[2] * *src2
);
53 i2f
= *src0
+ (f_ict_params
[3] * *src1
);
60 static void ict_int(void *_src0
, void *_src1
, void *_src2
, int csize
)
62 int32_t *src0
= _src0
, *src1
= _src1
, *src2
= _src2
;
66 for (i
= 0; i
< csize
; i
++) {
67 i0
= *src0
+ (((i_ict_params
[0] * *src2
) + (1 << 15)) >> 16);
68 i1
= *src0
- (((i_ict_params
[1] * *src1
) + (1 << 15)) >> 16)
69 - (((i_ict_params
[2] * *src2
) + (1 << 15)) >> 16);
70 i2
= *src0
+ (((i_ict_params
[3] * *src1
) + (1 << 15)) >> 16);
77 static void rct_int(void *_src0
, void *_src1
, void *_src2
, int csize
)
79 int32_t *src0
= _src0
, *src1
= _src1
, *src2
= _src2
;
83 for (i
= 0; i
< csize
; i
++) {
84 i1
= *src0
- (*src2
+ *src1
>> 2);
93 av_cold
void ff_jpeg2000dsp_init(Jpeg2000DSPContext
*c
)
95 c
->mct_decode
[FF_DWT97
] = ict_float
;
96 c
->mct_decode
[FF_DWT53
] = rct_int
;
97 c
->mct_decode
[FF_DWT97_INT
] = ict_int
;