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
ea604de9
Commit
ea604de9
authored
Jan 30, 2012
by
Carl Eugen Hoyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify "deloco" and support decoding of 48bit loco png.
parent
f0d6828d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
53 deletions
+31
-53
pngdec.c
libavcodec/pngdec.c
+31
-53
No files found.
libavcodec/pngdec.c
View file @
ea604de9
...
@@ -260,46 +260,21 @@ static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
...
@@ -260,46 +260,21 @@ static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type,
}
}
}
}
static
av_always_inline
void
convert_to_rgb32_loco
(
uint8_t
*
dst
,
const
uint8_t
*
src
,
int
width
,
int
loco
)
/* This used to be called "deloco" in FFmpeg
{
* and is actually an inverse reversible colorspace transformation */
int
j
;
#define YUV2RGB(NAME, TYPE) \
unsigned
int
r
,
g
,
b
,
a
;
static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
{ \
for
(
j
=
0
;
j
<
width
;
j
++
)
{
int i; \
r
=
src
[
0
];
for (i = 0; i < size; i += 3 + alpha) { \
g
=
src
[
1
];
int g = dst [i+1]; \
b
=
src
[
2
];
dst[i+0] += g; \
a
=
src
[
3
];
dst[i+2] += g; \
if
(
loco
)
{
} \
r
=
(
r
+
g
)
&
0xff
;
b
=
(
b
+
g
)
&
0xff
;
}
dst
[
0
]
=
r
;
dst
[
1
]
=
g
;
dst
[
2
]
=
b
;
dst
[
3
]
=
a
;
dst
+=
4
;
src
+=
4
;
}
}
}
static
void
convert_to_rgb32
(
uint8_t
*
dst
,
const
uint8_t
*
src
,
int
width
,
int
loco
)
YUV2RGB
(
rgb8
,
uint8_t
)
{
YUV2RGB
(
rgb16
,
uint16_t
)
if
(
loco
)
convert_to_rgb32_loco
(
dst
,
src
,
width
,
1
);
else
memcpy
(
dst
,
src
,
width
*
4
);
}
static
void
deloco_rgb24
(
uint8_t
*
dst
,
int
size
)
{
int
i
;
for
(
i
=
0
;
i
<
size
;
i
+=
3
)
{
int
g
=
dst
[
i
+
1
];
dst
[
i
+
0
]
+=
g
;
dst
[
i
+
2
]
+=
g
;
}
}
/* process exactly one decompressed row */
/* process exactly one decompressed row */
static
void
png_handle_row
(
PNGDecContext
*
s
)
static
void
png_handle_row
(
PNGDecContext
*
s
)
...
@@ -309,14 +284,6 @@ static void png_handle_row(PNGDecContext *s)
...
@@ -309,14 +284,6 @@ static void png_handle_row(PNGDecContext *s)
if
(
!
s
->
interlace_type
)
{
if
(
!
s
->
interlace_type
)
{
ptr
=
s
->
image_buf
+
s
->
image_linesize
*
s
->
y
;
ptr
=
s
->
image_buf
+
s
->
image_linesize
*
s
->
y
;
/* need to swap bytes correctly for RGB_ALPHA */
if
(
s
->
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
)
{
png_filter_row
(
s
,
s
->
tmp_row
,
s
->
crow_buf
[
0
],
s
->
crow_buf
+
1
,
s
->
last_row
,
s
->
row_size
,
s
->
bpp
);
convert_to_rgb32
(
ptr
,
s
->
tmp_row
,
s
->
width
,
s
->
filter_type
==
PNG_FILTER_TYPE_LOCO
);
FFSWAP
(
uint8_t
*
,
s
->
last_row
,
s
->
tmp_row
);
}
else
{
/* in normal case, we avoid one copy */
if
(
s
->
y
==
0
)
if
(
s
->
y
==
0
)
last_row
=
s
->
last_row
;
last_row
=
s
->
last_row
;
else
else
...
@@ -324,17 +291,28 @@ static void png_handle_row(PNGDecContext *s)
...
@@ -324,17 +291,28 @@ static void png_handle_row(PNGDecContext *s)
png_filter_row
(
s
,
ptr
,
s
->
crow_buf
[
0
],
s
->
crow_buf
+
1
,
png_filter_row
(
s
,
ptr
,
s
->
crow_buf
[
0
],
s
->
crow_buf
+
1
,
last_row
,
s
->
row_size
,
s
->
bpp
);
last_row
,
s
->
row_size
,
s
->
bpp
);
}
/* loco lags by 1 row so that it doesn't interfere with top prediction */
/* loco lags by 1 row so that it doesn't interfere with top prediction */
if
(
s
->
filter_type
==
PNG_FILTER_TYPE_LOCO
&&
if
(
s
->
filter_type
==
PNG_FILTER_TYPE_LOCO
&&
s
->
y
>
0
)
{
s
->
color_type
==
PNG_COLOR_TYPE_RGB
&&
s
->
y
>
0
)
if
(
s
->
bit_depth
==
16
)
{
deloco_rgb24
(
ptr
-
s
->
image_linesize
,
s
->
row_size
);
deloco_rgb16
((
uint16_t
*
)(
ptr
-
s
->
image_linesize
),
s
->
row_size
/
2
,
s
->
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
);
}
else
{
deloco_rgb8
(
ptr
-
s
->
image_linesize
,
s
->
row_size
,
s
->
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
);
}
}
s
->
y
++
;
s
->
y
++
;
if
(
s
->
y
==
s
->
height
)
{
if
(
s
->
y
==
s
->
height
)
{
s
->
state
|=
PNG_ALLIMAGE
;
s
->
state
|=
PNG_ALLIMAGE
;
if
(
s
->
filter_type
==
PNG_FILTER_TYPE_LOCO
&&
if
(
s
->
filter_type
==
PNG_FILTER_TYPE_LOCO
)
{
s
->
color_type
==
PNG_COLOR_TYPE_RGB
)
if
(
s
->
bit_depth
==
16
)
{
deloco_rgb24
(
ptr
,
s
->
row_size
);
deloco_rgb16
((
uint16_t
*
)
ptr
,
s
->
row_size
/
2
,
s
->
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
);
}
else
{
deloco_rgb8
(
ptr
,
s
->
row_size
,
s
->
color_type
==
PNG_COLOR_TYPE_RGB_ALPHA
);
}
}
}
}
}
else
{
}
else
{
got_line
=
0
;
got_line
=
0
;
...
...
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