Discussion:
[PATCH] mad: only use xing.nr_frames when != 0
Johannes Weißl
2011-03-14 02:01:35 UTC
Permalink
Otherwise mp3 files with wrong XING header can't be played.
---
nomad.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/nomad.c b/nomad.c
index 7fb9865..bc578b6 100644
--- a/nomad.c
+++ b/nomad.c
@@ -392,7 +392,7 @@ static void calc_fast(struct nomad *nomad)
{
nomad->info.avg_bitrate = -1;
nomad->info.vbr = -1;
- if (nomad->has_xing && (nomad->xing.flags & XING_FRAMES)) {
+ if (nomad->has_xing && (nomad->xing.flags & XING_FRAMES) && nomad->xing.nr_frames) {
nomad->info.nr_frames = nomad->xing.nr_frames;
mad_timer_multiply(&nomad->timer, nomad->info.nr_frames);
} else {
--
1.7.4.1
Johannes Weißl
2011-03-14 02:08:12 UTC
Permalink
---
ffmpeg.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index a55aa44..d371384 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -199,6 +199,11 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
err = -IP_ERROR_FILE_FORMAT;
break;
}
+
+ if (cc->sample_fmt == AV_SAMPLE_FMT_FLT || cc->sample_fmt == AV_SAMPLE_FMT_DBL) {
+ err = -IP_ERROR_SAMPLE_FORMAT;
+ break;
+ }
/* We assume below that no more errors follow. */
} while (0);

@@ -222,7 +227,19 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
priv->output = ffmpeg_output_create();

ip_data->private = priv;
- ip_data->sf = sf_rate(cc->sample_rate) | sf_channels(cc->channels) | sf_bits(16) | sf_signed(1);
+ ip_data->sf = sf_rate(cc->sample_rate) | sf_channels(cc->channels);
+ switch (cc->sample_fmt) {
+ case AV_SAMPLE_FMT_U8:
+ ip_data->sf |= sf_bits(8) | sf_signed(0);
+ break;
+ case AV_SAMPLE_FMT_S32:
+ ip_data->sf |= sf_bits(32) | sf_signed(1);
+ break;
+ /* AV_SAMPLE_FMT_S16 */
+ default:
+ ip_data->sf |= sf_bits(16) | sf_signed(1);
+ break;
+ }
return 0;
}
--
1.7.4.1
Gregory Petrosyan
2011-03-16 21:14:37 UTC
Permalink
+
+               if (cc->sample_fmt == AV_SAMPLE_FMT_FLT || cc->sample_fmt == AV_SAMPLE_FMT_DBL) {
+                       err = -IP_ERROR_SAMPLE_FORMAT;
+                       break;
+               }
               /* We assume below that no more errors follow. */
...
I get this (on OS X):

CC ffmpeg.lo
ffmpeg.c: In function 'ffmpeg_open':
ffmpeg.c:203: error: 'AV_SAMPLE_FMT_FLT' undeclared (first use in this function)
ffmpeg.c:203: error: (Each undeclared identifier is reported only once
ffmpeg.c:203: error: for each function it appears in.)
ffmpeg.c:203: error: 'AV_SAMPLE_FMT_DBL' undeclared (first use in this function)
ffmpeg.c:232: error: 'AV_SAMPLE_FMT_U8' undeclared (first use in this function)
ffmpeg.c:235: error: 'AV_SAMPLE_FMT_S32' undeclared (first use in this function)
make: *** [ffmpeg.lo] Error 1

                Gregory
Johannes Weißl
2011-03-16 22:34:45 UTC
Permalink
Post by Gregory Petrosyan
CC ffmpeg.lo
ffmpeg.c:203: error: 'AV_SAMPLE_FMT_FLT' undeclared (first use in this function)
[...]
Hmm, strange...

What version of ffmpeg are you using? Does it work when you strip the
"AV_" before the defines (old format)? What does `grep -r SAMPLE_FMT_FLT
/path/to/ffmpeg/includes` output?


Johannes
Johannes Weißl
2011-03-18 03:47:29 UTC
Permalink
Post by Johannes Weißl
Post by Gregory Petrosyan
CC ffmpeg.lo
ffmpeg.c:203: error: 'AV_SAMPLE_FMT_FLT' undeclared (first use in this function)
[...]
Hmm, strange...
What version of ffmpeg are you using? Does it work when you strip the
"AV_" before the defines (old format)? What does `grep -r SAMPLE_FMT_FLT
/path/to/ffmpeg/includes` output?
It seems they introduced the AV_* sample rates in 2010-11-02 (r25654). I
updated the patch (attached) which compiles fine on older versions of
ffmpeg.


Johannes
Gregory Petrosyan
2011-03-29 09:22:32 UTC
Permalink
Post by Johannes Weißl
Post by Johannes Weißl
Post by Gregory Petrosyan
CC ffmpeg.lo
ffmpeg.c:203: error: 'AV_SAMPLE_FMT_FLT' undeclared (first use in this function)
[...]
Hmm, strange...
What version of ffmpeg are you using? Does it work when you strip the
"AV_" before the defines (old format)? What does `grep -r SAMPLE_FMT_FLT
/path/to/ffmpeg/includes` output?
It seems they introduced the AV_* sample rates in 2010-11-02 (r25654). I
updated the patch (attached) which compiles fine on older versions of
ffmpeg.
This version works fine for me. Merged it to both master and maint — thanks a
lot for your work, as always!

