mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 08:12:17 +00:00
Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
ffdca, ffflac, ffaac, fftruehd). In the process, adds support for 32-bit samples. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29533 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
3961e12fca
commit
f89696a8e2
@ -212,7 +212,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
if (c->nch >= 5)
|
||||
reorder_channel_nch(s->pending_data,
|
||||
AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_DEFAULT,
|
||||
c->nch,
|
||||
s->expect_len / 2, 2);
|
||||
|
||||
@ -224,7 +224,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data)
|
||||
if (c->nch >= 5)
|
||||
reorder_channel_nch(src,
|
||||
AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_DEFAULT,
|
||||
c->nch,
|
||||
s->expect_len / 2, 2);
|
||||
len = avcodec_encode_audio(s->lavc_actx,dest,destsize,(void *)src);
|
||||
|
@ -293,6 +293,9 @@ void reorder_channel_copy(void *src,
|
||||
case AF_CHANNEL_LAYOUT_5_1_E << 16 | AF_CHANNEL_LAYOUT_5_1_B:
|
||||
reorder_copy_6ch(dest, src, samples, samplesize, 1, 3, 4, 5, 2, 0);
|
||||
break;
|
||||
case AF_CHANNEL_LAYOUT_5_1_F << 16 | AF_CHANNEL_LAYOUT_5_1_B:
|
||||
reorder_copy_6ch(dest, src, samples, samplesize, 1, 2, 4, 5, 0, 3);
|
||||
break;
|
||||
default:
|
||||
mp_msg(MSGT_GLOBAL, MSGL_WARN, "[reorder_channel_copy] unsupport "
|
||||
"from %x to %x, %d * %d\n", src_layout, dest_layout,
|
||||
@ -1099,6 +1102,9 @@ void reorder_channel(void *src,
|
||||
case AF_CHANNEL_LAYOUT_5_1_E << 16 | AF_CHANNEL_LAYOUT_5_1_B:
|
||||
reorder_self_2_4(src, samples, samplesize, 2, 4, 0, 1, 3, 5);
|
||||
break;
|
||||
case AF_CHANNEL_LAYOUT_5_1_F << 16 | AF_CHANNEL_LAYOUT_5_1_B:
|
||||
reorder_self_2_4(src, samples, samplesize, 3, 5, 0, 1, 2, 4);
|
||||
break;
|
||||
default:
|
||||
mp_msg(MSGT_GLOBAL, MSGL_WARN,
|
||||
"[reorder_channel] unsupported from %x to %x, %d * %d\n",
|
||||
@ -1111,22 +1117,18 @@ static int channel_layout_mapping_5ch[AF_CHANNEL_LAYOUT_SOURCE_NUM] = {
|
||||
AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_AAC_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_AC3_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_LIBA52_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_DCA_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_FLAC_5CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_5CH_DEFAULT,
|
||||
};
|
||||
|
||||
static int channel_layout_mapping_6ch[AF_CHANNEL_LAYOUT_SOURCE_NUM] = {
|
||||
AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_AC3_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_LIBA52_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_DCA_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_FLAC_6CH_DEFAULT,
|
||||
AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_6CH_DEFAULT,
|
||||
};
|
||||
|
||||
void reorder_channel_copy_nch(void *src,
|
||||
|
@ -53,8 +53,9 @@
|
||||
#define AF_CHANNEL_LAYOUT_5_1_C ((114<<8)|6|AF_LFE) // L C R Ls Rs LFE
|
||||
#define AF_CHANNEL_LAYOUT_5_1_D ((115<<8)|6|AF_LFE) // C L R Ls Rs LFE
|
||||
#define AF_CHANNEL_LAYOUT_5_1_E ((116<<8)|6|AF_LFE) // LFE L C R Ls Rs
|
||||
#define AF_CHANNEL_LAYOUT_6_1_A ((117<<8)|7|AF_LFE) // L R C LFE Ls Rs Cs
|
||||
#define AF_CHANNEL_LAYOUT_7_1_A ((118<<8)|8|AF_LFE) // L R C LFE Ls Rs Rls Rrs
|
||||
#define AF_CHANNEL_LAYOUT_5_1_F ((117<<8)|6|AF_LFE) // C L R LFE Ls Rs
|
||||
#define AF_CHANNEL_LAYOUT_6_1_A ((118<<8)|7|AF_LFE) // L R C LFE Ls Rs Cs
|
||||
#define AF_CHANNEL_LAYOUT_7_1_A ((119<<8)|8|AF_LFE) // L R C LFE Ls Rs Rls Rrs
|
||||
|
||||
|
||||
#define AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_B
|
||||
@ -65,16 +66,12 @@
|
||||
#define AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_D
|
||||
#define AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A
|
||||
#define AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_AC3_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_AC3_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_C
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_LIBA52_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_LIBA52_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_E
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_DCA_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_D
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_DCA_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_D
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A
|
||||
#define AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C
|
||||
#define AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_C
|
||||
#define AF_CHANNEL_LAYOUT_FLAC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A
|
||||
#define AF_CHANNEL_LAYOUT_FLAC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_D
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_F
|
||||
|
||||
#define AF_CHANNEL_MASK 0xFF
|
||||
#define AF_GET_CH_NUM(A) ((A)&0x7F)
|
||||
@ -103,12 +100,10 @@ void reorder_channel(void *buf,
|
||||
#define AF_CHANNEL_LAYOUT_ALSA_DEFAULT 0
|
||||
#define AF_CHANNEL_LAYOUT_AAC_DEFAULT 1
|
||||
#define AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT 2
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT 3
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT 4
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_DCA_DEFAULT 5
|
||||
#define AF_CHANNEL_LAYOUT_VORBIS_DEFAULT 6
|
||||
#define AF_CHANNEL_LAYOUT_FLAC_DEFAULT 7
|
||||
#define AF_CHANNEL_LAYOUT_SOURCE_NUM 8
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_DEFAULT 3
|
||||
#define AF_CHANNEL_LAYOUT_VORBIS_DEFAULT 4
|
||||
#define AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_DEFAULT 5
|
||||
#define AF_CHANNEL_LAYOUT_SOURCE_NUM 6
|
||||
#define AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT AF_CHANNEL_LAYOUT_ALSA_DEFAULT
|
||||
|
||||
/// Optimized channel reorder between different audio sources and targets.
|
||||
|
@ -174,27 +174,19 @@ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int m
|
||||
if(len2>0){
|
||||
if (((AVCodecContext *)sh_audio->context)->channels >= 5) {
|
||||
int src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT;
|
||||
int samplesize = av_get_bits_per_sample_format(((AVCodecContext *)
|
||||
sh_audio->context)->sample_fmt) / 8;
|
||||
const char *codec=((AVCodecContext*)sh_audio->context)->codec->name;
|
||||
if (!strcasecmp(codec, "ac3")
|
||||
|| !strcasecmp(codec, "eac3"))
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT;
|
||||
else if (!strcasecmp(codec, "dca"))
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_DCA_DEFAULT;
|
||||
else if (!strcasecmp(codec, "libfaad")
|
||||
|| !strcasecmp(codec, "mpeg4aac"))
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_AAC_DEFAULT;
|
||||
else if (!strcasecmp(codec, "liba52"))
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT;
|
||||
if (!strcasecmp(codec, "aac"))
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_DEFAULT;
|
||||
else if (!strcasecmp(codec, "vorbis"))
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_VORBIS_DEFAULT;
|
||||
else if (!strcasecmp(codec, "flac"))
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_FLAC_DEFAULT;
|
||||
else
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT;
|
||||
src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_DEFAULT;
|
||||
reorder_channel_nch(buf, src_ch_layout,
|
||||
AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
|
||||
((AVCodecContext *)sh_audio->context)->channels,
|
||||
len2 / 2, 2);
|
||||
len2 / samplesize, samplesize);
|
||||
}
|
||||
//len=len2;break;
|
||||
if(len<0) len=len2; else len+=len2;
|
||||
|
@ -109,7 +109,7 @@ static int encode_lavc(audio_encoder_t *encoder, uint8_t *dest, void *src, int s
|
||||
!strcmp(lavc_acodec->name,"libfaac"))) {
|
||||
int isac3 = !strcmp(lavc_acodec->name,"ac3");
|
||||
reorder_channel_nch(src, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
|
||||
isac3 ? AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT
|
||||
isac3 ? AF_CHANNEL_LAYOUT_LAVC_DEFAULT
|
||||
: AF_CHANNEL_LAYOUT_AAC_DEFAULT,
|
||||
encoder->params.channels,
|
||||
size / 2, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user