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
0979b0f7
Commit
0979b0f7
authored
Jul 25, 2006
by
J. Alexander Treuman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Thanks for making my code totally unreadable indent!
git-svn-id:
https://svn.musicpd.org/mpd/trunk@4455
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
e880a878
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
66 deletions
+40
-66
mp3_plugin.c
src/inputPlugins/mp3_plugin.c
+40
-66
No files found.
src/inputPlugins/mp3_plugin.c
View file @
0979b0f7
...
@@ -450,7 +450,7 @@ enum {
...
@@ -450,7 +450,7 @@ enum {
XING_FRAMES
=
0x00000001L
,
XING_FRAMES
=
0x00000001L
,
XING_BYTES
=
0x00000002L
,
XING_BYTES
=
0x00000002L
,
XING_TOC
=
0x00000004L
,
XING_TOC
=
0x00000004L
,
XING_SCALE
=
0x00000008L
XING_SCALE
=
0x00000008L
,
};
};
static
int
parse_xing
(
struct
xing
*
xing
,
struct
mad_bitptr
*
ptr
,
int
bitlen
)
static
int
parse_xing
(
struct
xing
*
xing
,
struct
mad_bitptr
*
ptr
,
int
bitlen
)
...
@@ -462,62 +462,49 @@ static int parse_xing(struct xing *xing, struct mad_bitptr *ptr, int bitlen)
...
@@ -462,62 +462,49 @@ static int parse_xing(struct xing *xing, struct mad_bitptr *ptr, int bitlen)
oldbitlen
=
bitlen
;
oldbitlen
=
bitlen
;
if
(
bitlen
<
16
)
if
(
bitlen
<
16
)
goto
fail
;
goto
fail
;
bits
=
mad_bit_read
(
ptr
,
16
);
bits
=
mad_bit_read
(
ptr
,
16
);
bitlen
-=
16
;
bitlen
-=
16
;
if
(
bits
==
XI_MAGIC
)
{
if
(
bits
==
XI_MAGIC
)
{
if
(
bitlen
<
16
)
if
(
bitlen
<
16
)
goto
fail
;
goto
fail
;
if
(
mad_bit_read
(
ptr
,
16
)
!=
NG_MAGIC
)
goto
fail
;
if
(
mad_bit_read
(
ptr
,
16
)
!=
NG_MAGIC
)
goto
fail
;
bitlen
-=
16
;
bitlen
-=
16
;
xing
->
magic
=
XING_MAGIC_XING
;
xing
->
magic
=
XING_MAGIC_XING
;
}
else
if
(
bits
==
IN_MAGIC
)
{
}
else
if
(
bits
==
IN_MAGIC
)
{
if
(
bitlen
<
16
)
if
(
bitlen
<
16
)
goto
fail
;
goto
fail
;
if
(
mad_bit_read
(
ptr
,
16
)
!=
FO_MAGIC
)
goto
fail
;
if
(
mad_bit_read
(
ptr
,
16
)
!=
FO_MAGIC
)
goto
fail
;
bitlen
-=
16
;
bitlen
-=
16
;
xing
->
magic
=
XING_MAGIC_INFO
;
xing
->
magic
=
XING_MAGIC_INFO
;
}
else
if
(
bits
==
NG_MAGIC
)
}
xing
->
magic
=
XING_MAGIC_XING
;
else
if
(
bits
==
NG_MAGIC
)
xing
->
magic
=
XING_MAGIC_XING
;
else
if
(
bits
==
FO_MAGIC
)
else
if
(
bits
==
FO_MAGIC
)
xing
->
magic
=
XING_MAGIC_INFO
;
xing
->
magic
=
XING_MAGIC_INFO
;
else
goto
fail
;
else
goto
fail
;
if
(
bitlen
<
32
)
if
(
bitlen
<
32
)
goto
fail
;
goto
fail
;
xing
->
flags
=
mad_bit_read
(
ptr
,
32
);
xing
->
flags
=
mad_bit_read
(
ptr
,
32
);
bitlen
-=
32
;
bitlen
-=
32
;
if
(
xing
->
flags
&
XING_FRAMES
)
{
if
(
xing
->
flags
&
XING_FRAMES
)
{
if
(
bitlen
<
32
)
if
(
bitlen
<
32
)
goto
fail
;
goto
fail
;
xing
->
frames
=
mad_bit_read
(
ptr
,
32
);
xing
->
frames
=
mad_bit_read
(
ptr
,
32
);
bitlen
-=
32
;
bitlen
-=
32
;
}
}
if
(
xing
->
flags
&
XING_BYTES
)
{
if
(
xing
->
flags
&
XING_BYTES
)
{
if
(
bitlen
<
32
)
if
(
bitlen
<
32
)
goto
fail
;
goto
fail
;
xing
->
bytes
=
mad_bit_read
(
ptr
,
32
);
xing
->
bytes
=
mad_bit_read
(
ptr
,
32
);
bitlen
-=
32
;
bitlen
-=
32
;
}
}
if
(
xing
->
flags
&
XING_TOC
)
{
if
(
xing
->
flags
&
XING_TOC
)
{
if
(
bitlen
<
800
)
if
(
bitlen
<
800
)
goto
fail
;
goto
fail
;
for
(
i
=
0
;
i
<
100
;
++
i
)
xing
->
toc
[
i
]
=
mad_bit_read
(
ptr
,
8
);
for
(
i
=
0
;
i
<
100
;
++
i
)
xing
->
toc
[
i
]
=
mad_bit_read
(
ptr
,
8
);
bitlen
-=
800
;
bitlen
-=
800
;
}
}
if
(
xing
->
flags
&
XING_SCALE
)
{
if
(
xing
->
flags
&
XING_SCALE
)
{
if
(
bitlen
<
32
)
if
(
bitlen
<
32
)
goto
fail
;
goto
fail
;
xing
->
scale
=
mad_bit_read
(
ptr
,
32
);
xing
->
scale
=
mad_bit_read
(
ptr
,
32
);
bitlen
-=
32
;
bitlen
-=
32
;
}
}
...
@@ -525,8 +512,7 @@ static int parse_xing(struct xing *xing, struct mad_bitptr *ptr, int bitlen)
...
@@ -525,8 +512,7 @@ static int parse_xing(struct xing *xing, struct mad_bitptr *ptr, int bitlen)
/* Make sure we consume no less than 120 bytes (960 bits) in hopes that
/* Make sure we consume no less than 120 bytes (960 bits) in hopes that
* the LAME tag is found there, and not right after the Xing header */
* the LAME tag is found there, and not right after the Xing header */
bitsleft
=
960
-
(
oldbitlen
-
bitlen
);
bitsleft
=
960
-
(
oldbitlen
-
bitlen
);
if
(
bitsleft
<
0
)
if
(
bitsleft
<
0
)
goto
fail
;
goto
fail
;
else
if
(
bitsleft
>
0
)
{
else
if
(
bitsleft
>
0
)
{
mad_bit_read
(
ptr
,
bitsleft
);
mad_bit_read
(
ptr
,
bitsleft
);
bitlen
-=
bitsleft
;
bitlen
-=
bitsleft
;
...
@@ -538,12 +524,11 @@ static int parse_xing(struct xing *xing, struct mad_bitptr *ptr, int bitlen)
...
@@ -538,12 +524,11 @@ static int parse_xing(struct xing *xing, struct mad_bitptr *ptr, int bitlen)
return
-
1
;
return
-
1
;
}
}
static
int
parse_extension
_header
s
(
struct
xing
*
xing
,
struct
mad_bitptr
ptr
,
static
int
parse_extensions
(
struct
xing
*
xing
,
struct
mad_bitptr
ptr
,
int
bitlen
)
int
bitlen
)
{
{
bitlen
=
parse_xing
(
xing
,
&
ptr
,
bitlen
);
bitlen
=
parse_xing
(
xing
,
&
ptr
,
bitlen
);
if
(
bitlen
<
0
)
if
(
bitlen
<
0
)
return
0
;
return
0
;
return
1
;
return
1
;
}
}
...
@@ -560,50 +545,41 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc,
...
@@ -560,50 +545,41 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc,
while
(
1
)
{
while
(
1
)
{
skip
=
0
;
skip
=
0
;
while
((
ret
=
while
((
ret
=
decodeNextFrameHeader
(
data
,
tag
,
replayGainInfo
))
==
DECODE_CONT
&&
decodeNextFrameHeader
(
data
,
tag
,
(
!
dc
||
!
dc
->
stop
));
replayGainInfo
))
==
DECODE_CONT
&&
(
!
dc
||
!
dc
->
stop
))
;
if
(
ret
==
DECODE_SKIP
)
skip
=
1
;
if
(
ret
==
DECODE_SKIP
)
else
if
(
ret
==
DECODE_BREAK
||
(
dc
&&
dc
->
stop
))
return
-
1
;
skip
=
1
;
else
if
(
ret
==
DECODE_BREAK
||
(
dc
&&
dc
->
stop
))
return
-
1
;
while
((
ret
=
decodeNextFrame
(
data
))
==
DECODE_CONT
&&
while
((
ret
=
decodeNextFrame
(
data
))
==
DECODE_CONT
&&
(
!
dc
||
!
dc
->
stop
))
;
(
!
dc
||
!
dc
->
stop
));
if
(
ret
==
DECODE_BREAK
||
(
dc
&&
dc
->
stop
))
return
-
1
;
if
(
ret
==
DECODE_BREAK
||
(
dc
&&
dc
->
stop
))
return
-
1
;
if
(
!
skip
&&
ret
==
DECODE_OK
)
if
(
!
skip
&&
ret
==
DECODE_OK
)
break
;
break
;
}
}
if
(
parse_extension
_header
s
(
&
xing
,
data
->
stream
.
anc_ptr
,
if
(
parse_extensions
(
&
xing
,
data
->
stream
.
anc_ptr
,
(
int
)
data
->
stream
.
anc_bitlen
))
{
(
int
)
data
->
stream
.
anc_bitlen
))
{
if
(
xing
.
flags
&
XING_FRAMES
)
{
if
(
xing
.
flags
&
XING_FRAMES
)
{
mad_timer_t
duration
=
data
->
frame
.
header
.
duration
;
mad_timer_t
duration
=
data
->
frame
.
header
.
duration
;
mad_timer_multiply
(
&
duration
,
xing
.
frames
);
mad_timer_multiply
(
&
duration
,
xing
.
frames
);
data
->
muteFrame
=
MUTEFRAME_SKIP
;
data
->
muteFrame
=
MUTEFRAME_SKIP
;
data
->
totalTime
=
((
float
)
mad_timer_count
(
duration
,
data
->
totalTime
=
((
float
)
mad_timer_count
(
duration
,
MAD_UNITS_MILLISECONDS
))
/
1000
;
MAD_UNITS_MILLISECONDS
))
/
1000
;
data
->
maxFrames
=
xing
.
frames
;
data
->
maxFrames
=
xing
.
frames
;
}
}
}
else
{
}
else
{
size_t
offset
=
data
->
inStream
->
offset
;
size_t
offset
=
data
->
inStream
->
offset
;
mad_timer_t
duration
=
data
->
frame
.
header
.
duration
;
mad_timer_t
duration
=
data
->
frame
.
header
.
duration
;
float
frameTime
=
((
float
)
mad_timer_count
(
duration
,
float
frameTime
=
((
float
)
mad_timer_count
(
duration
,
MAD_UNITS_MILLISECONDS
))
/
1000
;
MAD_UNITS_MILLISECONDS
))
/
1000
;
if
(
data
->
stream
.
this_frame
!=
NULL
)
if
(
data
->
stream
.
this_frame
!=
NULL
)
{
offset
-=
data
->
stream
.
bufend
-
data
->
stream
.
this_frame
;
offset
-=
data
->
stream
.
bufend
-
data
->
stream
.
this_frame
;
}
else
{
else
offset
-=
data
->
stream
.
bufend
-
data
->
stream
.
buffer
;
offset
-=
data
->
stream
.
bufend
-
data
->
stream
.
buffer
;
}
if
(
data
->
inStream
->
size
>=
offset
)
{
if
(
data
->
inStream
->
size
>=
offset
)
{
data
->
totalTime
=
data
->
totalTime
=
((
data
->
inStream
->
size
-
offset
)
*
8
.
0
)
/
(
data
->
frame
).
header
.
bitrate
;
((
data
->
inStream
->
size
-
data
->
maxFrames
=
data
->
totalTime
/
frameTime
+
FRAMES_CUSHION
;
offset
)
*
8
.
0
)
/
(
data
->
frame
).
header
.
bitrate
;
data
->
maxFrames
=
data
->
totalTime
/
frameTime
+
FRAMES_CUSHION
;
}
else
{
}
else
{
data
->
maxFrames
=
FRAMES_CUSHION
;
data
->
maxFrames
=
FRAMES_CUSHION
;
data
->
totalTime
=
0
;
data
->
totalTime
=
0
;
...
@@ -622,10 +598,8 @@ static void mp3DecodeDataFinalize(mp3DecodeData * data)
...
@@ -622,10 +598,8 @@ static void mp3DecodeDataFinalize(mp3DecodeData * data)
mad_frame_finish
(
&
data
->
frame
);
mad_frame_finish
(
&
data
->
frame
);
mad_stream_finish
(
&
data
->
stream
);
mad_stream_finish
(
&
data
->
stream
);
if
(
data
->
frameOffset
)
if
(
data
->
frameOffset
)
free
(
data
->
frameOffset
);
free
(
data
->
frameOffset
);
if
(
data
->
times
)
free
(
data
->
times
);
if
(
data
->
times
)
free
(
data
->
times
);
}
}
/* this is primarily used for getting total time for tags */
/* this is primarily used for getting total time for tags */
...
...
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