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
f0349df7
Commit
f0349df7
authored
Mar 12, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/vpk: add seeking support
parent
e35f9668
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
vpk.c
libavformat/vpk.c
+25
-0
No files found.
libavformat/vpk.c
View file @
f0349df7
...
...
@@ -24,6 +24,7 @@
#include "internal.h"
typedef
struct
VPKDemuxContext
{
unsigned
data_start
;
unsigned
block_count
;
unsigned
current_block
;
unsigned
last_block_size
;
...
...
@@ -70,6 +71,7 @@ static int vpk_read_header(AVFormatContext *s)
if
(
offset
<
avio_tell
(
s
->
pb
))
return
AVERROR_INVALIDDATA
;
avio_skip
(
s
->
pb
,
offset
-
avio_tell
(
s
->
pb
));
vpk
->
data_start
=
offset
;
avpriv_set_pts_info
(
st
,
64
,
1
,
st
->
codecpar
->
sample_rate
);
return
0
;
...
...
@@ -85,6 +87,7 @@ static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
if
(
vpk
->
current_block
==
vpk
->
block_count
)
{
unsigned
size
=
vpk
->
last_block_size
/
par
->
channels
;
unsigned
skip
=
(
par
->
block_align
-
vpk
->
last_block_size
)
/
par
->
channels
;
uint64_t
pos
=
avio_tell
(
s
->
pb
);
ret
=
av_new_packet
(
pkt
,
vpk
->
last_block_size
);
if
(
ret
<
0
)
...
...
@@ -96,6 +99,7 @@ static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
return
AVERROR
(
EIO
);
}
}
pkt
->
pos
=
pos
;
pkt
->
stream_index
=
0
;
}
else
if
(
vpk
->
current_block
<
vpk
->
block_count
)
{
ret
=
av_get_packet
(
s
->
pb
,
pkt
,
par
->
block_align
);
...
...
@@ -107,6 +111,26 @@ static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
return
ret
;
}
static
int
vpk_read_seek
(
AVFormatContext
*
s
,
int
stream_index
,
int64_t
timestamp
,
int
flags
)
{
AVStream
*
st
=
s
->
streams
[
stream_index
];
AVCodecParameters
*
par
=
st
->
codecpar
;
VPKDemuxContext
*
vpk
=
s
->
priv_data
;
int
samples_per_block
;
int64_t
ret
=
0
;
samples_per_block
=
av_get_audio_frame_duration2
(
par
,
par
->
block_align
);
timestamp
/=
samples_per_block
;
ret
=
avio_seek
(
s
->
pb
,
vpk
->
data_start
+
timestamp
*
par
->
block_align
,
SEEK_SET
);
if
(
ret
<
0
)
return
ret
;
vpk
->
current_block
=
timestamp
;
ff_update_cur_dts
(
s
,
st
,
timestamp
*
samples_per_block
);
return
0
;
}
AVInputFormat
ff_vpk_demuxer
=
{
.
name
=
"vpk"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"Sony PS2 VPK"
),
...
...
@@ -114,5 +138,6 @@ AVInputFormat ff_vpk_demuxer = {
.
read_probe
=
vpk_probe
,
.
read_header
=
vpk_read_header
,
.
read_packet
=
vpk_read_packet
,
.
read_seek
=
vpk_read_seek
,
.
extensions
=
"vpk"
,
};
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