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
257fbc3a
Commit
257fbc3a
authored
Sep 21, 2016
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/dds: add support for 4bpp format
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
9d16e46d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
2 deletions
+36
-2
dds.c
libavcodec/dds.c
+36
-2
No files found.
libavcodec/dds.c
View file @
257fbc3a
...
...
@@ -102,6 +102,7 @@ typedef struct DDSContext {
int
compressed
;
int
paletted
;
int
bpp
;
enum
DDSPostProc
postproc
;
const
uint8_t
*
tex_data
;
// Compressed texture
...
...
@@ -148,7 +149,7 @@ static int parse_pixel_format(AVCodecContext *avctx)
ctx
->
paletted
=
0
;
}
bpp
=
bytestream2_get_le32
(
gbc
);
// rgbbitcount
bpp
=
ctx
->
bpp
=
bytestream2_get_le32
(
gbc
);
// rgbbitcount
r
=
bytestream2_get_le32
(
gbc
);
// rbitmask
g
=
bytestream2_get_le32
(
gbc
);
// gbitmask
b
=
bytestream2_get_le32
(
gbc
);
// bbitmask
...
...
@@ -354,8 +355,11 @@ static int parse_pixel_format(AVCodecContext *avctx)
return
AVERROR_INVALIDDATA
;
}
}
else
{
/* 4 bpp */
if
(
bpp
==
4
&&
r
==
0
&&
g
==
0
&&
b
==
0
&&
a
==
0
)
avctx
->
pix_fmt
=
AV_PIX_FMT_PAL8
;
/* 8 bpp */
if
(
bpp
==
8
&&
r
==
0xff
&&
g
==
0
&&
b
==
0
&&
a
==
0
)
else
if
(
bpp
==
8
&&
r
==
0xff
&&
g
==
0
&&
b
==
0
&&
a
==
0
)
avctx
->
pix_fmt
=
AV_PIX_FMT_GRAY8
;
else
if
(
bpp
==
8
&&
r
==
0
&&
g
==
0
&&
b
==
0
&&
a
==
0xff
)
avctx
->
pix_fmt
=
AV_PIX_FMT_GRAY8
;
...
...
@@ -676,6 +680,36 @@ static int dds_decode(AVCodecContext *avctx, void *data,
/* Use the decompress function on the texture, one block per thread. */
ctx
->
tex_data
=
gbc
->
buffer
;
avctx
->
execute2
(
avctx
,
decompress_texture_thread
,
frame
,
NULL
,
ctx
->
slice_count
);
}
else
if
(
!
ctx
->
paletted
&&
ctx
->
bpp
==
4
)
{
uint8_t
*
dst
=
frame
->
data
[
0
];
int
x
,
y
,
i
;
/* Use the first 64 bytes as palette, then copy the rest. */
bytestream2_get_buffer
(
gbc
,
frame
->
data
[
1
],
16
*
4
);
for
(
i
=
0
;
i
<
16
;
i
++
)
{
AV_WN32
(
frame
->
data
[
1
]
+
i
*
4
,
(
frame
->
data
[
1
][
2
+
i
*
4
]
<<
0
)
+
(
frame
->
data
[
1
][
1
+
i
*
4
]
<<
8
)
+
(
frame
->
data
[
1
][
0
+
i
*
4
]
<<
16
)
+
(
frame
->
data
[
1
][
3
+
i
*
4
]
<<
24
)
);
}
frame
->
palette_has_changed
=
1
;
if
(
bytestream2_get_bytes_left
(
gbc
)
<
frame
->
height
*
frame
->
width
/
2
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Buffer is too small (%d < %d).
\n
"
,
bytestream2_get_bytes_left
(
gbc
),
frame
->
height
*
frame
->
width
/
2
);
return
AVERROR_INVALIDDATA
;
}
for
(
y
=
0
;
y
<
frame
->
height
;
y
++
)
{
for
(
x
=
0
;
x
<
frame
->
width
;
x
+=
2
)
{
uint8_t
val
=
bytestream2_get_byte
(
gbc
);
dst
[
x
]
=
val
&
0xF
;
dst
[
x
+
1
]
=
val
>>
4
;
}
dst
+=
frame
->
linesize
[
0
];
}
}
else
{
int
linesize
=
av_image_get_linesize
(
avctx
->
pix_fmt
,
frame
->
width
,
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