summaryrefslogtreecommitdiffstats
path: root/audio/decode
diff options
context:
space:
mode:
Diffstat (limited to 'audio/decode')
-rw-r--r--audio/decode/ad_lavc.c6
-rw-r--r--audio/decode/ad_mpg123.c12
2 files changed, 10 insertions, 8 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 802683bf7b..b013400cab 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -229,7 +229,7 @@ static int init(struct dec_audio *da, const char *decoder)
lavc_context->codec_tag = sh->format;
lavc_context->sample_rate = sh_audio->samplerate;
- lavc_context->bit_rate = sh_audio->i_bps * 8;
+ lavc_context->bit_rate = sh_audio->i_bps;
lavc_context->channel_layout = mp_chmap_to_lavc(&sh_audio->channels);
if (sh_audio->wf)
@@ -270,9 +270,9 @@ static int init(struct dec_audio *da, const char *decoder)
}
}
- da->i_bps = lavc_context->bit_rate / 8;
+ da->i_bps = lavc_context->bit_rate;
if (sh_audio->wf && sh_audio->wf->nAvgBytesPerSec)
- da->i_bps = sh_audio->wf->nAvgBytesPerSec;
+ da->i_bps = sh_audio->wf->nAvgBytesPerSec * 8;
return 1;
}
diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c
index 4d4fd52862..3c76eb51b3 100644
--- a/audio/decode/ad_mpg123.c
+++ b/audio/decode/ad_mpg123.c
@@ -254,7 +254,7 @@ static int compute_bitrate(struct mpg123_frameinfo *i)
{-1, 384, 1152, 576}, /* MPEG 2.5 */
{-1, -1, -1, -1}, /* Unknown */
};
- return (int) ((i->framesize + 4) * 8 * i->rate * 0.001 /
+ return (int) ((i->framesize + 4) * 8 * i->rate /
samples_per_frame[i->version][i->layer] + 0.5);
}
@@ -267,6 +267,9 @@ static void update_info(struct dec_audio *da)
if (mpg123_info(con->handle, &finfo) != MPG123_OK)
return;
+ /* finfo.bitrate is expressed in kilobits */
+ const int bitrate = finfo.bitrate * 1000;
+
if (finfo.vbr != MPG123_CBR) {
if (--con->delay < 1) {
if (++con->mean_count > ((unsigned int) -1) / 2)
@@ -274,14 +277,13 @@ static void update_info(struct dec_audio *da)
/* Might not be numerically optimal, but works fine enough. */
con->mean_rate = ((con->mean_count - 1) * con->mean_rate +
- finfo.bitrate) / con->mean_count;
- da->i_bps = (int) (con->mean_rate * 1000 / 8);
+ bitrate) / con->mean_count;
+ da->i_bps = (int) (con->mean_rate + 0.5);
con->delay = 10;
}
} else {
- da->i_bps = (finfo.bitrate ? finfo.bitrate : compute_bitrate(&finfo))
- * 1000 / 8;
+ da->i_bps = bitrate ? bitrate : compute_bitrate(&finfo);
con->delay = 1;
con->mean_rate = 0.;
con->mean_count = 0;