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
de5e71fb
Commit
de5e71fb
authored
Dec 14, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/tiff: add support for 12bit grayscale images
Fixes #4688.
parent
092cb179
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
tiff.c
libavcodec/tiff.c
+29
-0
No files found.
libavcodec/tiff.c
View file @
de5e71fb
...
...
@@ -310,6 +310,19 @@ static int deinvert_buffer(TiffContext *s, const uint8_t *src, int size)
return
0
;
}
static
void
unpack_gray
(
TiffContext
*
s
,
AVFrame
*
p
,
const
uint8_t
*
src
,
int
lnum
,
int
width
,
int
bpp
)
{
GetBitContext
gb
;
uint16_t
*
dst
=
(
uint16_t
*
)(
p
->
data
[
0
]
+
lnum
*
p
->
linesize
[
0
]);
init_get_bits8
(
&
gb
,
src
,
width
);
for
(
int
i
=
0
;
i
<
s
->
width
;
i
++
)
{
dst
[
i
]
=
get_bits
(
&
gb
,
bpp
);
}
}
static
void
unpack_yuv
(
TiffContext
*
s
,
AVFrame
*
p
,
const
uint8_t
*
src
,
int
lnum
)
{
...
...
@@ -540,6 +553,15 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
if
(
s
->
is_bayer
)
{
width
=
(
s
->
bpp
*
s
->
width
+
7
)
>>
3
;
}
if
(
p
->
format
==
AV_PIX_FMT_GRAY12
)
{
av_fast_padded_malloc
(
&
s
->
yuv_line
,
&
s
->
yuv_line_size
,
width
);
if
(
s
->
yuv_line
==
NULL
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Not enough memory
\n
"
);
return
AVERROR
(
ENOMEM
);
}
dst
=
s
->
yuv_line
;
stride
=
0
;
}
if
(
s
->
compr
==
TIFF_DEFLATE
||
s
->
compr
==
TIFF_ADOBE_DEFLATE
)
{
#if CONFIG_ZLIB
...
...
@@ -587,6 +609,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
if
(
is_yuv
)
{
unpack_yuv
(
s
,
p
,
dst
,
strip_start
+
line
);
line
+=
s
->
subsampling
[
1
]
-
1
;
}
else
if
(
p
->
format
==
AV_PIX_FMT_GRAY12
)
{
unpack_gray
(
s
,
p
,
dst
,
strip_start
+
line
,
width
,
s
->
bpp
);
}
dst
+=
stride
;
}
...
...
@@ -670,6 +694,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
if
(
is_yuv
)
{
unpack_yuv
(
s
,
p
,
dst
,
strip_start
+
line
);
line
+=
s
->
subsampling
[
1
]
-
1
;
}
else
if
(
p
->
format
==
AV_PIX_FMT_GRAY12
)
{
unpack_gray
(
s
,
p
,
dst
,
strip_start
+
line
,
width
,
s
->
bpp
);
}
dst
+=
stride
;
}
...
...
@@ -705,6 +731,9 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
case
81
:
s
->
avctx
->
pix_fmt
=
s
->
palette_is_set
?
AV_PIX_FMT_PAL8
:
AV_PIX_FMT_GRAY8
;
break
;
case
121
:
s
->
avctx
->
pix_fmt
=
AV_PIX_FMT_GRAY12
;
break
;
case
10081
:
switch
(
AV_RL32
(
s
->
pattern
))
{
case
0x02010100
:
...
...
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