comparison libmpcodecs/ad_ffmpeg.c @ 23974:30677153df21

Set lavc_context->channels before opening the codec, it is sufficient to select the desired number of codecs for ffdca and does not break other codecs like ffvorbis that do not (re)set the channel number during decode.
author reimar
date Wed, 01 Aug 2007 23:36:40 +0000
parents f29d31547c31
children ef6e50c3c172
comparison
equal deleted inserted replaced
23973:0d483afee811 23974:30677153df21
84 lavc_context->extradata_size = sh_audio->codecdata_len; 84 lavc_context->extradata_size = sh_audio->codecdata_len;
85 memcpy(lavc_context->extradata, (char *)sh_audio->codecdata, 85 memcpy(lavc_context->extradata, (char *)sh_audio->codecdata,
86 lavc_context->extradata_size); 86 lavc_context->extradata_size);
87 } 87 }
88 88
89 // Set desired number of channels
90 lavc_context->channels = audio_output_channels;
89 /* open it */ 91 /* open it */
90 if (avcodec_open(lavc_context, lavc_codec) < 0) { 92 if (avcodec_open(lavc_context, lavc_codec) < 0) {
91 mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec); 93 mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec);
92 return 0; 94 return 0;
93 } 95 }
103 // MACE 6:1 105 // MACE 6:1
104 sh_audio->ds->ss_div = 2*6; // 1 samples/packet 106 sh_audio->ds->ss_div = 2*6; // 1 samples/packet
105 sh_audio->ds->ss_mul = 2*sh_audio->wf->nChannels; // 1 byte*ch/packet 107 sh_audio->ds->ss_mul = 2*sh_audio->wf->nChannels; // 1 byte*ch/packet
106 } 108 }
107 109
108 // Set desired number of channels
109 lavc_context->channels = audio_output_channels;
110 // Decode at least 1 byte: (to get header filled) 110 // Decode at least 1 byte: (to get header filled)
111 x=decode_audio(sh_audio,sh_audio->a_buffer,1,sh_audio->a_buffer_size); 111 x=decode_audio(sh_audio,sh_audio->a_buffer,1,sh_audio->a_buffer_size);
112 if(x>0) sh_audio->a_buffer_len=x; 112 if(x>0) sh_audio->a_buffer_len=x;
113 113
114 sh_audio->channels=lavc_context->channels; 114 sh_audio->channels=lavc_context->channels;