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
9774145f
Commit
9774145f
authored
Feb 27, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exr: simplify decompression path
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
5c924c9b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
20 deletions
+35
-20
exr.c
libavcodec/exr.c
+35
-20
No files found.
libavcodec/exr.c
View file @
9774145f
...
...
@@ -199,10 +199,28 @@ static void reorder_pixels(uint8_t *src, uint8_t *dst, int size)
}
}
static
int
rle_uncompress
(
const
uint8_t
*
src
,
int
ssize
,
uint8_t
*
dst
,
int
dsize
)
static
int
zip_uncompress
(
const
uint8_t
*
src
,
int
compressed_size
,
int
uncompressed_size
,
EXRThreadData
*
td
)
{
int8_t
*
d
=
(
int8_t
*
)
dst
;
unsigned
long
dest_len
=
uncompressed_size
;
if
(
uncompress
(
td
->
tmp
,
&
dest_len
,
src
,
compressed_size
)
!=
Z_OK
||
dest_len
!=
uncompressed_size
)
return
AVERROR
(
EINVAL
);
predictor
(
td
->
tmp
,
uncompressed_size
);
reorder_pixels
(
td
->
tmp
,
td
->
uncompressed_data
,
uncompressed_size
);
return
0
;
}
static
int
rle_uncompress
(
const
uint8_t
*
src
,
int
compressed_size
,
int
uncompressed_size
,
EXRThreadData
*
td
)
{
int8_t
*
d
=
(
int8_t
*
)
td
->
tmp
;
const
int8_t
*
s
=
(
const
int8_t
*
)
src
;
int
ssize
=
compressed_size
;
int
dsize
=
uncompressed_size
;
int8_t
*
dend
=
d
+
dsize
;
int
count
;
...
...
@@ -232,7 +250,13 @@ static int rle_uncompress(const uint8_t *src, int ssize, uint8_t *dst, int dsize
}
}
return
dend
!=
d
;
if
(
dend
!=
d
)
return
AVERROR_INVALIDDATA
;
predictor
(
td
->
tmp
,
uncompressed_size
);
reorder_pixels
(
td
->
tmp
,
td
->
uncompressed_data
,
uncompressed_size
);
return
0
;
}
static
int
decode_block
(
AVCodecContext
*
avctx
,
void
*
tdata
,
...
...
@@ -251,7 +275,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
const
uint8_t
*
src
;
int
axmax
=
(
avctx
->
width
-
(
s
->
xmax
+
1
))
*
2
*
s
->
desc
->
nb_components
;
int
bxmin
=
s
->
xmin
*
2
*
s
->
desc
->
nb_components
;
int
i
,
x
,
buf_size
=
s
->
buf_size
;
int
ret
,
i
,
x
,
buf_size
=
s
->
buf_size
;
line_offset
=
AV_RL64
(
s
->
table
+
jobnr
*
8
);
// Check if the buffer has the required bytes needed from the offset
...
...
@@ -280,25 +304,16 @@ static int decode_block(AVCodecContext *avctx, void *tdata,
av_fast_padded_malloc
(
&
td
->
tmp
,
&
td
->
tmp_size
,
uncompressed_size
);
if
(
!
td
->
uncompressed_data
||
!
td
->
tmp
)
return
AVERROR
(
ENOMEM
);
}
if
((
s
->
compr
==
EXR_ZIP1
||
s
->
compr
==
EXR_ZIP16
)
&&
data_size
<
uncompressed_size
)
{
unsigned
long
dest_len
=
uncompressed_size
;
if
(
uncompress
(
td
->
tmp
,
&
dest_len
,
src
,
data_size
)
!=
Z_OK
||
dest_len
!=
uncompressed_size
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"error during zlib decompression
\n
"
);
return
AVERROR
(
EINVAL
);
}
}
else
if
(
s
->
compr
==
EXR_RLE
&&
data_size
<
uncompressed_size
)
{
if
(
rle_uncompress
(
src
,
data_size
,
td
->
tmp
,
uncompressed_size
))
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"error during rle decompression
\n
"
);
return
AVERROR
(
EINVAL
);
switch
(
s
->
compr
)
{
case
EXR_ZIP1
:
case
EXR_ZIP16
:
ret
=
zip_uncompress
(
src
,
data_size
,
uncompressed_size
,
td
);
break
;
case
EXR_RLE
:
ret
=
rle_uncompress
(
src
,
data_size
,
uncompressed_size
,
td
);
}
}
if
(
data_size
<
uncompressed_size
)
{
predictor
(
td
->
tmp
,
uncompressed_size
);
reorder_pixels
(
td
->
tmp
,
td
->
uncompressed_data
,
uncompressed_size
);
src
=
td
->
uncompressed_data
;
}
...
...
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