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
fdf588d7
Commit
fdf588d7
authored
8 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
avformat/ffmdec: Forward error code from ffm_read_header()
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
01ebb57c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavformat/ffmdec.c
+18
-5
18 additions, 5 deletions
libavformat/ffmdec.c
with
18 additions
and
5 deletions
libavformat/ffmdec.c
+
18
−
5
View file @
fdf588d7
...
@@ -402,6 +402,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -402,6 +402,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if
(
!
av_pix_fmt_desc_get
(
codecpar
->
format
))
{
if
(
!
av_pix_fmt_desc_get
(
codecpar
->
format
))
{
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid pix fmt id: %d
\n
"
,
codecpar
->
format
);
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid pix fmt id: %d
\n
"
,
codecpar
->
format
);
codecpar
->
format
=
AV_PIX_FMT_NONE
;
codecpar
->
format
=
AV_PIX_FMT_NONE
;
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
avio_r8
(
pb
);
// qmin
avio_r8
(
pb
);
// qmin
...
@@ -545,11 +546,15 @@ static int ffm_read_header(AVFormatContext *s)
...
@@ -545,11 +546,15 @@ static int ffm_read_header(AVFormatContext *s)
tag
=
avio_rl32
(
pb
);
tag
=
avio_rl32
(
pb
);
if
(
tag
==
MKTAG
(
'F'
,
'F'
,
'M'
,
'2'
))
if
(
tag
==
MKTAG
(
'F'
,
'F'
,
'M'
,
'2'
))
return
ffm2_read_header
(
s
);
return
ffm2_read_header
(
s
);
if
(
tag
!=
MKTAG
(
'F'
,
'F'
,
'M'
,
'1'
))
if
(
tag
!=
MKTAG
(
'F'
,
'F'
,
'M'
,
'1'
))
{
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
ffm
->
packet_size
=
avio_rb32
(
pb
);
ffm
->
packet_size
=
avio_rb32
(
pb
);
if
(
ffm
->
packet_size
!=
FFM_PACKET_SIZE
)
if
(
ffm
->
packet_size
!=
FFM_PACKET_SIZE
)
{
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
ffm
->
write_index
=
avio_rb64
(
pb
);
ffm
->
write_index
=
avio_rb64
(
pb
);
/* get also filesize */
/* get also filesize */
if
(
pb
->
seekable
)
{
if
(
pb
->
seekable
)
{
...
@@ -569,8 +574,10 @@ static int ffm_read_header(AVFormatContext *s)
...
@@ -569,8 +574,10 @@ static int ffm_read_header(AVFormatContext *s)
int
flags
;
int
flags
;
st
=
avformat_new_stream
(
s
,
NULL
);
st
=
avformat_new_stream
(
s
,
NULL
);
if
(
!
st
)
if
(
!
st
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
goto
fail
;
}
avpriv_set_pts_info
(
st
,
64
,
1
,
1000000
);
avpriv_set_pts_info
(
st
,
64
,
1
,
1000000
);
...
@@ -581,6 +588,7 @@ static int ffm_read_header(AVFormatContext *s)
...
@@ -581,6 +588,7 @@ static int ffm_read_header(AVFormatContext *s)
if
(
!
codec_desc
)
{
if
(
!
codec_desc
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid codec id: %d
\n
"
,
codecpar
->
codec_id
);
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid codec id: %d
\n
"
,
codecpar
->
codec_id
);
codecpar
->
codec_id
=
AV_CODEC_ID_NONE
;
codecpar
->
codec_id
=
AV_CODEC_ID_NONE
;
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
codecpar
->
codec_type
=
avio_r8
(
pb
);
/* codec_type */
codecpar
->
codec_type
=
avio_r8
(
pb
);
/* codec_type */
...
@@ -589,11 +597,13 @@ static int ffm_read_header(AVFormatContext *s)
...
@@ -589,11 +597,13 @@ static int ffm_read_header(AVFormatContext *s)
codec_desc
->
type
,
codecpar
->
codec_type
);
codec_desc
->
type
,
codecpar
->
codec_type
);
codecpar
->
codec_id
=
AV_CODEC_ID_NONE
;
codecpar
->
codec_id
=
AV_CODEC_ID_NONE
;
codecpar
->
codec_type
=
AVMEDIA_TYPE_UNKNOWN
;
codecpar
->
codec_type
=
AVMEDIA_TYPE_UNKNOWN
;
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
codecpar
->
bit_rate
=
avio_rb32
(
pb
);
codecpar
->
bit_rate
=
avio_rb32
(
pb
);
if
(
codecpar
->
bit_rate
<
0
)
{
if
(
codecpar
->
bit_rate
<
0
)
{
av_log
(
s
,
AV_LOG_WARNING
,
"Invalid bit rate %"
PRId64
"
\n
"
,
codecpar
->
bit_rate
);
av_log
(
s
,
AV_LOG_WARNING
,
"Invalid bit rate %"
PRId64
"
\n
"
,
codecpar
->
bit_rate
);
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
flags
=
avio_rb32
(
pb
);
flags
=
avio_rb32
(
pb
);
...
@@ -611,13 +621,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -611,13 +621,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
avio_rb32
(
pb
);
// time_base.den
avio_rb32
(
pb
);
// time_base.den
codecpar
->
width
=
avio_rb16
(
pb
);
codecpar
->
width
=
avio_rb16
(
pb
);
codecpar
->
height
=
avio_rb16
(
pb
);
codecpar
->
height
=
avio_rb16
(
pb
);
if
(
av_image_check_size
(
codecpar
->
width
,
codecpar
->
height
,
0
,
s
)
<
0
)
if
(
(
ret
=
av_image_check_size
(
codecpar
->
width
,
codecpar
->
height
,
0
,
s
)
)
<
0
)
goto
fail
;
goto
fail
;
avio_rb16
(
pb
);
// gop_size
avio_rb16
(
pb
);
// gop_size
codecpar
->
format
=
avio_rb32
(
pb
);
codecpar
->
format
=
avio_rb32
(
pb
);
if
(
!
av_pix_fmt_desc_get
(
codecpar
->
format
))
{
if
(
!
av_pix_fmt_desc_get
(
codecpar
->
format
))
{
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid pix fmt id: %d
\n
"
,
codecpar
->
format
);
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid pix fmt id: %d
\n
"
,
codecpar
->
format
);
codecpar
->
format
=
AV_PIX_FMT_NONE
;
codecpar
->
format
=
AV_PIX_FMT_NONE
;
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
avio_r8
(
pb
);
// qmin
avio_r8
(
pb
);
// qmin
...
@@ -668,12 +679,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -668,12 +679,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
VALIDATE_PARAMETER
(
frame_size
,
"frame size"
,
codecpar
->
frame_size
<
0
)
VALIDATE_PARAMETER
(
frame_size
,
"frame size"
,
codecpar
->
frame_size
<
0
)
break
;
break
;
default:
default:
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
if
(
flags
&
AV_CODEC_FLAG_GLOBAL_HEADER
)
{
if
(
flags
&
AV_CODEC_FLAG_GLOBAL_HEADER
)
{
int
size
=
avio_rb32
(
pb
);
int
size
=
avio_rb32
(
pb
);
if
(
size
<
0
||
size
>=
FF_MAX_EXTRADATA_SIZE
)
{
if
(
size
<
0
||
size
>=
FF_MAX_EXTRADATA_SIZE
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid extradata size %d
\n
"
,
size
);
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid extradata size %d
\n
"
,
size
);
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
goto
fail
;
}
}
codecpar
->
extradata
=
av_mallocz
(
size
+
AV_INPUT_BUFFER_PADDING_SIZE
);
codecpar
->
extradata
=
av_mallocz
(
size
+
AV_INPUT_BUFFER_PADDING_SIZE
);
...
@@ -699,7 +712,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
...
@@ -699,7 +712,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
return
0
;
return
0
;
fail:
fail:
avcodec_free_context
(
&
dummy_codec
);
avcodec_free_context
(
&
dummy_codec
);
return
-
1
;
return
ret
;
}
}
/* return < 0 if eof */
/* return < 0 if eof */
...
...
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