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
3f714d1f
Commit
3f714d1f
authored
May 30, 2013
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jpeg2000/j2k: merge non functional changes
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
941a8efa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
28 deletions
+33
-28
j2kdec.c
libavcodec/j2kdec.c
+30
-27
jpeg2000dec.c
libavcodec/jpeg2000dec.c
+3
-1
No files found.
libavcodec/j2kdec.c
View file @
3f714d1f
...
@@ -213,6 +213,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
...
@@ -213,6 +213,7 @@ static int get_siz(Jpeg2000DecoderContext *s)
s
->
reduction_factor
);
s
->
reduction_factor
);
s
->
avctx
->
height
=
ff_jpeg2000_ceildivpow2
(
s
->
height
-
s
->
image_offset_y
,
s
->
avctx
->
height
=
ff_jpeg2000_ceildivpow2
(
s
->
height
-
s
->
image_offset_y
,
s
->
reduction_factor
);
s
->
reduction_factor
);
switch
(
s
->
ncomponents
)
{
switch
(
s
->
ncomponents
)
{
case
1
:
case
1
:
if
(
s
->
precision
>
8
)
if
(
s
->
precision
>
8
)
...
@@ -426,7 +427,7 @@ static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
...
@@ -426,7 +427,7 @@ static int get_qcc(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q,
return
get_qcx
(
s
,
n
-
1
,
q
+
compno
);
return
get_qcx
(
s
,
n
-
1
,
q
+
compno
);
}
}
/*
*
get start of tile segment */
/* get start of tile segment */
static
int
get_sot
(
Jpeg2000DecoderContext
*
s
)
static
int
get_sot
(
Jpeg2000DecoderContext
*
s
)
{
{
if
(
bytestream2_get_bytes_left
(
&
s
->
g
)
<
8
)
if
(
bytestream2_get_bytes_left
(
&
s
->
g
)
<
8
)
...
@@ -525,7 +526,7 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
...
@@ -525,7 +526,7 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
return
0
;
return
0
;
}
}
/*
*
read the number of coding passes */
/* read the number of coding passes */
static
int
getnpasses
(
Jpeg2000DecoderContext
*
s
)
static
int
getnpasses
(
Jpeg2000DecoderContext
*
s
)
{
{
int
num
;
int
num
;
...
@@ -552,10 +553,10 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
...
@@ -552,10 +553,10 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
return
res
;
return
res
;
}
}
static
int
decode_packet
(
Jpeg2000DecoderContext
*
s
,
static
int
jpeg2000_
decode_packet
(
Jpeg2000DecoderContext
*
s
,
Jpeg2000CodingStyle
*
codsty
,
Jpeg2000CodingStyle
*
codsty
,
Jpeg2000ResLevel
*
rlevel
,
int
precno
,
Jpeg2000ResLevel
*
rlevel
,
int
precno
,
int
layno
,
uint8_t
*
expn
,
int
numgbits
)
int
layno
,
uint8_t
*
expn
,
int
numgbits
)
{
{
int
bandno
,
cblkno
,
ret
,
nb_code_blocks
;
int
bandno
,
cblkno
,
ret
,
nb_code_blocks
;
...
@@ -653,14 +654,13 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
...
@@ -653,14 +654,13 @@ static int jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
Jpeg2000ResLevel
*
rlevel
=
tile
->
comp
[
compno
].
reslevel
+
Jpeg2000ResLevel
*
rlevel
=
tile
->
comp
[
compno
].
reslevel
+
reslevelno
;
reslevelno
;
ok_reslevel
=
1
;
ok_reslevel
=
1
;
for
(
precno
=
0
;
precno
<
rlevel
->
num_precincts_x
*
rlevel
->
num_precincts_y
;
precno
++
)
{
for
(
precno
=
0
;
precno
<
rlevel
->
num_precincts_x
*
rlevel
->
num_precincts_y
;
precno
++
)
if
(
decode_packet
(
s
,
if
(
jpeg2000_
decode_packet
(
s
,
codsty
,
rlevel
,
codsty
,
rlevel
,
precno
,
layno
,
precno
,
layno
,
qntsty
->
expn
+
(
reslevelno
?
3
*
(
reslevelno
-
1
)
+
1
:
0
),
qntsty
->
expn
+
(
reslevelno
?
3
*
(
reslevelno
-
1
)
+
1
:
0
),
qntsty
->
nguardbits
))
qntsty
->
nguardbits
))
return
-
1
;
return
-
1
;
}
}
}
}
}
}
}
...
@@ -691,7 +691,8 @@ static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height,
...
@@ -691,7 +691,8 @@ static void decode_sigpass(Jpeg2000T1Context *t1, int width, int height,
t1
->
data
[
y
][
x
]
=
(
ff_mqc_decode
(
&
t1
->
mqc
,
t1
->
mqc
.
cx_states
+
ctxno
)
^
xorbit
)
?
t1
->
data
[
y
][
x
]
=
(
ff_mqc_decode
(
&
t1
->
mqc
,
t1
->
mqc
.
cx_states
+
ctxno
)
^
xorbit
)
?
-
mask
:
mask
;
-
mask
:
mask
;
ff_jpeg2000_set_significance
(
t1
,
x
,
y
,
t1
->
data
[
y
][
x
]
<
0
);
ff_jpeg2000_set_significance
(
t1
,
x
,
y
,
t1
->
data
[
y
][
x
]
<
0
);
}
}
t1
->
flags
[
y
+
1
][
x
+
1
]
|=
JPEG2000_T1_VIS
;
t1
->
flags
[
y
+
1
][
x
+
1
]
|=
JPEG2000_T1_VIS
;
}
}
...
@@ -792,7 +793,7 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
...
@@ -792,7 +793,7 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
int
vert_causal_ctx_csty_symbol
=
JPEG2000_CBLK_VSC
&
codsty
->
cblk_style
;
int
vert_causal_ctx_csty_symbol
=
JPEG2000_CBLK_VSC
&
codsty
->
cblk_style
;
for
(
y
=
0
;
y
<
height
+
2
;
y
++
)
for
(
y
=
0
;
y
<
height
+
2
;
y
++
)
memset
(
t1
->
flags
[
y
],
0
,
(
width
+
2
)
*
sizeof
(
int
));
memset
(
t1
->
flags
[
y
],
0
,
(
width
+
2
)
*
sizeof
(
int
));
for
(
y
=
0
;
y
<
height
;
y
++
)
for
(
y
=
0
;
y
<
height
;
y
++
)
memset
(
t1
->
data
[
y
],
0
,
width
*
sizeof
(
int
));
memset
(
t1
->
data
[
y
],
0
,
width
*
sizeof
(
int
));
...
@@ -804,16 +805,16 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
...
@@ -804,16 +805,16 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
while
(
passno
--
)
{
while
(
passno
--
)
{
switch
(
pass_t
)
{
switch
(
pass_t
)
{
case
0
:
case
0
:
decode_sigpass
(
t1
,
width
,
height
,
bpno
+
1
,
bandpos
,
decode_sigpass
(
t1
,
width
,
height
,
bpno
+
1
,
bandpos
,
bpass_csty_symbol
&&
(
clnpass_cnt
>=
4
),
vert_causal_ctx_csty_symbol
);
bpass_csty_symbol
&&
(
clnpass_cnt
>=
4
),
vert_causal_ctx_csty_symbol
);
break
;
break
;
case
1
:
case
1
:
decode_refpass
(
t1
,
width
,
height
,
bpno
+
1
);
decode_refpass
(
t1
,
width
,
height
,
bpno
+
1
);
if
(
bpass_csty_symbol
&&
clnpass_cnt
>=
4
)
if
(
bpass_csty_symbol
&&
clnpass_cnt
>=
4
)
ff_mqc_initdec
(
&
t1
->
mqc
,
cblk
->
data
);
ff_mqc_initdec
(
&
t1
->
mqc
,
cblk
->
data
);
break
;
break
;
case
2
:
case
2
:
decode_clnpass
(
s
,
t1
,
width
,
height
,
bpno
+
1
,
bandpos
,
decode_clnpass
(
s
,
t1
,
width
,
height
,
bpno
+
1
,
bandpos
,
codsty
->
cblk_style
&
JPEG2000_CBLK_SEGSYM
,
vert_causal_ctx_csty_symbol
);
codsty
->
cblk_style
&
JPEG2000_CBLK_SEGSYM
,
vert_causal_ctx_csty_symbol
);
clnpass_cnt
=
clnpass_cnt
+
1
;
clnpass_cnt
=
clnpass_cnt
+
1
;
if
(
bpass_csty_symbol
&&
clnpass_cnt
>=
4
)
if
(
bpass_csty_symbol
&&
clnpass_cnt
>=
4
)
...
@@ -921,15 +922,16 @@ static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
...
@@ -921,15 +922,16 @@ static void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
*
src
[
1
]
++
=
i1
;
*
src
[
1
]
++
=
i1
;
*
src
[
2
]
++
=
i2
;
*
src
[
2
]
++
=
i2
;
}
}
break
;
}
}
}
}
static
int
decode_tile
(
Jpeg2000DecoderContext
*
s
,
Jpeg2000Tile
*
tile
,
static
int
jpeg2000_decode_tile
(
Jpeg2000DecoderContext
*
s
,
Jpeg2000Tile
*
tile
,
AVFrame
*
picture
)
AVFrame
*
picture
)
)
{
{
int
compno
,
reslevelno
,
bandno
;
int
compno
,
reslevelno
,
bandno
;
int
x
,
y
;
int
x
,
y
;
uint8_t
*
line
;
uint8_t
*
line
;
Jpeg2000T1Context
t1
;
Jpeg2000T1Context
t1
;
...
@@ -1066,14 +1068,16 @@ static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
...
@@ -1066,14 +1068,16 @@ static void jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
av_freep
(
&
s
->
tile
);
av_freep
(
&
s
->
tile
);
}
}
static
int
decode_codestream
(
Jpeg2000DecoderContext
*
s
)
static
int
jpeg2000_
decode_codestream
(
Jpeg2000DecoderContext
*
s
)
{
{
Jpeg2000CodingStyle
*
codsty
=
s
->
codsty
;
Jpeg2000CodingStyle
*
codsty
=
s
->
codsty
;
Jpeg2000QuantStyle
*
qntsty
=
s
->
qntsty
;
Jpeg2000QuantStyle
*
qntsty
=
s
->
qntsty
;
uint8_t
*
properties
=
s
->
properties
;
uint8_t
*
properties
=
s
->
properties
;
for
(;;)
{
for
(;;)
{
int
oldpos
,
marker
,
len
,
ret
=
0
;
int
len
,
ret
=
0
;
int
marker
;
int
oldpos
;
if
(
bytestream2_get_bytes_left
(
&
s
->
g
)
<
2
)
{
if
(
bytestream2_get_bytes_left
(
&
s
->
g
)
<
2
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Missing EOC
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Missing EOC
\n
"
);
...
@@ -1081,7 +1085,6 @@ static int decode_codestream(Jpeg2000DecoderContext *s)
...
@@ -1081,7 +1085,6 @@ static int decode_codestream(Jpeg2000DecoderContext *s)
}
}
marker
=
bytestream2_get_be16u
(
&
s
->
g
);
marker
=
bytestream2_get_be16u
(
&
s
->
g
);
av_dlog
(
s
->
avctx
,
"marker 0x%.4X at pos 0x%x
\n
"
,
marker
,
bytestream2_tell
(
&
s
->
g
)
-
4
);
oldpos
=
bytestream2_tell
(
&
s
->
g
);
oldpos
=
bytestream2_tell
(
&
s
->
g
);
if
(
marker
==
JPEG2000_SOD
)
{
if
(
marker
==
JPEG2000_SOD
)
{
...
@@ -1137,7 +1140,7 @@ static int decode_codestream(Jpeg2000DecoderContext *s)
...
@@ -1137,7 +1140,7 @@ static int decode_codestream(Jpeg2000DecoderContext *s)
break
;
break
;
default:
default:
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"unsupported marker 0x%.4X at pos 0x%
x
\n
"
,
"unsupported marker 0x%.4X at pos 0x%
X
\n
"
,
marker
,
bytestream2_tell
(
&
s
->
g
)
-
4
);
marker
,
bytestream2_tell
(
&
s
->
g
)
-
4
);
bytestream2_skip
(
&
s
->
g
,
len
-
2
);
bytestream2_skip
(
&
s
->
g
,
len
-
2
);
break
;
break
;
...
@@ -1214,11 +1217,11 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
...
@@ -1214,11 +1217,11 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
ret
=
-
1
;
ret
=
-
1
;
goto
err_out
;
goto
err_out
;
}
}
if
(
ret
=
decode_codestream
(
s
))
if
(
ret
=
jpeg2000_
decode_codestream
(
s
))
goto
err_out
;
goto
err_out
;
for
(
tileno
=
0
;
tileno
<
s
->
numXtiles
*
s
->
numYtiles
;
tileno
++
)
for
(
tileno
=
0
;
tileno
<
s
->
numXtiles
*
s
->
numYtiles
;
tileno
++
)
if
(
ret
=
decode_tile
(
s
,
s
->
tile
+
tileno
,
s
->
picture
))
if
(
ret
=
jpeg2000_
decode_tile
(
s
,
s
->
tile
+
tileno
,
s
->
picture
))
goto
err_out
;
goto
err_out
;
jpeg2000_dec_cleanup
(
s
);
jpeg2000_dec_cleanup
(
s
);
...
...
libavcodec/jpeg2000dec.c
View file @
3f714d1f
...
@@ -601,6 +601,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
...
@@ -601,6 +601,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s,
if
(
band
->
coord
[
0
][
0
]
==
band
->
coord
[
0
][
1
]
||
if
(
band
->
coord
[
0
][
0
]
==
band
->
coord
[
0
][
1
]
||
band
->
coord
[
1
][
0
]
==
band
->
coord
[
1
][
1
])
band
->
coord
[
1
][
0
]
==
band
->
coord
[
1
][
1
])
continue
;
continue
;
nb_code_blocks
=
prec
->
nb_codeblocks_height
*
nb_code_blocks
=
prec
->
nb_codeblocks_height
*
prec
->
nb_codeblocks_width
;
prec
->
nb_codeblocks_width
;
for
(
cblkno
=
0
;
cblkno
<
nb_code_blocks
;
cblkno
++
)
{
for
(
cblkno
=
0
;
cblkno
<
nb_code_blocks
;
cblkno
++
)
{
...
@@ -1020,8 +1021,8 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
...
@@ -1020,8 +1021,8 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
uint8_t
*
line
;
uint8_t
*
line
;
Jpeg2000T1Context
t1
;
Jpeg2000T1Context
t1
;
/* Loop on tile components */
/* Loop on tile components */
for
(
compno
=
0
;
compno
<
s
->
ncomponents
;
compno
++
)
{
for
(
compno
=
0
;
compno
<
s
->
ncomponents
;
compno
++
)
{
Jpeg2000Component
*
comp
=
tile
->
comp
+
compno
;
Jpeg2000Component
*
comp
=
tile
->
comp
+
compno
;
Jpeg2000CodingStyle
*
codsty
=
tile
->
codsty
+
compno
;
Jpeg2000CodingStyle
*
codsty
=
tile
->
codsty
+
compno
;
...
@@ -1075,6 +1076,7 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
...
@@ -1075,6 +1076,7 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
Jpeg2000Component
*
comp
=
tile
->
comp
+
compno
;
Jpeg2000Component
*
comp
=
tile
->
comp
+
compno
;
float
*
datap
=
comp
->
f_data
;
float
*
datap
=
comp
->
f_data
;
int32_t
*
i_datap
=
comp
->
i_data
;
int32_t
*
i_datap
=
comp
->
i_data
;
y
=
tile
->
comp
[
compno
].
coord
[
1
][
0
]
-
s
->
image_offset_y
;
y
=
tile
->
comp
[
compno
].
coord
[
1
][
0
]
-
s
->
image_offset_y
;
line
=
picture
->
data
[
0
]
+
y
*
picture
->
linesize
[
0
];
line
=
picture
->
data
[
0
]
+
y
*
picture
->
linesize
[
0
];
for
(;
y
<
tile
->
comp
[
compno
].
coord
[
1
][
1
]
-
s
->
image_offset_y
;
y
+=
s
->
cdy
[
compno
])
{
for
(;
y
<
tile
->
comp
[
compno
].
coord
[
1
][
1
]
-
s
->
image_offset_y
;
y
+=
s
->
cdy
[
compno
])
{
...
...
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