Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
b87cc3c1
Commit
b87cc3c1
authored
Mar 18, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
seek support for mp4/aac
git-svn-id:
https://svn.musicpd.org/mpd/trunk@281
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
692dd6bc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
14 deletions
+43
-14
decode.c
src/decode.c
+4
-3
mp4_decode.c
src/mp4_decode.c
+39
-11
No files found.
src/decode.c
View file @
b87cc3c1
...
...
@@ -155,9 +155,10 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
waitOnDecode
(
pc
,
af
,
dc
,
cb
);
}
if
(
*
decode_pid
>
0
&&
dc
->
state
==
DECODE_STATE_DECODE
)
{
dc
->
seekWhere
=
pc
->
seekWhere
>
pc
->
totalTime
-
1
?
pc
->
totalTime
-
1
:
pc
->
seekWhere
;
dc
->
seekWhere
=
1
>
dc
->
seekWhere
?
1
:
dc
->
seekWhere
;
dc
->
seekWhere
=
pc
->
seekWhere
>
pc
->
totalTime
-
0
.
1
?
pc
->
totalTime
-
0
.
1
:
pc
->
seekWhere
;
dc
->
seekWhere
=
0
>
dc
->
seekWhere
?
0
:
dc
->
seekWhere
;
cb
->
begin
=
0
;
dc
->
seek
=
1
;
pc
->
elapsedTime
=
dc
->
seekWhere
;
...
...
src/mp4_decode.c
View file @
b87cc3c1
...
...
@@ -88,14 +88,15 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
long
sampleId
;
long
numSamples
;
int
eof
=
0
;
int
rc
;
long
dur
;
unsigned
int
sampleCount
;
char
*
sampleBuffer
;
size_t
sampleBufferLen
;
unsigned
int
initial
=
1
;
int
chunkLen
=
0
;
float
*
seekTable
;
long
seekTableEnd
=
-
1
;
int
seekPositionFound
=
0
;
fh
=
fopen
(
dc
->
file
,
"r"
);
if
(
!
fh
)
{
...
...
@@ -173,19 +174,46 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
dc
->
start
=
0
;
time
=
0
.
0
;
seekTable
=
malloc
(
sizeof
(
float
)
*
numSamples
);
for
(
sampleId
=
0
;
sampleId
<
numSamples
&&
!
eof
;
sampleId
++
)
{
if
(
dc
->
seek
)
{
if
(
dc
->
seek
&&
seekTableEnd
>
1
&&
seekTable
[
seekTableEnd
]
>=
dc
->
seekWhere
)
{
int
i
=
2
;
while
(
seekTable
[
i
]
<
dc
->
seekWhere
)
i
++
;
sampleId
=
i
-
1
;
time
=
seekTable
[
sampleId
];
}
if
((
dur
=
mp4ff_get_sample_duration
(
mp4fh
,
track
,
sampleId
))
==
0
)
{
eof
=
1
;
break
;
}
if
(
sampleId
>
seekTableEnd
)
{
seekTable
[
sampleId
]
=
time
;
seekTableEnd
=
sampleId
;
}
if
(
sampleId
==
0
)
dur
=
0
;
time
+=
((
float
)
dur
)
/
scale
;
if
(
dc
->
seek
&&
time
>
dc
->
seekWhere
)
seekPositionFound
=
1
;
if
(
dc
->
seek
&&
seekPositionFound
)
{
seekPositionFound
=
0
;
chunkLen
=
0
;
cb
->
end
=
0
;
cb
->
wrap
=
0
;
#warning implement seeking here!
dc
->
seek
=
0
;
}
dur
=
mp4ff_get_sample_duration
(
mp4fh
,
track
,
sampleId
);
rc
=
mp4ff_read_sample
(
mp4fh
,
track
,
sampleId
,
&
mp4Buffer
,
&
mp4BufferSize
);
if
(
dc
->
seek
)
continue
;
if
(
rc
==
0
)
{
if
(
mp4ff_read_sample
(
mp4fh
,
track
,
sampleId
,
&
mp4Buffer
,
&
mp4BufferSize
)
==
0
)
{
eof
=
1
;
break
;
}
...
...
@@ -193,13 +221,12 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
sampleBuffer
=
faacDecDecode
(
decoder
,
&
frameInfo
,
mp4Buffer
,
mp4BufferSize
);
if
(
mp4Buffer
)
free
(
mp4Buffer
);
if
(
sampleId
==
0
)
dur
=
0
;
time
+=
((
float
)
dur
)
/
scale
;
sampleCount
=
(
unsigned
long
)(
dur
*
channels
);
if
(
sampleCount
>
0
)
initial
=
0
;
sampleBufferLen
=
sampleCount
*
2
;
while
(
sampleBufferLen
>
0
)
{
while
(
sampleBufferLen
>
0
&&
!
dc
->
seek
)
{
size_t
size
=
sampleBufferLen
>
CHUNK_SIZE
-
chunkLen
?
CHUNK_SIZE
-
chunkLen
:
sampleBufferLen
;
...
...
@@ -255,6 +282,7 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
}
else
dc
->
state
=
DECODE_STATE_STOP
;
free
(
seekTable
);
faacDecClose
(
decoder
);
mp4ff_close
(
mp4fh
);
fclose
(
fh
);
...
...
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