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
5f5e37e0
Commit
5f5e37e0
authored
Aug 23, 2011
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support decoding of 2bpp and 4bpp TIFF images.
Based on patches by Kostya and ami_stuff.
parent
4ca6a151
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
3 deletions
+32
-3
tiff.c
libavcodec/tiff.c
+32
-3
No files found.
libavcodec/tiff.c
View file @
5f5e37e0
...
@@ -102,6 +102,33 @@ static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src,
...
@@ -102,6 +102,33 @@ static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src,
}
}
#endif
#endif
static
void
av_always_inline
horizontal_fill
(
unsigned
int
bpp
,
uint8_t
*
dst
,
int
usePtr
,
const
uint8_t
*
src
,
uint8_t
c
,
int
width
,
int
offset
)
{
int
i
;
if
(
bpp
==
2
)
{
for
(
i
=
0
;
i
<
width
;
i
++
)
{
dst
[(
i
+
offset
)
*
4
+
0
]
=
(
usePtr
?
src
[
i
]
:
c
)
>>
6
;
dst
[(
i
+
offset
)
*
4
+
1
]
=
(
usePtr
?
src
[
i
]
:
c
)
>>
4
&
0x3
;
dst
[(
i
+
offset
)
*
4
+
2
]
=
(
usePtr
?
src
[
i
]
:
c
)
>>
2
&
0x3
;
dst
[(
i
+
offset
)
*
4
+
3
]
=
(
usePtr
?
src
[
i
]
:
c
)
&
0x3
;
}
}
else
if
(
bpp
==
4
)
{
for
(
i
=
0
;
i
<
width
;
i
++
)
{
dst
[(
i
+
offset
)
*
2
+
0
]
=
(
usePtr
?
src
[
i
]
:
c
)
>>
4
;
dst
[(
i
+
offset
)
*
2
+
1
]
=
(
usePtr
?
src
[
i
]
:
c
)
&
0xF
;
}
}
else
{
if
(
usePtr
)
{
memcpy
(
dst
+
offset
,
src
,
width
);
}
else
{
memset
(
dst
+
offset
,
c
,
width
);
}
}
}
static
int
tiff_unpack_strip
(
TiffContext
*
s
,
uint8_t
*
dst
,
int
stride
,
const
uint8_t
*
src
,
int
size
,
int
lines
){
static
int
tiff_unpack_strip
(
TiffContext
*
s
,
uint8_t
*
dst
,
int
stride
,
const
uint8_t
*
src
,
int
size
,
int
lines
){
int
c
,
line
,
pixels
,
code
;
int
c
,
line
,
pixels
,
code
;
const
uint8_t
*
ssrc
=
src
;
const
uint8_t
*
ssrc
=
src
;
...
@@ -173,7 +200,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
...
@@ -173,7 +200,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
switch
(
s
->
compr
){
switch
(
s
->
compr
){
case
TIFF_RAW
:
case
TIFF_RAW
:
if
(
!
s
->
fill_order
)
{
if
(
!
s
->
fill_order
)
{
memcpy
(
dst
,
src
,
width
);
horizontal_fill
(
s
->
bpp
,
dst
,
1
,
src
,
0
,
width
,
0
);
}
else
{
}
else
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
width
;
i
++
)
for
(
i
=
0
;
i
<
width
;
i
++
)
...
@@ -190,7 +217,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
...
@@ -190,7 +217,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Copy went out of bounds
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Copy went out of bounds
\n
"
);
return
-
1
;
return
-
1
;
}
}
memcpy
(
dst
+
pixels
,
src
,
code
);
horizontal_fill
(
s
->
bpp
,
dst
,
1
,
src
,
0
,
code
,
pixels
);
src
+=
code
;
src
+=
code
;
pixels
+=
code
;
pixels
+=
code
;
}
else
if
(
code
!=
-
128
){
// -127..-1
}
else
if
(
code
!=
-
128
){
// -127..-1
...
@@ -200,7 +227,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
...
@@ -200,7 +227,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
return
-
1
;
return
-
1
;
}
}
c
=
*
src
++
;
c
=
*
src
++
;
memset
(
dst
+
pixels
,
c
,
code
);
horizontal_fill
(
s
->
bpp
,
dst
,
0
,
NULL
,
c
,
code
,
pixels
);
pixels
+=
code
;
pixels
+=
code
;
}
}
}
}
...
@@ -227,6 +254,8 @@ static int init_image(TiffContext *s)
...
@@ -227,6 +254,8 @@ static int init_image(TiffContext *s)
case
11
:
case
11
:
s
->
avctx
->
pix_fmt
=
PIX_FMT_MONOBLACK
;
s
->
avctx
->
pix_fmt
=
PIX_FMT_MONOBLACK
;
break
;
break
;
case
21
:
case
41
:
case
81
:
case
81
:
s
->
avctx
->
pix_fmt
=
PIX_FMT_PAL8
;
s
->
avctx
->
pix_fmt
=
PIX_FMT_PAL8
;
break
;
break
;
...
...
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