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
0e18fab6
Commit
0e18fab6
authored
Mar 27, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpcdec: no CamelCase
Renamed variables and functions.
parent
86827fc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
57 deletions
+65
-57
mpcdec_plugin.c
src/decoder/mpcdec_plugin.c
+65
-57
No files found.
src/decoder/mpcdec_plugin.c
View file @
0e18fab6
...
...
@@ -27,48 +27,54 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "mpcdec"
typedef
struct
_MpcCallbackD
ata
{
struct
input_stream
*
i
nStream
;
struct
mpc_decoder_d
ata
{
struct
input_stream
*
i
s
;
struct
decoder
*
decoder
;
}
MpcCallbackData
;
};
static
mpc_int32_t
mpc_read_cb
(
void
*
vdata
,
void
*
ptr
,
mpc_int32_t
size
)
static
mpc_int32_t
mpc_read_cb
(
void
*
vdata
,
void
*
ptr
,
mpc_int32_t
size
)
{
MpcCallbackData
*
data
=
(
MpcCallbackD
ata
*
)
vdata
;
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_d
ata
*
)
vdata
;
return
decoder_read
(
data
->
decoder
,
data
->
i
nStream
,
ptr
,
size
);
return
decoder_read
(
data
->
decoder
,
data
->
i
s
,
ptr
,
size
);
}
static
mpc_bool_t
mpc_seek_cb
(
void
*
vdata
,
mpc_int32_t
offset
)
static
mpc_bool_t
mpc_seek_cb
(
void
*
vdata
,
mpc_int32_t
offset
)
{
MpcCallbackData
*
data
=
(
MpcCallbackD
ata
*
)
vdata
;
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_d
ata
*
)
vdata
;
return
input_stream_seek
(
data
->
i
nStream
,
offset
,
SEEK_SET
);
return
input_stream_seek
(
data
->
i
s
,
offset
,
SEEK_SET
);
}
static
mpc_int32_t
mpc_tell_cb
(
void
*
vdata
)
static
mpc_int32_t
mpc_tell_cb
(
void
*
vdata
)
{
MpcCallbackData
*
data
=
(
MpcCallbackD
ata
*
)
vdata
;
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_d
ata
*
)
vdata
;
return
(
long
)(
data
->
i
nStream
->
offset
);
return
(
long
)(
data
->
i
s
->
offset
);
}
static
mpc_bool_t
mpc_canseek_cb
(
void
*
vdata
)
static
mpc_bool_t
mpc_canseek_cb
(
void
*
vdata
)
{
MpcCallbackData
*
data
=
(
MpcCallbackD
ata
*
)
vdata
;
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_d
ata
*
)
vdata
;
return
data
->
i
nStream
->
seekable
;
return
data
->
i
s
->
seekable
;
}
static
mpc_int32_t
mpc_getsize_cb
(
void
*
vdata
)
static
mpc_int32_t
mpc_getsize_cb
(
void
*
vdata
)
{
MpcCallbackData
*
data
=
(
MpcCallbackD
ata
*
)
vdata
;
struct
mpc_decoder_data
*
data
=
(
struct
mpc_decoder_d
ata
*
)
vdata
;
return
data
->
i
nStream
->
size
;
return
data
->
i
s
->
size
;
}
/* this _looks_ performance-critical, don't de-inline -- eric */
static
inline
int32_t
convertSample
(
MPC_SAMPLE_FORMAT
sample
)
static
inline
int32_t
mpc_to_mpd_sample
(
MPC_SAMPLE_FORMAT
sample
)
{
/* only doing 16-bit audio for now */
int32_t
val
;
...
...
@@ -106,32 +112,32 @@ mpc_to_mpd_buffer(int32_t *dest, const MPC_SAMPLE_FORMAT *src,
unsigned
num_samples
)
{
while
(
num_samples
--
>
0
)
*
dest
++
=
convertS
ample
(
*
src
++
);
*
dest
++
=
mpc_to_mpd_s
ample
(
*
src
++
);
}
static
void
mpc_decode
(
struct
decoder
*
mpd_decoder
,
struct
input_stream
*
i
nStream
)
mpc_decode
(
struct
decoder
*
mpd_decoder
,
struct
input_stream
*
i
s
)
{
mpc_decoder
decoder
;
mpc_reader
reader
;
mpc_streaminfo
info
;
struct
audio_format
audio_format
;
MpcCallbackD
ata
data
;
struct
mpc_decoder_d
ata
data
;
MPC_SAMPLE_FORMAT
sample_buffer
[
MPC_DECODER_BUFFER_LENGTH
];
mpc_uint32_t
ret
;
int32_t
chunk
[
G_N_ELEMENTS
(
sample_buffer
)];
long
bit
R
ate
=
0
;
unsigned
long
sample
P
os
=
0
;
mpc_uint32_t
vbr
UpdateA
cc
;
mpc_uint32_t
vbr
UpdateB
its
;
long
bit
_r
ate
=
0
;
unsigned
long
sample
_p
os
=
0
;
mpc_uint32_t
vbr
_update_a
cc
;
mpc_uint32_t
vbr
_update_b
its
;
float
total_time
;
struct
replay_gain_info
*
replay
GainI
nfo
=
NULL
;
struct
replay_gain_info
*
replay
_gain_i
nfo
=
NULL
;
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
data
.
i
nStream
=
inStream
;
data
.
i
s
=
is
;
data
.
decoder
=
mpd_decoder
;
reader
.
read
=
mpc_read_cb
;
...
...
@@ -169,62 +175,63 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
return
;
}
replay
GainI
nfo
=
replay_gain_info_new
();
replay
GainI
nfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
info
.
gain_album
*
0
.
01
;
replay
GainI
nfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
info
.
peak_album
/
32767
.
0
;
replay
GainI
nfo
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
info
.
gain_title
*
0
.
01
;
replay
GainI
nfo
->
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
info
.
peak_title
/
32767
.
0
;
replay
_gain_i
nfo
=
replay_gain_info_new
();
replay
_gain_i
nfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
info
.
gain_album
*
0
.
01
;
replay
_gain_i
nfo
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
info
.
peak_album
/
32767
.
0
;
replay
_gain_i
nfo
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
info
.
gain_title
*
0
.
01
;
replay
_gain_i
nfo
->
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
info
.
peak_title
/
32767
.
0
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
i
nStream
->
seekable
,
i
s
->
seekable
,
mpc_streaminfo_get_length
(
&
info
));
do
{
if
(
cmd
==
DECODE_COMMAND_SEEK
)
{
sample
P
os
=
decoder_seek_where
(
mpd_decoder
)
*
sample
_p
os
=
decoder_seek_where
(
mpd_decoder
)
*
audio_format
.
sample_rate
;
if
(
mpc_decoder_seek_sample
(
&
decoder
,
sample
P
os
))
if
(
mpc_decoder_seek_sample
(
&
decoder
,
sample
_p
os
))
decoder_command_finished
(
mpd_decoder
);
else
decoder_seek_error
(
mpd_decoder
);
}
vbr
UpdateA
cc
=
0
;
vbr
UpdateB
its
=
0
;
vbr
_update_a
cc
=
0
;
vbr
_update_b
its
=
0
;
ret
=
mpc_decoder_decode
(
&
decoder
,
sample_buffer
,
&
vbr
UpdateAcc
,
&
vbrUpdateB
its
);
&
vbr
_update_acc
,
&
vbr_update_b
its
);
if
(
ret
==
0
||
ret
==
(
mpc_uint32_t
)
-
1
)
break
;
sample
P
os
+=
ret
;
sample
_p
os
+=
ret
;
ret
*=
info
.
channels
;
mpc_to_mpd_buffer
(
chunk
,
sample_buffer
,
ret
);
total_time
=
((
float
)
sample
P
os
)
/
audio_format
.
sample_rate
;
bit
Rate
=
vbrUpdateB
its
*
audio_format
.
sample_rate
total_time
=
((
float
)
sample
_p
os
)
/
audio_format
.
sample_rate
;
bit
_rate
=
vbr_update_b
its
*
audio_format
.
sample_rate
/
1152
/
1000
;
cmd
=
decoder_data
(
mpd_decoder
,
i
nStream
,
cmd
=
decoder_data
(
mpd_decoder
,
i
s
,
chunk
,
ret
*
sizeof
(
chunk
[
0
]),
total_time
,
bit
Rate
,
replayGainI
nfo
);
bit
_rate
,
replay_gain_i
nfo
);
}
while
(
cmd
!=
DECODE_COMMAND_STOP
);
replay_gain_info_free
(
replay
GainI
nfo
);
replay_gain_info_free
(
replay
_gain_i
nfo
);
}
static
float
mpcGetTime
(
const
char
*
file
)
static
float
mpcdec_get_file_duration
(
const
char
*
file
)
{
struct
input_stream
i
nStream
;
struct
input_stream
i
s
;
float
total_time
=
-
1
;
mpc_reader
reader
;
mpc_streaminfo
info
;
MpcCallbackD
ata
data
;
struct
mpc_decoder_d
ata
data
;
data
.
i
nStream
=
&
inStream
;
data
.
i
s
=
&
is
;
data
.
decoder
=
NULL
;
reader
.
read
=
mpc_read_cb
;
...
...
@@ -236,24 +243,25 @@ static float mpcGetTime(const char *file)
mpc_streaminfo_init
(
&
info
);
if
(
!
input_stream_open
(
&
i
nStream
,
file
))
if
(
!
input_stream_open
(
&
i
s
,
file
))
return
-
1
;
if
(
mpc_streaminfo_read
(
&
info
,
&
reader
)
!=
ERROR_CODE_OK
)
{
input_stream_close
(
&
i
nStream
);
input_stream_close
(
&
i
s
);
return
-
1
;
}
total_time
=
mpc_streaminfo_get_length
(
&
info
);
input_stream_close
(
&
i
nStream
);
input_stream_close
(
&
i
s
);
return
total_time
;
}
static
struct
tag
*
mpcTagDup
(
const
char
*
file
)
static
struct
tag
*
mpcdec_tag_dup
(
const
char
*
file
)
{
float
total_time
=
mpc
GetTime
(
file
);
float
total_time
=
mpc
dec_get_file_duration
(
file
);
struct
tag
*
tag
;
if
(
total_time
<
0
)
{
...
...
@@ -266,11 +274,11 @@ static struct tag *mpcTagDup(const char *file)
return
tag
;
}
static
const
char
*
const
mpc
S
uffixes
[]
=
{
"mpc"
,
NULL
};
static
const
char
*
const
mpc
dec_s
uffixes
[]
=
{
"mpc"
,
NULL
};
const
struct
decoder_plugin
mpcdec_decoder_plugin
=
{
.
name
=
"mpc"
,
.
stream_decode
=
mpc_decode
,
.
tag_dup
=
mpc
TagD
up
,
.
suffixes
=
mpc
S
uffixes
,
.
tag_dup
=
mpc
dec_tag_d
up
,
.
suffixes
=
mpc
dec_s
uffixes
,
};
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