diff options
author | J. Alexander Treuman <jat@spatialrift.net> | 2006-07-25 20:08:22 +0000 |
---|---|---|
committer | J. Alexander Treuman <jat@spatialrift.net> | 2006-07-25 20:08:22 +0000 |
commit | e65fb6e14f07e07efff25bf38dfe7d922299169d (patch) | |
tree | 72866d7bc13bbba060f0a0e9581bf567a8182aaa /src/inputPlugins | |
parent | 0979b0f75ef5f0cbc48ef6c1aa451bebb61f05c8 (diff) | |
download | mpd-e65fb6e14f07e07efff25bf38dfe7d922299169d.tar.gz mpd-e65fb6e14f07e07efff25bf38dfe7d922299169d.tar.xz mpd-e65fb6e14f07e07efff25bf38dfe7d922299169d.zip |
Reworking xing parsing so lame tags will fit in better
git-svn-id: https://svn.musicpd.org/mpd/trunk@4456 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 0ca36c739..9bb5841d1 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -453,14 +453,14 @@ enum { 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 *oldbitlen) { unsigned long bits; - int oldbitlen; + int bitlen; int bitsleft; int i; - oldbitlen = bitlen; + bitlen = *oldbitlen; if (bitlen < 16) goto fail; bits = mad_bit_read(ptr, 16); @@ -511,38 +511,31 @@ 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 * the LAME tag is found there, and not right after the Xing header */ - bitsleft = 960 - (oldbitlen - bitlen); + bitsleft = 960 - ((*oldbitlen) - bitlen); if (bitsleft < 0) goto fail; else if (bitsleft > 0) { mad_bit_read(ptr, bitsleft); bitlen -= bitsleft; } - return bitlen; - fail: - xing->flags = 0; - return -1; -} - -static int parse_extensions(struct xing *xing, struct mad_bitptr ptr, - int bitlen) -{ - bitlen = parse_xing(xing, &ptr, bitlen); - if (bitlen < 0) return 0; + *oldbitlen = bitlen; return 1; + fail: + xing->flags = 0; + return 0; } static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc, MpdTag ** tag, ReplayGainInfo ** replayGainInfo) { struct xing xing; + struct mad_bitptr ptr; + int bitlen; + int found_xing; int ret; int skip; - memset(&xing, 0, sizeof(struct xing)); - xing.flags = 0; - while (1) { skip = 0; while ((ret = decodeNextFrameHeader(data, tag, replayGainInfo)) == DECODE_CONT && @@ -558,9 +551,15 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc, if (!skip && ret == DECODE_OK) break; } - if (parse_extensions(&xing, data->stream.anc_ptr, - (int)data->stream.anc_bitlen)) { + ptr = data->stream.anc_ptr; + bitlen = data->stream.anc_bitlen; + + found_xing = parse_xing(&xing, &ptr, &bitlen); + + if (found_xing) { + DEBUG("yay xing works!\n"); if (xing.flags & XING_FRAMES) { + DEBUG("yay we got frames from xing!\n"); mad_timer_t duration = data->frame.header.duration; mad_timer_multiply(&duration, xing.frames); data->muteFrame = MUTEFRAME_SKIP; |