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
aa16bbaf
Commit
aa16bbaf
authored
Jul 01, 2013
by
Michael Niedermayer
Committed by
Luca Barbato
Jul 02, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jpeg2000: Refactor SOT marker parsing
Signed-off-by:
Luca Barbato
<
lu_zero@gentoo.org
>
parent
daeb4e30
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
26 deletions
+18
-26
jpeg2000dec.c
libavcodec/jpeg2000dec.c
+18
-26
No files found.
libavcodec/jpeg2000dec.c
View file @
aa16bbaf
...
...
@@ -41,9 +41,8 @@
#define HAD_QCC 0x02
typedef
struct
Jpeg2000TilePart
{
uint16_t
tp_idx
;
// Tile-part index
uint8_t
tile_index
;
// Tile index who refers the tile-part
uint32_t
tp_len
;
// Length of tile-part
const
uint8_t
*
tp_end
;
GetByteContext
tpg
;
// bit stream in tile-part
}
Jpeg2000TilePart
;
...
...
@@ -55,6 +54,7 @@ typedef struct Jpeg2000Tile {
Jpeg2000CodingStyle
codsty
[
4
];
Jpeg2000QuantStyle
qntsty
[
4
];
Jpeg2000TilePart
tile_part
[
3
];
uint16_t
tp_idx
;
// Tile-part index
}
Jpeg2000Tile
;
typedef
struct
Jpeg2000DecoderContext
{
...
...
@@ -503,24 +503,18 @@ static int get_sot(Jpeg2000DecoderContext *s, int n)
return
AVERROR_PATCHWELCOME
;
}
tp
=
s
->
tile
[
s
->
curtileno
].
tile_part
+
TPsot
;
s
->
tile
[
Isot
].
tp_idx
=
TPsot
;
tp
=
s
->
tile
[
Isot
].
tile_part
+
TPsot
;
tp
->
tile_index
=
Isot
;
tp
->
tp_len
=
Psot
;
tp
->
tp_idx
=
TPsot
;
/* Start of bit stream. Pointer to SOD marker
* Check SOD marker is present. */
if
(
JPEG2000_SOD
==
bytestream2_get_be16
(
&
s
->
g
))
{
bytestream2_init
(
&
tp
->
tpg
,
s
->
g
.
buffer
,
tp
->
tp_len
-
n
-
4
);
bytestream2_skip
(
&
s
->
g
,
tp
->
tp_len
-
n
-
4
);
}
else
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"SOD marker not found
\n
"
);
return
AVERROR_INVALIDDATA
;
}
tp
->
tp_end
=
s
->
g
.
buffer
+
Psot
-
n
-
2
;
/* End address of bit stream =
* start address + (Psot - size of SOT HEADER(n)
* - size of SOT MARKER(2) - size of SOD marker(2) */
if
(
!
TPsot
)
{
Jpeg2000Tile
*
tile
=
s
->
tile
+
s
->
curtileno
;
/* copy defaults */
memcpy
(
tile
->
codsty
,
s
->
codsty
,
s
->
ncomponents
*
sizeof
(
Jpeg2000CodingStyle
));
memcpy
(
tile
->
qntsty
,
s
->
qntsty
,
s
->
ncomponents
*
sizeof
(
Jpeg2000QuantStyle
));
}
return
0
;
}
...
...
@@ -577,12 +571,6 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno)
if
(
!
tile
->
comp
)
return
AVERROR
(
ENOMEM
);
/* copy codsty, qnsty to tile. TODO: Is it the best way?
* codsty, qnsty is an array of 4 structs Jpeg2000CodingStyle
* and Jpeg2000QuantStyle */
memcpy
(
tile
->
codsty
,
s
->
codsty
,
s
->
ncomponents
*
sizeof
(
*
tile
->
codsty
));
memcpy
(
tile
->
qntsty
,
s
->
qntsty
,
s
->
ncomponents
*
sizeof
(
*
tile
->
qntsty
));
for
(
compno
=
0
;
compno
<
s
->
ncomponents
;
compno
++
)
{
Jpeg2000Component
*
comp
=
tile
->
comp
+
compno
;
Jpeg2000CodingStyle
*
codsty
=
tile
->
codsty
+
compno
;
...
...
@@ -1269,7 +1257,11 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
ret
=
get_qcd
(
s
,
len
,
qntsty
,
properties
);
break
;
case
JPEG2000_SOT
:
ret
=
get_sot
(
s
,
len
);
if
(
!
(
ret
=
get_sot
(
s
,
len
)))
{
codsty
=
s
->
tile
[
s
->
curtileno
].
codsty
;
qntsty
=
s
->
tile
[
s
->
curtileno
].
qntsty
;
properties
=
s
->
tile
[
s
->
curtileno
].
properties
;
}
break
;
case
JPEG2000_COM
:
// the comment is ignored
...
...
@@ -1286,7 +1278,7 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
bytestream2_skip
(
&
s
->
g
,
len
-
2
);
break
;
}
if
(
((
bytestream2_tell
(
&
s
->
g
)
-
oldpos
!=
len
)
&&
(
marker
!=
JPEG2000_SOT
))
||
ret
)
{
if
(
bytestream2_tell
(
&
s
->
g
)
-
oldpos
!=
len
||
ret
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error during processing marker segment %.4x
\n
"
,
marker
);
return
ret
?
ret
:
-
1
;
...
...
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