1 /*
2 * JPEG-LS common code
3 * Copyright (c) 2003 Michael Niedermayer
4 * Copyright (c) 2006 Konstantin Shishkov
5 *
6 * This file is part of FFmpeg.
7 *
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.
12 *
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.
17 *
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
21 */
22
23 /**
24 * @file
25 * JPEG-LS common code.
26 */
27
28 #include <stddef.h>
33
35 {
37
40
41 // QBPP = ceil(log2(RANGE))
43 ;
44
47
48 for (
i = 0;
i < 367;
i++) {
51 }
52 }
53
54 /**
55 * Custom value clipping function used in T1, T2, T3 calculation
56 */
57 static inline int iso_clip(
int v,
int vmin,
int vmax)
58 {
59 if (v > vmax || v < vmin)
60 return vmin;
61 else
62 return v;
63 }
64
66 {
67 const int basic_t1 = 3;
68 const int basic_t2 = 7;
69 const int basic_t3 = 21;
71
72 if (
s->maxval == 0 || reset_all)
73 s->maxval = (1 <<
s->bpp) - 1;
74
75 if (
s->maxval >= 128) {
77
78 if (
s->T1 == 0 || reset_all)
80 s->near + 1,
s->maxval);
81 if (
s->T2 == 0 || reset_all)
84 if (
s->T3 == 0 || reset_all)
87 } else {
89
90 if (
s->T1 == 0 || reset_all)
92 s->near + 1,
s->maxval);
93 if (
s->T2 == 0 || reset_all)
96 if (
s->T3 == 0 || reset_all)
99 }
100
101 if (
s->reset == 0 || reset_all)
103 ff_dlog(
NULL,
"[JPEG-LS RESET] T=%i,%i,%i\n",
s->T1,
s->T2,
s->T3);
104 }