Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
1b5cb6c0
Commit
1b5cb6c0
authored
May 27, 2013
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
j2k/jpeg2000: Partially merge quantization code
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
9a18395b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
16 deletions
+64
-16
j2k.c
libavcodec/j2k.c
+49
-9
j2k.h
libavcodec/j2k.h
+2
-1
j2kdec.c
libavcodec/j2kdec.c
+1
-1
j2kenc.c
libavcodec/j2kenc.c
+8
-1
jpeg2000.c
libavcodec/jpeg2000.c
+4
-4
No files found.
libavcodec/j2k.c
View file @
1b5cb6c0
...
...
@@ -173,10 +173,13 @@ void ff_j2k_set_significant(Jpeg2000T1Context *t1, int x, int y,
t1
->
flags
[
y
-
1
][
x
-
1
]
|=
JPEG2000_T1_SIG_SE
;
}
static
const
uint8_t
lut_gain
[
2
][
4
]
=
{
{
0
,
0
,
0
,
0
},
{
0
,
1
,
1
,
2
}
};
int
ff_j2k_init_component
(
Jpeg2000Component
*
comp
,
Jpeg2000CodingStyle
*
codsty
,
Jpeg2000QuantStyle
*
qntsty
,
int
cbps
,
int
dx
,
int
dy
)
int
cbps
,
int
dx
,
int
dy
,
AVCodecContext
*
avctx
)
{
uint8_t
log2_band_prec_width
,
log2_band_prec_height
;
int
reslevelno
,
bandno
,
gbandno
=
0
,
ret
,
i
,
j
,
csize
=
1
;
...
...
@@ -245,16 +248,53 @@ int ff_j2k_init_component(Jpeg2000Component *comp,
Jpeg2000Band
*
band
=
reslevel
->
band
+
bandno
;
int
cblkno
,
precno
;
int
nb_precincts
;
double
stepsize
;
if
(
qntsty
->
quantsty
!=
JPEG2000_QSTY_NONE
)
{
static
const
uint8_t
lut_gain
[
2
][
4
]
=
{{
0
,
0
,
0
,
0
},
{
0
,
1
,
1
,
2
}};
/* TODO: Implementation of quantization step not finished,
* see ISO/IEC 15444-1:2002 E.1 and A.6.4. */
switch
(
qntsty
->
quantsty
)
{
uint8_t
gain
;
int
numbps
;
numbps
=
cbps
+
lut_gain
[
codsty
->
transform
][
bandno
+
reslevelno
>
0
];
band
->
stepsize
=
SHL
(
2048
+
qntsty
->
mant
[
gbandno
],
2
+
numbps
-
qntsty
->
expn
[
gbandno
]);
}
else
band
->
stepsize
=
1
<<
13
;
case
JPEG2000_QSTY_NONE
:
/* TODO: to verify. No quantization in this case */
stepsize
=
1
;
break
;
case
JPEG2000_QSTY_SI
:
/*TODO: Compute formula to implement. */
numbps
=
cbps
+
lut_gain
[
codsty
->
transform
][
bandno
+
reslevelno
>
0
];
stepsize
=
SHL
(
2048
+
qntsty
->
mant
[
gbandno
],
2
+
numbps
-
qntsty
->
expn
[
gbandno
]);
break
;
case
JPEG2000_QSTY_SE
:
/* Exponent quantization step.
* Formula:
* delta_b = 2 ^ (R_b - expn_b) * (1 + (mant_b / 2 ^ 11))
* R_b = R_I + log2 (gain_b )
* see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */
/* TODO/WARN: value of log2 (gain_b ) not taken into account
* but it works (compared to OpenJPEG). Why?
* Further investigation needed. */
gain
=
cbps
;
stepsize
=
pow
(
2
.
0
,
gain
-
qntsty
->
expn
[
gbandno
]);
stepsize
*=
(
qntsty
->
mant
[
gbandno
]
/
2048
.
0
+
1
.
0
);
/* FIXME: In openjepg code stespize = stepsize * 0.5. Why?
* If not set output of entropic decoder is not correct. */
// stepsize *= 0.5;
break
;
default:
stepsize
=
0
;
av_log
(
avctx
,
AV_LOG_ERROR
,
"Unknown quantization format
\n
"
);
break
;
}
/* BITEXACT computing case --> convert to int */
// if (avctx->flags & CODEC_FLAG_BITEXACT)
band
->
stepsize
=
stepsize
*
(
1
<<
13
);
/* computation of tbx_0, tbx_1, tby_0, tby_1
* see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1
* codeblock width and height is computed for
* DCI JPEG 2000 codeblock_width = codeblock_width = 32 = 2 ^ 5 */
if
(
reslevelno
==
0
)
{
/* for reslevelno = 0, only one band, x0_b = y0_b = 0 */
for
(
i
=
0
;
i
<
2
;
i
++
)
...
...
libavcodec/j2k.h
View file @
1b5cb6c0
...
...
@@ -252,7 +252,8 @@ static inline int ff_jpeg2000_getsgnctxno(int flag, int *xorbit)
int
ff_j2k_init_component
(
Jpeg2000Component
*
comp
,
Jpeg2000CodingStyle
*
codsty
,
Jpeg2000QuantStyle
*
qntsty
,
int
cbps
,
int
dx
,
int
dy
);
int
cbps
,
int
dx
,
int
dy
,
AVCodecContext
*
avctx
);
void
ff_j2k_reinit
(
Jpeg2000Component
*
comp
,
Jpeg2000CodingStyle
*
codsty
);
void
ff_j2k_cleanup
(
Jpeg2000Component
*
comp
,
Jpeg2000CodingStyle
*
codsty
);
...
...
libavcodec/j2kdec.c
View file @
1b5cb6c0
...
...
@@ -439,7 +439,7 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
comp
->
coord
[
1
][
0
]
=
FFMAX
(
tiley
*
s
->
tile_height
+
s
->
tile_offset_y
,
s
->
image_offset_y
);
comp
->
coord
[
1
][
1
]
=
FFMIN
((
tiley
+
1
)
*
s
->
tile_height
+
s
->
tile_offset_y
,
s
->
height
);
if
(
ret
=
ff_j2k_init_component
(
comp
,
codsty
,
qntsty
,
s
->
cbps
[
compno
],
s
->
cdx
[
compno
],
s
->
cdy
[
compno
]))
if
(
ret
=
ff_j2k_init_component
(
comp
,
codsty
,
qntsty
,
s
->
cbps
[
compno
],
s
->
cdx
[
compno
],
s
->
cdy
[
compno
]
,
s
->
avctx
))
return
ret
;
}
return
0
;
...
...
libavcodec/j2kenc.c
View file @
1b5cb6c0
...
...
@@ -366,7 +366,14 @@ static int init_tiles(Jpeg2000EncoderContext *s)
for
(
j
=
0
;
j
<
2
;
j
++
)
comp
->
coord
[
i
][
j
]
=
ff_jpeg2000_ceildivpow2
(
comp
->
coord
[
i
][
j
],
s
->
chroma_shift
[
i
]);
if
(
ret
=
ff_j2k_init_component
(
comp
,
codsty
,
qntsty
,
s
->
cbps
[
compno
],
compno
?
1
<<
s
->
chroma_shift
[
0
]
:
1
,
compno
?
1
<<
s
->
chroma_shift
[
1
]
:
1
))
if
(
ret
=
ff_j2k_init_component
(
comp
,
codsty
,
qntsty
,
s
->
cbps
[
compno
],
compno
?
1
<<
s
->
chroma_shift
[
0
]
:
1
,
compno
?
1
<<
s
->
chroma_shift
[
1
]
:
1
,
s
->
avctx
))
return
ret
;
}
}
...
...
libavcodec/jpeg2000.c
View file @
1b5cb6c0
...
...
@@ -267,15 +267,15 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
int
numbps
;
case
JPEG2000_QSTY_NONE
:
/* TODO: to verify. No quantization in this case */
band
->
stepsize
=
(
float
)
(
1
<<
13
);
break
;
case
JPEG2000_QSTY_SI
:
/*TODO: Compute formula to implement. */
numbps
=
cbps
+
lut_gain
[
codsty
->
transform
][
bandno
+
reslevelno
>
0
];
band
->
stepsize
=
(
float
)
SHL
(
2048
+
qntsty
->
mant
[
gbandno
],
2
+
numbps
-
qntsty
->
expn
[
gbandno
]);
break
;
case
JPEG2000_QSTY_SI
:
/*TODO: Compute formula to implement. */
band
->
stepsize
=
(
float
)
(
1
<<
13
);
break
;
case
JPEG2000_QSTY_SE
:
/* Exponent quantization step.
* Formula:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment