Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
10c26e92
Commit
10c26e92
authored
12 years ago
by
Anton Khirnov
Browse files
Options
Downloads
Patches
Plain Diff
4xm: return meaningful error codes
parent
95d01c3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/4xm.c
+20
-19
20 additions, 19 deletions
libavcodec/4xm.c
with
20 additions
and
19 deletions
libavcodec/4xm.c
+
20
−
19
View file @
10c26e92
...
@@ -415,7 +415,7 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
...
@@ -415,7 +415,7 @@ static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length)
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"lengths %d %d %d %d
\n
"
,
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"lengths %d %d %d %d
\n
"
,
bitstream_size
,
bytestream_size
,
wordstream_size
,
bitstream_size
,
bytestream_size
,
wordstream_size
,
bitstream_size
+
bytestream_size
+
wordstream_size
-
length
);
bitstream_size
+
bytestream_size
+
wordstream_size
-
length
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
av_fast_malloc
(
&
f
->
bitstream_buffer
,
&
f
->
bitstream_buffer_size
,
av_fast_malloc
(
&
f
->
bitstream_buffer
,
&
f
->
bitstream_buffer_size
,
...
@@ -542,13 +542,14 @@ static inline void idct_put(FourXContext *f, int x, int y)
...
@@ -542,13 +542,14 @@ static inline void idct_put(FourXContext *f, int x, int y)
static
int
decode_i_mb
(
FourXContext
*
f
)
static
int
decode_i_mb
(
FourXContext
*
f
)
{
{
int
ret
;
int
i
;
int
i
;
f
->
dsp
.
clear_blocks
(
f
->
block
[
0
]);
f
->
dsp
.
clear_blocks
(
f
->
block
[
0
]);
for
(
i
=
0
;
i
<
6
;
i
++
)
for
(
i
=
0
;
i
<
6
;
i
++
)
if
(
decode_i_block
(
f
,
f
->
block
[
i
])
<
0
)
if
(
(
ret
=
decode_i_block
(
f
,
f
->
block
[
i
])
)
<
0
)
return
-
1
;
return
ret
;
return
0
;
return
0
;
}
}
...
@@ -694,7 +695,7 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length)
...
@@ -694,7 +695,7 @@ static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length)
static
int
decode_i_frame
(
FourXContext
*
f
,
const
uint8_t
*
buf
,
int
length
)
static
int
decode_i_frame
(
FourXContext
*
f
,
const
uint8_t
*
buf
,
int
length
)
{
{
int
x
,
y
;
int
x
,
y
,
ret
;
const
int
width
=
f
->
avctx
->
width
;
const
int
width
=
f
->
avctx
->
width
;
const
int
height
=
f
->
avctx
->
height
;
const
int
height
=
f
->
avctx
->
height
;
const
unsigned
int
bitstream_size
=
AV_RL32
(
buf
);
const
unsigned
int
bitstream_size
=
AV_RL32
(
buf
);
...
@@ -716,7 +717,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
...
@@ -716,7 +717,7 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
||
prestream_size
>
(
1
<<
26
))
{
||
prestream_size
>
(
1
<<
26
))
{
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"size mismatch %d %d %d
\n
"
,
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"size mismatch %d %d %d
\n
"
,
prestream_size
,
bitstream_size
,
length
);
prestream_size
,
bitstream_size
,
length
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
prestream
=
read_huffman_tables
(
f
,
prestream
);
prestream
=
read_huffman_tables
(
f
,
prestream
);
...
@@ -739,8 +740,8 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
...
@@ -739,8 +740,8 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length)
for
(
y
=
0
;
y
<
height
;
y
+=
16
)
{
for
(
y
=
0
;
y
<
height
;
y
+=
16
)
{
for
(
x
=
0
;
x
<
width
;
x
+=
16
)
{
for
(
x
=
0
;
x
<
width
;
x
+=
16
)
{
if
(
decode_i_mb
(
f
)
<
0
)
if
(
(
ret
=
decode_i_mb
(
f
)
)
<
0
)
return
-
1
;
return
ret
;
idct_put
(
f
,
x
,
y
);
idct_put
(
f
,
x
,
y
);
}
}
...
@@ -760,7 +761,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
...
@@ -760,7 +761,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
FourXContext
*
const
f
=
avctx
->
priv_data
;
FourXContext
*
const
f
=
avctx
->
priv_data
;
AVFrame
*
picture
=
data
;
AVFrame
*
picture
=
data
;
AVFrame
*
p
,
temp
;
AVFrame
*
p
,
temp
;
int
i
,
frame_4cc
,
frame_size
;
int
i
,
frame_4cc
,
frame_size
,
ret
;
frame_4cc
=
AV_RL32
(
buf
);
frame_4cc
=
AV_RL32
(
buf
);
if
(
buf_size
!=
AV_RL32
(
buf
+
4
)
+
8
||
buf_size
<
20
)
if
(
buf_size
!=
AV_RL32
(
buf
+
4
)
+
8
||
buf_size
<
20
)
...
@@ -797,7 +798,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
...
@@ -797,7 +798,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
// explicit check needed as memcpy below might not catch a NULL
// explicit check needed as memcpy below might not catch a NULL
if
(
!
cfrm
->
data
)
{
if
(
!
cfrm
->
data
)
{
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"realloc failure"
);
av_log
(
f
->
avctx
,
AV_LOG_ERROR
,
"realloc failure"
);
return
-
1
;
return
AVERROR
(
ENOMEM
)
;
}
}
memcpy
(
cfrm
->
data
+
cfrm
->
size
,
buf
+
20
,
data_size
);
memcpy
(
cfrm
->
data
+
cfrm
->
size
,
buf
+
20
,
data_size
);
...
@@ -834,32 +835,32 @@ static int decode_frame(AVCodecContext *avctx, void *data,
...
@@ -834,32 +835,32 @@ static int decode_frame(AVCodecContext *avctx, void *data,
avctx
->
release_buffer
(
avctx
,
p
);
avctx
->
release_buffer
(
avctx
,
p
);
p
->
reference
=
1
;
p
->
reference
=
1
;
if
(
ff_get_buffer
(
avctx
,
p
)
<
0
)
{
if
(
(
ret
=
ff_get_buffer
(
avctx
,
p
)
)
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
-
1
;
return
ret
;
}
}
if
(
frame_4cc
==
AV_RL32
(
"ifr2"
))
{
if
(
frame_4cc
==
AV_RL32
(
"ifr2"
))
{
p
->
pict_type
=
AV_PICTURE_TYPE_I
;
p
->
pict_type
=
AV_PICTURE_TYPE_I
;
if
(
decode_i2_frame
(
f
,
buf
-
4
,
frame_size
+
4
)
<
0
)
if
(
(
ret
=
decode_i2_frame
(
f
,
buf
-
4
,
frame_size
+
4
)
)
<
0
)
return
-
1
;
return
ret
;
}
else
if
(
frame_4cc
==
AV_RL32
(
"ifrm"
))
{
}
else
if
(
frame_4cc
==
AV_RL32
(
"ifrm"
))
{
p
->
pict_type
=
AV_PICTURE_TYPE_I
;
p
->
pict_type
=
AV_PICTURE_TYPE_I
;
if
(
decode_i_frame
(
f
,
buf
,
frame_size
)
<
0
)
if
(
(
ret
=
decode_i_frame
(
f
,
buf
,
frame_size
)
)
<
0
)
return
-
1
;
return
ret
;
}
else
if
(
frame_4cc
==
AV_RL32
(
"pfrm"
)
||
frame_4cc
==
AV_RL32
(
"pfr2"
))
{
}
else
if
(
frame_4cc
==
AV_RL32
(
"pfrm"
)
||
frame_4cc
==
AV_RL32
(
"pfr2"
))
{
if
(
!
f
->
last_picture
.
data
[
0
])
{
if
(
!
f
->
last_picture
.
data
[
0
])
{
f
->
last_picture
.
reference
=
1
;
f
->
last_picture
.
reference
=
1
;
if
(
ff_get_buffer
(
avctx
,
&
f
->
last_picture
)
<
0
)
{
if
(
(
ret
=
ff_get_buffer
(
avctx
,
&
f
->
last_picture
)
)
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
-
1
;
return
ret
;
}
}
memset
(
f
->
last_picture
.
data
[
0
],
0
,
avctx
->
height
*
FFABS
(
f
->
last_picture
.
linesize
[
0
]));
memset
(
f
->
last_picture
.
data
[
0
],
0
,
avctx
->
height
*
FFABS
(
f
->
last_picture
.
linesize
[
0
]));
}
}
p
->
pict_type
=
AV_PICTURE_TYPE_P
;
p
->
pict_type
=
AV_PICTURE_TYPE_P
;
if
(
decode_p_frame
(
f
,
buf
,
frame_size
)
<
0
)
if
(
(
ret
=
decode_p_frame
(
f
,
buf
,
frame_size
)
)
<
0
)
return
-
1
;
return
ret
;
}
else
if
(
frame_4cc
==
AV_RL32
(
"snd_"
))
{
}
else
if
(
frame_4cc
==
AV_RL32
(
"snd_"
))
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"ignoring snd_ chunk length:%d
\n
"
,
av_log
(
avctx
,
AV_LOG_ERROR
,
"ignoring snd_ chunk length:%d
\n
"
,
buf_size
);
buf_size
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment