1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-18 21:06:00 +00:00

audio: make AC3 pass-through with ad_spdif work

Do not fall back to 0 for samplerate when parser is not initialized.

Might fix some issues with using -ac spdifenc with audio in MKV
or MP4.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35517 b3059339-0415-0410-9bf9-f77b7e298cf2

Replace outdated list of unsupported formats by list of supported formats.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35534 b3059339-0415-0410-9bf9-f77b7e298cf2

Do not call af_fmt2str on the same data over and over.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35535 b3059339-0415-0410-9bf9-f77b7e298cf2

ad_spdif: use the more specific AF_FORMAT_AC3_LE when
we handle AC3.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35536 b3059339-0415-0410-9bf9-f77b7e298cf2

Make AF_FORMAT_IS_IEC61937 include AF_FORMAT_IS_AC3.

Our AC3 "sample format" is also iec61937.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35537 b3059339-0415-0410-9bf9-f77b7e298cf2

af_format: support endianness conversion also for iec61937
formats in general, not just AC3.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35538 b3059339-0415-0410-9bf9-f77b7e298cf2

Conflicts:
	audio/filter/af_format.c

af_format: Fix check_format, non-special formats are of course supported.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35545 b3059339-0415-0410-9bf9-f77b7e298cf2

Note: see mplayer bug #2110
This commit is contained in:
reimar 2012-11-29 17:03:04 +00:00 committed by wm4
parent 1e9f37072b
commit a4177fd581
4 changed files with 30 additions and 24 deletions

View File

@ -136,7 +136,6 @@ static int init(sh_audio_t *sh)
}
// get sample_rate & bitrate from parser
bps = srate = 0;
x = ds_get_packet_pts(sh->ds, &start, &pts);
in_size = x;
if (x <= 0) {
@ -144,10 +143,9 @@ static int init(sh_audio_t *sh)
x = 0;
}
ds_parse(sh->ds, &start, &x, pts, 0);
if (x == 0) { // not enough buffer
srate = 48000; //fake value
bps = 768000/8; //fake value
} else if (sh->avctx) {
srate = 48000; //fake value
bps = 768000/8; //fake value
if (x && sh->avctx) { // we have parser and large enough buffer
if (sh->avctx->sample_rate < 44100) {
mp_msg(MSGT_DECAUDIO,MSGL_INFO,
"This stream sample_rate[%d Hz] may be broken. "
@ -170,7 +168,7 @@ static int init(sh_audio_t *sh)
break;
case CODEC_ID_AC3:
spdif_ctx->iec61937_packet_size = 6144;
sh->sample_format = AF_FORMAT_IEC61937_LE;
sh->sample_format = AF_FORMAT_AC3_LE;
sh->samplerate = srate;
sh->channels = 2;
sh->i_bps = bps;

View File

@ -74,14 +74,14 @@ static int check_format(int format)
{
char buf[256];
switch(format & AF_FORMAT_SPECIAL_MASK){
case(AF_FORMAT_IMA_ADPCM):
case(AF_FORMAT_MPEG2):
case(AF_FORMAT_AC3):
mp_msg(MSGT_AFILTER, MSGL_ERR, "[format] Sample format %s not yet supported \n",
af_fmt2str(format,buf,256));
return AF_ERROR;
case 0: /* non-special formats */
case AF_FORMAT_MU_LAW:
case AF_FORMAT_A_LAW:
return AF_OK;
}
return AF_OK;
mp_msg(MSGT_AFILTER, MSGL_ERR, "[format] Sample format %s not yet supported \n",
af_fmt2str(format,buf,256));
return AF_ERROR;
}
// Initialization and runtime control
@ -92,14 +92,23 @@ static int control(struct af_instance* af, int cmd, void* arg)
char buf1[256];
char buf2[256];
struct mp_audio *data = arg;
int supported_ac3 = 0;
// Make sure this filter isn't redundant
if(af->data->format == data->format &&
af->data->bps == data->bps)
return AF_DETACH;
// A bit complex because we can convert AC3
// to generic iec61937 but not the other way
// round.
if (AF_FORMAT_IS_AC3(af->data->format))
supported_ac3 = AF_FORMAT_IS_AC3(data->format);
else if (AF_FORMAT_IS_IEC61937(af->data->format))
supported_ac3 = AF_FORMAT_IS_IEC61937(data->format);
// Allow trivial AC3-endianness conversion
if (!AF_FORMAT_IS_AC3(af->data->format) || !AF_FORMAT_IS_AC3(data->format))
if (!supported_ac3)
// Check for errors in configuration
if((AF_OK != check_bps(data->bps)) ||
(AF_OK != check_format(data->format)) ||
@ -107,9 +116,10 @@ static int control(struct af_instance* af, int cmd, void* arg)
(AF_OK != check_format(af->data->format)))
return AF_ERROR;
af_fmt2str(data->format,buf1,256);
af_fmt2str(af->data->format,buf2,256);
mp_msg(MSGT_AFILTER, MSGL_V, "[format] Changing sample format from %s to %s\n",
af_fmt2str(data->format,buf1,256),
af_fmt2str(af->data->format,buf2,256));
buf1, buf2);
af->data->rate = data->rate;
af->data->nch = data->nch;
@ -128,16 +138,14 @@ static int control(struct af_instance* af, int cmd, void* arg)
(af->data->format == AF_FORMAT_S16_NE))
{
mp_msg(MSGT_AFILTER, MSGL_V, "[format] Accelerated %s to %s conversion\n",
af_fmt2str(data->format,buf1,256),
af_fmt2str(af->data->format,buf2,256));
buf1, buf2);
af->play = play_float_s16;
}
if ((data->format == AF_FORMAT_S16_NE) &&
(af->data->format == AF_FORMAT_FLOAT_NE))
{
mp_msg(MSGT_AFILTER, MSGL_V, "[format] Accelerated %s to %s conversion\n",
af_fmt2str(data->format,buf1,256),
af_fmt2str(af->data->format,buf2,256));
buf1, buf2);
af->play = play_s16_float;
}
return AF_OK;

View File

@ -119,7 +119,7 @@
#define AF_FORMAT_UNKNOWN (-1)
#define AF_FORMAT_IS_AC3(fmt) (((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_AC3)
#define AF_FORMAT_IS_IEC61937(fmt) (((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_IEC61937)
#define AF_FORMAT_IS_IEC61937(fmt) (AF_FORMAT_IS_AC3(fmt) || ((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_IEC61937)
struct af_fmt_entry {
const char *name;

View File

@ -112,7 +112,7 @@ static int control(int cmd, void *arg)
long get_vol, set_vol;
float f_multi;
if(AF_FORMAT_IS_AC3(ao_data.format) || AF_FORMAT_IS_IEC61937(ao_data.format))
if(AF_FORMAT_IS_IEC61937(ao_data.format))
return CONTROL_TRUE;
if(mixer_channel) {
@ -436,7 +436,7 @@ static int init(int rate_hz, int channels, int format, int flags)
* while opening the abstract alias for the spdif subdevice
* 'iec958'
*/
if (AF_FORMAT_IS_AC3(format) || AF_FORMAT_IS_IEC61937(format)) {
if (AF_FORMAT_IS_IEC61937(format)) {
device.str = "iec958";
mp_msg(MSGT_AO,MSGL_V,"alsa-spdif-init: playing AC3/iec61937/iec958, %i channels\n", channels);
}
@ -489,7 +489,7 @@ static int init(int rate_hz, int channels, int format, int flags)
if (!alsa_handler) {
int open_mode = block ? 0 : SND_PCM_NONBLOCK;
int isac3 = AF_FORMAT_IS_AC3(format) || AF_FORMAT_IS_IEC61937(format);
int isac3 = AF_FORMAT_IS_IEC61937(format);
//modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC
if ((err = try_open_device(alsa_device, open_mode, isac3)) < 0)
{