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
bb675d3a
Commit
bb675d3a
authored
Dec 14, 2012
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vp56: make parse_header return standard error codes
Returning 0 for failure is misleading. CC: libav-stable@libav.org
parent
deabb52a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
16 deletions
+18
-16
vp5.c
libavcodec/vp5.c
+6
-6
vp56.c
libavcodec/vp56.c
+4
-4
vp56.h
libavcodec/vp56.h
+2
-0
vp6.c
libavcodec/vp6.c
+6
-6
No files found.
libavcodec/vp5.c
View file @
bb675d3a
...
@@ -49,18 +49,18 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
...
@@ -49,18 +49,18 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
{
{
vp56_rac_gets
(
c
,
8
);
vp56_rac_gets
(
c
,
8
);
if
(
vp56_rac_gets
(
c
,
5
)
>
5
)
if
(
vp56_rac_gets
(
c
,
5
)
>
5
)
return
0
;
return
AVERROR_INVALIDDATA
;
vp56_rac_gets
(
c
,
2
);
vp56_rac_gets
(
c
,
2
);
if
(
vp56_rac_get
(
c
))
{
if
(
vp56_rac_get
(
c
))
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"interlacing not supported
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"interlacing not supported
\n
"
);
return
0
;
return
AVERROR_PATCHWELCOME
;
}
}
rows
=
vp56_rac_gets
(
c
,
8
);
/* number of stored macroblock rows */
rows
=
vp56_rac_gets
(
c
,
8
);
/* number of stored macroblock rows */
cols
=
vp56_rac_gets
(
c
,
8
);
/* number of stored macroblock cols */
cols
=
vp56_rac_gets
(
c
,
8
);
/* number of stored macroblock cols */
if
(
!
rows
||
!
cols
)
{
if
(
!
rows
||
!
cols
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Invalid size %dx%d
\n
"
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Invalid size %dx%d
\n
"
,
cols
<<
4
,
rows
<<
4
);
cols
<<
4
,
rows
<<
4
);
return
0
;
return
AVERROR_INVALIDDATA
;
}
}
vp56_rac_gets
(
c
,
8
);
/* number of displayed macroblock rows */
vp56_rac_gets
(
c
,
8
);
/* number of displayed macroblock rows */
vp56_rac_gets
(
c
,
8
);
/* number of displayed macroblock cols */
vp56_rac_gets
(
c
,
8
);
/* number of displayed macroblock cols */
...
@@ -69,11 +69,11 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
...
@@ -69,11 +69,11 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
16
*
cols
!=
s
->
avctx
->
coded_width
||
16
*
cols
!=
s
->
avctx
->
coded_width
||
16
*
rows
!=
s
->
avctx
->
coded_height
)
{
16
*
rows
!=
s
->
avctx
->
coded_height
)
{
avcodec_set_dimensions
(
s
->
avctx
,
16
*
cols
,
16
*
rows
);
avcodec_set_dimensions
(
s
->
avctx
,
16
*
cols
,
16
*
rows
);
return
2
;
return
VP56_SIZE_CHANGE
;
}
}
}
else
if
(
!
s
->
macroblocks
)
}
else
if
(
!
s
->
macroblocks
)
return
0
;
return
AVERROR_INVALIDDATA
;
return
1
;
return
0
;
}
}
static
void
vp5_parse_vector_adjustment
(
VP56Context
*
s
,
VP56mv
*
vect
)
static
void
vp5_parse_vector_adjustment
(
VP56Context
*
s
,
VP56mv
*
vect
)
...
...
libavcodec/vp56.c
View file @
bb675d3a
...
@@ -514,10 +514,10 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
...
@@ -514,10 +514,10 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s
->
modelp
=
&
s
->
models
[
is_alpha
];
s
->
modelp
=
&
s
->
models
[
is_alpha
];
res
=
s
->
parse_header
(
s
,
buf
,
remaining_buf_size
,
&
golden_frame
);
res
=
s
->
parse_header
(
s
,
buf
,
remaining_buf_size
,
&
golden_frame
);
if
(
!
res
)
if
(
res
<
0
)
return
-
1
;
return
res
;
if
(
res
==
2
)
{
if
(
res
==
VP56_SIZE_CHANGE
)
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
4
;
i
++
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
if
(
s
->
frames
[
i
].
data
[
0
])
if
(
s
->
frames
[
i
].
data
[
0
])
...
@@ -536,7 +536,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
...
@@ -536,7 +536,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return
-
1
;
return
-
1
;
}
}
if
(
res
==
2
)
if
(
res
==
VP56_SIZE_CHANGE
)
if
(
vp56_size_changed
(
avctx
))
{
if
(
vp56_size_changed
(
avctx
))
{
avctx
->
release_buffer
(
avctx
,
p
);
avctx
->
release_buffer
(
avctx
,
p
);
return
-
1
;
return
-
1
;
...
...
libavcodec/vp56.h
View file @
bb675d3a
...
@@ -40,6 +40,8 @@ typedef struct VP56mv {
...
@@ -40,6 +40,8 @@ typedef struct VP56mv {
int16_t
y
;
int16_t
y
;
}
VP56mv
;
}
VP56mv
;
#define VP56_SIZE_CHANGE 1
typedef
void
(
*
VP56ParseVectorAdjustment
)(
VP56Context
*
s
,
typedef
void
(
*
VP56ParseVectorAdjustment
)(
VP56Context
*
s
,
VP56mv
*
vect
);
VP56mv
*
vect
);
typedef
void
(
*
VP56Filter
)(
VP56Context
*
s
,
uint8_t
*
dst
,
uint8_t
*
src
,
typedef
void
(
*
VP56Filter
)(
VP56Context
*
s
,
uint8_t
*
dst
,
uint8_t
*
src
,
...
...
libavcodec/vp6.c
View file @
bb675d3a
...
@@ -52,7 +52,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
...
@@ -52,7 +52,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
int
vrt_shift
=
0
;
int
vrt_shift
=
0
;
int
sub_version
;
int
sub_version
;
int
rows
,
cols
;
int
rows
,
cols
;
int
res
=
1
;
int
res
=
0
;
int
separated_coeff
=
buf
[
0
]
&
1
;
int
separated_coeff
=
buf
[
0
]
&
1
;
s
->
framep
[
VP56_FRAME_CURRENT
]
->
key_frame
=
!
(
buf
[
0
]
&
0x80
);
s
->
framep
[
VP56_FRAME_CURRENT
]
->
key_frame
=
!
(
buf
[
0
]
&
0x80
);
...
@@ -61,7 +61,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
...
@@ -61,7 +61,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
if
(
s
->
framep
[
VP56_FRAME_CURRENT
]
->
key_frame
)
{
if
(
s
->
framep
[
VP56_FRAME_CURRENT
]
->
key_frame
)
{
sub_version
=
buf
[
1
]
>>
3
;
sub_version
=
buf
[
1
]
>>
3
;
if
(
sub_version
>
8
)
if
(
sub_version
>
8
)
return
0
;
return
AVERROR_INVALIDDATA
;
s
->
filter_header
=
buf
[
1
]
&
0x06
;
s
->
filter_header
=
buf
[
1
]
&
0x06
;
if
(
buf
[
1
]
&
1
)
{
if
(
buf
[
1
]
&
1
)
{
av_log_missing_feature
(
s
->
avctx
,
"Interlacing"
,
0
);
av_log_missing_feature
(
s
->
avctx
,
"Interlacing"
,
0
);
...
@@ -79,7 +79,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
...
@@ -79,7 +79,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
/* buf[5] is number of displayed macroblock cols */
/* buf[5] is number of displayed macroblock cols */
if
(
!
rows
||
!
cols
)
{
if
(
!
rows
||
!
cols
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Invalid size %dx%d
\n
"
,
cols
<<
4
,
rows
<<
4
);
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Invalid size %dx%d
\n
"
,
cols
<<
4
,
rows
<<
4
);
return
0
;
return
AVERROR_INVALIDDATA
;
}
}
if
(
!
s
->
macroblocks
||
/* first frame */
if
(
!
s
->
macroblocks
||
/* first frame */
...
@@ -90,7 +90,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
...
@@ -90,7 +90,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
s
->
avctx
->
width
-=
s
->
avctx
->
extradata
[
0
]
>>
4
;
s
->
avctx
->
width
-=
s
->
avctx
->
extradata
[
0
]
>>
4
;
s
->
avctx
->
height
-=
s
->
avctx
->
extradata
[
0
]
&
0x0F
;
s
->
avctx
->
height
-=
s
->
avctx
->
extradata
[
0
]
&
0x0F
;
}
}
res
=
2
;
res
=
VP56_SIZE_CHANGE
;
}
}
ff_vp56_init_range_decoder
(
c
,
buf
+
6
,
buf_size
-
6
);
ff_vp56_init_range_decoder
(
c
,
buf
+
6
,
buf_size
-
6
);
...
@@ -102,7 +102,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
...
@@ -102,7 +102,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
s
->
sub_version
=
sub_version
;
s
->
sub_version
=
sub_version
;
}
else
{
}
else
{
if
(
!
s
->
sub_version
||
!
s
->
avctx
->
coded_width
||
!
s
->
avctx
->
coded_height
)
if
(
!
s
->
sub_version
||
!
s
->
avctx
->
coded_width
||
!
s
->
avctx
->
coded_height
)
return
0
;
return
AVERROR_INVALIDDATA
;
if
(
separated_coeff
||
!
s
->
filter_header
)
{
if
(
separated_coeff
||
!
s
->
filter_header
)
{
coeff_offset
=
AV_RB16
(
buf
+
1
)
-
2
;
coeff_offset
=
AV_RB16
(
buf
+
1
)
-
2
;
...
@@ -146,7 +146,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
...
@@ -146,7 +146,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
if
(
buf_size
<
0
)
{
if
(
buf_size
<
0
)
{
if
(
s
->
framep
[
VP56_FRAME_CURRENT
]
->
key_frame
)
if
(
s
->
framep
[
VP56_FRAME_CURRENT
]
->
key_frame
)
avcodec_set_dimensions
(
s
->
avctx
,
0
,
0
);
avcodec_set_dimensions
(
s
->
avctx
,
0
,
0
);
return
0
;
return
AVERROR_INVALIDDATA
;
}
}
if
(
s
->
use_huffman
)
{
if
(
s
->
use_huffman
)
{
s
->
parse_coeff
=
vp6_parse_coeff_huffman
;
s
->
parse_coeff
=
vp6_parse_coeff_huffman
;
...
...
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