FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavcodec
jpegls.h
Go to the documentation of this file.
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
#ifndef AVCODEC_JPEGLS_H
29
#define AVCODEC_JPEGLS_H
30
31
#include "
libavutil/common.h
"
32
#include "
avcodec.h
"
33
#include "
internal.h
"
34
35
typedef
struct
JpeglsContext
{
36
AVCodecContext
*
avctx
;
37
}
JpeglsContext
;
38
39
typedef
struct
JLSState
{
40
int
T1
,
T2
,
T3
;
41
int
A
[367],
B
[367],
C
[365],
N
[367];
42
int
limit
,
reset
,
bpp
,
qbpp
,
maxval
,
range
;
43
int
near
,
twonear
;
44
int
run_index
[4];
45
}
JLSState
;
46
47
/**
48
* Calculate initial JPEG-LS parameters
49
*/
50
void
ff_jpegls_init_state
(
JLSState
*
state
);
51
52
/**
53
* Calculate quantized gradient value, used for context determination
54
*/
55
static
inline
int
ff_jpegls_quantize
(
JLSState
*
s
,
int
v
)
56
{
57
if
(v == 0)
58
return
0;
59
if
(v < 0) {
60
if
(v <= -s->T3)
61
return
-4;
62
if
(v <= -s->T2)
63
return
-3;
64
if
(v <= -s->T1)
65
return
-2;
66
if
(v < -s->near)
67
return
-1;
68
return
0;
69
}
else
{
70
if
(v <= s->near)
71
return
0;
72
if
(v < s->T1)
73
return
1;
74
if
(v < s->T2)
75
return
2;
76
if
(v < s->T3)
77
return
3;
78
return
4;
79
}
80
}
81
82
/**
83
* Calculate JPEG-LS codec values
84
*/
85
void
ff_jpegls_reset_coding_parameters
(
JLSState
*
s
,
int
reset_all);
86
87
static
inline
void
ff_jpegls_downscale_state
(
JLSState
*
state
,
int
Q)
88
{
89
if
(state->
N
[Q] == state->
reset
) {
90
state->
A
[Q] >>= 1;
91
state->
B
[Q] >>= 1;
92
state->
N
[Q] >>= 1;
93
}
94
state->
N
[Q]++;
95
}
96
97
static
inline
int
ff_jpegls_update_state_regular
(
JLSState
*
state
,
98
int
Q,
int
err)
99
{
100
if
(
FFABS
(err) > 0xFFFF)
101
return
-0x10000;
102
state->
A
[Q] +=
FFABS
(err);
103
err *= state->
twonear
;
104
state->
B
[Q] += err;
105
106
ff_jpegls_downscale_state
(state, Q);
107
108
if
(state->
B
[Q] <= -state->
N
[Q]) {
109
state->
B
[Q] =
FFMAX
(state->
B
[Q] + state->
N
[Q], 1 - state->
N
[Q]);
110
if
(state->
C
[Q] > -128)
111
state->
C
[Q]--;
112
}
else
if
(state->
B
[Q] > 0) {
113
state->
B
[Q] =
FFMIN
(state->
B
[Q] - state->
N
[Q], 0);
114
if
(state->
C
[Q] < 127)
115
state->
C
[Q]++;
116
}
117
118
return
err;
119
}
120
121
#define R(a, i) (bits == 8 ? ((uint8_t *)(a))[i] : ((uint16_t *)(a))[i])
122
#define W(a, i, v) (bits == 8 ? (((uint8_t *)(a))[i] = v) : (((uint16_t *)(a))[i] = v))
123
124
#endif
/* AVCODEC_JPEGLS_H */
JLSState::reset
int reset
Definition:
jpegls.h:42
v
float v
Definition:
avf_showspectrum.c:96
s
const char * s
Definition:
avisynth_c.h:631
JLSState::T2
int T2
Definition:
jpegls.h:40
JpeglsContext
Definition:
jpegls.h:35
JLSState::C
int C[365]
Definition:
jpegls.h:41
JLSState::twonear
int twonear
Definition:
jpegls.h:43
JLSState::limit
int limit
Definition:
jpegls.h:42
ff_jpegls_init_state
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
Definition:
jpegls.c:31
JLSState::bpp
int bpp
Definition:
jpegls.h:42
JLSState
Definition:
jpegls.h:39
JLSState::maxval
int maxval
Definition:
jpegls.h:42
ff_jpegls_update_state_regular
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
Definition:
jpegls.h:97
JLSState::B
int B[367]
Definition:
jpegls.h:41
FFMAX
#define FFMAX(a, b)
Definition:
common.h:64
avcodec.h
Libavcodec external API header.
JLSState::near
int near
Definition:
jpegls.h:43
FFMIN
#define FFMIN(a, b)
Definition:
common.h:66
FFABS
#define FFABS(a)
Definition:
common.h:61
JLSState::qbpp
int qbpp
Definition:
jpegls.h:42
JpeglsContext::avctx
AVCodecContext * avctx
Definition:
jpegls.h:36
ff_jpegls_reset_coding_parameters
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
Definition:
jpegls.c:62
AVCodecContext
main external API structure.
Definition:
avcodec.h:1241
JLSState::A
int A[367]
Definition:
jpegls.h:41
JLSState::T1
int T1
Definition:
jpegls.h:40
JLSState::range
int range
Definition:
jpegls.h:42
JLSState::N
int N[367]
Definition:
jpegls.h:41
state
static uint32_t state
Definition:
trasher.c:27
internal.h
common internal api header.
common.h
common internal and external API header
ff_jpegls_quantize
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
Definition:
jpegls.h:55
JLSState::T3
int T3
Definition:
jpegls.h:40
JLSState::run_index
int run_index[4]
Definition:
jpegls.h:44
ff_jpegls_downscale_state
static void ff_jpegls_downscale_state(JLSState *state, int Q)
Definition:
jpegls.h:87
Generated on Wed Jun 10 2015 01:56:43 for FFmpeg by
1.8.6