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
770ac75a
Commit
770ac75a
authored
Feb 21, 2017
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/qdrw: add support for 2bpp and 4bpp packed pallette format
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
4e6b4455
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
114 additions
and
0 deletions
+114
-0
qdrw.c
libavcodec/qdrw.c
+114
-0
No files found.
libavcodec/qdrw.c
View file @
770ac75a
...
@@ -68,6 +68,114 @@ static int parse_palette(AVCodecContext *avctx, GetByteContext *gbc,
...
@@ -68,6 +68,114 @@ static int parse_palette(AVCodecContext *avctx, GetByteContext *gbc,
return
0
;
return
0
;
}
}
static
int
decode_rle_bpp2
(
AVCodecContext
*
avctx
,
AVFrame
*
p
,
GetByteContext
*
gbc
)
{
int
offset
=
avctx
->
width
;
uint8_t
*
outdata
=
p
->
data
[
0
];
int
i
,
j
;
for
(
i
=
0
;
i
<
avctx
->
height
;
i
++
)
{
int
size
,
left
,
code
,
pix
;
uint8_t
*
out
=
outdata
;
int
pos
=
0
;
/* size of packed line */
size
=
left
=
bytestream2_get_be16
(
gbc
);
if
(
bytestream2_get_bytes_left
(
gbc
)
<
size
)
return
AVERROR_INVALIDDATA
;
/* decode line */
while
(
left
>
0
)
{
code
=
bytestream2_get_byte
(
gbc
);
if
(
code
&
0x80
)
{
/* run */
pix
=
bytestream2_get_byte
(
gbc
);
for
(
j
=
0
;
j
<
257
-
code
;
j
++
)
{
out
[
pos
++
]
=
(
pix
&
0xC0
)
>>
6
;
out
[
pos
++
]
=
(
pix
&
0x30
)
>>
4
;
out
[
pos
++
]
=
(
pix
&
0x0C
)
>>
2
;
out
[
pos
++
]
=
(
pix
&
0x03
);
if
(
pos
>=
offset
)
{
pos
-=
offset
;
pos
++
;
}
if
(
pos
>=
offset
)
return
AVERROR_INVALIDDATA
;
}
left
-=
2
;
}
else
{
/* copy */
for
(
j
=
0
;
j
<
code
+
1
;
j
++
)
{
pix
=
bytestream2_get_byte
(
gbc
);
out
[
pos
++
]
=
(
pix
&
0xC0
)
>>
6
;
out
[
pos
++
]
=
(
pix
&
0x30
)
>>
4
;
out
[
pos
++
]
=
(
pix
&
0x0C
)
>>
2
;
out
[
pos
++
]
=
(
pix
&
0x03
);
if
(
pos
>=
offset
)
{
pos
-=
offset
;
pos
++
;
}
if
(
pos
>=
offset
)
return
AVERROR_INVALIDDATA
;
}
left
-=
1
+
(
code
+
1
);
}
}
outdata
+=
p
->
linesize
[
0
];
}
return
0
;
}
static
int
decode_rle_bpp4
(
AVCodecContext
*
avctx
,
AVFrame
*
p
,
GetByteContext
*
gbc
)
{
int
offset
=
avctx
->
width
;
uint8_t
*
outdata
=
p
->
data
[
0
];
int
i
,
j
;
for
(
i
=
0
;
i
<
avctx
->
height
;
i
++
)
{
int
size
,
left
,
code
,
pix
;
uint8_t
*
out
=
outdata
;
int
pos
=
0
;
/* size of packed line */
size
=
left
=
bytestream2_get_be16
(
gbc
);
if
(
bytestream2_get_bytes_left
(
gbc
)
<
size
)
return
AVERROR_INVALIDDATA
;
/* decode line */
while
(
left
>
0
)
{
code
=
bytestream2_get_byte
(
gbc
);
if
(
code
&
0x80
)
{
/* run */
pix
=
bytestream2_get_byte
(
gbc
);
for
(
j
=
0
;
j
<
257
-
code
;
j
++
)
{
out
[
pos
++
]
=
(
pix
&
0xF0
)
>>
4
;
out
[
pos
++
]
=
pix
&
0xF
;
if
(
pos
>=
offset
)
{
pos
-=
offset
;
pos
++
;
}
if
(
pos
>=
offset
)
return
AVERROR_INVALIDDATA
;
}
left
-=
2
;
}
else
{
/* copy */
for
(
j
=
0
;
j
<
code
+
1
;
j
++
)
{
pix
=
bytestream2_get_byte
(
gbc
);
out
[
pos
++
]
=
(
pix
&
0xF0
)
>>
4
;
out
[
pos
++
]
=
pix
&
0xF
;
if
(
pos
>=
offset
)
{
pos
-=
offset
;
pos
++
;
}
if
(
pos
>=
offset
)
return
AVERROR_INVALIDDATA
;
}
left
-=
1
+
(
code
+
1
);
}
}
outdata
+=
p
->
linesize
[
0
];
}
return
0
;
}
static
int
decode_rle16
(
AVCodecContext
*
avctx
,
AVFrame
*
p
,
GetByteContext
*
gbc
)
static
int
decode_rle16
(
AVCodecContext
*
avctx
,
AVFrame
*
p
,
GetByteContext
*
gbc
)
{
{
int
offset
=
avctx
->
width
;
int
offset
=
avctx
->
width
;
...
@@ -256,6 +364,8 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -256,6 +364,8 @@ static int decode_frame(AVCodecContext *avctx,
av_log
(
avctx
,
AV_LOG_DEBUG
,
"bppcount %d bpp %d
\n
"
,
bppcnt
,
bpp
);
av_log
(
avctx
,
AV_LOG_DEBUG
,
"bppcount %d bpp %d
\n
"
,
bppcnt
,
bpp
);
if
(
bppcnt
==
1
&&
bpp
==
8
)
{
if
(
bppcnt
==
1
&&
bpp
==
8
)
{
avctx
->
pix_fmt
=
AV_PIX_FMT_PAL8
;
avctx
->
pix_fmt
=
AV_PIX_FMT_PAL8
;
}
else
if
(
bppcnt
==
1
&&
(
bpp
==
4
||
bpp
==
2
))
{
avctx
->
pix_fmt
=
AV_PIX_FMT_PAL8
;
}
else
if
(
bppcnt
==
3
&&
bpp
==
5
)
{
}
else
if
(
bppcnt
==
3
&&
bpp
==
5
)
{
avctx
->
pix_fmt
=
AV_PIX_FMT_RGB555
;
avctx
->
pix_fmt
=
AV_PIX_FMT_RGB555
;
}
else
{
}
else
{
...
@@ -295,6 +405,10 @@ static int decode_frame(AVCodecContext *avctx,
...
@@ -295,6 +405,10 @@ static int decode_frame(AVCodecContext *avctx,
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_RGB555
)
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_RGB555
)
ret
=
decode_rle16
(
avctx
,
p
,
&
gbc
);
ret
=
decode_rle16
(
avctx
,
p
,
&
gbc
);
else
if
(
bpp
=
2
)
ret
=
decode_rle_bpp2
(
avctx
,
p
,
&
gbc
);
else
if
(
bpp
=
4
)
ret
=
decode_rle_bpp4
(
avctx
,
p
,
&
gbc
);
else
else
ret
=
decode_rle
(
avctx
,
p
,
&
gbc
,
bppcnt
);
ret
=
decode_rle
(
avctx
,
p
,
&
gbc
,
bppcnt
);
if
(
ret
<
0
)
if
(
ret
<
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