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
681559d3
Commit
681559d3
authored
Dec 25, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/cache: remember EOF point if hit and use it to handle SEEK_END
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
0c0168a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
cache.c
libavformat/cache.c
+10
-0
No files found.
libavformat/cache.c
View file @
681559d3
...
...
@@ -57,6 +57,7 @@ typedef struct Context {
int64_t
cache_pos
;
int64_t
inner_pos
;
int64_t
end
;
int
is_true_eof
;
URLContext
*
inner
;
int64_t
cache_hit
,
cache_miss
;
}
Context
;
...
...
@@ -174,6 +175,10 @@ static int cache_read(URLContext *h, unsigned char *buf, int size)
}
r
=
ffurl_read
(
c
->
inner
,
buf
,
size
);
if
(
r
==
0
&&
size
>
0
)
{
c
->
is_true_eof
=
1
;
av_assert0
(
c
->
end
>=
c
->
logical_pos
);
}
if
(
r
<=
0
)
return
r
;
c
->
inner_pos
+=
r
;
...
...
@@ -198,6 +203,8 @@ static int64_t cache_seek(URLContext *h, int64_t pos, int whence)
if
(
ffurl_seek
(
c
->
inner
,
c
->
inner_pos
,
SEEK_SET
)
<
0
)
av_log
(
h
,
AV_LOG_ERROR
,
"Inner protocol failed to seekback
\n
"
);
}
if
(
pos
>
0
)
c
->
is_true_eof
=
1
;
c
->
end
=
FFMAX
(
c
->
end
,
pos
);
return
pos
;
}
...
...
@@ -205,6 +212,9 @@ static int64_t cache_seek(URLContext *h, int64_t pos, int whence)
if
(
whence
==
SEEK_CUR
)
{
whence
=
SEEK_SET
;
pos
+=
c
->
logical_pos
;
}
else
if
(
whence
==
SEEK_END
&&
c
->
is_true_eof
)
{
whence
=
SEEK_SET
;
pos
+=
c
->
end
;
}
if
(
whence
==
SEEK_SET
&&
pos
>=
0
&&
pos
<
c
->
end
)
{
...
...
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