mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
0ff863c179
commit
53d3827843
|
@ -184,7 +184,6 @@ static int setup_format(sh_audio_t *sh_audio,
|
||||||
sh_audio->channels = lavc_chmap;
|
sh_audio->channels = lavc_chmap;
|
||||||
sh_audio->samplerate = samplerate;
|
sh_audio->samplerate = samplerate;
|
||||||
sh_audio->sample_format = sample_format;
|
sh_audio->sample_format = sample_format;
|
||||||
sh_audio->samplesize = af_fmt2bits(sh_audio->sample_format) / 8;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -206,22 +206,18 @@ static int set_format(sh_audio_t *sh, struct ad_mpg123_context *con)
|
||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
case MPG123_ENC_SIGNED_8:
|
case MPG123_ENC_SIGNED_8:
|
||||||
sh->sample_format = AF_FORMAT_S8;
|
sh->sample_format = AF_FORMAT_S8;
|
||||||
sh->samplesize = 1;
|
|
||||||
break;
|
break;
|
||||||
case MPG123_ENC_SIGNED_16:
|
case MPG123_ENC_SIGNED_16:
|
||||||
sh->sample_format = AF_FORMAT_S16_NE;
|
sh->sample_format = AF_FORMAT_S16_NE;
|
||||||
sh->samplesize = 2;
|
|
||||||
break;
|
break;
|
||||||
/* To stay compatible with the oldest libmpg123 headers, do not rely
|
/* To stay compatible with the oldest libmpg123 headers, do not rely
|
||||||
* on float and 32 bit encoding symbols being defined.
|
* on float and 32 bit encoding symbols being defined.
|
||||||
* Those formats came later */
|
* Those formats came later */
|
||||||
case 0x1180: /* MPG123_ENC_SIGNED_32 */
|
case 0x1180: /* MPG123_ENC_SIGNED_32 */
|
||||||
sh->sample_format = AF_FORMAT_S32_NE;
|
sh->sample_format = AF_FORMAT_S32_NE;
|
||||||
sh->samplesize = 4;
|
|
||||||
break;
|
break;
|
||||||
case 0x200: /* MPG123_ENC_FLOAT_32 */
|
case 0x200: /* MPG123_ENC_FLOAT_32 */
|
||||||
sh->sample_format = AF_FORMAT_FLOAT_NE;
|
sh->sample_format = AF_FORMAT_FLOAT_NE;
|
||||||
sh->samplesize = 4;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* This means we got a funny custom build of libmpg123 that only supports an unknown format. */
|
/* 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
|
/* Going to decode directly to MPlayer's memory. It is important
|
||||||
* to have MPG123_AUTO_RESAMPLE disabled for the buffer size
|
* to have MPG123_AUTO_RESAMPLE disabled for the buffer size
|
||||||
* being an all-time limit. */
|
* 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
|
#endif
|
||||||
con->new_format = 0;
|
con->new_format = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ static int init_audio_codec(sh_audio_t *sh_audio, const char *decoder)
|
||||||
{
|
{
|
||||||
assert(!sh_audio->initialized);
|
assert(!sh_audio->initialized);
|
||||||
resync_audio_stream(sh_audio);
|
resync_audio_stream(sh_audio);
|
||||||
sh_audio->samplesize = 4;
|
|
||||||
sh_audio->sample_format = AF_FORMAT_FLOAT_NE;
|
sh_audio->sample_format = AF_FORMAT_FLOAT_NE;
|
||||||
sh_audio->audio_out_minsize = 8192; // default, preinit() may change it
|
sh_audio->audio_out_minsize = 8192; // default, preinit() may change it
|
||||||
if (!sh_audio->ad_driver->preinit(sh_audio)) {
|
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
|
// Indicates that a filter seems to be buffering large amounts of data
|
||||||
int huge_filter_buffer = 0;
|
int huge_filter_buffer = 0;
|
||||||
// Decoded audio must be cut at boundaries of this many bytes
|
// 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.
|
/* Filter output size will be about filter_multiplier times input size.
|
||||||
* If some filter buffers audio in big blocks this might only hold
|
* If some filter buffers audio in big blocks this might only hold
|
||||||
|
|
|
@ -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);
|
struct sh_audio *sht = talloc_zero(demuxer, struct sh_audio);
|
||||||
sht->gsh = sh;
|
sht->gsh = sh;
|
||||||
sht->opts = sh->opts;
|
sht->opts = sh->opts;
|
||||||
sht->samplesize = 2;
|
|
||||||
sht->sample_format = AF_FORMAT_S16_NE;
|
sht->sample_format = AF_FORMAT_S16_NE;
|
||||||
sh->audio = sht;
|
sh->audio = sht;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -90,7 +90,6 @@ typedef struct sh_audio {
|
||||||
// output format:
|
// output format:
|
||||||
int sample_format;
|
int sample_format;
|
||||||
int samplerate;
|
int samplerate;
|
||||||
int samplesize;
|
|
||||||
struct mp_chmap channels;
|
struct mp_chmap channels;
|
||||||
int i_bps; // == bitrate (compressed bytes/sec)
|
int i_bps; // == bitrate (compressed bytes/sec)
|
||||||
// decoder buffers:
|
// decoder buffers:
|
||||||
|
|
|
@ -177,7 +177,7 @@ double written_audio_pts(struct MPContext *mpctx)
|
||||||
return MP_NOPTS_VALUE;
|
return MP_NOPTS_VALUE;
|
||||||
|
|
||||||
double bps = sh_audio->channels.num * sh_audio->samplerate *
|
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
|
// first calculate the end pts of audio that has been output by decoder
|
||||||
double a_pts = sh_audio->pts;
|
double a_pts = sh_audio->pts;
|
||||||
|
|
11
stream/tv.c
11
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,
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
|
||||||
&sh_audio->samplerate);
|
&sh_audio->samplerate);
|
||||||
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE,
|
|
||||||
&sh_audio->samplesize);
|
|
||||||
int nchannels = sh_audio->channels.num;
|
int nchannels = sh_audio->channels.num;
|
||||||
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
|
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
|
||||||
&nchannels);
|
&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->gsh->codec = "mp-pcm";
|
||||||
sh_audio->format = audio_format;
|
sh_audio->format = audio_format;
|
||||||
|
|
||||||
|
int samplesize = af_fmt2bits(audio_format) / 8;
|
||||||
|
|
||||||
sh_audio->i_bps =
|
sh_audio->i_bps =
|
||||||
sh_audio->samplerate * sh_audio->samplesize *
|
sh_audio->samplerate * samplesize * sh_audio->channels.num;
|
||||||
sh_audio->channels.num;
|
|
||||||
|
|
||||||
// emulate WF for win32 codecs:
|
// emulate WF for win32 codecs:
|
||||||
sh_audio->wf = malloc(sizeof(*sh_audio->wf));
|
sh_audio->wf = malloc(sizeof(*sh_audio->wf));
|
||||||
sh_audio->wf->wFormatTag = sh_audio->format;
|
sh_audio->wf->wFormatTag = sh_audio->format;
|
||||||
sh_audio->wf->nChannels = sh_audio->channels.num;
|
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->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;
|
sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;
|
||||||
|
|
||||||
mp_tmsg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
|
mp_tmsg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
|
||||||
|
|
|
@ -188,7 +188,6 @@ typedef struct {
|
||||||
/* AUDIO controls */
|
/* AUDIO controls */
|
||||||
#define TVI_CONTROL_AUD_GET_FORMAT 0x301
|
#define TVI_CONTROL_AUD_GET_FORMAT 0x301
|
||||||
#define TVI_CONTROL_AUD_GET_SAMPLERATE 0x302
|
#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_GET_CHANNELS 0x304
|
||||||
#define TVI_CONTROL_AUD_SET_SAMPLERATE 0x305
|
#define TVI_CONTROL_AUD_SET_SAMPLERATE 0x305
|
||||||
|
|
||||||
|
|
|
@ -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",
|
mp_msg(MSGT_TV, MSGL_V, "%s: get audio samplerate: %d\n",
|
||||||
info.short_name, *(int *)arg);
|
info.short_name, *(int *)arg);
|
||||||
return TVI_CONTROL_TRUE;
|
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:
|
case TVI_CONTROL_AUD_GET_CHANNELS:
|
||||||
init_audio(priv);
|
init_audio(priv);
|
||||||
if (!priv->audio_initialized) return TVI_CONTROL_FALSE;
|
if (!priv->audio_initialized) return TVI_CONTROL_FALSE;
|
||||||
|
|
Loading…
Reference in New Issue