Mercurial > mplayer.hg
changeset 29491:99eda963d27a
Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
ffdca, ffflac, ffaac, fftruehd). In the process, adds support for 32-bit
samples.
author | tack |
---|---|
date | Tue, 18 Aug 2009 22:24:36 +0000 |
parents | 5b8f21404b19 |
children | 869c68891fde |
files | libaf/af_lavcac3enc.c libaf/reorder_ch.c libaf/reorder_ch.h libmpcodecs/ad_ffmpeg.c libmpcodecs/ae_lavc.c |
diffstat | 5 files changed, 30 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/libaf/af_lavcac3enc.c Mon Aug 17 08:02:37 2009 +0000 +++ b/libaf/af_lavcac3enc.c Tue Aug 18 22:24:36 2009 +0000 @@ -212,7 +212,7 @@ 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 @@ 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);
--- a/libaf/reorder_ch.c Mon Aug 17 08:02:37 2009 +0000 +++ b/libaf/reorder_ch.c Tue Aug 18 22:24:36 2009 +0000 @@ -293,6 +293,9 @@ 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 @@ 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 @@ 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,
--- a/libaf/reorder_ch.h Mon Aug 17 08:02:37 2009 +0000 +++ b/libaf/reorder_ch.h Tue Aug 18 22:24:36 2009 +0000 @@ -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 @@ #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.
--- a/libmpcodecs/ad_ffmpeg.c Mon Aug 17 08:02:37 2009 +0000 +++ b/libmpcodecs/ad_ffmpeg.c Tue Aug 18 22:24:36 2009 +0000 @@ -174,27 +174,19 @@ 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;
--- a/libmpcodecs/ae_lavc.c Mon Aug 17 08:02:37 2009 +0000 +++ b/libmpcodecs/ae_lavc.c Tue Aug 18 22:24:36 2009 +0000 @@ -109,7 +109,7 @@ !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);