From 5469941f2b12004dc6214af2732eb57ceab7aaf2 Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Thu, 1 Sep 2011 17:58:29 -0700 Subject: [PATCH 01/10] Modify version string to post-release version 0.16.5~git --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d72e0e0e8..17e558af9 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +ver 0.16.5 (2010/??/??) + + ver 0.16.4 (2011/09/01) * don't abort configure when avahi is not found * auto-detect libmad without pkg-config diff --git a/configure.ac b/configure.ac index 49233f4c8..559284332 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(mpd, 0.16.4, musicpd-dev-team@lists.sourceforge.net) +AC_INIT(mpd, 0.16.5~git, musicpd-dev-team@lists.sourceforge.net) AC_CONFIG_SRCDIR([src/main.c]) AM_INIT_AUTOMAKE([foreign 1.10 dist-bzip2 subdir-objects]) AM_CONFIG_HEADER(config.h) From 5cf4ce9318acfcd3698b10e173315ad681d39560 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 8 Sep 2011 23:47:32 +0200 Subject: [PATCH 02/10] pcm_format: fix 32-to-24 bit conversion (the "silence" bug) D'oh, we were reading 16 bit integers instead of 32 bit integers! That caused silence when trying to play a 32 bit input file on a 24 bit sound card (e.g. USB sound chips with 24 bit packed samples). --- NEWS | 1 + src/pcm_format.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 17e558af9..ea128337e 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ver 0.16.5 (2010/??/??) +* pcm_format: fix 32-to-24 bit conversion (the "silence" bug) ver 0.16.4 (2011/09/01) diff --git a/src/pcm_format.c b/src/pcm_format.c index 3fd76a987..1e4b8d705 100644 --- a/src/pcm_format.c +++ b/src/pcm_format.c @@ -143,7 +143,7 @@ pcm_convert_16_to_24(int32_t *out, const int16_t *in, } static void -pcm_convert_32_to_24(int32_t *out, const int16_t *in, +pcm_convert_32_to_24(int32_t *out, const int32_t *in, unsigned num_samples) { while (num_samples > 0) { @@ -197,7 +197,7 @@ pcm_convert_to_24(struct pcm_buffer *buffer, *dest_size_r = num_samples * sizeof(*dest); dest = pcm_buffer_get(buffer, *dest_size_r); - pcm_convert_32_to_24(dest, (const int16_t *)src, + pcm_convert_32_to_24(dest, (const int32_t *)src, num_samples); return dest; } From c345c5ebae24086093252afc50ea15e4f0f21386 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 9 Sep 2011 20:46:27 +0200 Subject: [PATCH 03/10] .gitignore: add doxygen.conf --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 977ae6a12..4c626dbf3 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ tags *~ .#* .stgit* +doc/doxygen.conf doc/protocol.html doc/protocol doc/user From 48a84ca23ef40b87056214ea03b5f141a4ed54c4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Sep 2011 20:24:15 +0200 Subject: [PATCH 04/10] input/rewind: copy the MIME type only once Reduce heap usage by reducing the number of malloc() / free() calls. --- NEWS | 2 ++ src/input/rewind_input_plugin.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ea128337e..5f0d030cd 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ ver 0.16.5 (2010/??/??) * pcm_format: fix 32-to-24 bit conversion (the "silence" bug) +* input: + - rewind: reduce heap usage ver 0.16.4 (2011/09/01) diff --git a/src/input/rewind_input_plugin.c b/src/input/rewind_input_plugin.c index 6325a978e..f0d533bc8 100644 --- a/src/input/rewind_input_plugin.c +++ b/src/input/rewind_input_plugin.c @@ -83,12 +83,14 @@ copy_attributes(struct input_rewind *r) assert(dest != src); assert(src->mime == NULL || dest->mime != src->mime); + bool dest_ready = dest->ready; + dest->ready = src->ready; dest->seekable = src->seekable; dest->size = src->size; dest->offset = src->offset; - if (src->mime != NULL) { + if (!dest_ready && src->ready) { g_free(dest->mime); dest->mime = g_strdup(src->mime); } From 5aabee89967cf367e4128eedd60c8916459042c7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Sep 2011 21:14:53 +0200 Subject: [PATCH 05/10] decoder/ffmpeg: add local variable "av_stream" Code simplification. --- src/decoder/ffmpeg_decoder_plugin.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 70628df9d..9e8f2c00d 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -375,8 +375,9 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) return; } - AVCodecContext *codec_context = - format_context->streams[audio_stream]->codec; + AVStream *av_stream = format_context->streams[audio_stream]; + + AVCodecContext *codec_context = av_stream->codec; if (codec_context->codec_name[0] != 0) g_debug("codec '%s'", codec_context->codec_name); @@ -427,7 +428,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) if (packet.stream_index == audio_stream) cmd = ffmpeg_send_packet(decoder, input, &packet, codec_context, - &format_context->streams[audio_stream]->time_base); + &av_stream->time_base); else cmd = decoder_get_command(decoder); From 9aa91e0f171d63015a70b0f74335333bb4735763 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Sep 2011 21:03:03 +0200 Subject: [PATCH 06/10] decoder/ffmpeg: move formula to time_from_ffmpeg() --- src/decoder/ffmpeg_decoder_plugin.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 9e8f2c00d..484796fe3 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -214,6 +214,15 @@ align16(void *p, size_t *length_p) return (char *)p + add; } +G_GNUC_CONST +static double +time_from_ffmpeg(int64_t t, const AVRational time_base) +{ + assert(t != (int64_t)AV_NOPTS_VALUE); + + return av_rescale_q(t, time_base, (AVRational){1, 1}); +} + static enum decoder_command ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, const AVPacket *packet, @@ -222,8 +231,7 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, { if (packet->pts != (int64_t)AV_NOPTS_VALUE) decoder_timestamp(decoder, - av_rescale_q(packet->pts, *time_base, - (AVRational){1, 1})); + time_from_ffmpeg(packet->pts, *time_base)); #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0) AVPacket packet2 = *packet; From 42d8c2981f4e76fab5c4c3ed6ff840df7a41a1a4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Sep 2011 21:07:32 +0200 Subject: [PATCH 07/10] decoder/ffmpeg: higher precision timestamps --- NEWS | 2 ++ src/decoder/ffmpeg_decoder_plugin.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 5f0d030cd..8abe0baae 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ ver 0.16.5 (2010/??/??) * pcm_format: fix 32-to-24 bit conversion (the "silence" bug) * input: - rewind: reduce heap usage +* decoder: + - ffmpeg: higher precision timestamps ver 0.16.4 (2011/09/01) diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 484796fe3..1a1598f36 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -220,7 +220,8 @@ time_from_ffmpeg(int64_t t, const AVRational time_base) { assert(t != (int64_t)AV_NOPTS_VALUE); - return av_rescale_q(t, time_base, (AVRational){1, 1}); + return (double)av_rescale_q(t, time_base, (AVRational){1, 1024}) + / (double)1024; } static enum decoder_command From 724a59aaf7c396845bb5de7ad815c7ca842c2778 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Sep 2011 21:32:29 +0200 Subject: [PATCH 08/10] decoder/ffmpeg: don't require key frame for seeking Use flag AV_TIME_BASE. --- NEWS | 1 + src/decoder/ffmpeg_decoder_plugin.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 8abe0baae..9bd893930 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ver 0.16.5 (2010/??/??) - rewind: reduce heap usage * decoder: - ffmpeg: higher precision timestamps + - ffmpeg: don't require key frame for seeking ver 0.16.4 (2011/09/01) diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 1a1598f36..f8c9db700 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -447,7 +447,8 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) int64_t where = decoder_seek_where(decoder) * AV_TIME_BASE; - if (av_seek_frame(format_context, -1, where, 0) < 0) + if (av_seek_frame(format_context, -1, where, + AV_TIME_BASE) < 0) decoder_seek_error(decoder); else decoder_command_finished(decoder); From ce35ba9ac99ed96c7f55c6d80e85fb9bfe1ed09e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Sep 2011 21:12:53 +0200 Subject: [PATCH 09/10] decoder/ffmpeg: explicitly specify the current stream for seeking Use AVStream.time_base to convert the decoder_seek_where() value, and pass the current stream number to av_seek_frame(). --- src/decoder/ffmpeg_decoder_plugin.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index f8c9db700..77c1a122f 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -224,6 +224,14 @@ time_from_ffmpeg(int64_t t, const AVRational time_base) / (double)1024; } +G_GNUC_CONST +static int64_t +time_to_ffmpeg(double t, const AVRational time_base) +{ + return av_rescale_q((int64_t)(t * 1024), (AVRational){1, 1024}, + time_base); +} + static enum decoder_command ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, const AVPacket *packet, @@ -445,9 +453,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) if (cmd == DECODE_COMMAND_SEEK) { int64_t where = - decoder_seek_where(decoder) * AV_TIME_BASE; + time_to_ffmpeg(decoder_seek_where(decoder), + av_stream->time_base); - if (av_seek_frame(format_context, -1, where, + if (av_seek_frame(format_context, audio_stream, where, AV_TIME_BASE) < 0) decoder_seek_error(decoder); else From 2ed870c8546ce4654f956beea60546260d98a85c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 15 Sep 2011 21:41:25 +0200 Subject: [PATCH 10/10] decoder/ffmpeg: flush the codec after seeking Let the codec start with fresh buffers. This should fix the remaining seeking issues. --- src/decoder/ffmpeg_decoder_plugin.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 77c1a122f..ba47b2c2c 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -459,8 +459,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) if (av_seek_frame(format_context, audio_stream, where, AV_TIME_BASE) < 0) decoder_seek_error(decoder); - else + else { + avcodec_flush_buffers(codec_context); decoder_command_finished(decoder); + } } } while (cmd != DECODE_COMMAND_STOP);