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
1b709f23
Commit
1b709f23
authored
Sep 11, 2015
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jpeg2000: Refactor decode_packets
Move the packet-specific parsers in separate functions.
parent
29b00f88
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
65 deletions
+83
-65
jpeg2000dec.c
libavcodec/jpeg2000dec.c
+83
-65
No files found.
libavcodec/jpeg2000dec.c
View file @
1b709f23
...
...
@@ -732,85 +732,103 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
return
0
;
}
static
int
jpeg2000_decode_packets
(
Jpeg2000DecoderContext
*
s
,
Jpeg2000Tile
*
tile
)
static
int
decode_pgod_lrcp
(
Jpeg2000DecoderContext
*
s
,
Jpeg2000Tile
*
tile
)
{
int
ret
=
0
;
int
layno
,
reslevelno
,
compno
,
precno
,
ok_reslevel
;
int
x
,
y
;
s
->
bit_index
=
8
;
switch
(
tile
->
codsty
[
0
].
prog_order
)
{
case
JPEG2000_PGOD_LRCP
:
for
(
layno
=
0
;
layno
<
tile
->
codsty
[
0
].
nlayers
;
layno
++
)
{
ok_reslevel
=
1
;
for
(
reslevelno
=
0
;
ok_reslevel
;
reslevelno
++
)
{
ok_reslevel
=
0
;
for
(
compno
=
0
;
compno
<
s
->
ncomponents
;
compno
++
)
{
Jpeg2000CodingStyle
*
codsty
=
tile
->
codsty
+
compno
;
Jpeg2000QuantStyle
*
qntsty
=
tile
->
qntsty
+
compno
;
if
(
reslevelno
<
codsty
->
nreslevels
)
{
Jpeg2000ResLevel
*
rlevel
=
tile
->
comp
[
compno
].
reslevel
+
reslevelno
;
ok_reslevel
=
1
;
for
(
precno
=
0
;
precno
<
rlevel
->
num_precincts_x
*
rlevel
->
num_precincts_y
;
precno
++
)
if
((
ret
=
jpeg2000_decode_packet
(
s
,
codsty
,
rlevel
,
precno
,
layno
,
qntsty
->
expn
+
(
reslevelno
?
3
*
(
reslevelno
-
1
)
+
1
:
0
),
qntsty
->
nguardbits
))
<
0
)
return
ret
;
}
int
ret
;
for
(
layno
=
0
;
layno
<
tile
->
codsty
[
0
].
nlayers
;
layno
++
)
{
ok_reslevel
=
1
;
for
(
reslevelno
=
0
;
ok_reslevel
;
reslevelno
++
)
{
ok_reslevel
=
0
;
for
(
compno
=
0
;
compno
<
s
->
ncomponents
;
compno
++
)
{
Jpeg2000CodingStyle
*
codsty
=
tile
->
codsty
+
compno
;
Jpeg2000QuantStyle
*
qntsty
=
tile
->
qntsty
+
compno
;
if
(
reslevelno
<
codsty
->
nreslevels
)
{
Jpeg2000ResLevel
*
rlevel
=
tile
->
comp
[
compno
].
reslevel
+
reslevelno
;
ok_reslevel
=
1
;
for
(
precno
=
0
;
precno
<
rlevel
->
num_precincts_x
*
rlevel
->
num_precincts_y
;
precno
++
)
if
((
ret
=
jpeg2000_decode_packet
(
s
,
codsty
,
rlevel
,
precno
,
layno
,
qntsty
->
expn
+
(
reslevelno
?
3
*
(
reslevelno
-
1
)
+
1
:
0
),
qntsty
->
nguardbits
))
<
0
)
return
ret
;
}
}
}
break
;
}
case
JPEG2000_PGOD_CPRL
:
for
(
compno
=
0
;
compno
<
s
->
ncomponents
;
compno
++
)
{
Jpeg2000CodingStyle
*
codsty
=
tile
->
codsty
+
compno
;
Jpeg2000QuantStyle
*
qntsty
=
tile
->
qntsty
+
compno
;
return
0
;
}
/* Set bit stream buffer address according to tile-part.
* For DCinema one tile-part per component, so can be
* indexed by component. */
s
->
g
=
tile
->
tile_part
[
compno
].
tpg
;
static
int
decode_pgod_cprl
(
Jpeg2000DecoderContext
*
s
,
Jpeg2000Tile
*
tile
)
{
int
layno
,
reslevelno
,
compno
,
precno
;
int
ret
,
x
,
y
;
for
(
compno
=
0
;
compno
<
s
->
ncomponents
;
compno
++
)
{
Jpeg2000CodingStyle
*
codsty
=
tile
->
codsty
+
compno
;
Jpeg2000QuantStyle
*
qntsty
=
tile
->
qntsty
+
compno
;
/* Set bit stream buffer address according to tile-part.
* For DCinema one tile-part per component, so can be
* indexed by component. */
s
->
g
=
tile
->
tile_part
[
compno
].
tpg
;
/* Position loop (y axis)
* TODO: Automate computing of step 256.
* Fixed here, but to be computed before entering here. */
for
(
y
=
0
;
y
<
s
->
height
;
y
+=
256
)
{
/* Position loop (y axis)
* TODO:
A
utomate computing of step 256.
* TODO:
a
utomate computing of step 256.
* Fixed here, but to be computed before entering here. */
for
(
y
=
0
;
y
<
s
->
height
;
y
+=
256
)
{
/* Position loop (y axis)
* TODO: automate computing of step 256.
* Fixed here, but to be computed before entering here. */
for
(
x
=
0
;
x
<
s
->
width
;
x
+=
256
)
{
for
(
reslevelno
=
0
;
reslevelno
<
codsty
->
nreslevels
;
reslevelno
++
)
{
uint16_t
prcx
,
prcy
;
uint8_t
reducedresno
=
codsty
->
nreslevels
-
1
-
reslevelno
;
// ==> N_L - r
Jpeg2000ResLevel
*
rlevel
=
tile
->
comp
[
compno
].
reslevel
+
reslevelno
;
if
(
!
((
y
%
(
1
<<
(
rlevel
->
log2_prec_height
+
reducedresno
))
==
0
)
||
(
y
==
0
)))
// TODO: 2nd condition simplified as try0 always =0 for dcinema
continue
;
if
(
!
((
x
%
(
1
<<
(
rlevel
->
log2_prec_width
+
reducedresno
))
==
0
)
||
(
x
==
0
)))
// TODO: 2nd condition simplified as try0 always =0 for dcinema
continue
;
// check if a precinct exists
prcx
=
ff_jpeg2000_ceildivpow2
(
x
,
reducedresno
)
>>
rlevel
->
log2_prec_width
;
prcy
=
ff_jpeg2000_ceildivpow2
(
y
,
reducedresno
)
>>
rlevel
->
log2_prec_height
;
precno
=
prcx
+
rlevel
->
num_precincts_x
*
prcy
;
for
(
layno
=
0
;
layno
<
tile
->
codsty
[
0
].
nlayers
;
layno
++
)
{
if
((
ret
=
jpeg2000_decode_packet
(
s
,
codsty
,
rlevel
,
precno
,
layno
,
qntsty
->
expn
+
(
reslevelno
?
3
*
(
reslevelno
-
1
)
+
1
:
0
),
qntsty
->
nguardbits
))
<
0
)
return
ret
;
}
for
(
x
=
0
;
x
<
s
->
width
;
x
+=
256
)
{
for
(
reslevelno
=
0
;
reslevelno
<
codsty
->
nreslevels
;
reslevelno
++
)
{
uint16_t
prcx
,
prcy
;
uint8_t
reducedresno
=
codsty
->
nreslevels
-
1
-
reslevelno
;
// ==> N_L - r
Jpeg2000ResLevel
*
rlevel
=
tile
->
comp
[
compno
].
reslevel
+
reslevelno
;
if
(
!
((
y
%
(
1
<<
(
rlevel
->
log2_prec_height
+
reducedresno
))
==
0
)
||
(
y
==
0
)))
// TODO: 2nd condition simplified as try0 always =0 for dcinema
continue
;
if
(
!
((
x
%
(
1
<<
(
rlevel
->
log2_prec_width
+
reducedresno
))
==
0
)
||
(
x
==
0
)))
// TODO: 2nd condition simplified as try0 always =0 for dcinema
continue
;
// check if a precinct exists
prcx
=
ff_jpeg2000_ceildivpow2
(
x
,
reducedresno
)
>>
rlevel
->
log2_prec_width
;
prcy
=
ff_jpeg2000_ceildivpow2
(
y
,
reducedresno
)
>>
rlevel
->
log2_prec_height
;
precno
=
prcx
+
rlevel
->
num_precincts_x
*
prcy
;
for
(
layno
=
0
;
layno
<
tile
->
codsty
[
0
].
nlayers
;
layno
++
)
{
if
((
ret
=
jpeg2000_decode_packet
(
s
,
codsty
,
rlevel
,
precno
,
layno
,
qntsty
->
expn
+
(
reslevelno
?
3
*
(
reslevelno
-
1
)
+
1
:
0
),
qntsty
->
nguardbits
))
<
0
)
return
ret
;
}
}
}
}
}
return
0
;
}
static
int
jpeg2000_decode_packets
(
Jpeg2000DecoderContext
*
s
,
Jpeg2000Tile
*
tile
)
{
int
ret
=
0
;
s
->
bit_index
=
8
;
switch
(
tile
->
codsty
[
0
].
prog_order
)
{
case
JPEG2000_PGOD_LRCP
:
ret
=
decode_pgod_lrcp
(
s
,
tile
);
break
;
case
JPEG2000_PGOD_CPRL
:
ret
=
decode_pgod_cprl
(
s
,
tile
);
break
;
case
JPEG2000_PGOD_RLCP
:
...
...
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