From 77b95d08a55a35bc966b9a9096cd926c315d49b8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 15 Nov 2009 17:39:09 +0100 Subject: decoder/ffmpeg: align the output buffer On some platforms, libavcodec wants the output buffer aligned to 16 bytes (because it uses SSE/Altivec internally). It will segfault when you don't obey this rule. --- NEWS | 1 + src/decoder/ffmpeg_plugin.c | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index f1bdfeb1d..a037115b7 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ ver 0.15.6 (2009/??/??) - zzip: require libzzip 0.13 * decoders: - ffmpeg: convert metadata + - ffmpeg: align the output buffer - oggflac: rewind stream after FLAC detection - flac: fixed CUE seeking range check * output_thread: check again if output is open on PAUSE diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c index 2f7ed6d1f..b9aafaf7b 100644 --- a/src/decoder/ffmpeg_plugin.c +++ b/src/decoder/ffmpeg_plugin.c @@ -209,6 +209,21 @@ ffmpeg_helper(struct input_stream *input, return ret; } +/** + * On some platforms, libavcodec wants the output buffer aligned to 16 + * bytes (because it uses SSE/Altivec internally). This function + * returns the aligned version of the specified buffer, and corrects + * the buffer size. + */ +static void * +align16(void *p, size_t *length_p) +{ + unsigned add = 16 - (size_t)p % 16; + + *length_p -= add; + return (char *)p + add; +} + static enum decoder_command ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, const AVPacket *packet, @@ -217,7 +232,9 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, { enum decoder_command cmd = DECODE_COMMAND_NONE; int position; - uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2]; + uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16]; + int16_t *aligned_buffer; + size_t buffer_size; int len, audio_size; uint8_t *packet_data; int packet_size; @@ -225,11 +242,13 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, packet_data = packet->data; packet_size = packet->size; + buffer_size = sizeof(audio_buf); + aligned_buffer = align16(audio_buf, &buffer_size); + while ((packet_size > 0) && (cmd == DECODE_COMMAND_NONE)) { - audio_size = sizeof(audio_buf); + audio_size = buffer_size; len = avcodec_decode_audio2(codec_context, - (int16_t *)audio_buf, - &audio_size, + aligned_buffer, &audio_size, packet_data, packet_size); if (len < 0) { @@ -250,7 +269,7 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, : 0; cmd = decoder_data(decoder, is, - audio_buf, audio_size, + aligned_buffer, audio_size, position, codec_context->bit_rate / 1000, NULL); } -- cgit v1.2.3 From f51ba6464adf1d2324c418e106b66da525f01587 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 15 Nov 2009 18:44:53 +0100 Subject: id3: allow 4 MB RIFF/AIFF tags Allow RIFF/AIFF ID3 tags up to 4 MB (old limit was 256 kB). This might still be too small for some users, and when somebody complains, we might do something more clever (like streaming the data into libid3tag?). --- NEWS | 2 ++ src/tag_id3.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index a037115b7..8bd2369d2 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ ver 0.15.6 (2009/??/??) - input/mms: require libmms 0.4 * archive: - zzip: require libzzip 0.13 +* tags: + - id3: allow 4 MB RIFF/AIFF tags * decoders: - ffmpeg: convert metadata - ffmpeg: align the output buffer diff --git a/src/tag_id3.c b/src/tag_id3.c index ce0386a51..0ae37f3ec 100644 --- a/src/tag_id3.c +++ b/src/tag_id3.c @@ -481,7 +481,7 @@ tag_id3_riff_aiff_load(FILE *file) if (size == 0) return NULL; - if (size > 256 * 1024) + if (size > 4 * 1024 * 1024) /* too large, don't allocate so much memory */ return NULL; -- cgit v1.2.3 From 97f8e017c4c141a01b5d0213590f1a923b6a359d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 18 Nov 2009 19:55:38 +0100 Subject: decoder/flac: fixed NULL pointer dereference in CUE code The function flac_vtrack_tnum() was missing a strrchr()==NULL check. --- NEWS | 1 + src/decoder/_flac_common.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 8bd2369d2..3c4c2e0d8 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ ver 0.15.6 (2009/??/??) - ffmpeg: align the output buffer - oggflac: rewind stream after FLAC detection - flac: fixed CUE seeking range check + - flac: fixed NULL pointer dereference in CUE code * output_thread: check again if output is open on PAUSE * update: delete ignored symlinks from database * database: increased maximum line length to 32 kB diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c index e096750f3..9338dc6ae 100644 --- a/src/decoder/_flac_common.c +++ b/src/decoder/_flac_common.c @@ -415,6 +415,8 @@ flac_vtrack_tnum(const char* fname) * another/better way would be to use tag struct */ char* ptr = strrchr(fname, '_'); + if (ptr == NULL) + return 0; // copy ascii tracknumber to int char vtrack[4]; -- cgit v1.2.3 From 30847e6c7706f3c52d44b7648ac4c05b76e0331b Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Wed, 18 Nov 2009 18:49:25 -0800 Subject: mpd version 0.15.6 --- NEWS | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 3c4c2e0d8..632685c39 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -ver 0.15.6 (2009/??/??) +ver 0.15.6 (2009/11/18) * input: - lastfm: fixed variable name in GLib<2.16 code path - input/mms: require libmms 0.4 diff --git a/configure.ac b/configure.ac index 83fad5724..fe469036e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(mpd, 0.15.6~git, musicpd-dev-team@lists.sourceforge.net) +AC_INIT(mpd, 0.15.6, musicpd-dev-team@lists.sourceforge.net) AC_CONFIG_SRCDIR([src/main.c]) AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2]) AM_CONFIG_HEADER(config.h) -- cgit v1.2.3 From d1aee3ae74716a9f87b6fcc2ae6583c0cb40daec Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Wed, 18 Nov 2009 18:49:25 -0800 Subject: Modify version string to post-release version 0.15.7~git --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 632685c39..6b6944c1b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +ver 0.15.7 (2009/??/??) + + ver 0.15.6 (2009/11/18) * input: - lastfm: fixed variable name in GLib<2.16 code path diff --git a/configure.ac b/configure.ac index fe469036e..dcb8a1824 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(mpd, 0.15.6, musicpd-dev-team@lists.sourceforge.net) +AC_INIT(mpd, 0.15.7~git, musicpd-dev-team@lists.sourceforge.net) AC_CONFIG_SRCDIR([src/main.c]) AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2]) AM_CONFIG_HEADER(config.h) -- cgit v1.2.3 From 21fdf47b563ab7684dc7022aadf5d63bb011ea52 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 19 Nov 2009 19:49:44 +0100 Subject: decoder/flac: fixed compiler warning Removed the "vtrack" local variable (which triggered a gcc warning because it was after the newly introduced NULL check), and run strtol() on the original parameter. --- src/decoder/_flac_common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c index 9338dc6ae..7c8fe9875 100644 --- a/src/decoder/_flac_common.c +++ b/src/decoder/_flac_common.c @@ -419,9 +419,7 @@ flac_vtrack_tnum(const char* fname) return 0; // copy ascii tracknumber to int - char vtrack[4]; - g_strlcpy(vtrack, ++ptr, 4); - return (unsigned int)strtol(vtrack, NULL, 10); + return (unsigned int)strtol(++ptr, NULL, 10); } #endif /* FLAC_API_VERSION_CURRENT >= 7 */ -- cgit v1.2.3