[MPlayer-cvslog] r33588 - trunk/libmpcodecs/ae_lavc.c

reimar subversion at mplayerhq.hu
Sun Jun 12 01:36:53 CEST 2011


Author: reimar
Date: Sun Jun 12 01:36:52 2011
New Revision: 33588

Log:
Always choose AV_SAMPLE_FMT_S16 then the encoder supports it.

Modified:
   trunk/libmpcodecs/ae_lavc.c

Modified: trunk/libmpcodecs/ae_lavc.c
==============================================================================
--- trunk/libmpcodecs/ae_lavc.c	Sat Jun 11 18:40:10 2011	(r33587)
+++ trunk/libmpcodecs/ae_lavc.c	Sun Jun 12 01:36:52 2011	(r33588)
@@ -187,7 +187,17 @@ int mpae_init_lavc(audio_encoder_t *enco
 	lavc_actx->codec_type = AVMEDIA_TYPE_AUDIO;
 	lavc_actx->codec_id = lavc_acodec->id;
 	// put sample parameters
-	lavc_actx->sample_fmt = lavc_acodec->sample_fmts ? lavc_acodec->sample_fmts[0] : AV_SAMPLE_FMT_S16;
+	lavc_actx->sample_fmt = AV_SAMPLE_FMT_S16;
+	if (lavc_acodec->sample_fmts) {
+		const enum AVSampleFormat *fmts;
+		lavc_actx->sample_fmt = lavc_acodec->sample_fmts[0]; // fallback to first format
+		for (fmts = lavc_acodec->sample_fmts; *fmts != AV_SAMPLE_FMT_NONE; fmts++) {
+			if (*fmts == AV_SAMPLE_FMT_S16) { // preferred format found
+				lavc_actx->sample_fmt = *fmts;
+				break;
+			}
+		}
+	}
 	if (lavc_actx->sample_fmt != AV_SAMPLE_FMT_S16)
 	    mp_msg(MSGT_MENCODER, MSGL_ERR, "Encoder requires input not properly supported."
 	                                    "Try using e.g. 'ac3_fixed' instead of 'ac3' as codec\n");


More information about the MPlayer-cvslog mailing list