Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
abe3c697
Commit
abe3c697
authored
Mar 17, 2012
by
Ronald S. Bultje
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xwd: convert to bytestream2.
parent
5a3a906b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
32 deletions
+34
-32
xwddec.c
libavcodec/xwddec.c
+34
-32
No files found.
libavcodec/xwddec.c
View file @
abe3c697
...
...
@@ -45,43 +45,43 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
uint32_t
pixformat
,
pixdepth
,
bunit
,
bitorder
,
bpad
;
uint32_t
rgb
[
3
];
uint8_t
*
ptr
;
GetByteContext
gb
;
if
(
buf_size
<
XWD_HEADER_SIZE
)
return
AVERROR_INVALIDDATA
;
header_size
=
bytestream_get_be32
(
&
buf
);
if
(
buf_size
<
header_size
)
return
AVERROR_INVALIDDATA
;
bytestream2_init
(
&
gb
,
buf
,
buf_size
);
header_size
=
bytestream2_get_be32u
(
&
gb
);
version
=
bytestream
_get_be32
(
&
buf
);
version
=
bytestream
2_get_be32u
(
&
gb
);
if
(
version
!=
XWD_VERSION
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"unsupported version
\n
"
);
return
AVERROR_INVALIDDATA
;
}
if
(
header_size
<
XWD_HEADER_SIZE
)
{
if
(
buf_size
<
header_size
||
header_size
<
XWD_HEADER_SIZE
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid header size
\n
"
);
return
AVERROR_INVALIDDATA
;
}
pixformat
=
bytestream
_get_be32
(
&
buf
);
pixdepth
=
bytestream
_get_be32
(
&
buf
);
avctx
->
width
=
bytestream
_get_be32
(
&
buf
);
avctx
->
height
=
bytestream
_get_be32
(
&
buf
);
xoffset
=
bytestream
_get_be32
(
&
buf
);
be
=
bytestream
_get_be32
(
&
buf
);
bunit
=
bytestream
_get_be32
(
&
buf
);
bitorder
=
bytestream
_get_be32
(
&
buf
);
bpad
=
bytestream
_get_be32
(
&
buf
);
bpp
=
bytestream
_get_be32
(
&
buf
);
lsize
=
bytestream
_get_be32
(
&
buf
);
vclass
=
bytestream
_get_be32
(
&
buf
);
rgb
[
0
]
=
bytestream
_get_be32
(
&
buf
);
rgb
[
1
]
=
bytestream
_get_be32
(
&
buf
);
rgb
[
2
]
=
bytestream
_get_be32
(
&
buf
);
b
uf
+=
8
;
ncolors
=
bytestream
_get_be32
(
&
buf
);
b
uf
+=
header_size
-
(
XWD_HEADER_SIZE
-
20
);
pixformat
=
bytestream
2_get_be32u
(
&
gb
);
pixdepth
=
bytestream
2_get_be32u
(
&
gb
);
avctx
->
width
=
bytestream
2_get_be32u
(
&
gb
);
avctx
->
height
=
bytestream
2_get_be32u
(
&
gb
);
xoffset
=
bytestream
2_get_be32u
(
&
gb
);
be
=
bytestream
2_get_be32u
(
&
gb
);
bunit
=
bytestream
2_get_be32u
(
&
gb
);
bitorder
=
bytestream
2_get_be32u
(
&
gb
);
bpad
=
bytestream
2_get_be32u
(
&
gb
);
bpp
=
bytestream
2_get_be32u
(
&
gb
);
lsize
=
bytestream
2_get_be32u
(
&
gb
);
vclass
=
bytestream
2_get_be32u
(
&
gb
);
rgb
[
0
]
=
bytestream
2_get_be32u
(
&
gb
);
rgb
[
1
]
=
bytestream
2_get_be32u
(
&
gb
);
rgb
[
2
]
=
bytestream
2_get_be32u
(
&
gb
);
b
ytestream2_skipu
(
&
gb
,
8
)
;
ncolors
=
bytestream
2_get_be32u
(
&
gb
);
b
ytestream2_skipu
(
&
gb
,
header_size
-
(
XWD_HEADER_SIZE
-
20
)
);
av_log
(
avctx
,
AV_LOG_DEBUG
,
"pixformat %d, pixdepth %d, bunit %d, bitorder %d, bpad %d
\n
"
,
pixformat
,
pixdepth
,
bunit
,
bitorder
,
bpad
);
...
...
@@ -143,7 +143,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
return
AVERROR_INVALIDDATA
;
}
if
(
b
uf_size
<
header_size
+
ncolors
*
XWD_CMAP_SIZE
+
avctx
->
height
*
lsize
)
{
if
(
b
ytestream2_get_bytes_left
(
&
gb
)
<
ncolors
*
XWD_CMAP_SIZE
+
avctx
->
height
*
lsize
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"input buffer too small
\n
"
);
return
AVERROR_INVALIDDATA
;
}
...
...
@@ -192,7 +192,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
else
if
(
rgb
[
0
]
==
0xFF
&&
rgb
[
1
]
==
0xFF00
&&
rgb
[
2
]
==
0xFF0000
)
avctx
->
pix_fmt
=
be
?
PIX_FMT_ABGR
:
PIX_FMT_RGBA
;
}
b
uf
+=
ncolors
*
XWD_CMAP_SIZE
;
b
ytestream2_skipu
(
&
gb
,
ncolors
*
XWD_CMAP_SIZE
)
;
break
;
default:
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid visual class
\n
"
);
...
...
@@ -222,11 +222,13 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
for
(
i
=
0
;
i
<
ncolors
;
i
++
)
{
buf
+=
4
;
// skip colormap entry number
red
=
*
buf
;
buf
+=
2
;
green
=
*
buf
;
buf
+=
2
;
blue
=
*
buf
;
buf
+=
2
;
buf
+=
2
;
// skip bitmask flag and padding
bytestream2_skipu
(
&
gb
,
4
);
// skip colormap entry number
red
=
bytestream2_get_byteu
(
&
gb
);
bytestream2_skipu
(
&
gb
,
1
);
green
=
bytestream2_get_byteu
(
&
gb
);
bytestream2_skipu
(
&
gb
,
1
);
blue
=
bytestream2_get_byteu
(
&
gb
);
bytestream2_skipu
(
&
gb
,
3
);
// skip bitmask flag and padding
dst
[
i
]
=
red
<<
16
|
green
<<
8
|
blue
;
}
...
...
@@ -234,8 +236,8 @@ static int xwd_decode_frame(AVCodecContext *avctx, void *data,
ptr
=
p
->
data
[
0
];
for
(
i
=
0
;
i
<
avctx
->
height
;
i
++
)
{
bytestream
_get_buffer
(
&
buf
,
ptr
,
rsize
);
b
uf
+=
lsize
-
rsize
;
bytestream
2_get_bufferu
(
&
gb
,
ptr
,
rsize
);
b
ytestream2_skipu
(
&
gb
,
lsize
-
rsize
)
;
ptr
+=
p
->
linesize
[
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