Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
cd4f1bb1
Commit
cd4f1bb1
authored
Jul 10, 2014
by
Rémi Denis-Courmont
Committed by
Jean-Baptiste Kempf
Jul 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
smf: revector
parent
54b15b34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
40 deletions
+72
-40
modules/demux/smf.c
modules/demux/smf.c
+72
-40
No files found.
modules/demux/smf.c
View file @
cd4f1bb1
...
...
@@ -356,6 +356,68 @@ skip:
return
0
;
}
static
int
SeekSet0
(
demux_t
*
demux
)
{
stream_t
*
stream
=
demux
->
s
;
demux_sys_t
*
sys
=
demux
->
p_sys
;
/* Default SMF tempo is 120BPM, i.e. half a second per quarter note */
date_Init
(
&
sys
->
pts
,
sys
->
ppqn
*
2
,
1
);
date_Set
(
&
sys
->
pts
,
VLC_TS_0
);
sys
->
pulse
=
0
;
sys
->
tick
=
VLC_TS_0
;
for
(
unsigned
i
=
0
;
i
<
sys
->
trackc
;
i
++
)
{
mtrk_t
*
tr
=
sys
->
trackv
+
i
;
tr
->
offset
=
0
;
tr
->
next
=
0
;
/* Why 0xF6 (Tuning Calibration)?
* Because it has zero bytes of data, so the parser will detect the
* error if the first event uses running status. */
tr
->
running_event
=
0xF6
;
if
(
stream_Seek
(
stream
,
tr
->
start
)
||
ReadDeltaTime
(
stream
,
tr
))
{
msg_Err
(
demux
,
"fatal parsing error"
);
return
-
1
;
}
}
return
0
;
}
static
int
ReadEvents
(
demux_t
*
demux
,
uint64_t
*
restrict
pulse
)
{
uint64_t
cur_pulse
=
*
pulse
,
next_pulse
=
UINT64_MAX
;
demux_sys_t
*
sys
=
demux
->
p_sys
;
for
(
unsigned
i
=
0
;
i
<
sys
->
trackc
;
i
++
)
{
mtrk_t
*
track
=
sys
->
trackv
+
i
;
while
(
track
->
next
<=
cur_pulse
)
{
if
(
HandleMessage
(
demux
,
track
)
||
ReadDeltaTime
(
demux
->
s
,
track
))
{
msg_Err
(
demux
,
"fatal parsing error"
);
return
-
1
;
}
}
if
(
next_pulse
>
track
->
next
)
next_pulse
=
track
->
next
;
}
if
(
next_pulse
!=
UINT64_MAX
)
date_Increment
(
&
sys
->
pts
,
next_pulse
-
cur_pulse
);
*
pulse
=
next_pulse
;
return
0
;
}
/*****************************************************************************
* Demux: read chunks and send them to the synthesizer
*****************************************************************************
...
...
@@ -383,31 +445,15 @@ static int Demux (demux_t *demux)
}
/* MIDI events in chronological order across all tracks */
uint64_t
cur_pulse
=
sys
->
pulse
,
next_pulse
=
UINT64_MAX
;
for
(
unsigned
i
=
0
;
i
<
sys
->
trackc
;
i
++
)
{
mtrk_t
*
track
=
sys
->
trackv
+
i
;
uint64_t
pulse
=
sys
->
pulse
;
while
(
track
->
next
==
cur_pulse
)
{
if
(
HandleMessage
(
demux
,
track
)
||
ReadDeltaTime
(
demux
->
s
,
track
))
{
msg_Err
(
demux
,
"fatal parsing error"
);
return
VLC_EGENERIC
;
}
}
if
(
next_pulse
>
track
->
next
)
next_pulse
=
track
->
next
;
}
if
(
ReadEvents
(
demux
,
&
pulse
))
return
VLC_EGENERIC
;
if
(
next_
pulse
==
UINT64_MAX
)
if
(
pulse
==
UINT64_MAX
)
return
0
;
/* all tracks are done */
date_Increment
(
&
sys
->
pts
,
next_pulse
-
cur_pulse
);
sys
->
pulse
=
next_pulse
;
sys
->
pulse
=
pulse
;
return
1
;
}
...
...
@@ -538,14 +584,10 @@ static int Open (vlc_object_t *obj)
if
(
stream_Read
(
stream
,
NULL
,
14
)
<
14
)
goto
error
;
/* Default SMF tempo is 120BPM, i.e. half a second per quarter note */
date_Init
(
&
sys
->
pts
,
ppqn
*
2
,
1
);
date_Set
(
&
sys
->
pts
,
VLC_TS_0
);
sys
->
pulse
=
0
;
sys
->
tick
=
VLC_TS_0
;
demux
->
p_sys
=
sys
;
sys
->
ppqn
=
ppqn
;
sys
->
trackc
=
tracks
;
sys
->
trackc
=
tracks
;
/* Prefetch track offsets */
for
(
unsigned
i
=
0
;
i
<
tracks
;
i
++
)
{
...
...
@@ -579,20 +621,11 @@ static int Open (vlc_object_t *obj)
tr
->
start
=
stream_Tell
(
stream
);
tr
->
length
=
GetDWBE
(
head
+
4
);
tr
->
offset
=
0
;
tr
->
next
=
0
;
/* Why 0xF6 (Tuning Calibration)?
* Because it has zero bytes of data, so the parser will detect the
* error if the first event uses running status. */
tr
->
running_event
=
0xF6
;
if
(
ReadDeltaTime
(
stream
,
tr
)
<
0
)
{
msg_Err
(
demux
,
"fatal parsing error"
);
goto
error
;
}
}
if
(
SeekSet0
(
demux
))
goto
error
;
es_format_t
fmt
;
es_format_Init
(
&
fmt
,
AUDIO_ES
,
VLC_CODEC_MIDI
);
fmt
.
audio
.
i_channels
=
2
;
...
...
@@ -601,7 +634,6 @@ static int Open (vlc_object_t *obj)
demux
->
pf_demux
=
Demux
;
demux
->
pf_control
=
Control
;
demux
->
p_sys
=
sys
;
return
VLC_SUCCESS
;
error:
...
...
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