summaryrefslogtreecommitdiffstats
path: root/audio/decode
diff options
context:
space:
mode:
Diffstat (limited to 'audio/decode')
-rw-r--r--audio/decode/ad_lavc.c1
-rw-r--r--audio/decode/ad_mpg123.c6
-rw-r--r--audio/decode/dec_audio.c4
3 files changed, 3 insertions, 8 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index abd47f2fa3..1e63f0c3f2 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -184,7 +184,6 @@ static int setup_format(sh_audio_t *sh_audio,
sh_audio->channels = lavc_chmap;
sh_audio->samplerate = samplerate;
sh_audio->sample_format = sample_format;
- sh_audio->samplesize = af_fmt2bits(sh_audio->sample_format) / 8;
return 1;
}
return 0;
diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c
index df9e82306d..47cb5d2039 100644
--- a/audio/decode/ad_mpg123.c
+++ b/audio/decode/ad_mpg123.c
@@ -206,22 +206,18 @@ static int set_format(sh_audio_t *sh, struct ad_mpg123_context *con)
switch (encoding) {
case MPG123_ENC_SIGNED_8:
sh->sample_format = AF_FORMAT_S8;
- sh->samplesize = 1;
break;
case MPG123_ENC_SIGNED_16:
sh->sample_format = AF_FORMAT_S16_NE;
- sh->samplesize = 2;
break;
/* To stay compatible with the oldest libmpg123 headers, do not rely
* on float and 32 bit encoding symbols being defined.
* Those formats came later */
case 0x1180: /* MPG123_ENC_SIGNED_32 */
sh->sample_format = AF_FORMAT_S32_NE;
- sh->samplesize = 4;
break;
case 0x200: /* MPG123_ENC_FLOAT_32 */
sh->sample_format = AF_FORMAT_FLOAT_NE;
- sh->samplesize = 4;
break;
default:
/* This means we got a funny custom build of libmpg123 that only supports an unknown format. */
@@ -233,7 +229,7 @@ static int set_format(sh_audio_t *sh, struct ad_mpg123_context *con)
/* Going to decode directly to MPlayer's memory. It is important
* to have MPG123_AUTO_RESAMPLE disabled for the buffer size
* being an all-time limit. */
- sh->audio_out_minsize = 1152 * 2 * sh->samplesize;
+ sh->audio_out_minsize = 1152 * 2 * (af_fmt2bits(sh->sample_format) / 8);
#endif
con->new_format = 0;
}
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 127139ff60..e381a12a3c 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -58,7 +58,6 @@ static int init_audio_codec(sh_audio_t *sh_audio, const char *decoder)
{
assert(!sh_audio->initialized);
resync_audio_stream(sh_audio);
- sh_audio->samplesize = 4;
sh_audio->sample_format = AF_FORMAT_FLOAT_NE;
sh_audio->audio_out_minsize = 8192; // default, preinit() may change it
if (!sh_audio->ad_driver->preinit(sh_audio)) {
@@ -305,7 +304,8 @@ int decode_audio(sh_audio_t *sh_audio, struct bstr *outbuf, int minlen)
// Indicates that a filter seems to be buffering large amounts of data
int huge_filter_buffer = 0;
// Decoded audio must be cut at boundaries of this many bytes
- int unitsize = sh_audio->channels.num * sh_audio->samplesize * 16;
+ int bps = af_fmt2bits(sh_audio->sample_format) / 8;
+ int unitsize = sh_audio->channels.num * bps * 16;
/* Filter output size will be about filter_multiplier times input size.
* If some filter buffers audio in big blocks this might only hold