Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
9cec1bbd
Commit
9cec1bbd
authored
Jun 24, 2011
by
Nicolas George
Committed by
Diego Biurrun
Jul 04, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ogg: propagate return values and return more meaningful error values
Signed-off-by:
Diego Biurrun
<
diego@biurrun.de
>
parent
5029a406
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
25 deletions
+34
-25
oggdec.c
libavformat/oggdec.c
+34
-25
No files found.
libavformat/oggdec.c
View file @
9cec1bbd
...
@@ -192,7 +192,7 @@ static int ogg_read_page(AVFormatContext *s, int *str)
...
@@ -192,7 +192,7 @@ static int ogg_read_page(AVFormatContext *s, int *str)
AVIOContext
*
bc
=
s
->
pb
;
AVIOContext
*
bc
=
s
->
pb
;
struct
ogg
*
ogg
=
s
->
priv_data
;
struct
ogg
*
ogg
=
s
->
priv_data
;
struct
ogg_stream
*
os
;
struct
ogg_stream
*
os
;
int
i
=
0
;
int
ret
,
i
=
0
;
int
flags
,
nsegs
;
int
flags
,
nsegs
;
uint64_t
gp
;
uint64_t
gp
;
uint32_t
serial
;
uint32_t
serial
;
...
@@ -200,8 +200,9 @@ static int ogg_read_page(AVFormatContext *s, int *str)
...
@@ -200,8 +200,9 @@ static int ogg_read_page(AVFormatContext *s, int *str)
uint8_t
sync
[
4
];
uint8_t
sync
[
4
];
int
sp
=
0
;
int
sp
=
0
;
if
(
avio_read
(
bc
,
sync
,
4
)
<
4
)
ret
=
avio_read
(
bc
,
sync
,
4
);
return
-
1
;
if
(
ret
<
4
)
return
ret
<
0
?
ret
:
AVERROR_EOF
;
do
{
do
{
int
c
;
int
c
;
...
@@ -213,17 +214,17 @@ static int ogg_read_page(AVFormatContext *s, int *str)
...
@@ -213,17 +214,17 @@ static int ogg_read_page(AVFormatContext *s, int *str)
c
=
avio_r8
(
bc
);
c
=
avio_r8
(
bc
);
if
(
bc
->
eof_reached
)
if
(
bc
->
eof_reached
)
return
-
1
;
return
AVERROR_EOF
;
sync
[
sp
++
&
3
]
=
c
;
sync
[
sp
++
&
3
]
=
c
;
}
while
(
i
++
<
MAX_PAGE_SIZE
);
}
while
(
i
++
<
MAX_PAGE_SIZE
);
if
(
i
>=
MAX_PAGE_SIZE
){
if
(
i
>=
MAX_PAGE_SIZE
){
av_log
(
s
,
AV_LOG_INFO
,
"ogg, can't find sync word
\n
"
);
av_log
(
s
,
AV_LOG_INFO
,
"ogg, can't find sync word
\n
"
);
return
-
1
;
return
AVERROR_INVALIDDATA
;
}
}
if
(
avio_r8
(
bc
)
!=
0
)
/* version */
if
(
avio_r8
(
bc
)
!=
0
)
/* version */
return
-
1
;
return
AVERROR_INVALIDDATA
;
flags
=
avio_r8
(
bc
);
flags
=
avio_r8
(
bc
);
gp
=
avio_rl64
(
bc
);
gp
=
avio_rl64
(
bc
);
...
@@ -248,7 +249,7 @@ static int ogg_read_page(AVFormatContext *s, int *str)
...
@@ -248,7 +249,7 @@ static int ogg_read_page(AVFormatContext *s, int *str)
idx
=
ogg_new_stream
(
s
,
serial
,
1
);
idx
=
ogg_new_stream
(
s
,
serial
,
1
);
}
}
if
(
idx
<
0
)
if
(
idx
<
0
)
return
-
1
;
return
idx
;
}
}
os
=
ogg
->
streams
+
idx
;
os
=
ogg
->
streams
+
idx
;
...
@@ -257,8 +258,9 @@ static int ogg_read_page(AVFormatContext *s, int *str)
...
@@ -257,8 +258,9 @@ static int ogg_read_page(AVFormatContext *s, int *str)
if
(
os
->
psize
>
0
)
if
(
os
->
psize
>
0
)
ogg_new_buf
(
ogg
,
idx
);
ogg_new_buf
(
ogg
,
idx
);
if
(
avio_read
(
bc
,
os
->
segments
,
nsegs
)
<
nsegs
)
ret
=
avio_read
(
bc
,
os
->
segments
,
nsegs
);
return
-
1
;
if
(
ret
<
nsegs
)
return
ret
<
0
?
ret
:
AVERROR_EOF
;
os
->
nsegs
=
nsegs
;
os
->
nsegs
=
nsegs
;
os
->
segp
=
0
;
os
->
segp
=
0
;
...
@@ -289,8 +291,9 @@ static int ogg_read_page(AVFormatContext *s, int *str)
...
@@ -289,8 +291,9 @@ static int ogg_read_page(AVFormatContext *s, int *str)
os
->
buf
=
nb
;
os
->
buf
=
nb
;
}
}
if
(
avio_read
(
bc
,
os
->
buf
+
os
->
bufpos
,
size
)
<
size
)
ret
=
avio_read
(
bc
,
os
->
buf
+
os
->
bufpos
,
size
);
return
-
1
;
if
(
ret
<
size
)
return
ret
<
0
?
ret
:
AVERROR_EOF
;
os
->
bufpos
+=
size
;
os
->
bufpos
+=
size
;
os
->
granule
=
gp
;
os
->
granule
=
gp
;
...
@@ -306,7 +309,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
...
@@ -306,7 +309,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
int64_t
*
fpos
)
int64_t
*
fpos
)
{
{
struct
ogg
*
ogg
=
s
->
priv_data
;
struct
ogg
*
ogg
=
s
->
priv_data
;
int
idx
,
i
;
int
idx
,
i
,
ret
;
struct
ogg_stream
*
os
;
struct
ogg_stream
*
os
;
int
complete
=
0
;
int
complete
=
0
;
int
segp
=
0
,
psize
=
0
;
int
segp
=
0
,
psize
=
0
;
...
@@ -317,8 +320,9 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
...
@@ -317,8 +320,9 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
idx
=
ogg
->
curidx
;
idx
=
ogg
->
curidx
;
while
(
idx
<
0
){
while
(
idx
<
0
){
if
(
ogg_read_page
(
s
,
&
idx
)
<
0
)
ret
=
ogg_read_page
(
s
,
&
idx
);
return
-
1
;
if
(
ret
<
0
)
return
ret
;
}
}
os
=
ogg
->
streams
+
idx
;
os
=
ogg
->
streams
+
idx
;
...
@@ -330,6 +334,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
...
@@ -330,6 +334,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
if
(
os
->
header
<
0
){
if
(
os
->
header
<
0
){
os
->
codec
=
ogg_find_codec
(
os
->
buf
,
os
->
bufpos
);
os
->
codec
=
ogg_find_codec
(
os
->
buf
,
os
->
bufpos
);
if
(
!
os
->
codec
){
if
(
!
os
->
codec
){
av_log
(
s
,
AV_LOG_WARNING
,
"Codec not found
\n
"
);
os
->
header
=
0
;
os
->
header
=
0
;
return
0
;
return
0
;
}
}
...
@@ -428,10 +433,12 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
...
@@ -428,10 +433,12 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
static
int
ogg_get_headers
(
AVFormatContext
*
s
)
static
int
ogg_get_headers
(
AVFormatContext
*
s
)
{
{
struct
ogg
*
ogg
=
s
->
priv_data
;
struct
ogg
*
ogg
=
s
->
priv_data
;
int
ret
;
do
{
do
{
if
(
ogg_packet
(
s
,
NULL
,
NULL
,
NULL
,
NULL
)
<
0
)
ret
=
ogg_packet
(
s
,
NULL
,
NULL
,
NULL
,
NULL
);
return
-
1
;
if
(
ret
<
0
)
return
ret
;
}
while
(
!
ogg
->
headers
);
}
while
(
!
ogg
->
headers
);
av_dlog
(
s
,
"found headers
\n
"
);
av_dlog
(
s
,
"found headers
\n
"
);
...
@@ -478,12 +485,12 @@ static int ogg_get_length(AVFormatContext *s)
...
@@ -478,12 +485,12 @@ static int ogg_get_length(AVFormatContext *s)
static
int
ogg_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
static
int
ogg_read_header
(
AVFormatContext
*
s
,
AVFormatParameters
*
ap
)
{
{
struct
ogg
*
ogg
=
s
->
priv_data
;
struct
ogg
*
ogg
=
s
->
priv_data
;
int
i
;
int
ret
,
i
;
ogg
->
curidx
=
-
1
;
ogg
->
curidx
=
-
1
;
//linear headers seek from start
//linear headers seek from start
if
(
ogg_get_headers
(
s
)
<
0
){
ret
=
ogg_get_headers
(
s
);
return
-
1
;
if
(
ret
<
0
)
}
return
ret
;
for
(
i
=
0
;
i
<
ogg
->
nstreams
;
i
++
)
for
(
i
=
0
;
i
<
ogg
->
nstreams
;
i
++
)
if
(
ogg
->
streams
[
i
].
header
<
0
)
if
(
ogg
->
streams
[
i
].
header
<
0
)
...
@@ -530,15 +537,16 @@ static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -530,15 +537,16 @@ static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
{
{
struct
ogg
*
ogg
;
struct
ogg
*
ogg
;
struct
ogg_stream
*
os
;
struct
ogg_stream
*
os
;
int
idx
=
-
1
;
int
idx
=
-
1
,
ret
;
int
pstart
,
psize
;
int
pstart
,
psize
;
int64_t
fpos
,
pts
,
dts
;
int64_t
fpos
,
pts
,
dts
;
//Get an ogg packet
//Get an ogg packet
retry:
retry:
do
{
do
{
if
(
ogg_packet
(
s
,
&
idx
,
&
pstart
,
&
psize
,
&
fpos
)
<
0
)
ret
=
ogg_packet
(
s
,
&
idx
,
&
pstart
,
&
psize
,
&
fpos
);
return
AVERROR
(
EIO
);
if
(
ret
<
0
)
return
ret
;
}
while
(
idx
<
0
||
!
s
->
streams
[
idx
]);
}
while
(
idx
<
0
||
!
s
->
streams
[
idx
]);
ogg
=
s
->
priv_data
;
ogg
=
s
->
priv_data
;
...
@@ -552,8 +560,9 @@ retry:
...
@@ -552,8 +560,9 @@ retry:
os
->
keyframe_seek
=
0
;
os
->
keyframe_seek
=
0
;
//Alloc a pkt
//Alloc a pkt
if
(
av_new_packet
(
pkt
,
psize
)
<
0
)
ret
=
av_new_packet
(
pkt
,
psize
);
return
AVERROR
(
EIO
);
if
(
ret
<
0
)
return
ret
;
pkt
->
stream_index
=
idx
;
pkt
->
stream_index
=
idx
;
memcpy
(
pkt
->
data
,
os
->
buf
+
pstart
,
psize
);
memcpy
(
pkt
->
data
,
os
->
buf
+
pstart
,
psize
);
...
...
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