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
f86f39cb
Commit
f86f39cb
authored
Dec 17, 2014
by
Paul B Mahol
Committed by
Vittorio Giovara
Jan 14, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tiff: support decoding GBRP and GBRAP formats
Signed-off-by:
Vittorio Giovara
<
vittorio.giovara@gmail.com
>
parent
92806167
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
57 deletions
+81
-57
tiff.c
libavcodec/tiff.c
+81
-57
No files found.
libavcodec/tiff.c
View file @
f86f39cb
...
@@ -52,6 +52,7 @@ typedef struct TiffContext {
...
@@ -52,6 +52,7 @@ typedef struct TiffContext {
int
le
;
int
le
;
enum
TiffCompr
compr
;
enum
TiffCompr
compr
;
enum
TiffPhotometric
photometric
;
enum
TiffPhotometric
photometric
;
int
planar
;
int
fax_opts
;
int
fax_opts
;
int
predictor
;
int
predictor
;
int
fill_order
;
int
fill_order
;
...
@@ -172,6 +173,9 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
...
@@ -172,6 +173,9 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
int
c
,
line
,
pixels
,
code
,
ret
;
int
c
,
line
,
pixels
,
code
,
ret
;
int
width
=
((
s
->
width
*
s
->
bpp
)
+
7
)
>>
3
;
int
width
=
((
s
->
width
*
s
->
bpp
)
+
7
)
>>
3
;
if
(
s
->
planar
)
width
/=
s
->
bppcount
;
if
(
size
<=
0
)
if
(
size
<=
0
)
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
...
@@ -248,7 +252,7 @@ static int init_image(TiffContext *s, AVFrame *frame)
...
@@ -248,7 +252,7 @@ static int init_image(TiffContext *s, AVFrame *frame)
{
{
int
ret
;
int
ret
;
switch
(
s
->
bpp
*
10
+
s
->
bppcount
)
{
switch
(
s
->
planar
*
1000
+
s
->
bpp
*
10
+
s
->
bppcount
)
{
case
11
:
case
11
:
s
->
avctx
->
pix_fmt
=
AV_PIX_FMT_MONOBLACK
;
s
->
avctx
->
pix_fmt
=
AV_PIX_FMT_MONOBLACK
;
break
;
break
;
...
@@ -276,6 +280,18 @@ static int init_image(TiffContext *s, AVFrame *frame)
...
@@ -276,6 +280,18 @@ static int init_image(TiffContext *s, AVFrame *frame)
case
644
:
case
644
:
s
->
avctx
->
pix_fmt
=
s
->
le
?
AV_PIX_FMT_RGBA64LE
:
AV_PIX_FMT_RGBA64BE
;
s
->
avctx
->
pix_fmt
=
s
->
le
?
AV_PIX_FMT_RGBA64LE
:
AV_PIX_FMT_RGBA64BE
;
break
;
break
;
case
1243
:
s
->
avctx
->
pix_fmt
=
AV_PIX_FMT_GBRP
;
break
;
case
1324
:
s
->
avctx
->
pix_fmt
=
AV_PIX_FMT_GBRAP
;
break
;
case
1483
:
s
->
avctx
->
pix_fmt
=
s
->
le
?
AV_PIX_FMT_GBRP16LE
:
AV_PIX_FMT_GBRP16BE
;
break
;
case
1644
:
s
->
avctx
->
pix_fmt
=
s
->
le
?
AV_PIX_FMT_GBRAP16LE
:
AV_PIX_FMT_GBRAP16BE
;
break
;
default:
default:
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"This format is not supported (bpp=%d, bppcount=%d)
\n
"
,
"This format is not supported (bpp=%d, bppcount=%d)
\n
"
,
...
@@ -507,10 +523,7 @@ static int tiff_decode_tag(TiffContext *s)
...
@@ -507,10 +523,7 @@ static int tiff_decode_tag(TiffContext *s)
break
;
break
;
}
}
case
TIFF_PLANAR
:
case
TIFF_PLANAR
:
if
(
value
==
2
)
{
s
->
planar
=
value
==
2
;
avpriv_report_missing_feature
(
s
->
avctx
,
"Planar format"
);
return
AVERROR_PATCHWELCOME
;
}
break
;
break
;
case
TIFF_T4OPTIONS
:
case
TIFF_T4OPTIONS
:
if
(
s
->
compr
==
TIFF_G3
)
if
(
s
->
compr
==
TIFF_G3
)
...
@@ -538,7 +551,7 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -538,7 +551,7 @@ static int decode_frame(AVCodecContext *avctx,
TiffContext
*
const
s
=
avctx
->
priv_data
;
TiffContext
*
const
s
=
avctx
->
priv_data
;
AVFrame
*
const
p
=
data
;
AVFrame
*
const
p
=
data
;
unsigned
off
;
unsigned
off
;
int
id
,
le
,
ret
;
int
id
,
le
,
ret
,
plane
,
planes
;
int
i
,
j
,
entries
,
stride
;
int
i
,
j
,
entries
,
stride
;
unsigned
soff
,
ssize
;
unsigned
soff
,
ssize
;
uint8_t
*
dst
;
uint8_t
*
dst
;
...
@@ -596,8 +609,6 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -596,8 +609,6 @@ static int decode_frame(AVCodecContext *avctx,
av_log
(
avctx
,
AV_LOG_WARNING
,
"Image data size missing
\n
"
);
av_log
(
avctx
,
AV_LOG_WARNING
,
"Image data size missing
\n
"
);
s
->
stripsize
=
avpkt
->
size
-
s
->
stripoff
;
s
->
stripsize
=
avpkt
->
size
-
s
->
stripoff
;
}
}
stride
=
p
->
linesize
[
0
];
dst
=
p
->
data
[
0
];
if
(
s
->
stripsizesoff
)
{
if
(
s
->
stripsizesoff
)
{
if
(
s
->
stripsizesoff
>=
avpkt
->
size
)
if
(
s
->
stripsizesoff
>=
avpkt
->
size
)
...
@@ -612,6 +623,10 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -612,6 +623,10 @@ static int decode_frame(AVCodecContext *avctx,
avpkt
->
size
-
s
->
strippos
);
avpkt
->
size
-
s
->
strippos
);
}
}
planes
=
s
->
planar
?
s
->
bppcount
:
1
;
for
(
plane
=
0
;
plane
<
planes
;
plane
++
)
{
stride
=
p
->
linesize
[
plane
];
dst
=
p
->
data
[
plane
];
for
(
i
=
0
;
i
<
s
->
height
;
i
+=
s
->
rps
)
{
for
(
i
=
0
;
i
<
s
->
height
;
i
+=
s
->
rps
)
{
if
(
s
->
stripsizesoff
)
if
(
s
->
stripsizesoff
)
ssize
=
tget
(
&
stripsizes
,
s
->
sstype
,
le
);
ssize
=
tget
(
&
stripsizes
,
s
->
sstype
,
le
);
...
@@ -636,7 +651,7 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -636,7 +651,7 @@ static int decode_frame(AVCodecContext *avctx,
dst
+=
s
->
rps
*
stride
;
dst
+=
s
->
rps
*
stride
;
}
}
if
(
s
->
predictor
==
2
)
{
if
(
s
->
predictor
==
2
)
{
dst
=
p
->
data
[
0
];
dst
=
p
->
data
[
plane
];
soff
=
s
->
bpp
>>
3
;
soff
=
s
->
bpp
>>
3
;
ssize
=
s
->
width
*
soff
;
ssize
=
s
->
width
*
soff
;
if
(
s
->
avctx
->
pix_fmt
==
AV_PIX_FMT_RGB48LE
||
if
(
s
->
avctx
->
pix_fmt
==
AV_PIX_FMT_RGB48LE
||
...
@@ -663,13 +678,22 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -663,13 +678,22 @@ static int decode_frame(AVCodecContext *avctx,
}
}
if
(
s
->
photometric
==
TIFF_PHOTOMETRIC_WHITE_IS_ZERO
)
{
if
(
s
->
photometric
==
TIFF_PHOTOMETRIC_WHITE_IS_ZERO
)
{
dst
=
p
->
data
[
0
];
dst
=
p
->
data
[
plane
];
for
(
i
=
0
;
i
<
s
->
height
;
i
++
)
{
for
(
i
=
0
;
i
<
s
->
height
;
i
++
)
{
for
(
j
=
0
;
j
<
p
->
linesize
[
0
]
;
j
++
)
for
(
j
=
0
;
j
<
stride
;
j
++
)
dst
[
j
]
=
255
-
dst
[
j
];
dst
[
j
]
=
255
-
dst
[
j
];
dst
+=
stride
;
dst
+=
stride
;
}
}
}
}
}
if
(
s
->
planar
&&
s
->
bppcount
>
2
)
{
FFSWAP
(
uint8_t
*
,
p
->
data
[
0
],
p
->
data
[
2
]);
FFSWAP
(
int
,
p
->
linesize
[
0
],
p
->
linesize
[
2
]);
FFSWAP
(
uint8_t
*
,
p
->
data
[
0
],
p
->
data
[
1
]);
FFSWAP
(
int
,
p
->
linesize
[
0
],
p
->
linesize
[
1
]);
}
*
got_frame
=
1
;
*
got_frame
=
1
;
return
avpkt
->
size
;
return
avpkt
->
size
;
...
...
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