[FFmpeg-cvslog] avcodec: allow either planar or interleaved sample format when encoding mono

Justin Ruggles git at videolan.org
Mon Oct 8 13:21:15 CEST 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Thu Sep 20 01:04:15 2012 -0400| [37f701f1c3967e7e2e3e6d67b4280bdcf13fdee1] | committer: Justin Ruggles

avcodec: allow either planar or interleaved sample format when encoding mono

When there is only 1 channel, the planar and interleaved formats of the same
data type should be treated as identical.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37f701f1c3967e7e2e3e6d67b4280bdcf13fdee1
---

 libavcodec/utils.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a72c434..d1b9d0a 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -792,9 +792,16 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
     if (av_codec_is_encoder(avctx->codec)) {
         int i;
         if (avctx->codec->sample_fmts) {
-            for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
+            for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
                 if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
                     break;
+                if (avctx->channels == 1 &&
+                    av_get_planar_sample_fmt(avctx->sample_fmt) ==
+                    av_get_planar_sample_fmt(avctx->codec->sample_fmts[i])) {
+                    avctx->sample_fmt = avctx->codec->sample_fmts[i];
+                    break;
+                }
+            }
             if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
                 av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
                 ret = AVERROR(EINVAL);



More information about the ffmpeg-cvslog mailing list