Gregory

Johannes Weißl
2011-03-14 03:10:06 UTC
Permalink
Support Matroska audio files.
---
ffmpeg.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index d371384..28a2796 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -438,6 +438,6 @@ const struct input_plugin_ops ip_ops = {
#ifdef USE_FALLBACK_IP
const char *const ip_extensions[] = { "any", NULL };
#else
-const char *const ip_extensions[] = { "ape", "wma", NULL };
+const char *const ip_extensions[] = { "ape", "wma", "mka", NULL };
#endif
const char *const ip_mime_types[] = { NULL };
--
1.7.4.1
Gregory Petrosyan
2011-03-16 21:41:43 UTC
Permalink
Post by Johannes Weißl
Support Matroska audio files.
Thanks, merged!

                Gregory
Johannes Weißl
2011-03-14 05:07:03 UTC
Permalink
Also gets rid of this debug message right after cmus starts:
do_lib_filter: filter results could grow, clear tracks and re-add (slow)
---
lib.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib.c b/lib.c
index 3af92f6..1367731 100644
--- a/lib.c
+++ b/lib.c
@@ -481,11 +481,12 @@ static void unset_live_filter(void)

void lib_set_filter(struct expr *expr)
{
+ int clear_before = lib_live_filter || filter;
unset_live_filter();
if (filter)
expr_free(filter);
filter = expr;
- do_lib_filter(1);
+ do_lib_filter(clear_before);
}

static struct tree_track *get_sel_track(void)
--
1.7.4.1
Gregory Petrosyan
2011-03-16 21:18:07 UTC
Permalink
Post by Johannes Weißl
do_lib_filter: filter results could grow, clear tracks and re-add (slow)
Thanks, merged to master.

                Gregory
Johannes Weißl
2011-03-15 14:13:19 UTC
Permalink
Position scaling was just using denominator, but time_base can also be
expressed as e.g. 128/1225, in which case the nominator is ignored (and
seekings doesn't work). This fixes seeking for APE files (and
potentially others).

Also replace constant with AV_TIME_BASE.
---
ffmpeg.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 191f50a..bd08568 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -335,8 +335,7 @@ static int ffmpeg_seek(struct input_plugin_data *ip_data, double offset)
#if (LIBAVFORMAT_VERSION_INT < ((50<<16)+(3<<8)+0))
int64_t pts = (int64_t) offset;
#else
- /* time base is 1/framerate */
- int64_t pts = (int64_t) offset * st->time_base.den;
+ int64_t pts = av_rescale_q(offset * AV_TIME_BASE, AV_TIME_BASE_Q, st->time_base);
#endif

ret = av_seek_frame(priv->input_context, priv->stream_index, pts, 0);
@@ -406,7 +405,7 @@ static int ffmpeg_read_comments(struct input_plugin_data *ip_data, struct keyval
static int ffmpeg_duration(struct input_plugin_data *ip_data)
{
struct ffmpeg_private *priv = ip_data->private;
- return priv->input_context->duration / 1000000L;
+ return priv->input_context->duration / AV_TIME_BASE;
}

const struct input_plugin_ops ip_ops = {
--
1.7.4.1
Gregory Petrosyan
2011-03-16 21:25:44 UTC
Permalink
Post by Johannes Weißl
Position scaling was just using denominator, but time_base can also be
expressed as e.g. 128/1225, in which case the nominator is ignored (and
seekings doesn't work). This fixes seeking for APE files (and
potentially others).
Also replace constant with AV_TIME_BASE.
Merged both patches to main and master. Thanks a lot, once again!

                Gregory
Johannes Weißl
2011-03-15 14:13:18 UTC
Permalink
Otherwise ffmpeg can't ever recover from a failed call of
avcodec_decode_audio. This enables playback of e.g. SHN files.
---
ffmpeg.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index a55aa44..191f50a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -246,12 +246,12 @@ static int ffmpeg_close(struct input_plugin_data *ip_data)
static int ffmpeg_fill_buffer(AVFormatContext *ic, AVCodecContext *cc, struct ffmpeg_input *input,
struct ffmpeg_output *output)
{
- /* frame_size specifies the size of output->buffer for
- * avcodec_decode_audio2. */
- int frame_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
- int len;
-
while (1) {
+ /* frame_size specifies the size of output->buffer for
+ * avcodec_decode_audio2. */
+ int frame_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ int len;
+
if (input->curr_pkt_size <= 0) {
av_free_packet(&input->pkt);
if (av_read_frame(ic, &input->pkt) < 0) {
--
1.7.4.1
Gregory Petrosyan
2011-03-16 21:16:49 UTC
Permalink
Post by Johannes Weißl
Otherwise mp3 files with wrong XING header can't be played.
Thanks! Pushed to both maint and master.

                Gregory
Loading...