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
570fcaf3
Commit
570fcaf3
authored
Sep 14, 2015
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jpeg2000: Factor out prec init
Makes debugging a little simpler.
parent
95a41311
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
96 deletions
+112
-96
jpeg2000.c
libavcodec/jpeg2000.c
+112
-96
No files found.
libavcodec/jpeg2000.c
View file @
570fcaf3
...
...
@@ -244,78 +244,15 @@ static void init_band_stepsize(AVCodecContext *avctx,
band
->
i_stepsize
=
band
->
f_stepsize
*
(
1
<<
16
);
}
static
int
init_
band
(
AVCodecContext
*
avctx
,
static
int
init_
prec
(
Jpeg2000Band
*
band
,
Jpeg2000ResLevel
*
reslevel
,
Jpeg2000Component
*
comp
,
Jpeg2000CodingStyle
*
codsty
,
Jpeg2000QuantStyle
*
qntsty
,
int
bandno
,
int
gbandno
,
int
reslevelno
,
int
cbps
,
int
dx
,
int
dy
)
int
precno
,
int
bandno
,
int
reslevelno
,
int
log2_band_prec_width
,
int
log2_band_prec_height
)
{
Jpeg2000Band
*
band
=
reslevel
->
band
+
bandno
;
uint8_t
log2_band_prec_width
,
log2_band_prec_height
;
int
declvl
=
codsty
->
nreslevels
-
reslevelno
;
// N_L -r see ISO/IEC 15444-1:2002 B.5
int
cblkno
,
precno
;
int
nb_precincts
;
int
i
,
j
;
init_band_stepsize
(
avctx
,
band
,
codsty
,
qntsty
,
bandno
,
gbandno
,
reslevelno
,
cbps
);
/* 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
++
)
for
(
j
=
0
;
j
<
2
;
j
++
)
band
->
coord
[
i
][
j
]
=
ff_jpeg2000_ceildivpow2
(
comp
->
coord_o
[
i
][
j
]
-
comp
->
coord_o
[
i
][
0
],
declvl
-
1
);
log2_band_prec_width
=
reslevel
->
log2_prec_width
;
log2_band_prec_height
=
reslevel
->
log2_prec_height
;
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
band
->
log2_cblk_width
=
FFMIN
(
codsty
->
log2_cblk_width
,
reslevel
->
log2_prec_width
);
band
->
log2_cblk_height
=
FFMIN
(
codsty
->
log2_cblk_height
,
reslevel
->
log2_prec_height
);
}
else
{
/* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */
/* x0_b and y0_b are computed with ((bandno + 1 >> i) & 1) */
for
(
i
=
0
;
i
<
2
;
i
++
)
for
(
j
=
0
;
j
<
2
;
j
++
)
/* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */
band
->
coord
[
i
][
j
]
=
ff_jpeg2000_ceildivpow2
(
comp
->
coord_o
[
i
][
j
]
-
comp
->
coord_o
[
i
][
0
]
-
(((
bandno
+
1
>>
i
)
&
1
)
<<
declvl
-
1
),
declvl
);
/* TODO: Manage case of 3 band offsets here or
* in coding/decoding function? */
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
band
->
log2_cblk_width
=
FFMIN
(
codsty
->
log2_cblk_width
,
reslevel
->
log2_prec_width
-
1
);
band
->
log2_cblk_height
=
FFMIN
(
codsty
->
log2_cblk_height
,
reslevel
->
log2_prec_height
-
1
);
log2_band_prec_width
=
reslevel
->
log2_prec_width
-
1
;
log2_band_prec_height
=
reslevel
->
log2_prec_height
-
1
;
}
for
(
j
=
0
;
j
<
2
;
j
++
)
band
->
coord
[
0
][
j
]
=
ff_jpeg2000_ceildiv
(
band
->
coord
[
0
][
j
],
dx
);
for
(
j
=
0
;
j
<
2
;
j
++
)
band
->
coord
[
1
][
j
]
=
ff_jpeg2000_ceildiv
(
band
->
coord
[
1
][
j
],
dy
);
nb_precincts
=
reslevel
->
num_precincts_x
*
reslevel
->
num_precincts_y
;
band
->
prec
=
av_mallocz_array
(
nb_precincts
,
sizeof
(
*
band
->
prec
));
if
(
!
band
->
prec
)
return
AVERROR
(
ENOMEM
);
for
(
precno
=
0
;
precno
<
nb_precincts
;
precno
++
)
{
Jpeg2000Prec
*
prec
=
band
->
prec
+
precno
;
int
nb_codeblocks
;
int
nb_codeblocks
,
cblkno
;
/* TODO: Explain formula for JPEG200 DCINEMA. */
/* TODO: Verify with previous count of codeblocks per band */
...
...
@@ -408,6 +345,85 @@ static int init_band(AVCodecContext *avctx,
cblk
->
lengthinc
=
0
;
cblk
->
npasses
=
0
;
}
return
0
;
}
static
int
init_band
(
AVCodecContext
*
avctx
,
Jpeg2000ResLevel
*
reslevel
,
Jpeg2000Component
*
comp
,
Jpeg2000CodingStyle
*
codsty
,
Jpeg2000QuantStyle
*
qntsty
,
int
bandno
,
int
gbandno
,
int
reslevelno
,
int
cbps
,
int
dx
,
int
dy
)
{
Jpeg2000Band
*
band
=
reslevel
->
band
+
bandno
;
uint8_t
log2_band_prec_width
,
log2_band_prec_height
;
int
declvl
=
codsty
->
nreslevels
-
reslevelno
;
// N_L -r see ISO/IEC 15444-1:2002 B.5
int
precno
;
int
nb_precincts
;
int
i
,
j
,
ret
;
init_band_stepsize
(
avctx
,
band
,
codsty
,
qntsty
,
bandno
,
gbandno
,
reslevelno
,
cbps
);
/* 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
++
)
for
(
j
=
0
;
j
<
2
;
j
++
)
band
->
coord
[
i
][
j
]
=
ff_jpeg2000_ceildivpow2
(
comp
->
coord_o
[
i
][
j
]
-
comp
->
coord_o
[
i
][
0
],
declvl
-
1
);
log2_band_prec_width
=
reslevel
->
log2_prec_width
;
log2_band_prec_height
=
reslevel
->
log2_prec_height
;
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
band
->
log2_cblk_width
=
FFMIN
(
codsty
->
log2_cblk_width
,
reslevel
->
log2_prec_width
);
band
->
log2_cblk_height
=
FFMIN
(
codsty
->
log2_cblk_height
,
reslevel
->
log2_prec_height
);
}
else
{
/* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */
/* x0_b and y0_b are computed with ((bandno + 1 >> i) & 1) */
for
(
i
=
0
;
i
<
2
;
i
++
)
for
(
j
=
0
;
j
<
2
;
j
++
)
/* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */
band
->
coord
[
i
][
j
]
=
ff_jpeg2000_ceildivpow2
(
comp
->
coord_o
[
i
][
j
]
-
comp
->
coord_o
[
i
][
0
]
-
(((
bandno
+
1
>>
i
)
&
1
)
<<
declvl
-
1
),
declvl
);
/* TODO: Manage case of 3 band offsets here or
* in coding/decoding function? */
/* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
band
->
log2_cblk_width
=
FFMIN
(
codsty
->
log2_cblk_width
,
reslevel
->
log2_prec_width
-
1
);
band
->
log2_cblk_height
=
FFMIN
(
codsty
->
log2_cblk_height
,
reslevel
->
log2_prec_height
-
1
);
log2_band_prec_width
=
reslevel
->
log2_prec_width
-
1
;
log2_band_prec_height
=
reslevel
->
log2_prec_height
-
1
;
}
for
(
j
=
0
;
j
<
2
;
j
++
)
band
->
coord
[
0
][
j
]
=
ff_jpeg2000_ceildiv
(
band
->
coord
[
0
][
j
],
dx
);
for
(
j
=
0
;
j
<
2
;
j
++
)
band
->
coord
[
1
][
j
]
=
ff_jpeg2000_ceildiv
(
band
->
coord
[
1
][
j
],
dy
);
nb_precincts
=
reslevel
->
num_precincts_x
*
reslevel
->
num_precincts_y
;
band
->
prec
=
av_mallocz_array
(
nb_precincts
,
sizeof
(
*
band
->
prec
));
if
(
!
band
->
prec
)
return
AVERROR
(
ENOMEM
);
for
(
precno
=
0
;
precno
<
nb_precincts
;
precno
++
)
{
ret
=
init_prec
(
band
,
reslevel
,
comp
,
precno
,
bandno
,
reslevelno
,
log2_band_prec_width
,
log2_band_prec_height
);
if
(
ret
<
0
)
return
ret
;
}
return
0
;
...
...
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