+#define MAKE_SFMT_PAIR(a,b) ((a)+SAMPLE_FMT_NB*(b))
+ if (dec->sample_fmt!=enc->sample_fmt &&
+ MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt)!=ost->reformat_pair) {
+ if (!audio_out2)
+ audio_out2 = av_malloc(audio_out_size);
+ if (!audio_out2)
+ av_exit(1);
+ if (ost->reformat_ctx)
+ av_audio_convert_free(ost->reformat_ctx);
+ ost->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt, 1,
+ dec->sample_fmt, 1, NULL, 0);
+ if (!ost->reformat_ctx) {
+ fprintf(stderr, "Cannot convert %s sample format to %s sample format\n",
+ avcodec_get_sample_fmt_name(dec->sample_fmt),
+ avcodec_get_sample_fmt_name(enc->sample_fmt));
+ av_exit(1);
+ }
+ ost->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt);
+ }
+