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
8712a1f7
Commit
8712a1f7
authored
Nov 04, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mp4: no CamelCasee
Renamed functions and variables.
parent
ab07cdd4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
106 deletions
+111
-106
mp4_plugin.c
src/decoder/mp4_plugin.c
+109
-104
decoder_list.c
src/decoder_list.c
+2
-2
No files found.
src/decoder/mp4_plugin.c
View file @
8712a1f7
...
...
@@ -26,13 +26,14 @@
#include <faad.h>
/* all code here is either based on or copied from FAAD2's frontend code */
static
int
mp4_getAACTrack
(
mp4ff_t
*
infile
)
static
int
mp4_get_aac_track
(
mp4ff_t
*
infile
)
{
/* find AAC track */
int
i
,
rc
;
int
num
T
racks
=
mp4ff_total_tracks
(
infile
);
int
num
_t
racks
=
mp4ff_total_tracks
(
infile
);
for
(
i
=
0
;
i
<
num
T
racks
;
i
++
)
{
for
(
i
=
0
;
i
<
num
_t
racks
;
i
++
)
{
unsigned
char
*
buff
=
NULL
;
unsigned
int
buff_size
=
0
;
#ifdef HAVE_MP4AUDIOSPECIFICCONFIG
...
...
@@ -65,22 +66,23 @@ static int mp4_getAACTrack(mp4ff_t * infile)
return
-
1
;
}
static
uint32_t
mp4_inputStreamReadCallback
(
void
*
inStream
,
void
*
buffer
,
uint32_t
length
)
static
uint32_t
mp4_read
(
void
*
user_data
,
void
*
buffer
,
uint32_t
length
)
{
return
input_stream_read
((
struct
input_stream
*
)
inStream
,
return
input_stream_read
((
struct
input_stream
*
)
user_data
,
buffer
,
length
);
}
static
uint32_t
mp4_inputStreamSeekCallback
(
void
*
inStream
,
uint64_t
position
)
static
uint32_t
mp4_seek
(
void
*
user_data
,
uint64_t
position
)
{
return
input_stream_seek
((
struct
input_stream
*
)
inStream
,
return
input_stream_seek
((
struct
input_stream
*
)
user_data
,
position
,
SEEK_SET
)
?
0
:
-
1
;
}
static
bool
mp4_decode
(
struct
decoder
*
mpd_decoder
,
struct
input_stream
*
in
S
tream
)
mp4_decode
(
struct
decoder
*
mpd_decoder
,
struct
input_stream
*
in
put_s
tream
)
{
mp4ff_t
*
mp4fh
;
mp4ff_callback_t
*
mp4cb
;
...
...
@@ -88,33 +90,33 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
float
file_time
,
total_time
;
int32_t
scale
;
faacDecHandle
decoder
;
faacDecFrameInfo
frame
I
nfo
;
faacDecFrameInfo
frame
_i
nfo
;
faacDecConfigurationPtr
config
;
struct
audio_format
audio_format
;
unsigned
char
*
mp4
B
uffer
;
unsigned
int
mp4
BufferS
ize
;
unsigned
char
*
mp4
_b
uffer
;
unsigned
int
mp4
_buffer_s
ize
;
uint32_t
sample_rate
;
unsigned
char
channels
;
long
sample
I
d
;
long
num
S
amples
;
long
sample
_i
d
;
long
num
_s
amples
;
long
dur
;
unsigned
int
sample
C
ount
;
char
*
sample
B
uffer
;
size_t
sample
BufferLen
;
unsigned
int
sample
_c
ount
;
char
*
sample
_b
uffer
;
size_t
sample
_buffer_length
;
unsigned
int
initial
=
1
;
float
*
seek
T
able
;
long
seek
TableE
nd
=
-
1
;
bool
seek
PositionF
ound
=
false
;
float
*
seek
_t
able
;
long
seek
_table_e
nd
=
-
1
;
bool
seek
_position_f
ound
=
false
;
long
offset
;
uint16_t
bit
R
ate
=
0
;
uint16_t
bit
_r
ate
=
0
;
bool
seeking
=
false
;
double
seek_where
=
0
;
bool
initialized
=
false
;
mp4cb
=
xmalloc
(
sizeof
(
mp4ff_callback_t
));
mp4cb
->
read
=
mp4_
inputStreamReadCallback
;
mp4cb
->
seek
=
mp4_
inputStreamSeekCallbac
k
;
mp4cb
->
user_data
=
in
S
tream
;
mp4cb
->
read
=
mp4_
read
;
mp4cb
->
seek
=
mp4_
see
k
;
mp4cb
->
user_data
=
in
put_s
tream
;
mp4fh
=
mp4ff_open_read
(
mp4cb
);
if
(
!
mp4fh
)
{
...
...
@@ -123,7 +125,7 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
return
false
;
}
track
=
mp4_get
AACT
rack
(
mp4fh
);
track
=
mp4_get
_aac_t
rack
(
mp4fh
);
if
(
track
<
0
)
{
ERROR
(
"No AAC track found in mp4 stream.
\n
"
);
mp4ff_close
(
mp4fh
);
...
...
@@ -145,12 +147,12 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
audio_format
.
bits
=
16
;
mp4
B
uffer
=
NULL
;
mp4
BufferS
ize
=
0
;
mp4ff_get_decoder_config
(
mp4fh
,
track
,
&
mp4
Buffer
,
&
mp4BufferS
ize
);
mp4
_b
uffer
=
NULL
;
mp4
_buffer_s
ize
=
0
;
mp4ff_get_decoder_config
(
mp4fh
,
track
,
&
mp4
_buffer
,
&
mp4_buffer_s
ize
);
if
(
faacDecInit2
(
decoder
,
mp4Buffer
,
mp4BufferSize
,
&
sample_rate
,
&
channels
)
<
0
)
{
if
(
faacDecInit2
(
decoder
,
mp4_buffer
,
mp4_buffer_size
,
&
sample_rate
,
&
channels
)
<
0
)
{
ERROR
(
"Error not a AAC stream.
\n
"
);
faacDecClose
(
decoder
);
mp4ff_close
(
mp4fh
);
...
...
@@ -163,8 +165,8 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
file_time
=
mp4ff_get_track_duration_use_offsets
(
mp4fh
,
track
);
scale
=
mp4ff_time_scale
(
mp4fh
,
track
);
if
(
mp4
B
uffer
)
free
(
mp4
B
uffer
);
if
(
mp4
_b
uffer
)
free
(
mp4
_b
uffer
);
if
(
scale
<
0
)
{
ERROR
(
"Error getting audio format of mp4 AAC track.
\n
"
);
...
...
@@ -175,8 +177,8 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
}
total_time
=
((
float
)
file_time
)
/
scale
;
num
S
amples
=
mp4ff_num_samples
(
mp4fh
,
track
);
if
(
num
S
amples
>
(
long
)(
INT_MAX
/
sizeof
(
float
)))
{
num
_s
amples
=
mp4ff_num_samples
(
mp4fh
,
track
);
if
(
num
_s
amples
>
(
long
)(
INT_MAX
/
sizeof
(
float
)))
{
ERROR
(
"Integer overflow.
\n
"
);
faacDecClose
(
decoder
);
mp4ff_close
(
mp4fh
);
...
...
@@ -186,32 +188,32 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
file_time
=
0
.
0
;
seek
Table
=
xmalloc
(
sizeof
(
float
)
*
numS
amples
);
seek
_table
=
xmalloc
(
sizeof
(
float
)
*
num_s
amples
);
for
(
sample
Id
=
0
;
sampleId
<
numSamples
;
sampleI
d
++
)
{
for
(
sample
_id
=
0
;
sample_id
<
num_samples
;
sample_i
d
++
)
{
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_SEEK
)
{
seeking
=
true
;
seek_where
=
decoder_seek_where
(
mpd_decoder
);
}
if
(
seeking
&&
seek
TableE
nd
>
1
&&
seek
Table
[
seekTableE
nd
]
>=
seek_where
)
{
if
(
seeking
&&
seek
_table_e
nd
>
1
&&
seek
_table
[
seek_table_e
nd
]
>=
seek_where
)
{
int
i
=
2
;
while
(
seek
T
able
[
i
]
<
seek_where
)
while
(
seek
_t
able
[
i
]
<
seek_where
)
i
++
;
sample
I
d
=
i
-
1
;
file_time
=
seek
Table
[
sampleI
d
];
sample
_i
d
=
i
-
1
;
file_time
=
seek
_table
[
sample_i
d
];
}
dur
=
mp4ff_get_sample_duration
(
mp4fh
,
track
,
sample
I
d
);
offset
=
mp4ff_get_sample_offset
(
mp4fh
,
track
,
sample
I
d
);
dur
=
mp4ff_get_sample_duration
(
mp4fh
,
track
,
sample
_i
d
);
offset
=
mp4ff_get_sample_offset
(
mp4fh
,
track
,
sample
_i
d
);
if
(
sample
Id
>
seekTableE
nd
)
{
seek
Table
[
sampleI
d
]
=
file_time
;
seek
TableEnd
=
sampleI
d
;
if
(
sample
_id
>
seek_table_e
nd
)
{
seek
_table
[
sample_i
d
]
=
file_time
;
seek
_table_end
=
sample_i
d
;
}
if
(
sample
I
d
==
0
)
if
(
sample
_i
d
==
0
)
dur
=
0
;
if
(
offset
>
dur
)
dur
=
0
;
...
...
@@ -220,10 +222,10 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
file_time
+=
((
float
)
dur
)
/
scale
;
if
(
seeking
&&
file_time
>
seek_where
)
seek
PositionF
ound
=
true
;
seek
_position_f
ound
=
true
;
if
(
seeking
&&
seek
PositionF
ound
)
{
seek
PositionF
ound
=
false
;
if
(
seeking
&&
seek
_position_f
ound
)
{
seek
_position_f
ound
=
false
;
seeking
=
0
;
decoder_command_finished
(
mpd_decoder
);
}
...
...
@@ -231,63 +233,64 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
if
(
seeking
)
continue
;
if
(
mp4ff_read_sample
(
mp4fh
,
track
,
sample
Id
,
&
mp4B
uffer
,
&
mp4
BufferS
ize
)
==
0
)
if
(
mp4ff_read_sample
(
mp4fh
,
track
,
sample
_id
,
&
mp4_b
uffer
,
&
mp4
_buffer_s
ize
)
==
0
)
break
;
#ifdef HAVE_FAAD_BUFLEN_FUNCS
sample
Buffer
=
faacDecDecode
(
decoder
,
&
frameInfo
,
mp4B
uffer
,
mp4BufferS
ize
);
sample
_buffer
=
faacDecDecode
(
decoder
,
&
frame_info
,
mp4_b
uffer
,
mp4_buffer_s
ize
);
#else
sample
Buffer
=
faacDecDecode
(
decoder
,
&
frameInfo
,
mp4B
uffer
);
sample
_buffer
=
faacDecDecode
(
decoder
,
&
frame_info
,
mp4_b
uffer
);
#endif
if
(
mp4
B
uffer
)
free
(
mp4
B
uffer
);
if
(
frame
I
nfo
.
error
>
0
)
{
if
(
mp4
_b
uffer
)
free
(
mp4
_b
uffer
);
if
(
frame
_i
nfo
.
error
>
0
)
{
ERROR
(
"faad2 error: %s
\n
"
,
faacDecGetErrorMessage
(
frame
I
nfo
.
error
));
faacDecGetErrorMessage
(
frame
_i
nfo
.
error
));
break
;
}
if
(
!
initialized
)
{
channels
=
frame
I
nfo
.
channels
;
channels
=
frame
_i
nfo
.
channels
;
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
scale
=
frame
I
nfo
.
samplerate
;
scale
=
frame
_i
nfo
.
samplerate
;
#endif
audio_format
.
sample_rate
=
scale
;
audio_format
.
channels
=
frame
I
nfo
.
channels
;
audio_format
.
channels
=
frame
_i
nfo
.
channels
;
decoder_initialized
(
mpd_decoder
,
&
audio_format
,
inStream
->
seekable
,
total_time
);
input_stream
->
seekable
,
total_time
);
initialized
=
true
;
}
if
(
channels
*
(
unsigned
long
)(
dur
+
offset
)
>
frame
I
nfo
.
samples
)
{
dur
=
frame
I
nfo
.
samples
/
channels
;
if
(
channels
*
(
unsigned
long
)(
dur
+
offset
)
>
frame
_i
nfo
.
samples
)
{
dur
=
frame
_i
nfo
.
samples
/
channels
;
offset
=
0
;
}
sample
C
ount
=
(
unsigned
long
)(
dur
*
channels
);
sample
_c
ount
=
(
unsigned
long
)(
dur
*
channels
);
if
(
sample
C
ount
>
0
)
{
if
(
sample
_c
ount
>
0
)
{
initial
=
0
;
bit
Rate
=
frameI
nfo
.
bytesconsumed
*
8
.
0
*
frame
I
nfo
.
channels
*
scale
/
frame
I
nfo
.
samples
/
1000
+
0
.
5
;
bit
_rate
=
frame_i
nfo
.
bytesconsumed
*
8
.
0
*
frame
_i
nfo
.
channels
*
scale
/
frame
_i
nfo
.
samples
/
1000
+
0
.
5
;
}
sample
BufferLen
=
sampleC
ount
*
2
;
sample
_buffer_length
=
sample_c
ount
*
2
;
sample
B
uffer
+=
offset
*
channels
*
2
;
sample
_b
uffer
+=
offset
*
channels
*
2
;
decoder_data
(
mpd_decoder
,
in
Stream
,
sampleB
uffer
,
sample
BufferLen
,
file_time
,
bit
R
ate
,
NULL
);
decoder_data
(
mpd_decoder
,
in
put_stream
,
sample_b
uffer
,
sample
_buffer_length
,
file_time
,
bit
_r
ate
,
NULL
);
if
(
decoder_get_command
(
mpd_decoder
)
==
DECODE_COMMAND_STOP
)
break
;
}
free
(
seek
T
able
);
free
(
seek
_t
able
);
faacDecClose
(
decoder
);
mp4ff_close
(
mp4fh
);
free
(
mp4cb
);
...
...
@@ -301,10 +304,11 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
return
true
;
}
static
struct
tag
*
mp4DataDup
(
const
char
*
file
,
int
*
mp4MetadataFound
)
static
struct
tag
*
mp4_load_tag
(
const
char
*
file
,
int
*
tag_found
)
{
struct
tag
*
ret
=
NULL
;
struct
input_stream
in
S
tream
;
struct
input_stream
in
put_s
tream
;
mp4ff_t
*
mp4fh
;
mp4ff_callback_t
*
callback
;
int32_t
track
;
...
...
@@ -312,29 +316,29 @@ static struct tag *mp4DataDup(const char *file, int *mp4MetadataFound)
int32_t
scale
;
int
i
;
*
mp4MetadataF
ound
=
0
;
*
tag_f
ound
=
0
;
if
(
!
input_stream_open
(
&
in
S
tream
,
file
))
{
DEBUG
(
"mp4
DataDup
: Failed to open file: %s
\n
"
,
file
);
if
(
!
input_stream_open
(
&
in
put_s
tream
,
file
))
{
DEBUG
(
"mp4
_load_tag
: Failed to open file: %s
\n
"
,
file
);
return
NULL
;
}
callback
=
xmalloc
(
sizeof
(
mp4ff_callback_t
));
callback
->
read
=
mp4_
inputStreamReadCallback
;
callback
->
seek
=
mp4_
inputStreamSeekCallbac
k
;
callback
->
user_data
=
&
in
S
tream
;
callback
->
read
=
mp4_
read
;
callback
->
seek
=
mp4_
see
k
;
callback
->
user_data
=
&
in
put_s
tream
;
mp4fh
=
mp4ff_open_read
(
callback
);
if
(
!
mp4fh
)
{
free
(
callback
);
input_stream_close
(
&
in
S
tream
);
input_stream_close
(
&
in
put_s
tream
);
return
NULL
;
}
track
=
mp4_get
AACT
rack
(
mp4fh
);
track
=
mp4_get
_aac_t
rack
(
mp4fh
);
if
(
track
<
0
)
{
mp4ff_close
(
mp4fh
);
input_stream_close
(
&
in
S
tream
);
input_stream_close
(
&
in
put_s
tream
);
free
(
callback
);
return
NULL
;
}
...
...
@@ -344,7 +348,7 @@ static struct tag *mp4DataDup(const char *file, int *mp4MetadataFound)
scale
=
mp4ff_time_scale
(
mp4fh
,
track
);
if
(
scale
<
0
)
{
mp4ff_close
(
mp4fh
);
input_stream_close
(
&
in
S
tream
);
input_stream_close
(
&
in
put_s
tream
);
free
(
callback
);
tag_free
(
ret
);
return
NULL
;
...
...
@@ -359,25 +363,25 @@ static struct tag *mp4DataDup(const char *file, int *mp4MetadataFound)
if
(
0
==
strcasecmp
(
"artist"
,
item
))
{
tag_add_item
(
ret
,
TAG_ITEM_ARTIST
,
value
);
*
mp4MetadataF
ound
=
1
;
*
tag_f
ound
=
1
;
}
else
if
(
0
==
strcasecmp
(
"title"
,
item
))
{
tag_add_item
(
ret
,
TAG_ITEM_TITLE
,
value
);
*
mp4MetadataF
ound
=
1
;
*
tag_f
ound
=
1
;
}
else
if
(
0
==
strcasecmp
(
"album"
,
item
))
{
tag_add_item
(
ret
,
TAG_ITEM_ALBUM
,
value
);
*
mp4MetadataF
ound
=
1
;
*
tag_f
ound
=
1
;
}
else
if
(
0
==
strcasecmp
(
"track"
,
item
))
{
tag_add_item
(
ret
,
TAG_ITEM_TRACK
,
value
);
*
mp4MetadataF
ound
=
1
;
*
tag_f
ound
=
1
;
}
else
if
(
0
==
strcasecmp
(
"disc"
,
item
))
{
/* Is that the correct id? */
tag_add_item
(
ret
,
TAG_ITEM_DISC
,
value
);
*
mp4MetadataF
ound
=
1
;
*
tag_f
ound
=
1
;
}
else
if
(
0
==
strcasecmp
(
"genre"
,
item
))
{
tag_add_item
(
ret
,
TAG_ITEM_GENRE
,
value
);
*
mp4MetadataF
ound
=
1
;
*
tag_f
ound
=
1
;
}
else
if
(
0
==
strcasecmp
(
"date"
,
item
))
{
tag_add_item
(
ret
,
TAG_ITEM_DATE
,
value
);
*
mp4MetadataF
ound
=
1
;
*
tag_f
ound
=
1
;
}
free
(
item
);
...
...
@@ -385,20 +389,21 @@ static struct tag *mp4DataDup(const char *file, int *mp4MetadataFound)
}
mp4ff_close
(
mp4fh
);
input_stream_close
(
&
in
S
tream
);
input_stream_close
(
&
in
put_s
tream
);
return
ret
;
}
static
struct
tag
*
mp4TagDup
(
const
char
*
file
)
static
struct
tag
*
mp4_tag_dup
(
const
char
*
file
)
{
struct
tag
*
ret
=
NULL
;
int
mp4MetadataF
ound
=
0
;
int
tag_f
ound
=
0
;
ret
=
mp4
DataDup
(
file
,
&
mp4MetadataF
ound
);
ret
=
mp4
_load_tag
(
file
,
&
tag_f
ound
);
if
(
!
ret
)
return
NULL
;
if
(
!
mp4MetadataF
ound
)
{
if
(
!
tag_f
ound
)
{
struct
tag
*
temp
=
tag_id3_load
(
file
);
if
(
temp
)
{
temp
->
time
=
ret
->
time
;
...
...
@@ -411,13 +416,13 @@ static struct tag *mp4TagDup(const char *file)
}
static
const
char
*
const
mp4_suffixes
[]
=
{
"m4a"
,
"mp4"
,
NULL
};
static
const
char
*
const
mp4_mime
T
ypes
[]
=
{
"audio/mp4"
,
"audio/m4a"
,
NULL
};
static
const
char
*
const
mp4_mime
_t
ypes
[]
=
{
"audio/mp4"
,
"audio/m4a"
,
NULL
};
const
struct
decoder_plugin
mp4
P
lugin
=
{
const
struct
decoder_plugin
mp4
_p
lugin
=
{
.
name
=
"mp4"
,
.
stream_decode
=
mp4_decode
,
.
tag_dup
=
mp4
TagD
up
,
.
tag_dup
=
mp4
_tag_d
up
,
.
stream_types
=
INPUT_PLUGIN_STREAM_FILE
|
INPUT_PLUGIN_STREAM_URL
,
.
suffixes
=
mp4_suffixes
,
.
mime_types
=
mp4_mime
T
ypes
,
.
mime_types
=
mp4_mime
_t
ypes
,
};
src/decoder_list.c
View file @
8712a1f7
...
...
@@ -26,7 +26,7 @@ extern const struct decoder_plugin oggvorbisPlugin;
extern
const
struct
decoder_plugin
flacPlugin
;
extern
const
struct
decoder_plugin
oggflacPlugin
;
extern
const
struct
decoder_plugin
audiofilePlugin
;
extern
const
struct
decoder_plugin
mp4
P
lugin
;
extern
const
struct
decoder_plugin
mp4
_p
lugin
;
extern
const
struct
decoder_plugin
aacPlugin
;
extern
const
struct
decoder_plugin
mpcPlugin
;
extern
const
struct
decoder_plugin
wavpackPlugin
;
...
...
@@ -53,7 +53,7 @@ static const struct decoder_plugin *const decoder_plugins[] = {
&
aacPlugin
,
#endif
#ifdef HAVE_MP4
&
mp4
P
lugin
,
&
mp4
_p
lugin
,
#endif
#ifdef HAVE_MPCDEC
&
mpcPlugin
,
...
...
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