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
70f2314d
Commit
70f2314d
authored
Jun 26, 2010
by
Måns Rullgård
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcx: convert VLAs to malloc/free
Originally committed as revision 23796 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
164d166e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
pcx.c
libavcodec/pcx.c
+11
-7
No files found.
libavcodec/pcx.c
View file @
70f2314d
...
...
@@ -87,6 +87,8 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
bytes_per_scanline
;
uint8_t
*
ptr
;
uint8_t
const
*
bufstart
=
buf
;
uint8_t
*
scanline
;
int
ret
=
-
1
;
if
(
buf
[
0
]
!=
0x0a
||
buf
[
1
]
>
5
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"this is not PCX encoded data
\n
"
);
...
...
@@ -154,9 +156,11 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
ptr
=
p
->
data
[
0
];
stride
=
p
->
linesize
[
0
];
if
(
nplanes
==
3
&&
bits_per_pixel
==
8
)
{
uint8_t
scanline
[
bytes_per_scanline
];
scanline
=
av_malloc
(
bytes_per_scanline
);
if
(
!
scanline
)
return
AVERROR
(
ENOMEM
);
if
(
nplanes
==
3
&&
bits_per_pixel
==
8
)
{
for
(
y
=
0
;
y
<
h
;
y
++
)
{
buf
=
pcx_rle_decode
(
buf
,
scanline
,
bytes_per_scanline
,
compressed
);
...
...
@@ -170,7 +174,6 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
}
else
if
(
nplanes
==
1
&&
bits_per_pixel
==
8
)
{
uint8_t
scanline
[
bytes_per_scanline
];
const
uint8_t
*
palstart
=
bufstart
+
buf_size
-
769
;
for
(
y
=
0
;
y
<
h
;
y
++
,
ptr
+=
stride
)
{
...
...
@@ -184,11 +187,10 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
if
(
*
buf
++
!=
12
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"expected palette after image data
\n
"
);
return
-
1
;
goto
end
;
}
}
else
if
(
nplanes
==
1
)
{
/* all packed formats, max. 16 colors */
uint8_t
scanline
[
bytes_per_scanline
];
GetBitContext
s
;
for
(
y
=
0
;
y
<
h
;
y
++
)
{
...
...
@@ -202,7 +204,6 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
}
}
else
{
/* planar, 4, 8 or 16 colors */
uint8_t
scanline
[
bytes_per_scanline
];
int
i
;
for
(
y
=
0
;
y
<
h
;
y
++
)
{
...
...
@@ -230,7 +231,10 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
*
picture
=
s
->
picture
;
*
data_size
=
sizeof
(
AVFrame
);
return
buf
-
bufstart
;
ret
=
buf
-
bufstart
;
end:
av_free
(
scanline
);
return
ret
;
}
static
av_cold
int
pcx_end
(
AVCodecContext
*
avctx
)
{
...
...
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