1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-10-12 19:59:20 +02:00

lavr: only save/restore the mixing matrix if mixing is being done

This commit is contained in:
Justin Ruggles 2012-11-29 20:49:36 -05:00
parent e798085f96
commit f322b20735

View File

@ -259,6 +259,7 @@ int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta,
AVAudioResampleContext and force resampling */ AVAudioResampleContext and force resampling */
if (!avr->resample_needed) { if (!avr->resample_needed) {
int fifo_samples; int fifo_samples;
int restore_matrix = 0;
double matrix[AVRESAMPLE_MAX_CHANNELS * AVRESAMPLE_MAX_CHANNELS] = { 0 }; double matrix[AVRESAMPLE_MAX_CHANNELS * AVRESAMPLE_MAX_CHANNELS] = { 0 };
/* buffer any remaining samples in the output FIFO before closing */ /* buffer any remaining samples in the output FIFO before closing */
@ -274,9 +275,12 @@ int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta,
goto reinit_fail; goto reinit_fail;
} }
/* save the channel mixing matrix */ /* save the channel mixing matrix */
ret = avresample_get_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS); if (avr->am) {
if (ret < 0) ret = avresample_get_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS);
goto reinit_fail; if (ret < 0)
goto reinit_fail;
restore_matrix = 1;
}
/* close the AVAudioResampleContext */ /* close the AVAudioResampleContext */
avresample_close(avr); avresample_close(avr);
@ -284,9 +288,11 @@ int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta,
avr->force_resampling = 1; avr->force_resampling = 1;
/* restore the channel mixing matrix */ /* restore the channel mixing matrix */
ret = avresample_set_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS); if (restore_matrix) {
if (ret < 0) ret = avresample_set_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS);
goto reinit_fail; if (ret < 0)
goto reinit_fail;
}
/* re-open the AVAudioResampleContext */ /* re-open the AVAudioResampleContext */
ret = avresample_open(avr); ret = avresample_open(avr);