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
3344f5cb
Commit
3344f5cb
authored
12 years ago
by
Anton Khirnov
Browse files
Options
Downloads
Patches
Plain Diff
nuv: return meaningful error codes.
parent
a1c525f7
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/nuv.c
+17
-13
17 additions, 13 deletions
libavcodec/nuv.c
with
17 additions
and
13 deletions
libavcodec/nuv.c
+
17
−
13
View file @
3344f5cb
...
...
@@ -87,7 +87,7 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c, const uint8_t *buf,
int
i
;
if
(
size
<
2
*
64
*
4
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"insufficient rtjpeg quant data
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
for
(
i
=
0
;
i
<
64
;
i
++
,
buf
+=
4
)
c
->
lq
[
i
]
=
AV_RL32
(
buf
);
...
...
@@ -113,13 +113,15 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
int
quality
)
{
NuvContext
*
c
=
avctx
->
priv_data
;
int
ret
;
width
=
FFALIGN
(
width
,
2
);
height
=
FFALIGN
(
height
,
2
);
if
(
quality
>=
0
)
get_quant_quality
(
c
,
quality
);
if
(
width
!=
c
->
width
||
height
!=
c
->
height
)
{
if
(
av_image_check_size
(
height
,
width
,
0
,
avctx
)
<
0
)
return
0
;
if
(
(
ret
=
av_image_check_size
(
height
,
width
,
0
,
avctx
)
)
<
0
)
return
ret
;
avctx
->
width
=
c
->
width
=
width
;
avctx
->
height
=
c
->
height
=
height
;
av_fast_malloc
(
&
c
->
decomp_buf
,
&
c
->
decomp_size
,
...
...
@@ -127,7 +129,7 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
if
(
!
c
->
decomp_buf
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Can't allocate decompression buffer.
\n
"
);
return
0
;
return
AVERROR
(
ENOMEM
)
;
}
ff_rtjpeg_decode_init
(
&
c
->
rtj
,
&
c
->
dsp
,
c
->
width
,
c
->
height
,
c
->
lq
,
c
->
cq
);
...
...
@@ -135,7 +137,7 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
ff_rtjpeg_decode_init
(
&
c
->
rtj
,
&
c
->
dsp
,
c
->
width
,
c
->
height
,
c
->
lq
,
c
->
cq
);
return
1
;
return
0
;
}
static
int
decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
got_frame
,
...
...
@@ -159,7 +161,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if
(
buf_size
<
12
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"coded frame too small
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
// codec data (rtjpeg quant tables)
...
...
@@ -178,7 +180,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if
(
buf
[
0
]
!=
'V'
||
buf_size
<
12
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"not a nuv video frame
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
comptype
=
buf
[
1
];
switch
(
comptype
)
{
...
...
@@ -213,8 +215,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
w
=
AV_RL16
(
&
buf
[
6
]);
h
=
AV_RL16
(
&
buf
[
8
]);
q
=
buf
[
10
];
if
(
!
codec_reinit
(
avctx
,
w
,
h
,
q
))
return
-
1
;
if
(
(
result
=
codec_reinit
(
avctx
,
w
,
h
,
q
))
<
0
)
return
result
;
buf
=
&
buf
[
RTJPEG_HEADER_SIZE
];
buf_size
-=
RTJPEG_HEADER_SIZE
;
}
...
...
@@ -227,7 +229,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
result
=
avctx
->
reget_buffer
(
avctx
,
&
c
->
pic
);
if
(
result
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"get_buffer() failed
\n
"
);
return
-
1
;
return
result
;
}
c
->
pic
.
pict_type
=
keyframe
?
AV_PICTURE_TYPE_I
:
AV_PICTURE_TYPE_P
;
...
...
@@ -258,7 +260,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
break
;
default:
av_log
(
avctx
,
AV_LOG_ERROR
,
"unknown compression
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
*
picture
=
c
->
pic
;
...
...
@@ -269,6 +271,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
static
av_cold
int
decode_init
(
AVCodecContext
*
avctx
)
{
NuvContext
*
c
=
avctx
->
priv_data
;
int
ret
;
avctx
->
pix_fmt
=
AV_PIX_FMT_YUV420P
;
c
->
pic
.
data
[
0
]
=
NULL
;
c
->
decomp_buf
=
NULL
;
...
...
@@ -283,8 +287,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_dsputil_init
(
&
c
->
dsp
,
avctx
);
if
(
!
codec_reinit
(
avctx
,
avctx
->
width
,
avctx
->
height
,
-
1
))
return
1
;
if
(
(
ret
=
codec_reinit
(
avctx
,
avctx
->
width
,
avctx
->
height
,
-
1
))
<
0
)
return
ret
;
return
0
;
}
...
...
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