comparison libmpcodecs/ad_ffmpeg.c @ 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 0f1b5b68af32
children 2c47c6dd92b5
comparison
equal deleted inserted replaced
29490:5b8f21404b19 29491:99eda963d27a
172 if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; } 172 if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; }
173 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) 173 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!)
174 if(len2>0){ 174 if(len2>0){
175 if (((AVCodecContext *)sh_audio->context)->channels >= 5) { 175 if (((AVCodecContext *)sh_audio->context)->channels >= 5) {
176 int src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT; 176 int src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT;
177 int samplesize = av_get_bits_per_sample_format(((AVCodecContext *)
178 sh_audio->context)->sample_fmt) / 8;
177 const char *codec=((AVCodecContext*)sh_audio->context)->codec->name; 179 const char *codec=((AVCodecContext*)sh_audio->context)->codec->name;
178 if (!strcasecmp(codec, "ac3") 180 if (!strcasecmp(codec, "aac"))
179 || !strcasecmp(codec, "eac3")) 181 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_AAC_DEC_DEFAULT;
180 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_AC3_DEFAULT;
181 else if (!strcasecmp(codec, "dca"))
182 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_DCA_DEFAULT;
183 else if (!strcasecmp(codec, "libfaad")
184 || !strcasecmp(codec, "mpeg4aac"))
185 src_ch_layout = AF_CHANNEL_LAYOUT_AAC_DEFAULT;
186 else if (!strcasecmp(codec, "liba52"))
187 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_LIBA52_DEFAULT;
188 else if (!strcasecmp(codec, "vorbis")) 182 else if (!strcasecmp(codec, "vorbis"))
189 src_ch_layout = AF_CHANNEL_LAYOUT_VORBIS_DEFAULT; 183 src_ch_layout = AF_CHANNEL_LAYOUT_VORBIS_DEFAULT;
190 else if (!strcasecmp(codec, "flac"))
191 src_ch_layout = AF_CHANNEL_LAYOUT_FLAC_DEFAULT;
192 else 184 else
193 src_ch_layout = AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT; 185 src_ch_layout = AF_CHANNEL_LAYOUT_LAVC_DEFAULT;
194 reorder_channel_nch(buf, src_ch_layout, 186 reorder_channel_nch(buf, src_ch_layout,
195 AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, 187 AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
196 ((AVCodecContext *)sh_audio->context)->channels, 188 ((AVCodecContext *)sh_audio->context)->channels,
197 len2 / 2, 2); 189 len2 / samplesize, samplesize);
198 } 190 }
199 //len=len2;break; 191 //len=len2;break;
200 if(len<0) len=len2; else len+=len2; 192 if(len<0) len=len2; else len+=len2;
201 buf+=len2; 193 buf+=len2;
202 maxlen -= len2; 194 maxlen -= len2;