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
4c8c4f2d
Commit
4c8c4f2d
authored
Aug 29, 2019
by
Nick Renieris
Committed by
Paul B Mahol
Sep 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/tiff: Convert DNGs to sRGB color space
Signed-off-by:
Nick Renieris
<
velocityra@gmail.com
>
parent
c31c7089
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
tiff.c
libavcodec/tiff.c
+23
-11
No files found.
libavcodec/tiff.c
View file @
4c8c4f2d
...
@@ -731,14 +731,23 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
...
@@ -731,14 +731,23 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
return
0
;
return
0
;
}
}
static
float
av_always_inline
linear_to_srgb
(
float
value
)
{
if
(
value
<=
0
.
003130
8
f
)
return
value
*
12
.
92
f
;
else
return
powf
(
value
*
1
.
055
f
,
1
.
0
f
/
2
.
4
f
)
-
0
.
055
f
;
}
/**
/**
* Map stored raw sensor values into linear reference values
.
* Map stored raw sensor values into linear reference values
(see: DNG Specification - Chapter 5)
*
See: DNG Specification - Chapter 5
*
Then convert to sRGB color space.
*/
*/
static
uint16_t
av_always_inline
dng_raw_to_linear16
(
uint16_t
value
,
static
uint16_t
av_always_inline
dng_process_color16
(
uint16_t
value
,
const
uint16_t
*
lut
,
const
uint16_t
*
lut
,
uint16_t
black_level
,
uint16_t
black_level
,
float
scale_factor
)
{
float
scale_factor
)
{
float
value_norm
;
// Lookup table lookup
// Lookup table lookup
if
(
lut
)
if
(
lut
)
value
=
lut
[
value
];
value
=
lut
[
value
];
...
@@ -747,16 +756,19 @@ static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
...
@@ -747,16 +756,19 @@ static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
value
=
av_clip_uint16_c
((
unsigned
)
value
-
black_level
);
value
=
av_clip_uint16_c
((
unsigned
)
value
-
black_level
);
// Color scaling
// Color scaling
value
=
av_clip_uint16_c
((
unsigned
)(((
float
)
value
*
scale_factor
)
*
0xFFFF
));
value_norm
=
(
float
)
value
*
scale_factor
;
// Color space conversion (sRGB)
value
=
av_clip_uint16_c
((
uint16_t
)(
linear_to_srgb
(
value_norm
)
*
0xFFFF
));
return
value
;
return
value
;
}
}
static
uint16_t
av_always_inline
dng_
raw_to_linea
r8
(
uint16_t
value
,
static
uint16_t
av_always_inline
dng_
process_colo
r8
(
uint16_t
value
,
const
uint16_t
*
lut
,
const
uint16_t
*
lut
,
uint16_t
black_level
,
uint16_t
black_level
,
float
scale_factor
)
{
float
scale_factor
)
{
return
dng_
raw_to_linea
r16
(
value
,
lut
,
black_level
,
scale_factor
)
>>
8
;
return
dng_
process_colo
r16
(
value
,
lut
,
black_level
,
scale_factor
)
>>
8
;
}
}
static
void
dng_blit
(
TiffContext
*
s
,
uint8_t
*
dst
,
int
dst_stride
,
static
void
dng_blit
(
TiffContext
*
s
,
uint8_t
*
dst
,
int
dst_stride
,
...
@@ -774,7 +786,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
...
@@ -774,7 +786,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
uint16_t
*
src_u16
=
(
uint16_t
*
)
src
;
uint16_t
*
src_u16
=
(
uint16_t
*
)
src
;
for
(
col
=
0
;
col
<
width
;
col
++
)
for
(
col
=
0
;
col
<
width
;
col
++
)
*
dst_u16
++
=
dng_
raw_to_linea
r16
(
*
src_u16
++
,
s
->
dng_lut
,
s
->
black_level
,
scale_factor
);
*
dst_u16
++
=
dng_
process_colo
r16
(
*
src_u16
++
,
s
->
dng_lut
,
s
->
black_level
,
scale_factor
);
dst
+=
dst_stride
*
sizeof
(
uint16_t
);
dst
+=
dst_stride
*
sizeof
(
uint16_t
);
src
+=
src_stride
*
sizeof
(
uint16_t
);
src
+=
src_stride
*
sizeof
(
uint16_t
);
...
@@ -782,7 +794,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
...
@@ -782,7 +794,7 @@ static void dng_blit(TiffContext *s, uint8_t *dst, int dst_stride,
}
else
{
}
else
{
for
(
line
=
0
;
line
<
height
;
line
++
)
{
for
(
line
=
0
;
line
<
height
;
line
++
)
{
for
(
col
=
0
;
col
<
width
;
col
++
)
for
(
col
=
0
;
col
<
width
;
col
++
)
*
dst
++
=
dng_
raw_to_linea
r8
(
*
src
++
,
s
->
dng_lut
,
s
->
black_level
,
scale_factor
);
*
dst
++
=
dng_
process_colo
r8
(
*
src
++
,
s
->
dng_lut
,
s
->
black_level
,
scale_factor
);
dst
+=
dst_stride
;
dst
+=
dst_stride
;
src
+=
src_stride
;
src
+=
src_stride
;
...
...
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