summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-09 23:22:15 +0100
committerwm4 <wm4@nowhere>2013-11-09 23:32:58 +0100
commit53d38278431987cc7c266e9fe84d481762bea47a (patch)
tree675d6f2ebce175a7442724842d55f68fbe1aaf1b
parent0ff863c1797c734dde8c1f99593a01cf5e1c15bc (diff)
downloadmpv-53d38278431987cc7c266e9fe84d481762bea47a.tar.bz2
mpv-53d38278431987cc7c266e9fe84d481762bea47a.tar.xz
Remove sh_audio->samplesize
This member was redundant. sh_audio->sample_format indicates the sample size already. The TV code is a bit strange: the redundant sample size was part of the internal TV interface. Assume it's really redundant and not something else. The PCM decoder ignores the sample size anyway.
-rw-r--r--audio/decode/ad_lavc.c1
-rw-r--r--audio/decode/ad_mpg123.c6
-rw-r--r--audio/decode/dec_audio.c4
-rw-r--r--demux/demux.c1
-rw-r--r--demux/stheader.h1
-rw-r--r--mpvcore/player/audio.c2
-rw-r--r--stream/tv.c11
-rw-r--r--stream/tv.h1
-rw-r--r--stream/tvi_v4l2.c7
9 files changed, 9 insertions, 25 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
diff --git a/demux/demux.c b/demux/demux.c
index a0164d529a..b5934824dc 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -259,7 +259,6 @@ struct sh_stream *new_sh_stream(demuxer_t *demuxer, enum stream_type type)
struct sh_audio *sht = talloc_zero(demuxer, struct sh_audio);
sht->gsh = sh;
sht->opts = sh->opts;
- sht->samplesize = 2;
sht->sample_format = AF_FORMAT_S16_NE;
sh->audio = sht;
break;
diff --git a/demux/stheader.h b/demux/stheader.h
index 963bf07b5e..5aa77ba693 100644
--- a/demux/stheader.h
+++ b/demux/stheader.h
@@ -90,7 +90,6 @@ typedef struct sh_audio {
// output format:
int sample_format;
int samplerate;
- int samplesize;
struct mp_chmap channels;
int i_bps; // == bitrate (compressed bytes/sec)
// decoder buffers:
diff --git a/mpvcore/player/audio.c b/mpvcore/player/audio.c
index a0c558f02a..e89e22c208 100644
--- a/mpvcore/player/audio.c
+++ b/mpvcore/player/audio.c
@@ -177,7 +177,7 @@ double written_audio_pts(struct MPContext *mpctx)
return MP_NOPTS_VALUE;
double bps = sh_audio->channels.num * sh_audio->samplerate *
- sh_audio->samplesize;
+ (af_fmt2bits(sh_audio->sample_format) / 8);
// first calculate the end pts of audio that has been output by decoder
double a_pts = sh_audio->pts;
diff --git a/stream/tv.c b/stream/tv.c
index 0e5fe8c22d..08bb11c6ce 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -794,8 +794,6 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
&sh_audio->samplerate);
- funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE,
- &sh_audio->samplesize);
int nchannels = sh_audio->channels.num;
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
&nchannels);
@@ -804,17 +802,18 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
sh_audio->gsh->codec = "mp-pcm";
sh_audio->format = audio_format;
+ int samplesize = af_fmt2bits(audio_format) / 8;
+
sh_audio->i_bps =
- sh_audio->samplerate * sh_audio->samplesize *
- sh_audio->channels.num;
+ sh_audio->samplerate * samplesize * sh_audio->channels.num;
// emulate WF for win32 codecs:
sh_audio->wf = malloc(sizeof(*sh_audio->wf));
sh_audio->wf->wFormatTag = sh_audio->format;
sh_audio->wf->nChannels = sh_audio->channels.num;
- sh_audio->wf->wBitsPerSample = sh_audio->samplesize * 8;
+ sh_audio->wf->wBitsPerSample = samplesize * 8;
sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
- sh_audio->wf->nBlockAlign = sh_audio->samplesize * sh_audio->channels.num;
+ sh_audio->wf->nBlockAlign = samplesize * sh_audio->channels.num;
sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;
mp_tmsg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
diff --git a/stream/tv.h b/stream/tv.h
index ded9ace6c8..9cbc7ef652 100644
--- a/stream/tv.h
+++ b/stream/tv.h
@@ -188,7 +188,6 @@ typedef struct {
/* AUDIO controls */
#define TVI_CONTROL_AUD_GET_FORMAT 0x301
#define TVI_CONTROL_AUD_GET_SAMPLERATE 0x302
-#define TVI_CONTROL_AUD_GET_SAMPLESIZE 0x303
#define TVI_CONTROL_AUD_GET_CHANNELS 0x304
#define TVI_CONTROL_AUD_SET_SAMPLERATE 0x305
diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c
index 5891ac4556..d99370d8dd 100644
--- a/stream/tvi_v4l2.c
+++ b/stream/tvi_v4l2.c
@@ -974,13 +974,6 @@ static int do_control(priv_t *priv, int cmd, void *arg)
mp_msg(MSGT_TV, MSGL_V, "%s: get audio samplerate: %d\n",
info.short_name, *(int *)arg);
return TVI_CONTROL_TRUE;
- case TVI_CONTROL_AUD_GET_SAMPLESIZE:
- init_audio(priv);
- if (!priv->audio_initialized) return TVI_CONTROL_FALSE;
- *(int *)arg = priv->audio_in.bytes_per_sample;
- mp_msg(MSGT_TV, MSGL_V, "%s: get audio samplesize: %d\n",
- info.short_name, *(int *)arg);
- return TVI_CONTROL_TRUE;
case TVI_CONTROL_AUD_GET_CHANNELS:
init_audio(priv);
if (!priv->audio_initialized) return TVI_CONTROL_FALSE;